Agora C++ API Reference for All Platforms

Classes | Public Types | Public Member Functions | List of all members
agora::media::IAudioFrameObserverBase Class Referenceabstract

Inherited by agora::media::IAudioFrameObserver.

## Classes
struct | AudioFrame
struct | AudioParams

## Public Types
enum | AUDIO_FRAME_TYPE { FRAME_TYPE_PCM16 = 0 }
enum | { MAX_HANDLE_TIME_CNT = 10 }
enum | AUDIO_FRAME_POSITION { AUDIO_FRAME_POSITION_NONE = 0x0000, AUDIO_FRAME_POSITION_PLAYBACK = 0x0001, AUDIO_FRAME_POSITION_RECORD = 0x0002, AUDIO_FRAME_POSITION_MIXED = 0x0004, AUDIO_FRAME_POSITION_BEFORE_MIXING = 0x0008, AUDIO_FRAME_POSITION_EAR_MONITORING = 0x0010 }

## Public Member Functions
virtual | ~IAudioFrameObserverBase ()
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
virtual AudioParams | getPlaybackAudioParams ()=0
virtual AudioParams | getRecordAudioParams ()=0
virtual AudioParams | getMixedAudioParams ()=0
virtual AudioParams | getEarMonitoringAudioParams ()=0

## Detailed Description

The IAudioFrameObserverBase class.

## Member Enumeration Documentation

## ◆ AUDIO_FRAME_TYPE

enum agora::media::IAudioFrameObserverBase::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

enum agora::media::IAudioFrameObserverBase::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 agora::media::IAudioFrameObserverBase::~IAudioFrameObserverBase | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ onRecordAudioFrame()

virtual bool agora::media::IAudioFrameObserverBase::onRecordAudioFrame | ( | const char * | channelId,
|  | AudioFrame & | audioFrame
| ) |  |
| pure virtual

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 agora::media::IAudioFrameObserverBase::onPlaybackAudioFrame | ( | const char * | channelId,
|  | AudioFrame & | audioFrame
| ) |  |
| pure virtual

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.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ onMixedAudioFrame()

virtual bool agora::media::IAudioFrameObserverBase::onMixedAudioFrame | ( | const char * | channelId,
|  | AudioFrame & | audioFrame
| ) |  |
| pure virtual

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.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ onEarMonitoringAudioFrame()

virtual bool agora::media::IAudioFrameObserverBase::onEarMonitoringAudioFrame | ( | AudioFrame & | audioFrame | ) |
| pure virtual

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.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ onPlaybackAudioFrameBeforeMixing()

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

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 agora::media::IAudioFrameObserverBase::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.

## ◆ getPlaybackAudioParams()

virtual AudioParams agora::media::IAudioFrameObserverBase::getPlaybackAudioParams | ( |  | ) |
| pure virtual

Sets the audio playback format Note**:

- The SDK calculates the sample interval according to the `AudioParams` you set in the return value of this callback and triggers the `onPlaybackAudioFrame` callback at the calculated sample interval. Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). Ensure that the value of sample interval is equal to or greater than 0.01.

Returns
  Sets the audio format. See AgoraAudioParams.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ getRecordAudioParams()

virtual AudioParams agora::media::IAudioFrameObserverBase::getRecordAudioParams | ( |  | ) |
| pure virtual

Sets the audio recording format Note**:

- The SDK calculates the sample interval according to the `AudioParams` you set in the return value of this callback and triggers the `onRecordAudioFrame` callback at the calculated sample interval. Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). Ensure that the value of sample interval is equal to or greater than 0.01.

Returns
  Sets the audio format. See AgoraAudioParams.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ getMixedAudioParams()

virtual AudioParams agora::media::IAudioFrameObserverBase::getMixedAudioParams | ( |  | ) |
| pure virtual

Sets the audio mixing format Note**:

- The SDK calculates the sample interval according to the `AudioParams` you set in the return value of this callback and triggers the `onMixedAudioFrame` callback at the calculated sample interval. Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). Ensure that the value of sample interval is equal to or greater than 0.01.

Returns
  Sets the audio format. See AgoraAudioParams.

Implemented in agora::rtc::IMediaRecorderEx.

## ◆ getEarMonitoringAudioParams()

virtual AudioParams agora::media::IAudioFrameObserverBase::getEarMonitoringAudioParams | ( |  | ) |
| pure virtual

Sets the ear monitoring audio format Note**:

- The SDK calculates the sample interval according to the `AudioParams` you set in the return value of this callback and triggers the `onEarMonitoringAudioFrame` callback at the calculated sample interval. Sample interval (seconds) = `samplesPerCall`/(`sampleRate` × `channel`). Ensure that the value of sample interval is equal to or greater than 0.01.

Returns
  Sets the audio format. See AgoraAudioParams.

Implemented in agora::rtc::IMediaRecorderEx.