IAgoraRtcAudioFrameObserver

The audio frame observer.

You can call RegisterAudioFrameObserver to register or unregister the IAgoraRtcAudioFrameObserver audio frame observer.

IsMultipleChannelFrameWanted

Determines whether to receive audio data from multiple channels.

public virtual bool IsMultipleChannelFrameWanted()
        {
            return true;
        }
Since
v3.0.1

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

In the multi-channel scenario, if you want to get audio data from multiple channels, set the return value of this callback as true. After that, the SDK triggers the OnPlaybackAudioFrameBeforeMixingEx callback to send you the before-mixing audio frame from various channels. You can also get the channel ID of each audio frame.

Attention:
  • Once you set the return value of the callback as true, the SDK triggers only the OnPlaybackAudioFrameBeforeMixingEx callback to send the audio data. OnPlaybackAudioFrameBeforeMixing will not be triggered. In the multi-channel scenario, Agora recommends setting the return value as true.
  • If you set the return value of this callback as false, the SDK triggers only the OnPlaybackAudioFrameBeforeMixing callback to send the audio data.

Returns

  • true: Receive audio data from multiple channels.
  • false: Do not receive audio data from multiple channels.

OnMixedAudioFrame

Retrieves the mixed captured and playback audio frame.

public virtual bool OnMixedAudioFrame(AudioFrame audioFrame)
        {
            return true;
        }
Attention: This callback only returns the single-channel data.

Parameters

audioFrame
The playback audio frame. For details, see 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.

OnPlaybackAudioFrame

Gtes the audio frame for playback.

public virtual bool OnPlaybackAudioFrame(AudioFrame audioFrame)
        {
            return true;
        }

Parameters

audioFrame
The playback audio frame. For details, see 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.

OnPlaybackAudioFrameBeforeMixing

Retrieves the audio frame of a specified user before mixing.

public virtual bool OnPlaybackAudioFrameBeforeMixing(uint uid, AudioFrame audioFrame)
        {
            return true;
        }

Parameters

uid
The user ID of the specified user.
audioFrame
The audio frame. For details, see 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.

OnPlaybackAudioFrameBeforeMixingEx

Gets the before-mixing playback audio frame from multiple channels.

public virtual bool OnPlaybackAudioFrameBeforeMixingEx(string channelId, uint uid, AudioFrame audioFrame)
        {
            return true;
        }

After you successfully register the audio frame observer, if you set the return value of IsMultipleChannelFrameWanted as true, the SDK triggers this callback each time it receives an audio frame from any of the channels.

Parameters

channelId
The channel name of this audio frame.
uid
The ID of the user sending the audio frame.
audioFrame
playback audio frame. For details, see AudioFrame.

Returns

  • true: Valid buffer in AudioFrame, and the captured audio frame is sent out.
  • false: Invalid buffer in AudioFrame, and the captured audio frame is discarded.

OnRecordAudioFrame

Gets the captured audio frame.

public virtual bool OnRecordAudioFrame(AudioFrame audioFrame)
        {
            return true;
        }

Parameters

audioFrame
The playback audio frame. For details, see 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.