Hatim
Hey,
I just started to work with Decklink SDI device, and I'm trying to write a code to get a frame from the input of my Decklink SDI . But it just doesn't work. here is my code :
and this what I get when I try to debug this :
any idea how it could work ??
thanks for your help in advance
I just started to work with Decklink SDI device, and I'm trying to write a code to get a frame from the input of my Decklink SDI . But it just doesn't work. here is my code :
- Code: Select all
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <objbase.h> // Necessary for COM
#include <comutil.h>
#include "DeckLinkAPI_h.h"
#include <iostream>
#include <stdint.h>
using std::endl;
using std::cout;
int _tmain (int argc, _TCHAR* argv[])
{
IDeckLinkIterator* deckLinkIterator;
IDeckLinkAPIInformation* deckLinkAPIInformation;
IDeckLink* decklink;
HRESULT result;
int i ;
IDeckLinkInput* decklinkinput = NULL;
IDeckLinkDisplayModeIterator* displayModeIterator = NULL;
IDeckLinkInputCallback* theCallback = NULL;
IDeckLinkVideoInputFrame* decklinkInputVideoframe =NULL;
IDeckLinkDisplayMode* displayMode = NULL;
IDeckLinkAudioInputPacket* inputAudioPacket;
IDeckLinkVideoFrame* videoFrame;
IBMDStreamingDeviceInput* capture;
IDeckLinkVideoFrame* deckLinkVideoFrame = NULL;
IDeckLinkScreenPreviewCallback* screenCallback = NULL;
unsigned long avaibleFrames = NULL;
IBMDStreamingDeviceInput* bmdStreamingDeviceInput=NULL;
unsigned long j ;
// Initialize COM on this thread
result = CoInitialize(NULL);
if (FAILED(result))
{
cout<< "Initialization of COM failed - result = %08x.\n"<< endl;
return 1;
}
// Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);
if (FAILED(result))
{
cout<< "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"<<endl;
return 1;
}
while (deckLinkIterator->Next(&decklink) == S_OK)
{
result = decklink->QueryInterface(IID_IDeckLinkInput,(void**) &decklinkinput);
if(result != S_OK)
{
cout<<"could not obtain the IDeckLinkInput interface 1 " <<endl;
}
result = decklinkinput->EnableVideoInput(BMDDisplayMode::bmdModeHD1080i50,BMDPixelFormat::bmdFormat8BitYUV,bmdVideoInputEnableFormatDetection);
decklinkinput->QueryInterface(IID_IDeckLinkVideoInputFrame,(void**) &decklinkInputVideoframe);
result = decklinkinput->DisableAudioInput();
result = decklinkinput->StartStreams();
//theCallback->VideoInputFrameArrived(inputVideoFrame, inputAudioPacket);// causes errors
result = decklinkinput->GetAvailableVideoFrameCount(&avaibleFrames);
result = decklinkinput->StopStreams();
j = decklinkInputVideoframe->GetHeight(); // causes errors
cout << " Number of avaible video frame %d " <<avaibleFrames <<endl;
cout<<j<<endl;
decklink->Release();
}
// Uninitalize COM on this thread
CoUninitialize();
// Wait for any key press before exiting
_getch();
return 0;
}[code][/code]
and this what I get when I try to debug this :
- Code: Select all
Unhandled exception at 0x000000013f481191 in DeviceList.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
any idea how it could work ??
thanks for your help in advance