Agora RTC Objective-C API Reference  Refactor
Data Structures | Public Types | Public Member Functions
IAudioFrameObserverBase Class Referenceabstract

Inherited by IAudioFrameObserver.

Data Structures

struct  AudioFrame
 

Public Types

enum  AUDIO_FRAME_TYPE { FRAME_TYPE_PCM16 = 0 }
 

Public Member Functions

virtual bool onRecordAudioFrame (const char *channelId, AudioFrame &audioFrame)=0
 
virtual bool onPlaybackAudioFrame (const char *channelId, AudioFrame &audioFrame)=0
 
virtual bool onMixedAudioFrame (const char *channelId, AudioFrame &audioFrame)=0
 
virtual bool onEarMonitoringAudioFrame (AudioFrame &audioFrame)=0
 
virtual bool onPlaybackAudioFrameBeforeMixing (const char *channelId, base::user_id_t userId, AudioFrame &audioFrame)
 
virtual int getObservedAudioFramePosition ()=0
 

Detailed Description

The IAudioFrameObserverBase class.

Member Enumeration Documentation

◆ AUDIO_FRAME_TYPE

Audio frame types.

Enumerator
FRAME_TYPE_PCM16 

0: 16-bit PCM.

◆ anonymous enum

anonymous enum
Enumerator
MAX_HANDLE_TIME_CNT 

◆ AUDIO_FRAME_POSITION

Enumerator
AUDIO_FRAME_POSITION_NONE 
AUDIO_FRAME_POSITION_PLAYBACK 

The position for observing the playback audio of all remote users after mixing

AUDIO_FRAME_POSITION_RECORD 

The position for observing the recorded audio of the local user

AUDIO_FRAME_POSITION_MIXED 

The position for observing the mixed audio of the local user and all remote users

AUDIO_FRAME_POSITION_BEFORE_MIXING 

The position for observing the audio of a single remote user before mixing

AUDIO_FRAME_POSITION_EAR_MONITORING 

The position for observing the ear monitoring audio of the local user

Constructor & Destructor Documentation

◆ ~IAudioFrameObserverBase()

virtual ~IAudioFrameObserverBase ( )
inlinevirtual

Member Function Documentation

◆ onRecordAudioFrame()

virtual bool onRecordAudioFrame ( const char *  channelId,
AudioFrame audioFrame 
)
pure virtual

Occurs when the recorded audio frame is received.

Parameters
channelIdThe channel name
audioFrameThe reference to the audio frame: AudioFrame.
Returns
  • true: The recorded audio frame is valid and is encoded and sent.
  • false: The recorded audio frame is invalid and is not encoded or sent.

◆ onPlaybackAudioFrame()

virtual bool onPlaybackAudioFrame ( const char *  channelId,
AudioFrame audioFrame 
)
pure virtual

Occurs when the playback audio frame is received.

Parameters
channelIdThe channel name
audioFrameThe reference to the audio frame: AudioFrame.
Returns
  • true: The playback audio frame is valid and is encoded and sent.
  • false: The playback audio frame is invalid and is not encoded or sent.

◆ onMixedAudioFrame()

virtual bool onMixedAudioFrame ( const char *  channelId,
AudioFrame audioFrame 
)
pure virtual

Occurs when the mixed audio data is received.

Parameters
channelIdThe channel name
audioFrameThe reference to the audio frame: AudioFrame.
Returns
  • true: The mixed audio data is valid and is encoded and sent.
  • false: The mixed audio data is invalid and is not encoded or sent.

◆ onEarMonitoringAudioFrame()

virtual bool onEarMonitoringAudioFrame ( AudioFrame audioFrame)
pure virtual

Occurs when the ear monitoring audio frame is received.

Parameters
audioFrameThe reference to the audio frame: AudioFrame.
Returns
  • true: The ear monitoring audio data is valid and is encoded and sent.
  • false: The ear monitoring audio data is invalid and is not encoded or sent.

◆ onPlaybackAudioFrameBeforeMixing()

virtual bool onPlaybackAudioFrameBeforeMixing ( const char *  channelId,
base::user_id_t  userId,
AudioFrame audioFrame 
)
inlinevirtual

Occurs when the before-mixing playback audio frame is received.

Parameters
channelIdThe channel name
userIdID of the remote user.
audioFrameThe reference to the audio frame: AudioFrame.
Returns
  • true: The before-mixing playback audio frame is valid and is encoded and sent.
  • false: The before-mixing playback audio frame is invalid and is not encoded or sent.

◆ getObservedAudioFramePosition()

virtual int getObservedAudioFramePosition ( )
pure virtual

Sets the frame position for the audio observer.

Returns
A bit mask that controls the frame position of the audio observer.
Note
- Use '|' (the OR operator) to observe multiple frame positions.

After you successfully register the audio observer, the SDK triggers this callback each time it receives a audio frame. You can determine which position to observe by setting the return value. The SDK provides 4 positions for observer. Each position corresponds to a callback function:

  • AUDIO_FRAME_POSITION_PLAYBACK (1 << 0): The position for playback audio frame is received, which corresponds to the onPlaybackFrame callback.
  • AUDIO_FRAME_POSITION_RECORD (1 << 1): The position for record audio frame is received, which corresponds to the onRecordFrame callback.
  • AUDIO_FRAME_POSITION_MIXED (1 << 2): The position for mixed audio frame is received, which corresponds to the onMixedFrame callback.
  • AUDIO_FRAME_POSITION_BEFORE_MIXING (1 << 3): The position for playback audio frame before mixing is received, which corresponds to the onPlaybackFrameBeforeMixing callback.
    Returns
    The bit mask that controls the audio observation positions. See AUDIO_FRAME_POSITION.