Documentation
ExpressVideoSDK Video Call
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Video Call
  • Upgrade using advanced features
  • Distincitve features
  • Customize the video and audio
  • Get the raw audio data

Get the raw audio data

Last updated:2023-11-14 14:43

Introduction

ZEGOCLOUD SDKs allow you to get the raw audio data, and you can write this data to the local device to achieve audio recording.

Prerequisites

Before obtaining the original audio data, make sure:

  • A project has been created in ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - How to view project information .
  • ZEGO Express SDK has been integrated into the project to implement basic real-time audio and video functions. For details, please refer to Integrate the SDK and Implement a basic video call.

Enable Original Audio Data Function

// The required audio data type Bitmask, all three callbacks are enabled in the example here
ZegoAudioDataCallbackBitMask bitmask = ZegoAudioDataCallbackBitMaskCaptured | ZegoAudioDataCallbackBitMaskPlayback | ZegoAudioDataCallbackBitMaskMixed;

// Required audio data parameters, the example here is mono, 16K
ZegoAudioFrameParam *param = [[ZegoAudioFrameParam alloc] init];
param.channel = ZegoAudioChannelMono;
param.sampleRate = ZegoAudioSampleRate16K;

// Turn on the function of obtaining original audio data
[[ZegoExpressEngine sharedEngine] startAudioDataObserver:bitmask param:param];

Set Callback to Get Original Audio Data and Process

// Set audio data callback
[[ZegoExpressEngine sharedEngine] setAudioDataHandler:self];
// Implement the following three callbacks as needed, corresponding to the three options of Bitmask above

-(void)onCapturedAudioData:(const unsigned char *)data dataLength:(unsigned int)dataLength param:(ZegoAudioFrameParam *)param {
    // Collect audio data locally and receive a callback after pushing the stream
}

-(void)onPlaybackAudioData:(const unsigned char *)data dataLength:(unsigned int)dataLength param:(ZegoAudioFrameParam *)param {
    // Pull the audio data remotely, you can receive a callback after starting to pull the stream
}

-(void)onMixedAudioData:(const unsigned char *)data dataLength:(unsigned int)dataLength param:(ZegoAudioFrameParam *)param {
    // Callback of audio data mixed with local collection and remote streaming sound
}
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code