Raw Data


The Video SDK provides you with an option to access and send real-time raw audio and video data of a session. After accessing the raw data, you can process it and apply additional effects to it to enhance the session experience.

This section will provide you with information on how to enable and gain access to the raw data of a session.

Specify Raw Data Memory Mode

In order to receive raw data of any type, you must first select the memory mode you wish to use. The SDK supports heap-based and stack-based memory modes.

Stack-Based Memory

  • Variables are allocated automatically and deallocated after the data leaves scope.
  • Variables are not accessible from or transferable to other threads.
  • Typically has faster access than heap-based memory allocation.
  • Memory space is managed by the CPU and will not become fragmented.
  • Variables cannot be resized.

Heap-Based Memory

  • Variables are allocated and deallocated manually. You must allocate and free variables to avoid memory leaks.
  • Variables can be accessed globally.
  • Has relatively slower access than stack-based memory allocation.
  • Has no guarantee on the efficiency of memory space and can become fragmented.
  • Variables can be resized.

For more information on these types of memory allocation, refer to Stack-based memory allocation and Heap-based dynamic memory allocation guides.

After determining which memory mode is right for you, you must specify it when the SDK is initialized. Note that this must be done for audio, video and share data types individually. The two types of memory allocation are defined with the following enum values:

Stack-based Memory: ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeStack

Heap-based Memory: ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap

To specify raw data memory mode, provide one of these enums to the ZoomInstantSDKInitParams method during SDK initialization.

ZoomInstantSDKRawDataMemoryMode modeHeap = ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap;
ZoomInstantSDKInitParams params = new ZoomInstantSDKInitParams();
params.videoRawDataMemoryMode = modeHeap; // Set video memory to heap
params.audioRawDataMemoryMode = modeHeap; // Set audio memory to heap
params.shareRawDataMemoryMode = modeHeap; // Set share memory to heap

Accessing Raw Video Data

Raw video data is encoded in the YUV420p format. YUV420 is a data object commonly used by the renderer based on OpenGL ES.

To access and modify the video data, you will need to do the following:

  1. Implement an instance of the ZoomInstantSDKRawDataPipeDelegate.
  2. Use callback functions provided by the ZoomInstantSDKRawDataPipeDelegate to receive each frame of the raw video data.
  3. Pass the delegate into the video pipe of a specific user.
ZoomInstantSDKRawDataPipeDelegate dataDelegate = new ZoomInstantSDKRawDataPipeDelegate() {
    @Override
    public void onRawDataFrameReceived(ZoomInstantSDKVideoRawData zoomInstantSDKVideoRawData) {
            
    }

    @Override
    public void onRawDataStatusChanged(ZoomInstantSDKRawDataPipeDelegate.RawDataStatus status) {

    }
};

ZoomInstantSDKRawDataPipe pipe = user.getVideoPipe();
pipe.subscribe(ZoomInstantSDKVideoResolution.VideoResolution_720P, dataDelegate);

Each frame of video data will be made available through the ZoomInstantSDKVideoRawData object. Various pieces of data can be accessed through this object in onVideoRawDataFrame:

int height = rawData.getStreamHeight();
int width = rawData.getStreamWidth();
ByteBuffer uBuffer = rawData.getuBuffer();
ByteBuffer vBuffer = rawData.getvBuffer();
ByteBuffer yBuffer = rawData.getyBuffer();

Access Raw Audio Data

Through your implementation of ZoomInstantSDKDelegate, you can access mixed(combined audio output from one or more user, as heard in a session) and per-user raw audio data.

Note: Unlike raw video data, raw audio data will default to stack-based memory if you do not specify a memory mode.

To access raw audio data, you will need to listen for the following callbacks in your listener:

@Override
public void onMixedAudioRawDataReceived(ZoomInstantSDKAudioRawData rawData) {
    // Access mixed data for the whole session here
}

@Override
public void onOneWayAudioRawDataReceived(ZoomInstantSDKAudioRawData rawData, ZoomInstantSDKUser user) {
    // Access user-specific raw data here for the user associated with the userId
}

From within the callbacks, you can access the data buffer with rawData.buffer property.

For more information on implementing your ZoomInstantSDKDelegate, read listen for callbacks event.

Send Raw Video Data

In addition to being able to receive and process raw video data, you may also send raw as well as processed video data of a user from the user’s device. To do this, you must provide an implementation of ZoomInstantSDKVideoSource in your ZoomInstantSDKSessionContext object when joining a session.

ZoomInstantSDKVideoSource source = new ZoomInstantSDKVideoSource() {
    @Override
    public void onInitialize(ZoomInstantSDKVideoSender sender, List<ZoomInstantSDKVideoCapability> list, ZoomInstantSDKVideoCapability zoomInstantSDKVideoCapability) {
        sender.sendVideoFrame(/* Your raw data buffer goes here -> */ buffer, width, height, frameLength, rotation);
    }

    @Override
    public void onPropertyChange(List<ZoomInstantSDKVideoCapability> list, ZoomInstantSDKVideoCapability zoomInstantSDKVideoCapability) {

    }

    @Override
    public void onStartSend() {

    }

    @Override
    public void onStopSend() {

    }

    @Override
    public void onUninitialized() {

    }
};

ZoomInstantSDKSessionContext params = new ZoomInstantSDKSessionContext();
params.externalVideoSource = source;

Advanced Guides:

Need help?

The first place to look is on our Developer Forum. If you can't find the answer or your request includes sensitive information, contact Developer Support.