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 InMeetingServiceListener.java class.

/**
	 * Callback event of alpha channel mode changes.
	 *
	 * @param isAlphaModeOn true means it's in alpha channel mode. Otherwise, it's not.
	 */
	void onVideoAlphaChannelStatusChanged(boolean isAlphaModeOn);

This callback is triggered when alpha channel mode is turned on.

Add these methods to the InMeetingVideoController class.

/**
     * Determine if alpha channel mode can be enabled.
     * @return true means it can be enabled. Otherwise false.
     */
    boolean canEnableAlphaChannelMode();
/**
     * Enable or disable alpha channel mode.
     * @param enable true indicates to enable alpha channel mode. Otherwise, disable it.
     * @return If the function succeeds, the return value is {@link MobileRTCSDKError#SDKERR_SUCCESS}.
     * Otherwise the function fails and return an error. To get extended error information, see {@link  MobileRTCSDKError} enum.
     */
    MobileRTCSDKError enableAlphaChannelMode(boolean enable);
    /**
     * Determine if alpha channel mode is enabled.
     * @return TRUE indicates is in alpha channel mode. Otherwise false.
     */
    boolean 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 class ZoomSDKVideoRawData.java.

/**
     * Get YUVI420 Alpha buffer
     *
     * @return Alpha buffer
     */
    public ByteBuffer getAlphaBuffer() {
        return aBuffer;
    }

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.

Now that you've received the data, edit the raw data.