AgoraAudioDataFrameProtocol Protocol Reference

Conforms to NSObject
Declared in AgoraAudioFrame.h

Overview

The protocol of the raw audio data.

– onRecordAudioFrame: required method

Occurs when the recorded audio frame of the local user is received.

- (BOOL)onRecordAudioFrame:(AgoraAudioFrame *_Nonnull)frame

Parameters

frame

The raw audio data. See AgoraAudioFrame.

Return Value

  • YES: Reserved for future use.
  • NO: Reserved for future use.

Availability

v3.4.5

After you successfully register the audio delegate, the SDK triggers the onRecordAudioFrame callback every 10 ms by default, and the reported audio frame format is the same as the recorded audio frame format.

Discussion

Note: To ensure that the received audio frame has the expected format, you can register the getRecordAudioParams callback when calling the setAudioDataFrame method and set the audio recording format in the return value of getRecordAudioParams. The SDK calculates the sample interval according to the AgoraAudioParam you set in the return value of getRecordAudioParams and triggers the onRecordAudioFrame callback at the sample interval.

Declared In

AgoraAudioFrame.h

– onPlaybackAudioFrame: required method

Occurs when the playback audio frame of all remote users is received.

- (BOOL)onPlaybackAudioFrame:(AgoraAudioFrame *_Nonnull)frame

Parameters

frame

The raw audio data. See AgoraAudioFrame.

Return Value

  • YES: Reserved for future use.
  • NO: Reserved for future use.

Availability

v3.4.5

After you successfully register the audio delegate, the SDK triggers the onPlaybackAudioFrame callback every 10 ms by default, and the reported audio frame format is the same as the playback audio frame format.

Discussion

Note: To ensure that the received audio frame has the expected format, you can register the getPlaybackAudioParams callback when calling the setAudioDataFrame method and set the audio playback format in the return value of getPlaybackAudioParams. The SDK calculates the sample interval according to the AgoraAudioParam you set in the return value of getPlaybackAudioParams and triggers the onPlaybackAudioFrame callback at the sample interval.

Declared In

AgoraAudioFrame.h

– onMixedAudioFrame: required method

Occurs when the mixed audio frame of the local user and all remote users is received.

- (BOOL)onMixedAudioFrame:(AgoraAudioFrame *_Nonnull)frame

Parameters

frame

The raw audio data. See AgoraAudioFrame.

Return Value

  • YES: Reserved for future use.
  • NO: Reserved for future use.

Availability

v3.4.5

To trigger this callback, you need to register the getObservedAudioFramePosition callback when calling the setAudioDataFrame method and set the return value of getObservedAudioFramePosition as AgoraAudioFramePositionMixed (1 << 2). After the setting is successful, the SDK triggers the onMixedAudioFrame callback every 10 ms by default, and the reported audio frame format is the same as the mixed audio frame format.

Discussion

Note: To ensure that the received audio frame has the expected format, you can register the getMixedAudioParams callback when calling the setAudioDataFrame method and set the audio mixing format in the return value of getMixedAudioParams. The SDK calculates the sample interval according to the AgoraAudioFrame you set in the return value of getMixedAudioParams and triggers the onMixedAudioFrame callback at the sample interval.

Declared In

AgoraAudioFrame.h

– onPlaybackAudioFrameBeforeMixing:uid: required method

Occurs when the audio frame of a remote user is received before mixing.

- (BOOL)onPlaybackAudioFrameBeforeMixing:(AgoraAudioFrame *_Nonnull)frame uid:(NSUInteger)uid

Parameters

frame

The raw audio data. See AgoraAudioFrame.

uid

The user ID of the remote user.

Return Value

  • YES: Reserved for future use.
  • NO: Reserved for future use.

Availability

v3.4.5

To trigger this callback, you need to register the getObservedAudioFramePosition callback when calling the setAudioDataFrame method and set the return value of getObservedAudioFramePosition as AgoraAudioFramePositionBeforeMixing (1 << 3). After the setting is successful, the SDK triggers the onPlaybackAudioFrameBeforeMixing callback every 10 ms by default.

Declared In

AgoraAudioFrame.h

– getObservedAudioFramePosition required method

Sets the audio observation positions.

- (AgoraAudioFramePosition)getObservedAudioFramePosition

Return Value

