我根据 Blackmagic Decklink SDK 编写了一个小程序。当我使用 DeckLinkInput 接口时,我收到读取访问冲突消息“this->dl_input was nulltr”。经过数小时的调试,我不知道如何解决这个问题。也许一个问题是我是 C++ 新手。我写了以下代码:
class ControlVideo {
public:
HRESULT result;
IDeckLink *deckLink = nullptr;
IDeckLinkInput *dl_input = nullptr;
IDeckLinkInputCallback *theCallback = nullptr;
IDeckLinkDisplayMode *dl_displayMode = nullptr;
IDeckLinkDisplayModeIterator* dl_displayModeIterator = nullptr;
bool inputCallback(IDeckLinkInput* dl_input);
bool startCapture();
};
/**
* Function that initializes the input callback
* The callback will be called for each incoming frame
*/
bool ControlVideo::inputCallback(IDeckLinkInput *dl_input) {
if (dl_input == nullptr) {
std::cout << "DECKLINK INPUT IS NULLPOINTER.";
}
else {
if (dl_input->SetCallback(theCallback) == S_OK) {
std::cout << "Input Callback called. \n";
return true;
}
else {
std::cout << "DeckLink Callback fails. \n";
return false;
}
}
}
/**
* Function that start the stream
*/
bool ControlVideo::startCapture() {
ControlVideo ctrlVideo;
//make a callback for each incoming frame
ctrlVideo.inputCallback(dl_input);
if (dl_input->StartStreams() == S_OK) {
std::cout << "Stream has been started. \n";
return true;
}
else {
throw std::runtime_error("Error: Stream can not been started. \n");
return false;
}
}
int main() {
//Create object and initialize the DeckLink
InitializeDecklink init;
init.initializeDevice();
init.printDevice();
ControlVideo ctrlVideo;
ctrlVideo.startCapture();
return 0;
}
有人可以告诉我我做错了什么吗?谢谢你。