BlackMagic COM in Qt
-
wrote on 3 Dec 2012, 14:14 last edited by
I am trying to write a Qt Windows application that will utilize the BlackMagic Decklink SDK. This SDK uses COM for instantiating a class (IDeckLinkIterator) which provides access to all other classes.
So far, I have used dumpcpp to create .h/.cpp files for API and successfully built the application.
My .pro file looks like
@
QT += core gui activeqt
CONFIG += qaxcontainergreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = decklink
TEMPLATE = appSOURCES += main.cpp
mainwindow.cpp
decklinkapi.cppHEADERS += mainwindow.h
decklinkapi.hFORMS += mainwindow.ui
TYPELIBS = $$system(dumpcpp -getfile {D864517A-EDD5-466D-867D-C819F1C052BB})
isEmpty(TYPELIBS) {
message("Decklink API type library not found!")
}
@Then to test the application I want to simply instantiate a class that tells me what version of the SDK I'm using. The Win32 code to do this is
@
IDeckLinkIterator* deckLinkIterator;
IDeckLinkAPIInformation* deckLinkAPIInformation;
IDeckLink* deckLink;
int numDevices = 0;
HRESULT result;// Initialize COM on this thread
result = CoInitialize(NULL);// Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system
result = CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL, IID_IDeckLinkIterator, (void**)&deckLinkIterator);// We can get the version of the API like this:
result = deckLinkIterator->QueryInterface(IID_IDeckLinkAPIInformation, (void**)&deckLinkAPIInformation);
if (result == S_OK)
{
LONGLONG deckLinkVersion;
int dlVerMajor, dlVerMinor, dlVerPoint;// We can also use the BMDDeckLinkAPIVersion flag with GetString
deckLinkAPIInformation->GetInt(BMDDeckLinkAPIVersion, &deckLinkVersion);dlVerMajor = (deckLinkVersion & 0xFF000000) >> 24;
dlVerMinor = (deckLinkVersion & 0x00FF0000) >> 16;
dlVerPoint = (deckLinkVersion & 0x0000FF00) >> 8;printf("DeckLinkAPI version: %d.%d.%d\n", dlVerMajor, dlVerMinor, dlVerPoint);
deckLinkAPIInformation->Release();
}// Enumerate all cards in this system
while (deckLinkIterator->Next(&deckLink) == S_OK)
{
// get device
}
@How would I do that in Qt? My main problem is how to create objects.
-
wrote on 4 Dec 2012, 10:58 last edited by
Well, I am not sure what you want to achieve here with Qt.
The Component Object Model is a Microsoft only technology, so there is no "cross-platform" way to deal with it: thus Qt is not COM enabled.
The code you have is pretty much it. You can't instantiate the objects directly because they come from the COM API however you should be able to use them from a Qt GUI if that's what you want, after successfully instantiating them as you describe here.
1/2