Remove backgrounds with an alpha channel
The code on this page works with either the default UI or the custom UI.
Meeting hosts who hold a raw streaming token can enable alpha channel mode, which requests that Zoom send both the original video data and a mask demarking the edge of a participant's body. The SDK can then use the alpha mask and raw data to remove the participant's background and render meeting participants natively in the host's virtual world.
Add new methods
Add a new method to the ZoomSDKMeetingActionController.h class.
/**
* @brief Callback event of alpha channel mode changes.
* @param isAlphaModeOn YES means it's in alpha channel mode. Otherwise, it's not.
*/
- (void)onVideoAlphaChannelStatusChanged:(BOOL)isAlphaModeOn;
This callback is triggered when alpha channel mode is turned on.
Add these methods to the ZoomSDKMeetingActionController.h class.
/**
* @brief Determine if alpha channel mode can be enabled.
* @return YES means it can be enabled. Otherwise NO.
*/
- (BOOL)canEnableAlphaChannelMode;
/**
* @brief Enable or disable alpha channel mode.
* @param enabled YES indicates to enable alpha channel mode. Otherwise, disable it.
* @return If the function succeeds, the return value is ZoomSDKError_Success.
*/
- (ZoomSDKError)enableAlphaChannelMode:(BOOL)enabled;
/**
* @brief Determine if alpha channel mode is enabled.
* @return YES indicates is in alpha channel mode. Otherwise NO.
*/
- (BOOL)isAlphaChannelModeEnabled;
Enable alpha channel mode
Before enabling the alpha channel, call canEnableAlphaChannelMode to check whether the alpha channel mode is enabled. To enable or disable the alpha channel, call EnableAlphaChannelMode.
Add a new method to the ZoomSDKRenderer.h class.
/**
* @brief Get video alpha mask data buffer.
* @return buffer address if alpha data exists. Otherwise nil.
*/
-(char*_Nullable)getAlphaBuffer;
/**
* @brief Get the alpha buffer length.
* @return The length of alpha data.
*/
-(unsigned int)getAlphaBufferLen;
The raw data will have two more values after performing these steps: GetAlphaBuffer for the alpha data buffer, and another, GetAlphaBufferLen, for the alpha data buffer length.