Agora RTC Objective-C API Reference Refactor

Instance Methods
<AgoraAudioFrameDelegate> Protocol Reference

Inherits <NSObject>.

## Instance Methods
(BOOL) | - onRecordAudioFrame:channelId:
(BOOL) | - onPlaybackAudioFrame:channelId:
(BOOL) | - onMixedAudioFrame:channelId:
(BOOL) | - onEarMonitoringAudioFrame:
(BOOL) | - onPlaybackAudioFrameBeforeMixing:channelId:uid:
(AgoraAudioFramePosition) | - getObservedAudioFramePosition

## Detailed Description

The AgoraAudioFrameDelegate protocol enables audio frame callback event notifications to your application.

## Method Documentation

## ◆ onRecordAudioFrame:channelId:

- (BOOL) onRecordAudioFrame: |  | (AgoraAudioFrame *_Nonnull) | frame
channelId: |  | (NSString *_Nonnull) | channelId
| optional

Occurs when the recorded audio frame is received.

Parameters

  frame | A pointer to the audio frame: AgoraAudioFrame.
  channelId | Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are: All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. The space character. Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".

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:channelId:

- (BOOL) onPlaybackAudioFrame: |  | (AgoraAudioFrame *_Nonnull) | frame
channelId: |  | (NSString *_Nonnull) | channelId
| optional

Occurs when the playback audio frame is received.

Parameters

  channelId | Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are: All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. The space character. Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
  frame | A pointer to the audio frame: AgoraAudioFrame.

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:channelId:

- (BOOL) onMixedAudioFrame: |  | (AgoraAudioFrame *_Nonnull) | frame
channelId: |  | (NSString *_Nonnull) | channelId
| optional

Occurs when the mixed audio data is received.

Parameters

  frame | The A pointer to the audio frame: AgoraAudioFrame.
  channelId | Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are: All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. The space character. Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".

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:

- (BOOL) onEarMonitoringAudioFrame: |  | (AgoraAudioFrame *_Nonnull) | frame |
| optional

Occurs when the ear monitoring audio frame is received.

Parameters

  frame | A pointer to the audio frame: AgoraAudioFrame.

Returns
  - true: The ear monitoring audio frame is valid and is encoded and sent.
  - false: The ear monitoring audio frame is invalid and is not encoded or sent.

## ◆ onPlaybackAudioFrameBeforeMixing:channelId:uid:

- (BOOL) onPlaybackAudioFrameBeforeMixing: |  | (AgoraAudioFrame *_Nonnull) | frame
channelId: |  | (NSString *_Nonnull) | channelId
uid: |  | (NSUInteger) | uid
| optional

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

Parameters

  channelId | Unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are: All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. The space character. Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
  uid | ID of the remote user.
  frame | A pointer to the audio frame: AgoraAudioFrame.

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

- (AgoraAudioFramePosition) getObservedAudioFramePosition |  |  |
| optional

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:

- `AgoraAudioFramePositionPlayback (1 << 0)`: The position for playback audio frame is received, which corresponds to the onPlaybackFrame callback.
- `AgoraAudioFramePositionRecord (1 << 1)`: The position for record audio frame is received, which corresponds to the onRecordFrame callback.
- `AgoraAudioFramePositionMixed (1 << 2)`: The position for mixed audio frame is received, which corresponds to the onMixedFrame callback.
- `AgoraAudioFramePositionBeforeMixing (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 AgoraAudioFramePosition.