Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    BlackMagic COM in Qt

    3rd Party Software
    2
    2
    4013
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      wshirey 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 += qaxcontainer

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

      TARGET = decklink
      TEMPLATE = app

      SOURCES += main.cpp
      mainwindow.cpp
      decklinkapi.cpp

      HEADERS += mainwindow.h
      decklinkapi.h

      FORMS += 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.

      1 Reply Last reply Reply Quote 0
      • R
        rcari 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 Reply Last reply Reply Quote 0
        • First post
          Last post