I’m having trouble getting the event to fire in the IVideoSettingContext wrapper. This is my implementation:
// video_setting_context_wrap.h class ISettingServiceWrap; IVideoSettingContext* InitIVideoSettingContextFunc(IVideoSettingContextEvent* pEvent, ISettingServiceWrap* pOwner); void UninitIVideoSettingContextFunc(IVideoSettingContext* obj); BEGIN_CLASS_DEFINE_WITHCALLBACK(IVideoSettingContext, IVideoSettingContextEvent) NORMAL_CLASS(IVideoSettingContext) INIT_UNINIT_WITHEVENT_AND_OWNSERVICE(IVideoSettingContext, ISettingServiceWrap) // function definitions omitted for brevity CallBack_FUNC_1(onComputerCamDeviceChanged, IList*, pNewCameraList) END_CLASS_DEFINE(IVideoSettingContext) END_ZOOM_SDK_NAMESPACE // video_setting_context_wrap.cpp IVideoSettingContext* InitIVideoSettingContextFunc(IVideoSettingContextEvent* pEvent, ISettingServiceWrap* pOwner) { if (pOwner && pOwner->GetSDKObj()) { ZOOM_SDK_NAMESPACE::IVideoSettingContext* pObj = pOwner->GetSDKObj()->GetVideoSettings(); if (pObj) { // the following returns SDKERR_SUCCESS pObj->SetVideoDeviceEvent(pEvent); } return pObj; } return NULL; } void UninitIVideoSettingContextFunc(IVideoSettingContext* pObj) { if (pObj) { pObj->SetVideoDeviceEvent(NULL); } }
I originally asked this question via email and received this response, which I have some questions about:
From the snippet code, we assume that Lenovo is using the same macro_define.h as we do. The most possible reason that the callback event is not fired is that they didn’t wrap the class IVideoSettingContext in a right way. This class should be wrapped in another way. Here is the code snippet for how to wrap IVideoSettingContext. The code also works for IAudioSettingContext.
- Make sure to have following codes at the beginning of the video_setting_context_wrap.h. ( Note that we can not use the macro INIT_UNINIT_WITHEVENT_AND_OWNSERVICE here)
class ISettingServiceWrap; IVideoSettingContext* InitIVideoSettingContextFunc(IVideoSettingContextEvent* pEvent, ISettingServiceWrap* pOwner); void UninitIVideoSettingContextFunc(ISettingServiceWrap* obj); BEGIN_CLASS_DEFINE_WITHCALLBACK(IVideoSettingContext, IVideoSettingContextEvent) NORMAL_CLASS(IVideoSettingContext) void Init(ISettingServiceWrap* pOwner) {m_obj = InitIVideoSettingContextFunc(this, pOwner);}; void Uninit(ISettingServiceWrap* pOwner) {UninitIVideoSettingContextFunc(pOwner);m_obj=NULL;};
- Make sure to implement the function InitIVideoSettingContextFunc() in video_setting_context_wrap.cpp
IVideoSettingContext* InitIVideoSettingContextFunc(IVideoSettingContextEvent* pEvent, ISettingServiceWrap* pOwner) { if (pOwner && pOwner->GetSDKObj()) { pOwner->SetVideoDeviceEvent(pEvent); ZOOM_SDK_NAMESPACE::IVideoSettingContext* pObj = pOwner->GetSDKObj()->GetVideoSettings(); return pObj; } return NULL; } void UninitIVideoSettingContextFunc(ISettingServiceWrap* pOwner) { if (pOwner) { pOwner->SetEvent(NULL); } }
In the InitIVideoSettingContextFunc function, you’re calling pOwner->SetVideoDeviceEvent(pEvent). In this case pOwner is a pointer to ISettingServiceWrap, which doesn’t contain the function SetVideoDeviceEvent, it’s defined instead for IVideoSettingContext, so I don’t see how this can work.