Use virtual backgrounds
The code on this page only works with the custom UI.
Use IsSupportVirtualBG in IVirtualBGSettingContext to determine whether the device supports virtual backgrounds, then use ISettingService to enable them. You can also check to see if the smart virtual background - virtual backgrounds with green screens - are supported.
// Create ISettingService object to perform Settings actions
ZOOM_SDK_NAMESPACE::ISettingService* settingService;
ZOOM_SDK_NAMESPACE::SDKError settingServiceInitReturnVal = ZOOM_SDK_NAMESPACE::CreateSettingService(&settingService);
if (settingServiceInitReturnVal == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS) {
ZOOM_SDK_NAMESPACE::IVirtualBGSettingContext* virtualBGSettings;
virtualBGSettings = settingService->GetVirtualBGSettings();
if (virtualBGSettings->IsSupportVirtualBG()){
// Virtual background is supported
// Check if smart virtual background is supported
if (virtualBGSettings->IsDeviceSupportSmartVirtualBG()){
}
}
}
If the device supports virtual backgrounds, use IVirtualBGSettingContext* to list, add, remove, and set virtual backgrounds.
// To list available virtual backgrounds
virtualBGSettings->GetBGImageList();
// The list will contain a NONE, BLUR and any added items
// The IVirtualBGImageInfo has isSelected() method to check if the item is currently selected
// To add virtual background to list, first check if have permission to add
if (virtualBGSettings->IsAllowToAddNewVBItem()) {
virtualBGSettings->AddBGImage(imagePath)
;
}
/*
To remove a specific virtual background from the list.
Note: You cannot remove NONE and BLUR type.
*/
if (virtualBGSettings->isAllowDelete()) {
virtualBGSettings->RemoveBGImage(IVirtualBGImageInfo);
}
// To set a specific virtual background
virtualBGSettings->UseBGImage(IVirtualBGImageInfo);
Users can preview the virtual background.
ITestVideoDeviceHelper* testVideoDeviceHelper = virtualBGSettings->GetTestVideoDeviceHelper();
//preview requires even and window handle, otherwise it might fail to start and stop
testVideoDeviceHelper->SetEvent(eventHandler);
testVideoDeviceHelper->SetVideoPreviewParentWnd(hParentWnd, rc);
// Start preview
testVideoDeviceHelper->TestVideoStartPreview(deviceID);
// Stop preview
testVideoDeviceHelper->TestVideoStopPreview();
Users can also have green screen support for virtual backgrounds.
/*
For green background, there are these 3 methods available
*/
virtualBGSettings->IsUsingGreenScreenOn();
virtualBGSettings->SetUsingGreenScreen(true);
virtualBGSettings->IsDeviceSupportGreenVirtualBackgroundVideo();