Voice SDK v3.7.1 API Reference for All Platforms (C++)
agora::media::IAudioFrameObserver Class Referenceabstract

Classes

struct  AudioFrame
 

Public Types

enum  AUDIO_FRAME_TYPE { FRAME_TYPE_PCM16 = 0 }
 

Public Member Functions

 IAudioFrameObserver ()
 
virtual ~IAudioFrameObserver ()
 
virtual bool onRecordAudioFrame (AudioFrame &audioFrame)=0
 
virtual bool onPlaybackAudioFrame (AudioFrame &audioFrame)=0
 
virtual bool onMixedAudioFrame (AudioFrame &audioFrame)=0
 
virtual bool onPlaybackAudioFrameBeforeMixing (unsigned int uid, AudioFrame &audioFrame)=0
 
virtual bool isMultipleChannelFrameWanted ()
 
virtual bool onPlaybackAudioFrameBeforeMixingEx (const char *channelId, unsigned int uid, AudioFrame &audioFrame)
 

Detailed Description

Member Enumeration Documentation

◆ AUDIO_FRAME_TYPE

The frame type.

Enumerator
FRAME_TYPE_PCM16 

0: PCM16.

Constructor & Destructor Documentation

◆ IAudioFrameObserver()

agora::media::IAudioFrameObserver::IAudioFrameObserver ( )
inline

◆ ~IAudioFrameObserver()

virtual agora::media::IAudioFrameObserver::~IAudioFrameObserver ( )
inlinevirtual

Member Function Documentation

◆ onRecordAudioFrame()

virtual bool agora::media::IAudioFrameObserver::onRecordAudioFrame ( AudioFrame audioFrame)
pure virtual

Gets the captured audio frame.

Note
To ensure that the captured audio frame has the expected format, Agora recommends that you call setRecordingAudioFrameParameters after calling registerAudioFrameObserver to set the audio capturing format.
Parameters
audioFramePointer to AudioFrame.
Returns
  • true: Reserved for future use.
  • false: Reserved for future use.

◆ onPlaybackAudioFrame()

virtual bool agora::media::IAudioFrameObserver::onPlaybackAudioFrame ( AudioFrame audioFrame)
pure virtual

Gets the audio playback frame for getting the audio.

Note
To ensure that the audio playback frame has the expected format, Agora recommends that you call setPlaybackAudioFrameParameters after calling registerAudioFrameObserver to set the audio playback format.
Parameters
audioFramePointer to AudioFrame.
Returns
  • true: Reserved for future use.
  • false: Reserved for future use.

◆ onMixedAudioFrame()

virtual bool agora::media::IAudioFrameObserver::onMixedAudioFrame ( AudioFrame audioFrame)
pure virtual

Gets the mixed captured and playback audio frame.

Note
Parameters
audioFramePointer to AudioFrame.
Returns
  • true: Reserved for future use.
  • false: Reserved for future use.

◆ onPlaybackAudioFrameBeforeMixing()

virtual bool agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixing ( unsigned int  uid,
AudioFrame audioFrame 
)
pure virtual

Gets the audio frame of a specified user before mixing.

The SDK triggers this callback if isMultipleChannelFrameWanted returns false.

Note
To ensure that the audio playback frame has the expected format, Agora recommends that you call setPlaybackAudioFrameParameters after calling registerAudioFrameObserver to set the audio playback format.
Parameters
uidThe user ID
audioFramePointer to AudioFrame.
Returns
  • true: Reserved for future use.
  • false: Reserved for future use.

◆ isMultipleChannelFrameWanted()

virtual bool agora::media::IAudioFrameObserver::isMultipleChannelFrameWanted ( )
inlinevirtual

Determines whether to receive audio data from multiple channels.

Since
v3.0.1

After you register the audio frame observer, the SDK triggers this callback every time it captures an audio frame.

In the multi-channel scenario, if you want to get audio data from multiple channels, set the return value of this callback as true. After that, the SDK triggers the onPlaybackAudioFrameBeforeMixingEx callback to send you the before-mixing audio data from various channels. You can also get the channel ID of each audio frame.

Note
  • Once you set the return value of this callback as true, the SDK triggers only the onPlaybackAudioFrameBeforeMixingEx callback to send the before-mixing audio frame. onPlaybackAudioFrameBeforeMixing is not triggered. In the multi-channel scenario, Agora recommends setting the return value as true.
  • If you set the return value of this callback as false, the SDK triggers only the onPlaybackAudioFrameBeforeMixing callback to send the audio data.
Returns
  • true: Receive audio data from multiple channels.
  • false: Do not receive audio data from multiple channels.

◆ onPlaybackAudioFrameBeforeMixingEx()

virtual bool agora::media::IAudioFrameObserver::onPlaybackAudioFrameBeforeMixingEx ( const char *  channelId,
unsigned int  uid,
AudioFrame audioFrame 
)
inlinevirtual

Gets the before-mixing playback audio frame from multiple channels.

After you successfully register the audio frame observer, if you set the return value of isMultipleChannelFrameWanted as true, the SDK triggers this callback each time it receives a before-mixing audio frame from any of the channel.

Note
To ensure that the audio playback frame has the expected format, Agora recommends that you call setPlaybackAudioFrameParameters after calling registerAudioFrameObserver to set the audio playback format.
Parameters
channelIdThe channel ID of this audio frame.
uidThe ID of the user sending this audio frame.
audioFrameThe pointer to AudioFrame.
Returns
  • true: Reserved for future use.
  • false: Reserved for future use.