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

ZoomVideoSDKRawDataMemoryMode.ZoomVideoSDKRawDataMemoryModeStack

Heap-based Memory

ZoomVideoSDKRawDataMemoryMode.ZoomVideoSDKRawDataMemoryModeHeap

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

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

Receive raw audio data

See the sample code below.

CExampleRawAudioSenderAndSpeaker.h
#pragma once
#include "helpers/zoom_video_sdk_audio_send_rawdata_interface.h"

class CExampleRawAudioSenderAndSpeaker : public ZOOM_VIDEO_SDK_NAMESPACE::IZoomVideoSDKVirtualAudioMic, public ZOOM_VIDEO_SDK_NAMESPACE::IZoomVideoSDKVirtualAudioSpeaker
{
public:
    void SendRawAudio(char* data, unsigned int data_length, int sample_rate);

    //IZoomVideoSDKVirtualAudioMic
    virtual void onMicInitialize(ZOOM_VIDEO_SDK_NAMESPACE::IZoomVideoSDKAudioSender* rawdata_sender);
    virtual void onMicStartSend();
    virtual void onMicStopSend();
    virtual void onMicUninitialized();

    //IZoomVideoSDKVirtualAudioSpeaker
    virtual void onVirtualSpeakerMixedAudioReceived(AudioRawData* data_);
    virtual void onVirtualSpeakerOneWayAudioReceived(AudioRawData* data_, ZOOM_VIDEO_SDK_NAMESPACE::IZoomVideoSDKUser* pUser);
    virtual void onVirtualSpeakerSharedAudioReceived(AudioRawData* data_);
protected:
    ZOOM_VIDEO_SDK_NAMESPACE::IZoomVideoSDKAudioSender* virtual_audio_sender_;
};
CExampleRawAudioSenderAndSpeaker.cpp
#include "CExampleRawAudioSenderAndSpeaker.h"
#include "helpers/zoom_video_sdk_user_helper_interface.h"

USING_ZOOM_VIDEO_SDK_NAMESPACE;

// NOTE TO JON This code needs to be added to the session context before joining a meeting:
//ZoomVideoSDKSessionContext session_context;
//session_context.sessionName = session_name_;
//session_context.sessionPassword = session_password_;
//session_context.userName = sUserName;
//session_context.token = token_.c_str();
//session_context.videoOption.localVideoOn = is_video_on;
//session_context.audioOption.connect = true;
//session_context.audioOption.mute = is_mute_audio;
//CExampleRawAudioSenderAndSpeaker* rawAudioSenderAndSpeaker = new CExampleRawAudioSenderAndSpeaker();
//session_context.virtualAudioMic = rawAudioSenderAndSpeaker;
//session_context.virtualAudioSpeaker = rawAudioSenderAndSpeaker;

void CExampleRawAudioSenderAndSpeaker::SendRawAudio(char* data, unsigned int data_length, int sample_rate)
{
    if (!virtual_audio_sender_)
    {
        return;
    }

    // See zoom_video_sdk_audio_send_rawdata_interface.h for raw audio data information
    virtual_audio_sender_->Send(data, data_length, sample_rate);
}

void CExampleRawAudioSenderAndSpeaker::onMicInitialize(IZoomVideoSDKAudioSender* rawdata_sender)
{
    // Once the sender has been recieved from this callback, then Send can be called
    virtual_audio_sender_ = rawdata_sender;
}

void CExampleRawAudioSenderAndSpeaker::onMicStartSend()
{
    if (!virtual_audio_sender_)
    {
        return;
    }

    // Virtual Mic began sending raw audio
}

void CExampleRawAudioSenderAndSpeaker::onMicStopSend()
{
    if (!virtual_audio_sender_)
    {
        return;
    }

    // Virtual Mic stopped sending raw audio
}

void CExampleRawAudioSenderAndSpeaker::onMicUninitialized()
{
    virtual_audio_sender_ = nullptr;
}

void CExampleRawAudioSenderAndSpeaker::onVirtualSpeakerMixedAudioReceived(AudioRawData* data_)
{
    // Handle mixed audio raw data here
    data_->GetBuffer();
    data_->GetBufferLen();
    data_->GetChannelNum();
    data_->GetSampleRate();
}

void CExampleRawAudioSenderAndSpeaker::onVirtualSpeakerOneWayAudioReceived(AudioRawData* data_, IZoomVideoSDKUser* pUser)
{
    // Handle audio raw data from single user here
    data_->GetBuffer();
    data_->GetBufferLen();
    data_->GetChannelNum();
    data_->GetSampleRate();
    pUser->getUserName();
}

void CExampleRawAudioSenderAndSpeaker::onVirtualSpeakerSharedAudioReceived(AudioRawData* data_)
{
    // Handle audio raw data from share here
    data_->GetBuffer();
    data_->GetBufferLen();
    data_->GetChannelNum();
    data_->GetSampleRate();
}

Next Steps

Need help?

If you're looking for help, try Developer Support or our Developer Forum. Priority support is also available with Premier Developer Support plans.