提交工单
咨询集成、功能及报价等问题
ZEGOCLOUD SDKs allow you to get the raw audio data, and you can write this data to the local device to achieve audio recording.
Before obtaining the original audio data, make sure:
// 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 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
}