The bit mask that controls the audio observation positions. See AgoraAudioFramePosition.

Availability

v3.4.5

After you successfully register the audio delegate, the SDK uses the getObservedAudioFramePosition callback to determine at each specific audio-frame processing node whether to trigger the following callbacks:

You can set the positions that you want to observe by modifying the return value of getObservedAudioFramePosition according to your scenario.

Note:

  • To observe multiple positions, use | (the OR operator).
  • The default return value of getObservedAudioFramePosition is AgoraAudioFramePositionPlayback (1 << 0) and AgoraAudioFramePositionRecord (1 << 1).
  • To conserve system resources, you can reduce the number of frame positions that you want to observe.

Declared In

AgoraAudioFrame.h

– getMixedAudioParams required method

Sets the audio mixing format for the onMixedAudioFrame callback.

- (AgoraAudioParam *_Nonnull)getMixedAudioParams

Return Value

Sets the audio format. See AgoraAudioParam.

Availability

v3.4.5

Register the getMixedAudioParams callback when calling the setAudioDataFrame method. After you successfully register the audio delegate, the SDK triggers this callback. You can set the audio mixing format in the return value of this callback.

Discussion

Note: The SDK calculates the sample interval according to the AgoraAudioParam 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.

Declared In

AgoraAudioFrame.h

– getRecordAudioParams required method

Sets the audio recording format for the onRecordAudioFrame callback.

- (AgoraAudioParam *_Nonnull)getRecordAudioParams

Return Value

Sets the audio format. See AgoraAudioParam.

Availability

v3.4.5

Register the getRecordAudioParams callback when calling the setAudioDataFrame method. After you successfully register the audio delegate, the SDK triggers this callback. You can set the audio recording format in the return value of this callback.

Discussion

Note: The SDK calculates the sample interval according to the AgoraAudioParam 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.

Declared In

AgoraAudioFrame.h

– getPlaybackAudioParams required method

Sets the audio playback format for the onPlaybackAudioFrame callback.

- (AgoraAudioParam *_Nonnull)getPlaybackAudioParams

Return Value

Sets the audio format. See AgoraAudioParam.

Availability

v3.4.5

Register the getPlaybackAudioParams callback when calling the setAudioDataFrame method. After you successfully register the audio delegate, the SDK triggers this callback. You can set the audio playback format in the return value of this callback.

Discussion

Note: The SDK calculates the sample interval according to the AgoraAudioParam 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.

Declared In

AgoraAudioFrame.h

– isMultipleChannelFrameWanted

Determines whether to receive raw audio data from multiple channels.

- (BOOL)isMultipleChannelFrameWanted

Return Value

  • YES: Receive audio data from multiple channels.
  • NO: Do not receive audio data from multiple channels.

Availability

v3.5.0

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

In a multi-channel scenario, if you want to get audio data from multiple channels, set the return value of this callback as YES, and set the return value of getObservedAudioFramePosition as AgoraAudioFramePositionBeforeMixing (1 << 3). 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 YES, the SDK triggers only the onPlaybackAudioFrameBeforeMixingEx callback to send the before-mixing audio frame. onPlaybackAudioFrameBeforeMixing is not triggered. In a multi-channel scenario, Agora recommends setting the return value as YES.
  • If you set the return value of this callback as NO, the SDK triggers only the onPlaybackAudioFrameBeforeMixing callback to send the audio data.

Declared In

AgoraAudioFrame.h

– onPlaybackAudioFrameBeforeMixingEx:channelId:uid:

Gets the audio frame of a remote user before mixing from one of the multiple channels.

- (BOOL)onPlaybackAudioFrameBeforeMixingEx:(AgoraAudioFrame *_Nonnull)frame channelId:(NSString *_Nonnull)channelId uid:(NSUInteger)uid

Parameters

frame

The raw audio data. See AgoraAudioFrame.

channelId

The channel name.

uid

The user ID of the remote user.

Return Value

  • YES: Reserved for future use.
  • NO: Reserved for future use.

Availability

v3.5.0

To trigger this callback, you need to register the following callbacks and set their return values when calling the setAudioDataFrame method:

After the setting is successful, the SDK triggers the onPlaybackAudioFrameBeforeMixingEx callback every 10 ms by default.

Declared In

AgoraAudioFrame.h