- Posts: 3
- Joined: Fri Dec 10, 2021 10:24 pm
- Real Name: Sebastian Ware
I am attempting to do FFI from dart to the Blackmagic Switcher SDK. I can connect and perform simple tasks such as switching input and getting info about my ATEM mini switcher.
Next step is to register a callback and I have tried to adapt the Obj-C++ example SwitcherPanel to pure C++ but I am getting a compilation error when comparing the incoming REFIID with the const defined in BMDSwitcherAPI.h.
My implementation at the end, and the error is in the implementation of QueryInterface on the line:
I have looked att ten different examples and nothing gets me any closer to understanding what is going wrong. Any help would be much appreciated. Including pointers to functional C++ code. Google is falling short... /Sebastian
switcher_monitor.cpp
Next step is to register a callback and I have tried to adapt the Obj-C++ example SwitcherPanel to pure C++ but I am getting a compilation error when comparing the incoming REFIID with the const defined in BMDSwitcherAPI.h.
- Code: Select all
error: invalid operands to binary expression ('REFIID' (aka 'CFUUIDBytes') and 'const REFIID' (aka 'const CFUUIDBytes'))
My implementation at the end, and the error is in the implementation of QueryInterface on the line:
- Code: Select all
if (iid == IID_IBMDSwitcherCallback)
I have looked att ten different examples and nothing gets me any closer to understanding what is going wrong. Any help would be much appreciated. Including pointers to functional C++ code. Google is falling short... /Sebastian
switcher_monitor.cpp
- Code: Select all
#include "BMDSwitcherAPI.h"
#include "com_ptr.h"
#include <libkern/OSAtomic.h>
#include <map>
#include <string>
// Callback class to monitor switcher disconnection
class SwitcherMonitor : public IBMDSwitcherCallback
{
public:
SwitcherMonitor(void (*callback)(char *)) : mCallback(callback), mRefCount(1) { }
protected:
virtual ~SwitcherMonitor() { }
public:
// IBMDSwitcherCallback interface
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv)
{
if (!ppv)
return E_POINTER;
if (iid == IID_IBMDSwitcherCallback)
{
*ppv = static_cast<IBMDSwitcherCallback*>(this);
AddRef();
return S_OK;
}
if (CFEqual(&iid, IUnknownUUID))
{
*ppv = static_cast<IUnknown*>(this);
AddRef();
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE AddRef(void)
{
return ::OSAtomicIncrement32(&mRefCount);
}
ULONG STDMETHODCALLTYPE Release(void)
{
int newCount = ::OSAtomicDecrement32(&mRefCount);
if (newCount == 0)
delete this;
return newCount;
}
// Switcher events ignored by this sample app
HRESULT STDMETHODCALLTYPE Notify(BMDSwitcherEventType eventType, BMDSwitcherVideoMode coreVideoMode)
{
if (eventType == bmdSwitcherEventTypeDisconnected)
{
mCallback((char*)"disconnected");
}
else {
mCallback((char*)"other_event");
}
return S_OK;
}
private:
void (*mCallback)(char *);
int mRefCount;
};
Last edited by jhsware on Tue Dec 14, 2021 8:14 am, edited 1 time in total.