Raw data

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

This section will provide you with information on enabling and gaining access to a session’s raw data.

Specify raw data memory mode

To utilize 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 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 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.

Specify your chosen memory mode when initializing the SDK. Note this is done for audio and video individually. The two types of memory allocation are defined by the following enum values:

Stack-based Memory: ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeStack

Heap-based Memory: ZoomInstantSDKRawDataMemoryMode.ZoomInstantSDKRawDataMemoryModeHeap

To specify a raw data memory mode, provide one of these enum cases to the ZoomInstantSDKInitParams during SDK initialization.

ZoomInstantSDKInitParams initParams;
// Set audio memory mode to stack.
initParams.audioRawDataMemoryMode = ZoomInstantSDKRawDataMemoryModeStack;
// Set video memory mode to stack.
initParams.videoRawDataMemoryMode = ZoomInstantSDKRawDataMemoryModeStack;
// Set share memory mode to stack.
initParams.shareRawDataMemoryMode = ZoomInstantSDKRawDataMemoryModeStack;

Accessing raw audio data

Through an implementation of IZoomInstantSDKDelegate, you can access mixed 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.

void CExampleListener::onMixedAudioRawDataReceived(AudioRawData* data_)
{
    // Access mixed data for the whole session here.
	if (!data_) return;

	unsigned int audioChannelNumber = data_->GetChannelNum();
	unsigned int audioSampleRate = data_->GetSampleRate();
    unsigned int bufferLength = data_->GetBuffer();
    
    char* buffer = data_->GetBuffer();
}

void CExampleListener::onOneWayAudioRawDataReceived(AudioRawData* data_, IZoomInstantSDKUser* pUser)
{	
    // Access user-specific raw data here for the user associated with the user.
	if (!data_) return;

	unsigned int audioChannelNumber = data_->GetChannelNum();
	unsigned int audioSampleRate = data_->GetSampleRate();
    unsigned int bufferLength = data_->GetBuffer();
    
    char* buffer = data_->GetBuffer();
}

Once you have implemented these callbacks, you must subscribe the listener to receive audio data through an instance of IZoomInstantSDKAudioHelper.

// Get the IZoomInstantSDKAudioHelper to perform audio actions, including raw audio data actions.
IZoomInstantSDKAudioHelper* pAudioHelper = m_pInstantSDK->getAudioHelper();
// Call subscribe to subscribe to raw audio data.
pAudioHelper->subscribe();

Next steps