Agora RTC Objective-C API Reference Refactor

Public Types | Public Member Functions
IAudioFrameObserver Class Referenceabstract

Inherits IAudioFrameObserverBase.

## Public Types
enum | AUDIO_FRAME_TYPE { FRAME_TYPE_PCM16 = 0 }

## Public Member Functions
virtual bool | onPlaybackAudioFrameBeforeMixing (const char *channelId, rtc::uid_t uid, AudioFrame &audioFrame)=0
virtual bool | onPlaybackAudioFrameBeforeMixing (const char *channelId, base::user_id_t userId, AudioFrame &audioFrame)
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 IAudioFrameObserver class.

## Member Enumeration Documentation

## ◆ AUDIO_FRAME_TYPE

enum AUDIO_FRAME_TYPE
| inherited

Audio frame types.

Enumerator
FRAME_TYPE_PCM16 | 0: 16-bit PCM.

## ◆ anonymous enum

anonymous enum
| inherited

Enumerator
MAX_HANDLE_TIME_CNT |

## ◆ AUDIO_FRAME_POSITION

enum AUDIO_FRAME_POSITION
| inherited

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

## Member Function Documentation

## ◆ onPlaybackAudioFrameBeforeMixing() [1/3]

virtual bool onPlaybackAudioFrameBeforeMixing | ( | const char * | channelId,
|  | rtc::uid_t | uid,
|  | AudioFrame & | audioFrame
| ) |  |
| pure virtual

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

Parameters

  channelId | The channel name
  uid | ID of the remote user.
  audioFrame | The 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.

## ◆ onPlaybackAudioFrameBeforeMixing() [2/3]

virtual bool onPlaybackAudioFrameBeforeMixing
| inline

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

Parameters

  channelId | The channel name
  userId | ID of the remote user.
  audioFrame | The 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.

## ◆ onRecordAudioFrame()

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

Occurs when the recorded audio frame is received.

Parameters

  channelId | The channel name
  audioFrame | The 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 inherited

Occurs when the playback audio frame is received.

Parameters

  channelId | The channel name
  audioFrame | The 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 inherited

Occurs when the mixed audio data is received.

Parameters

  channelId | The channel name
  audioFrame | The 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 inherited

Occurs when the ear monitoring audio frame is received.

Parameters

  audioFrame | The 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() [3/3]

virtual bool onPlaybackAudioFrameBeforeMixing | ( | const char * | channelId,
|  | base::user_id_t | userId,
|  | AudioFrame & | audioFrame
| ) |  |
| inline virtual inherited

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

Parameters

  channelId | The channel name
  userId | ID of the remote user.
  audioFrame | The 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 inherited

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.