IRtcEngine

The basic interface of the Agora SDK that implements the core functions of real-time communication.

IRtcEngine provides the main methods that your app can call.

Before calling other APIs, you must call CreateAgoraRtcEngine to create an IRtcEngine object.

InitEventHandler

Adds event handlers

public abstract int InitEventHandler(IRtcEngineEventHandler engineEventHandler);

Details

The SDK uses the IRtcEngineEventHandler class to send callbacks to the app. The app inherits the methods of this class to receive these callbacks. All methods in this class have default (empty) implementations. Therefore, apps only need to inherits callbacks according to the scenarios. In the callbacks, avoid time-consuming tasks or calling APIs that can block the thread, such as the SendStreamMessage method. Otherwise, the SDK may not work properly.

Parameters

engineEventHandler
Callback events to be added. See IRtcEngineEventHandler.

Returns

  • 0: Success.
  • < 0: Failure.

AddVideoWatermark [1/2]

Adds a watermark image to the local video.

public abstract int AddVideoWatermark(RtcImage watermark);

Details

Deprecated:
This method is deprecated. Use AddVideoWatermark [2/2] instead.

This method adds a PNG watermark image to the local video stream in a live streaming session. Once the watermark image is added, all the users in the channel (CDN audience included) and the video capturing device can see and capture it. If you only want to add a watermark to the CDN live streaming, see StartRtmpStreamWithTranscoding.

Attention:
  • The URL descriptions are different for the local video and CDN live streaming: In a local video stream, URL refers to the absolute path of the added watermark image file in the local video stream. In a CDN live stream, URL refers to the URL address of the added watermark image in the CDN live streaming.
  • The source file of the watermark image must be in the PNG file format. If the width and height of the PNG file differ from your settings in this method, the PNG file will be cropped to conform to your settings.
  • The Agora SDK supports adding only one watermark image onto a local video or CDN live stream. The newly added watermark image replaces the previous one.

Parameters

watermark
The watermark image to be added to the local live streaming: RtcImage.

Returns

  • 0: Success.
  • < 0: Failure.

AddVideoWatermark [2/2]

Adds a watermark image to the local video.

public abstract int AddVideoWatermark(string watermarkUrl, WatermarkOptions options);

Details

This method adds a PNG watermark image to the local video in the live streaming. Once the watermark image is added, all the audience in the channel (CDN audience included), and the capturing device can see and capture it. The Agora SDK supports adding only one watermark image onto a local video or CDN live stream. The newly added watermark image replaces the previous one.

The watermark coordinates are dependent on the settings in the SetVideoEncoderConfiguration method:
  • If the orientation mode of the encoding video (ORIENTATION_MODE) is fixed landscape mode or the adaptive landscape mode, the watermark uses the landscape orientation.
  • If the orientation mode of the encoding video (ORIENTATION_MODE) is fixed portrait mode or the adaptive portrait mode, the watermark uses the portrait orientation.
  • When setting the watermark position, the region must be less than the dimensions set in the SetVideoEncoderConfiguration method; otherwise, the watermark image will be cropped.
Attention:
  • Ensure that calling this method after EnableVideo.
  • If you only want to add a watermark to the media push, you can call this method or the StartRtmpStreamWithTranscoding method.
  • This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray.
  • If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings.
  • If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer.

Parameters

watermarkUrl
The local file path of the watermark image to be added. This method supports adding a watermark image from the local absolute or relative file path.
options
The options of the watermark image to be added. See WatermarkOptions.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustAudioMixingPlayoutVolume

Adjusts the volume of audio mixing for local playback.

public abstract int AdjustAudioMixingPlayoutVolume(int volume);

Details

Attention: Call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Parameters

volume
The volume of audio mixing for local playback. The value ranges between 0 and 100 (default). 100 represents the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustAudioMixingPublishVolume

Adjusts the volume of audio mixing for publishing.

public abstract int AdjustAudioMixingPublishVolume(int volume);

Details

This method adjusts the volume of audio mixing for publishing (sending to other users).

Attention:

Call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Parameters

volume
The volume of audio mixing for local playback. The value ranges between 0 and 100 (default). 100 represents the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustAudioMixingVolume

Adjusts the volume during audio mixing.

public abstract int AdjustAudioMixingVolume(int volume);

Details

This method adjusts the audio mixing volume on both the local client and remote clients.

Attention:

Parameters

volume
Audio mixing volume. The value ranges between 0 and 100. The default value is 100, which means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustCustomAudioPlayoutVolume

Adjusts the volume of the custom audio track played locally.

public abstract int AdjustCustomAudioPlayoutVolume(uint trackId, int volume);

Details

Attention: Ensure you have called the CreateCustomAudioTrack method to create a custom audio track before calling this method.

If you want to change the volume of the audio to be played locally, you need to call this method again.

Parameters

trackId
The audio track ID. Set this parameter to the custom audio track ID returned in CreateCustomAudioTrack.
volume
The volume of the audio source. The value can range from 0 to 100. 0 means mute; 100 means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustCustomAudioPublishVolume

Adjusts the volume of the custom audio track played remotely.

public abstract int AdjustCustomAudioPublishVolume(uint trackId, int volume);

Details

Attention: Ensure you have called the CreateCustomAudioTrack method to create a custom audio track before calling this method.

If you want to change the volume of the audio played remotely, you need to call this method again.

Parameters

trackId
The audio track ID. Set this parameter to the custom audio track ID returned in CreateCustomAudioTrack.
volume
The volume of the audio source. The value can range from 0 to 100. 0 means mute; 100 means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustLoopbackSignalVolume

Adjusts the volume of the signal captured by the sound card.

public abstract int AdjustLoopbackSignalVolume(int volume);

Details

After calling EnableLoopbackRecording to enable loopback audio capturing, you can call this method to adjust the volume of the signal captured by the sound card.

Parameters

volume
Audio mixing volume. The value ranges between 0 and 100. The default value is 100, which means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

AdjustPlaybackSignalVolume

Adjusts the playback signal volume of all remote users.

public abstract int AdjustPlaybackSignalVolume(int volume);

This method is used to adjust the signal volume of all remote users mixed and played locally. If you need to adjust the signal volume of a specified remote user played locally, it is recommended that you call AdjustUserPlaybackSignalVolume instead.

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

volume
The volume of the user. The value range is [0,400].
  • 0: Mute.
  • 100: (Default) The original volume.
  • 400: Four times the original volume (amplifying the audio signals by four times).

Returns

  • 0: Success.
  • < 0: Failure.

AdjustRecordingSignalVolume

Adjusts the capturing signal volume.

public abstract int AdjustRecordingSignalVolume(int volume);

If you only need to mute the audio signal, Agora recommends that you use MuteRecordingSignal instead.

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

volume
The volume of the user. The value range is [0,400].
  • 0: Mute.
  • 100: (Default) The original volume.
  • 400: Four times the original volume (amplifying the audio signals by four times).

Returns

  • 0: Success.
  • < 0: Failure.

AdjustUserPlaybackSignalVolume

Adjusts the playback signal volume of a specified remote user.

public abstract int AdjustUserPlaybackSignalVolume(uint uid, int volume);

You can call this method to adjust the playback volume of a specified remote user. To adjust the playback volume of different remote users, call the method as many times, once for each remote user.

Call timing

Call this method after joining a channel.

Restrictions

None.

Parameters

uid
The user ID of the remote user.
volume
The volume of the user. The value range is [0,400].
  • 0: Mute.
  • 100: (Default) The original volume.
  • 400: Four times the original volume (amplifying the audio signals by four times).

Returns

  • 0: Success.
  • < 0: Failure.

ClearVideoWatermarks

Removes the watermark image from the video stream.

public abstract int ClearVideoWatermarks();

Returns

  • 0: Success.
  • < 0: Failure.

Complain

Allows a user to complain about the call quality after a call ends.

public abstract int Complain(string callId, string description);

Details

This method allows users to complain about the quality of the call. Call this method after the user leaves the channel.

Parameters

callId
The current call ID. You can get the call ID by calling GetCallId.
description
(Optional) A description of the call. The string length should be less than 800 bytes.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -7: The method is called before IRtcEngine is initialized.

ConfigRhythmPlayer

Configures the virtual metronome.

public abstract int ConfigRhythmPlayer(AgoraRhythmPlayerConfig config);

Details

After calling StartRhythmPlayer, you can call this method to reconfigure the virtual metronome.

After successfully calling this method, the SDK triggers the OnRhythmPlayerStateChanged callback locally to report the status of the virtual metronome.

Attention:
  • This method is for Android and iOS only.
  • After enabling the virtual metronome, the SDK plays the specified audio effect file from the beginning, and controls the playback duration of each file according to beatsPerMinute you set in AgoraRhythmPlayerConfig. For example, if you set beatsPerMinute as 60, the SDK plays one beat every second. If the file duration exceeds the beat duration, the SDK only plays the audio within the beat duration.
  • By default, the sound of the virtual metronome is published in the channel. If you do not want the sound to be heard by the remote users, you can set publishRhythmPlayerTrack in ChannelMediaOptions as false.

Parameters

config
The metronome configuration. See AgoraRhythmPlayerConfig.

Returns

  • 0: Success.
  • < 0: Failure.

Initialize

Initializes IRtcEngine.

public abstract int Initialize(RtcEngineContext context);

Details

All called methods provided by the IRtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

Attention:
  • The SDK supports creating only one IRtcEngine instance for an app.

Parameters

context

Configurations for the IRtcEngine instance. See RtcEngineContext.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -7: The SDK is not initialized.
    • -22: The resource request failed. The SDK fails to allocate resources because your app consumes too much system resource or the system resources are insufficient.
    • -101: The App ID is invalid.

CreateAgoraRtcEngine

Creates one IRtcEngine object.

public static IRtcEngine CreateAgoraRtcEngine()
        {
            return instance ?? (instance = new RtcEngine(IntPtr.Zero));
        }

Details

Currently, the Agora RTC SDK v4.x supports creating only one IRtcEngine object for each app.

Returns

One IRtcEngine object.

CreateDataStream [1/2]

Creates a data stream.

public abstract int CreateDataStream(ref int streamId, bool reliable, bool ordered);

Details

Each user can create up to five data streams during the lifecycle of IRtcEngine. The data stream will be destroyed when leaving the channel, and the data stream needs to be recreated if needed.

Attention:
  • Call this method after joining a channel.
  • Agora does not support setting reliable as true and ordered as false.

Parameters

streamId
An output parameter; the ID of the data stream created.
reliable
Whether or not the data stream is reliable:
  • true: The recipients receive the data from the sender within five seconds. If the recipient does not receive the data within five seconds, the SDK triggers the OnStreamMessageError callback and returns an error code.
  • false: There is no guarantee that the recipients receive the data stream within five seconds and no error message is reported for any delay or missing data stream.
ordered
Whether or not the recipients receive the data stream in the sent order:
  • true: The recipients receive the data in the sent order.
  • false: The recipients do not receive the data in the sent order.

Returns

  • 0: The data stream is successfully created.
  • < 0: Failure.

CreateDataStream [2/2]

Creates a data stream.

public abstract int CreateDataStream(ref int streamId, DataStreamConfig config);

Details

Creates a data stream. Each user can create up to five data streams in a single channel.

Compared with CreateDataStream [1/2], this method does not support data reliability. If a data packet is not received five seconds after it was sent, the SDK directly discards the data.

Parameters

streamId
An output parameter; the ID of the data stream created.
config
The configurations for the data stream. See DataStreamConfig.

Returns

  • 0: The data stream is successfully created.
  • < 0: Failure.

CreateMediaPlayer

Creates a media player instance.

public abstract IMediaPlayer CreateMediaPlayer();

Returns

  • The IMediaPlayer instance, if the method call succeeds.
  • An empty pointer, if the method call fails.

CreateCustomAudioTrack

Creates a custom audio track.

public abstract uint CreateCustomAudioTrack(AUDIO_TRACK_TYPE trackType, AudioTrackConfig config);

Details

Attention: Ensure that you call this method before joining a channel.
To publish a custom audio source, see the following steps:
  1. Call this method to create a custom audio track and get the audio track ID.
  2. Call JoinChannel [2/2] to join the channel. In ChannelMediaOptions, set publishCustomAduioTrackId to the audio track ID that you want to publish, and set publishCustomAudioTrack to true.
  3. Call PushAudioFrame and specify trackId as the audio track ID set in step 2. You can then publish the corresponding custom audio source in the channel.

Parameters

trackType
The type of the custom audio track. See AUDIO_TRACK_TYPE.
Attention: If AUDIO_TRACK_DIRECT is specified for this parameter, you must set publishMicrophoneTrack to false in ChannelMediaOptions when calling JoinChannel [2/2] to join the channel; otherwise, joining the channel fails and returns the error code -2.
config
The configuration of the custom audio track. See AudioTrackConfig.

Returns

  • If the method call is successful, the audio track ID is returned as the unique identifier of the audio track.
  • If the method call fails, a negative value is returned.

CreateCustomVideoTrack

Creates a custom video track.

public abstract video_track_id_t CreateCustomVideoTrack();

Details

To publish a custom video source, see the following steps:
  1. Call this method to create a video track and get the video track ID.
  2. Call JoinChannel [2/2] to join the channel. In ChannelMediaOptions, set customVideoTrackId to the video track ID that you want to publish, and set publishCustomVideoTrack to true.
  3. Call PushVideoFrame and specify videoTrackId as the video track ID set in step 2. You can then publish the corresponding custom video source in the channel.

Returns

  • If the method call is successful, the video track ID is returned as the unique identifier of the video track.
  • If the method call fails, a negative value is returned.

DestroyCustomAudioTrack

Destroys the specified audio track.

public abstract int DestroyCustomAudioTrack(uint trackId);

Details

Parameters

trackId
The custom audio track ID returned in CreateCustomAudioTrack.

Returns

  • 0: Success.
  • < 0: Failure.

DestroyCustomVideoTrack

Destroys the specified video track.

public abstract int DestroyCustomVideoTrack(video_track_id_t video_track_id);

Parameters

video_track_id
The video track ID returned by calling the CreateCustomVideoTrack method.

Returns

  • 0: Success.
  • < 0: Failure.

DestroyMediaPlayer

Destroys the media player instance.

public abstract int DestroyMediaPlayer(IMediaPlayer mediaPlayer);

Parameters

mediaPlayer

One IMediaPlayer object.

Returns

  • ≥ 0: Success. Returns the ID of media player instance.
  • < 0: Failure.

DisableAudio

Disables the audio module.

public abstract int DisableAudio();

The audio module is enabled by default, and you can call this method to disable the audio module.

Call timing

It can be called either before or after joining the channel. It is still valid after one leaves channel.

Restrictions

This method resets the internal engine and takes some time to take effect. Agora recommends using the following API methods to control the audio modules separately:

Returns

  • 0: Success.
  • < 0: Failure.

DisableAudioSpectrumMonitor

Disables audio spectrum monitoring.

public abstract int DisableAudioSpectrumMonitor();

Details

After calling EnableAudioSpectrumMonitor, if you want to disable audio spectrum monitoring, you can call this method.

Attention:

You can call this method either before or after joining a channel.

Returns

  • 0: Success.
  • < 0: Failure.

DisableVideo

Disables the video module.

public abstract int DisableVideo();

This method is used to disable the video module.

Call timing

This method can be called either before or after joining the channel.
  • If it is called before joining the channel, the audio-only mode is enabled.
  • If it is called after joining the channel, it switches from video mode to audio-only mode. Then, calling EnableVideo can swithch to video mode again.

Restrictions

  • This method affects the internal engine and can be called after leaving the channel.
  • Calling this method will reset the entire engine, resulting in a slow response time. Instead of calling this method, you can independently control a specific video module based on your actual needs using the following methods:

Returns

  • 0: Success.
  • < 0: Failure.

Dispose

Releases the IRtcEngine instance.

public abstract void Dispose(bool sync = false);

Details

This method releases all resources used by the Agora SDK. Use this method for apps in which users occasionally make voice or video calls. When users do not make calls, you can free up resources for other operations.

After a successful method call, you can no longer use any method or callback in the SDK anymore. If you want to use the real-time communication functions again, you must call CreateAgoraRtcEngine and Initialize to create a new IRtcEngine instance.

Attention:
  • This method can be called synchronously. You need to wait for the resource of IRtcEngine to be released before performing other operations (for example, create a new IRtcEngine object). Therefore, Agora recommends calling this method in the child thread to avoid blocking the main thread.
  • Besides, Agora does not recommend you calling Dispose in any callback of the SDK. Otherwise, the SDK cannot release the resources until the callbacks return results, which may result in a deadlock.

Parameters

sync

Whether the method is called synchronously:

  • true: Synchronous call.
  • false: Asynchronous call. Currently this method only supports synchronous calls. Do not set this parameter to this value.

EnableAudio

Enables the audio module.

public abstract int EnableAudio();

The audio module is enabled by default After calling DisableAudio to disable the audio module, you can call this method to re-enable it.

Call timing

It can be called either before or after joining the channel. It is still valid after one leaves channel.

Restrictions

  • Calling this method will reset the entire engine, resulting in a slow response time. Instead of callling this method, you can independently control a specific audio module based on your actual needs using the following methods:
  • A successful call of this method resets EnableLocalAudio, MuteRemoteAudioStream, and MuteAllRemoteAudioStreams. Proceed it with caution.

Returns

  • 0: Success.
  • < 0: Failure.

EnableAudioSpectrumMonitor

Turns on audio spectrum monitoring.

public abstract int EnableAudioSpectrumMonitor(int intervalInMS = 100);

Details

If you want to obtain the audio spectrum data of local or remote users, you can register the audio spectrum observer and enable audio spectrum monitoring.

Attention:

You can call this method either before or after joining a channel.

Parameters

intervalInMS

The interval (in milliseconds) at which the SDK triggers the OnLocalAudioSpectrum and OnRemoteAudioSpectrum callbacks. The default value is 100. Do not set this parameter to a value less than 10, otherwise calling this method would fail.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: Invalid parameters.

EnableAudioVolumeIndication

Enables the reporting of users' volume indication.

public abstract int EnableAudioVolumeIndication(int interval, int smooth, bool reportVad);

This method enables the SDK to regularly report the volume information to the app of the local user who sends a stream and remote users (three users at most) whose instantaneous volumes are the highest.

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

interval
Sets the time interval between two consecutive volume indications:
  • ≤ 0: Disables the volume indication.
  • > 0: Time interval (ms) between two consecutive volume indications. Ensure this parameter is set to a value greater than 10, otherwise you will not receive the OnAudioVolumeIndication callback. Agora recommends that this value is set as greater than 100.
smooth
The smoothing factor that sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The recommended value is 3. The greater the value, the more sensitive the indicator.
reportVad
  • true: Enables the voice activity detection of the local user. Once it is enabled, the vad parameter of the OnAudioVolumeIndication callback reports the voice activity status of the local user.
  • false: (Default) Disables the voice activity detection of the local user. Once it is disabled, the vad parameter of the OnAudioVolumeIndication callback does not report the voice activity status of the local user, except for the scenario where the engine automatically detects the voice activity of the local user.

Returns

  • 0: Success.
  • < 0: Failure.

EnableCameraCenterStage

Enables or disables portrait center stage.

public abstract int EnableCameraCenterStage(bool enabled);

The portrait center stage feature is off by default. You need to call this method to turn it on. If you need to disable this feature, you need to call this method again and set enabled to false.

Attention: This method is for iOS and macOS only.

Applicable scenarios

The portrait center stage feature can be widely used in scenarios such as online meetings, shows, online education, etc. The host can use this feature to ensure that they are always in the center of the screen, whether they move or not, in order to achieve a good display effect.

Call timing

This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Restrictions

Due to the high performance requirements of this feature, you need to use it on the following types of devices or devices with higher performance:
  • iPad:
    • 12.9-inch iPad Pro (5th generation)
    • 11-inch iPad Pro (3rd generation)
    • iPad (9th generation)
    • iPad mini (6th generation)
    • iPad Air (5th generation)
  • 2020 M1 MacBook Pro 13-inch + iPhone 11 (using iPhone as external camera for the MacBook)

Agora recommends that you call IsCameraCenterStageSupported to check whether the current device supports portrait center stage before enabling this feature.

Parameters

enabled
Whether to enable the portrait center stage:
  • true: Enable portrait center stage.
  • false: Disable portrait center stage.

Returns

  • 0: Success.
  • < 0: Failure.

EnableContentInspect

Enables or disables video screenshot and upload.

public abstract int EnableContentInspect(bool enabled, ContentInspectConfig config);

Details

When video screenshot and upload function is enabled, the SDK takes screenshots and uploads videos sent by local users based on the type and frequency of the module you set in ContentInspectConfig. After video screenshot and upload, the Agora server sends the callback notification to your app server in HTTPS requests and sends all screenshots to the third-party cloud storage service.

Note: Before calling this method, ensure that you have contacted technical support to activate the video screenshot upload service.

Parameters

enabled
Whether to enable video screenshot and upload:
  • true: Enables video screenshot and upload.
  • false: Disables video screenshot and upload.
config
Configuration of video screenshot and upload. See ContentInspectConfig.
Note: When the video moderation module is set to video moderation via Agora self-developed extension(CONTENT_INSPECT_SUPERVISION), the video screenshot and upload dynamic library libagora_content_inspect_extension.dll is required. Deleting this library disables the screenshot and upload feature.

Returns

  • 0: Success.
  • < 0: Failure.

EnableDualStreamMode [1/2]

Enables or disables dual-stream mode on the sender side.

public abstract int EnableDualStreamMode(bool enabled);

Details

Deprecated:
This method is deprecated as of v4.2.0. Use SetDualStreamMode [1/2] instead.
Dual streams are a pairing of a high-quality video stream and a low-quality video stream:
  • High-quality video stream: High bitrate, high resolution.
  • Low-quality video stream: Low bitrate, low resolution.

After you enable dual-stream mode, you can call SetRemoteVideoStreamType to choose to receive either the high-quality video stream or the low-quality video stream on the subscriber side.

Note:
  • This method is applicable to all types of streams from the sender, including but not limited to video streams collected from cameras, screen sharing streams, and custom-collected video streams.
  • If you need to enable dual video streams in a multi-channel scenario, you can call the EnableDualStreamModeEx method.
  • You can call this method either before or after joining a channel.

Parameters

enabled
Whether to enable dual-stream mode:
  • true: Enable dual-stream mode.
  • false: (Default) Disable dual-stream mode.

Returns

  • 0: Success.
  • < 0: Failure.

EnableDualStreamMode [2/2]

Sets the dual-stream mode on the sender side and the low-quality video stream.

public abstract int EnableDualStreamMode(bool enabled, SimulcastStreamConfig streamConfig);

Details

Deprecated:
This method is deprecated as of v4.2.0. Use SetDualStreamMode [2/2] instead.
You can call this method to enable or disable the dual-stream mode on the publisher side. Dual streams are a pairing of a high-quality video stream and a low-quality video stream:
  • High-quality video stream: High bitrate, high resolution.
  • Low-quality video stream: Low bitrate, low resolution.

After you enable dual-stream mode, you can call SetRemoteVideoStreamType to choose to receive either the high-quality video stream or the low-quality video stream on the subscriber side.

Note:
  • This method is applicable to all types of streams from the sender, including but not limited to video streams collected from cameras, screen sharing streams, and custom-collected video streams.
  • If you need to enable dual video streams in a multi-channel scenario, you can call the EnableDualStreamModeEx method.
  • You can call this method either before or after joining a channel.

Parameters

enabled
Whether to enable dual-stream mode:
  • true: Enable dual-stream mode.
  • false: (Default) Disable dual-stream mode.
streamConfig
The configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: When setting mode to DISABLE_SIMULCAST_STREAM, setting streamConfig will not take effect.

Returns

  • 0: Success.
  • < 0: Failure.

EnableCustomAudioLocalPlayback

Sets whether to enable the local playback of external audio source.

public abstract int EnableCustomAudioLocalPlayback(uint trackId, bool enabled);

Details

Attention: Ensure you have called the CreateCustomAudioTrack method to create a custom audio track before calling this method.

After calling this method to enable the local playback of external audio source, if you need to stop local playback, you can call this method again and set enabled to false.

You can call AdjustCustomAudioPlayoutVolume to adjust the local playback volume of the custom audio track.

Parameters

trackId
The audio track ID. Set this parameter to the custom audio track ID returned in CreateCustomAudioTrack.
enabled
Whether to play the external audio source:
  • true: Play the external audio source.
  • false: (Default) Do not play the external source.

Returns

  • 0: Success.
  • < 0: Failure.

EnableEncryption

Enables or disables the built-in encryption.

public abstract int EnableEncryption(bool enabled, EncryptionConfig config);

Details

In scenarios requiring high security, Agora recommends calling this method to enable the built-in encryption before joining a channel.

All users in the same channel must use the same encryption mode and encryption key. After the user leaves the channel, the SDK automatically disables the built-in encryption. To enable the built-in encryption, call this method before the user joins the channel again.

Attention: If you enable the built-in encryption, you cannot use the Media Push function.

Parameters

enabled
Whether to enable built-in encryption:
  • true: Enable the built-in encryption.
  • false: (Default) Disable the built-in encryption.
config
Built-in encryption configurations. See EncryptionConfig.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: An invalid parameter is used. Set the parameter with a valid value.
    • -4: The built-in encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library.
    • -7: The SDK is not initialized. Initialize the IRtcEngine instance before calling this method.

EnableExtension

Enables or disables extensions.

public abstract int EnableExtension(string provider, string extension, bool enable = true, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE);

Call timing

Agora recommends that you call this method after joining a channel.

Restrictions

  • If you want to enable multiple extensions, you need to call this method multiple times.
  • After a successful call of this method, you cannot load other extensions.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
enable
Whether to enable the extension:
  • true: Enable the extension.
  • false: Disable the extension.
type
Source type of the extension. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.
    • -3: The extension library is not loaded. Agora recommends that you check the storage location or the name of the dynamic library.

EnableFaceDetection

Enables or disables face detection for the local user.

public abstract int EnableFaceDetection(bool enabled);

Details

You can call this method either before or after joining a channel.

Attention: This method is for Android and iOS only.
Once face detection is enabled, the SDK triggers the OnFacePositionChanged callback to report the face information of the local user, which includes the following:
  • The width and height of the local video.
  • The position of the human face in the local view.
  • The distance between the human face and the screen.

This method needs to be called after the camera is started (for example, by calling StartPreview [2/2] orEnableVideo ).

Parameters

enabled
Whether to enable face detection for the local user:
  • true: Enable face detection.
  • false: (Default) Disable face detection.

Returns

  • 0: Success.
  • < 0: Failure.

EnableInEarMonitoring

Enables in-ear monitoring.

public abstract int EnableInEarMonitoring(bool enabled, int includeAudioFilters);

Details

This method enables or disables in-ear monitoring.

Attention:
  • Users must use earphones (wired or Bluetooth) to hear the in-ear monitoring effect.
  • You can call this method either before or after joining a channel.

Parameters

enabled
Enables or disables in-ear monitoring.
  • true: Enables in-ear monitoring.
  • false: (Default) Disables in-ear monitoring.
includeAudioFilters
The audio filter types of in-ear monitoring. See EAR_MONITORING_FILTER_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.
    • - 8: Make sure the current audio routing is Bluetooth or headset.

EnableInstantMediaRendering

Enables audio and video frame instant rendering.

public abstract int EnableInstantMediaRendering();

Details

After successfully calling this method, the SDK enables the instant frame rendering mode, which can speed up the first frame rendering speed after the user joins the channel.
Attention:
  • Once the instant rendering function is enabled, it can only be canceled by calling the Dispose method to destroy the IRtcEngine object.
  • In this mode, the SDK uses Agora's custom encryption algorithm to shorten the time required to establish transmission links, and the security is reduced compared to the standard DTLS (Datagram Transport Layer Security). If the application scenario requires higher security standards, Agora recommends that you do not use this method.

Applicable scenarios

Agora recommends that you enable this mode for the audience in a live streaming scenario.

Returns

  • 0: Success.
  • < 0: Failure.
    • -7: The method is called before IRtcEngine is initialized.

EnableLocalAudio

Enables or disables the local audio capture.

public abstract int EnableLocalAudio(bool enabled);

The audio function is enabled by default when users joining a channel. This method disables or re-enables the local audio function to stop or restart local audio capturing.

The difference between this method and MuteLocalAudioStream are as follows:
  • EnableLocalAudio: Disables or re-enables the local audio capturing and processing. If you disable or re-enable local audio capturing using the EnableLocalAudio method, the local user might hear a pause in the remote audio playback.
  • MuteLocalAudioStream: Sends or stops sending the local audio streams without affecting the audio capture status.

Applicable scenarios

This method does not affect receiving the remote audio streams, and EnableLocalAudio(false) is applicable to scenarios where the user wants to receive remote audio streams without sending any audio stream to other users in the channel.

Call timing

You can call this method either before or after joining a channel. Calling it before joining a channel only sets the device state, and it takes effect immediately after you join the channel.

Restrictions

None.

Parameters

enabled
  • true: (Default) Re-enable the local audio function, that is, to start the local audio capturing device (for example, the microphone).
  • false: Disable the local audio function, that is, to stop local audio capturing.

Returns

  • 0: Success.
  • < 0: Failure.

EnableLocalVideo

Enables/Disables the local video capture.

public abstract int EnableLocalVideo(bool enabled);

Details

This method disables or re-enables the local video capture, and does not affect receiving the remote video stream.

After calling EnableVideo, the local video capture is enabled by default.

If you call EnableLocalVideo(false) to disable local video capture within the channel, it also simultaneously stops publishing the video stream within the channel. If you want to restart video catpure, you can call EnableLocalVideo(true) and then call UpdateChannelMediaOptions to set the options parameter to publish the locally captured video stream in the channel.

After the local video capturer is successfully disabled or re-enabled, the SDK triggers the OnRemoteVideoStateChanged callback on the remote client.

Attention:
  • You can call this method either before or after joining a channel.
  • This method enables the internal engine and is valid after leaving the channel.

Parameters

enabled

Whether to enable the local video capture.

  • true: (Default) Enable the local video capture.
  • false: Disable the local video capture. Once the local video is disabled, the remote users cannot receive the video stream of the local user, while the local user can still receive the video streams of remote users. When set to false, this method does not require a local camera.

Returns

  • 0: Success.
  • < 0: Failure.

EnableLoopbackRecording

Enables loopback audio capturing.

public abstract int EnableLoopbackRecording(bool enabled, string deviceName = "");

Details

If you enable loopback audio capturing, the output of the sound card is mixed into the audio stream sent to the other end.

Attention:
  • This method applies to the macOS and Windows only.
  • macOS does not support loopback audio capture of the default sound card. If you need to use this function, use a virtual sound card and pass its name to the deviceName parameter. Agora recommends using AgoraALD as the virtual sound card for audio capturing.
  • You can call this method either before or after joining a channel.
  • If you call the DisableAudio method to disable the audio module, audio capturing will be disabled as well. If you need to enable audio capturing, call the EnableAudio method to enable the audio module and then call the EnableLoopbackRecording method.

Parameters

enabled
Sets whether to enable loopback audio capturing.
  • true: Enable loopback audio capturing.
  • false: (Default) Disable loopback audio capturing.
deviceName
  • macOS: The device name of the virtual sound card. The default value is set to NULL, which means using AgoraALD for loopback audio capturing.
  • Windows: The device name of the sound card. The default is set to NULL, which means the SDK uses the sound card of your device for loopback audio capturing.

Returns

  • 0: Success.
  • < 0: Failure.

EnableMultiCamera

Enables or disables multi-camera capture.

public abstract int EnableMultiCamera(bool enabled, CameraCapturerConfiguration config);

Details

In scenarios where there are existing cameras to capture video, Agora recommends that you use the following steps to capture and publish video with multiple cameras:
  1. Call this method to enable multi-channel camera capture.
  2. Call StartPreview [2/2] to start the local video preview.
  3. Call StartCameraCapture, and set sourceType to start video capture with the second camera.
  4. Call JoinChannelEx, and set publishSecondaryCameraTrack to true to publish the video stream captured by the second camera in the channel.
If you want to disable multi-channel camera capture, use the following steps:
  1. Call StopCameraCapture.
  2. Call this method with enabled set to false.
Note:
You can call this method before and after StartPreview [2/2] to enable multi-camera capture:
  • If it is enabled before StartPreview [2/2], the local video preview shows the image captured by the two cameras at the same time.
  • If it is enabled after StartPreview [2/2], the SDK stops the current camera capture first, and then enables the primary camera and the second camera. The local video preview appears black for a short time, and then automatically returns to normal.

This method applies to iOS only.

When using this function, ensure that the system version is 13.0 or later.

The minimum iOS device types that support multi-camera capture are as follows:
  • iPhone XR
  • iPhone XS
  • iPhone XS Max
  • iPad Pro 3rd generation and later

Parameters

enabled
Whether to enable multi-camera video capture mode:
  • true: Enable multi-camera capture mode; the SDK uses multiple cameras to capture video.
  • false: Disable multi-camera capture mode; the SDK uses a single camera to capture video.
config
Capture configuration for the second camera. See CameraCapturerConfiguration.

Returns

  • 0: Success.
  • < 0: Failure.

EnableSpatialAudio

Enables or disables the spatial audio effect.

public abstract int EnableSpatialAudio(bool enabled);

Details

After enabling the spatial audio effect, you can call SetRemoteUserSpatialAudioParams to set the spatial audio effect parameters of the remote user.

Note:
  • You can call this method either before or after joining a channel.
  • This method relies on the spatial audio dynamic library libagora_spatial_audio_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

enabled
Whether to enable the spatial audio effect:
  • true: Enable the spatial audio effect.
  • false: Disable the spatial audio effect.

Returns

  • 0: Success.
  • < 0: Failure.

EnableSoundPositionIndication

Enables or disables stereo panning for remote users.

public abstract int EnableSoundPositionIndication(bool enabled);

Details

Ensure that you call this method before joining a channel to enable stereo panning for remote users so that the local user can track the position of a remote user by calling SetRemoteVoicePosition.

Parameters

enabled
Whether to enable stereo panning for remote users:
  • true: Enable stereo panning.
  • false: Disable stereo panning.

Returns

  • 0: Success.
  • < 0: Failure.

EnableVideo

Enables the video module.

public abstract int EnableVideo();

The video module is disabled by default, call this method to enable it. If you need to disable the video module later, you need to call DisableVideo.

Call timing

This method can be called either before joining a channel or while in the channel:
  • If called before joining a channel, it enables the video module.
  • If called during an audio-only call, the audio call automatically switches to a video call.

Restrictions

  • This method enables the internal engine and is valid after leaving the channel.
  • Calling this method will reset the entire engine, resulting in a slow response time. Instead of calling this method, you can independently control a specific video module based on your actual needs using the following methods:
  • A successful call of this method resets EnableLocalVideo, MuteRemoteVideoStream, and MuteAllRemoteVideoStreams. Proceed it with caution.

Returns

  • 0: Success.
  • < 0: Failure.

EnableVideoImageSource

Sets whether to replace the current video feeds with images when publishing video streams.

public abstract int EnableVideoImageSource(bool enable, ImageTrackOptions options);

Details

Attention: Agora recommends that you call this method after joining a channel.

When publishing video streams, you can call this method to replace the current video feeds with custom images.

Once you enable this function, you can select images to replace the video feeds through the ImageTrackOptions parameter. If you disable this function, the remote users see the video feeds that you publish.

Parameters

enable
Whether to replace the current video feeds with custom images:
  • true: Replace the current video feeds with custom images.
  • false: (Default) Do not replace the current video feeds with custom images.
options
Image configurations. See ImageTrackOptions.

Returns

  • 0: Success.
  • < 0: Failure.

EnableVirtualBackground

Enables/Disables the virtual background.

public abstract int EnableVirtualBackground(bool enabled, VirtualBackgroundSource backgroundSource, SegmentationProperty segproperty, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Details

The virtual background feature enables the local user to replace their original background with a static image, dynamic video, blurred background, or portrait-background segmentation to achieve picture-in-picture effect. Once the virtual background feature is enabled, all users in the channel can see the custom background.

Call this method after calling EnableVideo or StartPreview [2/2].

Attention:
  • This feature has high requirements on device performance. When calling this method, the SDK automatically checks the capabilities of the current device. Agora recommends you use virtual background on devices with the following processors:
    • Snapdragon 700 series 750G and later
    • Snapdragon 800 series 835 and later
    • Dimensity 700 series 720 and later
    • Kirin 800 series 810 and later
    • Kirin 900 series 980 and later
    • Devices with an i5 CPU and better
    • Devices with an A9 chip and better, as follows:
      • iPhone 6S and later
      • iPad Air 3rd generation and later
      • iPad 5th generation and later
      • iPad Pro 1st generation and later
      • iPad mini 5th generation and later
  • Agora recommends that you use this feature in scenarios that meet the following conditions:
    • A high-definition camera device is used, and the environment is uniformly lit.
    • There are few objects in the captured video. Portraits are half-length and unobstructed. Ensure that the background is a solid color that is different from the color of the user's clothing.
  • This method relies on the virtual background dynamic library libagora_segmentation_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

enabled
Whether to enable virtual background:
  • true: Enable virtual background.
  • false: Disable virtual background.
backgroundSource
The custom background. See VirtualBackgroundSource. To adapt the resolution of the custom background image to that of the video captured by the SDK, the SDK scales and crops the custom background image while ensuring that the content of the custom background image is not distorted.
segproperty
Processing properties for background images. See SegmentationProperty.
type
The type of the video source. See MEDIA_SOURCE_TYPE.
Attention: In this method, this parameter supports only the following two settings:
  • The default value is PRIMARY_CAMERA_SOURCE.
  • If you want to use the second camera to capture video, set this parameter to SECONDARY_CAMERA_SOURCE.

Returns

  • 0: Success.
  • < 0: Failure.
    • -4: The device capabilities do not meet the requirements for the virtual background feature. Agora recommends you try it on devices with higher performance.

EnableWebSdkInteroperability

Enables interoperability with the Agora Web SDK (applicable only in the live streaming scenarios).

public abstract int EnableWebSdkInteroperability(bool enabled);

Details

Deprecated:
The SDK automatically enables interoperability with the Web SDK, so you no longer need to call this method.

You can call this method to enable or disable interoperability with the Agora Web SDK. If a channel has Web SDK users, ensure that you call this method, or the video of the Native user will be a black screen for the Web user.

This method is only applicable in live streaming scenarios, and interoperability is enabled by default in communication scenarios.

Parameters

enabled
Whether to enable interoperability:
  • true: Enable interoperability.
  • false: (Default) Disable interoperability.

Returns

  • 0: Success.
  • < 0: Failure.

FollowSystemLoopbackDevice

Sets whether the loopback device follows the system default playback device.

public abstract int FollowSystemLoopbackDevice(bool enable);

Details

This method is for Windows and macOS only.

Parameters

enable
Whether to follow the system default audio playback device:
  • true: Follow the system default audio playback device. When the default playback device of the system is changed, the SDK immediately switches to the loopback device.
  • false: Do not follow the system default audio playback device. The SDK switches the audio loopback device to the system default audio playback device only when the current audio playback device is disconnected.

Returns

  • 0: Success.
  • < 0: Failure.

GetAudioDeviceInfo

Gets the audio device information.

public abstract int GetAudioDeviceInfo(ref DeviceInfoMobile deviceInfo);

Details

After calling this method, you can get whether the audio device supports ultra-low-latency capture and playback.

Attention:
  • This method is for Android only.
  • You can call this method either before or after joining a channel.

Parameters

deviceInfo
Audio frame information. See DeviceInfoMobile.

Returns

  • 0: Success.
  • < 0: Failure.

GetAudioMixingCurrentPosition

Retrieves the playback position (ms) of the music file.

public abstract int GetAudioMixingCurrentPosition();

Details

Retrieves the playback position (ms) of the audio.

Attention:
  • You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.
  • If you need to call GetAudioMixingCurrentPosition multiple times, ensure that the time interval between calling this method is more than 500 ms.

Returns

  • ≥ 0: The current playback position (ms) of the audio mixing, if this method call succeeds. 0 represents that the current music file does not start playing.
  • < 0: Failure.

GetAudioMixingDuration

Retrieves the duration (ms) of the music file.

public abstract int GetAudioMixingDuration();

Details

Retrieves the total duration (ms) of the audio.

Attention:

You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Returns

  • ≥ 0: The audio mixing duration, if this method call succeeds.
  • < 0: Failure.

GetAudioMixingPlayoutVolume

Retrieves the audio mixing volume for local playback.

public abstract int GetAudioMixingPlayoutVolume();

Details

This method helps troubleshoot audio volume‑related issues.

Attention:

You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Returns

  • ≥ 0: The audio mixing volume, if this method call succeeds. The value range is [0,100].
  • < 0: Failure.

GetAudioMixingPublishVolume

Retrieves the audio mixing volume for publishing.

public abstract int GetAudioMixingPublishVolume();

Details

This method helps troubleshoot audio volume‑related issues.

Attention: You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Returns

  • ≥ 0: The audio mixing volume, if this method call succeeds. The value range is [0,100].
  • < 0: Failure.

GetAudioTrackCount

Gets the index of audio tracks of the current music file.

public abstract int GetAudioTrackCount();

Details

Note:
  • You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Returns

  • The SDK returns the index of the audio tracks if the method call succeeds.
  • < 0: Failure.

GetCallId

Retrieves the call ID.

public abstract int GetCallId(ref string callId);

Details

When a user joins a channel on a client, a callId is generated to identify the call from the client. You can call this method to get the callId parameter, and pass it in when calling methods such as Rate and Complain.

Attention: Call this method after joining a channel.

Parameters

callId
Output parameter, the current call ID.

Returns

  • 0: Success.
  • < 0: Failure.

GetCameraMaxZoomFactor

Gets the maximum zoom ratio supported by the camera.

public abstract float GetCameraMaxZoomFactor();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

The maximum zoom factor.

GetConnectionState

Gets the current connection state of the SDK.

public abstract CONNECTION_STATE_TYPE GetConnectionState();

Details

You can call this method either before or after joining a channel.

Returns

The current connection state. See CONNECTION_STATE_TYPE.

GetCurrentMonotonicTimeInMs

Gets the current Monotonic Time of the SDK.

public abstract long GetCurrentMonotonicTimeInMs();

Details

Monotonic Time refers to a monotonically increasing time series whose value increases over time. The unit is milliseconds.

In custom video capture and custom audio capture scenarios, in order to ensure audio and video synchronization, Agora recommends that you call this method to obtain the current Monotonic Time of the SDK, and then pass this value into the timestamp parameter in the captured video frame (VideoFrame) and audio frame (AudioFrame).

Returns

  • ≥0: The method call is successful, and returns the current Monotonic Time of the SDK (in milliseconds).
  • < 0: Failure.

GetEffectCurrentPosition

Retrieves the playback position of the audio effect file.

public abstract int GetEffectCurrentPosition(int soundId);

Details

Attention: Call this method after PlayEffect.

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.

Returns

  • The playback position (ms) of the specified audio effect file, if the method call succeeds.
  • < 0: Failure.

GetEffectDuration

Retrieves the duration of the audio effect file.

public abstract int GetEffectDuration(string filePath);

Details

Attention: Call this method after joining a channel.

Parameters

filePath
File path:
  • Android: The file path, which needs to be accurate to the file name and suffix. Agora supports URL addresses, absolute paths, or file paths that start with /assets/. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: content://com.android.providers.media.documents/document/audio%3A14441
  • Windows: The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: C:\music\audio.mp4.
  • iOS or macOS: The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: /var/mobile/Containers/Data/audio.mp4.

Returns

  • The total duration (ms) of the specified audio effect file, if the method call succeeds.
  • < 0: Failure.

GetEffectsVolume

Retrieves the volume of the audio effects.

public abstract int GetEffectsVolume();

Details

The volume is an integer ranging from 0 to 100. The default value is 100, which means the original volume.

Attention: Call this method after PlayEffect.

Returns

  • Volume of the audio effects, if this method call succeeds.
  • < 0: Failure.

GetErrorDescription

Gets the warning or error description.

public abstract string GetErrorDescription(int code);

Parameters

code
The error code or warning code reported by the SDK.

Returns

The specific error or warning description.

GetExtensionProperty

Gets detailed information on the extensions.

public abstract int GetExtensionProperty(string provider, string extension, string key, ref string value, int buf_len, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE);

Details

Parameters

provider
An output parameter. The name of the extension provider.
extension
An output parameter. The name of the extension.
key
An output parameter. The key of the extension.
value
An output parameter. The value of the extension key.
type
Source type of the extension. See MEDIA_SOURCE_TYPE.
buf_len
Maximum length of the JSON string indicating the extension property. The maximum value is 512 bytes.

Returns

  • 0: Success.
  • < 0: Failure.

GetLoopbackDevice

Gets the current loopback device.

public abstract int GetLoopbackDevice(ref string deviceId);

Details

This method is for Windows and macOS only.

Parameters

deviceId
Output parameter, the ID of the current loopback device.

Returns

  • 0: Success.
  • < 0: Failure.

GetNativeHandler

Gets the C++ handle of the Native SDK.

public abstract int GetNativeHandler(ref IntPtr nativeHandler);

Details

This method retrieves the C++ handle of the SDK, which is used for registering the audio and video frame observer.

Parameters

nativeHandler
Output parameter, the native handle of the SDK.

Returns

  • 0: Success.
  • < 0: Failure.

GetNetworkType

Gets the type of the local network connection.

public abstract int GetNetworkType();

Details

You can use this method to get the type of network in use at any stage.

Note: You can call this method either before or after joining a channel.

Returns

  • ≥ 0: The method call is successful, and the local network connection type is returned.
    • 0: The SDK disconnects from the network.
    • 1: The network type is LAN.
    • 2: The network type is Wi-Fi (including hotspots).
    • 3: The network type is mobile 2G.
    • 4: The network type is mobile 3G.
    • 5: The network type is mobile 4G.
    • 6: The network type is mobile 5G.
  • < 0: The method call failed with an error code.
    • -1: The network type is unknown.

GetNtpWallTimeInMs

Gets the current NTP (Network Time Protocol) time.

public abstract UInt64 GetNtpWallTimeInMs();

Details

In the real-time chorus scenario, especially when the downlink connections are inconsistent due to network issues among multiple receiving ends, you can call this method to obtain the current NTP time as the reference time, in order to align the lyrics and music of multiple receiving ends and achieve chorus synchronization.

Returns

The Unix timestamp (ms) of the current NTP time.

GetPlaybackDefaultDevice [1/2]

Gets the default audio playback device.

public abstract int GetPlaybackDefaultDevice(ref string deviceId, ref string deviceName);

Details

Attention: This method is for Windows and macOS only.

Parameters

deviceId
Output parameter; indicates the ID of the default audio playback device.
deviceName
Output parameter; indicates the name of the default audio playback device.

Returns

  • 0: Success.
  • < 0: Failure.

GetPlaybackDefaultDevice [2/2]

Get the system‘s default audio playback device and its type.

public abstract int GetPlaybackDefaultDevice(ref string deviceId, ref string deviceTypeName, ref string deviceName);

Details

Attention: This method applies to macOS only.

Parameters

deviceId
Output parameter; indicates the ID of the default audio playback device.
deviceName
Output parameter; indicates the name of the default audio playback device.
deviceTypeName
Output parameter; indicates the type of audio devices, such as built-in, USB and HDMI.

Returns

  • 0: Success.
  • < 0: Failure.

GetRecordingDefaultDevice [1/2]

Gets the default audio capture device.

public abstract int GetRecordingDefaultDevice(ref string deviceId, ref string deviceName);

Details

Attention: This method is for Windows and macOS only.

Parameters

deviceId
Output parameter; indicates the ID of the default audio capture device.
deviceName
Output parameter; indicates the name of the default audio capture device.

Returns

  • 0: Success.
  • < 0: Failure.

GetRecordingDefaultDevice [2/2]

Gets the default audio capture device and its type.

 public abstract int GetRecordingDefaultDevice(ref string deviceId, ref string deviceTypeName, ref string deviceName);

Details

Attention: This method applies to macOS only.

Parameters

deviceId
Output parameter; indicates the ID of the default audio capture device.
deviceName
Output parameter; indicates the name of the default audio capture device.
deviceTypeName
Output parameter; indicates the type of audio devices, such as built-in, USB and HDMI.

Returns

  • 0: Success.
  • < 0: Failure.

GetScreenCaptureSources

Gets a list of shareable screens and windows.

public abstract ScreenCaptureSourceInfo[] GetScreenCaptureSources(SIZE thumbSize, SIZE iconSize, bool includeScreen);

Details

You can call this method before sharing a screen or window to get a list of shareable screens and windows, which enables a user to use thumbnails in the list to easily choose a particular screen or window to share. This list also contains important information such as window ID and screen ID, with which you can call StartScreenCaptureByWindowId or StartScreenCaptureByDisplayId to start the sharing.

Note: This method applies to macOS and Windows only.

Parameters

thumbSize
The target size of the screen or window thumbnail (the width and height are in pixels). The SDK scales the original image to make the length of the longest side of the image the same as that of the target size without distorting the original image. For example, if the original image is 400 × 300 and thumbSize is 100 × 100, the actual size of the thumbnail is 100 × 75. If the target size is larger than the original size, the thumbnail is the original image and the SDK does not scale it.
iconSize
The target size of the icon corresponding to the application program (the width and height are in pixels). The SDK scales the original image to make the length of the longest side of the image the same as that of the target size without distorting the original image. For example, if the original image is 400 × 300 and iconSize is 100 × 100, the actual size of the icon is 100 × 75. If the target size is larger than the original size, the icon is the original image and the SDK does not scale it.
includeScreen
Whether the SDK returns the screen information in addition to the window information:
  • true: The SDK returns screen and window information.
  • false: The SDK returns window information only.

Returns

The ScreenCaptureSourceInfo array.

GetVolumeOfEffect

Gets the volume of a specified audio effect file.

public abstract int GetVolumeOfEffect(int soundId);

Parameters

soundId
The ID of the audio effect file.

Returns

  • ≥ 0: Returns the volume of the specified audio effect, if the method call is successful. The value ranges between 0 and 100. 100 represents the original volume.
  • < 0: Failure.

GetVersion

Gets the SDK version.

public abstract string GetVersion(ref int build);

Parameters

build
The SDK build index.

Returns

The SDK version number. The format is a string.

GetUserInfoByUid

Gets the user information by passing in the user ID.

public abstract int GetUserInfoByUid(uint uid, ref UserInfo userInfo);

Details

After a remote user joins the channel, the SDK gets the user ID and account of the remote user, caches them in a mapping table object, and triggers the OnUserInfoUpdated callback on the local client. After receiving the callback, you can call this method to get the user account of the remote user from the UserInfo object by passing in the user ID.

Parameters

uid
The user ID.
userInfo
Input and output parameter. The UserInfo object that identifies the user information.
  • Input: A UserInfo object.
  • Output: A UserInfo object that contains the user account and user ID of the user.

Returns

  • 0: Success.
  • < 0: Failure.

GetUserInfoByUserAccount

Gets the user information by passing in the user account.

public abstract int GetUserInfoByUserAccount(string userAccount, ref UserInfo userInfo);

Details

After a remote user joins the channel, the SDK gets the user ID and account of the remote user, caches them in a mapping table object, and triggers the OnUserInfoUpdated callback on the local client. After receiving the callback, you can call this method to get the user account of the remote user from the UserInfo object by passing in the user ID.

Parameters

userAccount
The user account.
userInfo
Input and output parameter. The UserInfo object that identifies the user information.
  • Input: A UserInfo object.
  • Output: A UserInfo object that contains the user account and user ID of the user.

Returns

  • 0: Success.
  • < 0: Failure.

IsCameraAutoFocusFaceModeSupported

Checks whether the device supports the face auto-focus function.

public abstract bool IsCameraAutoFocusFaceModeSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device supports the face auto-focus function.
  • false: The device does not support the face auto-focus function.

IsCameraAutoExposureFaceModeSupported

Checks whether the device supports auto exposure.

public abstract bool IsCameraAutoExposureFaceModeSupported();

Details

Attention:
  • This method applies to iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device supports auto exposure.
  • false: The device does not support auto exposure.

IsCameraCenterStageSupported

Check if the camera supports portrait center stage.

public abstract bool IsCameraCenterStageSupported();
Attention: This method is for iOS and macOS only.

Before calling EnableCameraCenterStage to enable portrait center stage, it is recommended to call this method to check if the current device supports the feature.

Call timing

This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Restrictions

None.

Returns

  • true: The current camera supports the portrait center stage.
  • false: The current camera supports the portrait center stage.

IsCameraExposurePositionSupported

Checks whether the device supports manual exposure.

public abstract bool IsCameraExposurePositionSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device supports manual exposure.
  • false: The device does not support manual exposure.

IsCameraExposureSupported

Queries whether the current camera supports adjusting exposure value.

public abstract bool IsCameraExposureSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • Before calling SetCameraExposureFactor, Agora recoomends that you call this method to query whether the current camera supports adjusting the exposure value.
  • By calling this method, you adjust the exposure value of the currently active camera, that is, the camera specified when calling SetCameraCapturerConfiguration.

Returns

  • true: Success.
  • false: Failure.

IsCameraFaceDetectSupported

Checks whether the device camera supports face detection.

public abstract bool IsCameraFaceDetectSupported();
Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device camera supports face detection.
  • false: The device camera does not support face detection.

IsCameraFocusSupported

Check whether the device supports the manual focus function.

public abstract bool IsCameraFocusSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device supports the manual focus function.
  • false: The device does not support the manual focus function.

IsCameraTorchSupported

Checks whether the device supports camera flash.

public abstract bool IsCameraTorchSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • The app enables the front camera by default. If your front camera does not support flash, this method returns false. If you want to check whether the rear camera supports the flash function, call SwitchCamera before this method.
  • On iPads with system version 15, even if IsCameraTorchSupported returns true, you might fail to successfully enable the flash by calling SetCameraTorchOn due to system issues.

Returns

  • true: The device supports camera flash.
  • false: The device does not support camera flash.

IsCameraZoomSupported

Checks whether the device supports camera zoom.

public abstract bool IsCameraZoomSupported();

Details

Attention:
  • This method is for Android and iOS only.
  • This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Returns

  • true: The device supports camera zoom.
  • false: The device does not support camera zoom.

IsFeatureAvailableOnDevice

Checks whether the device supports the specified advanced feature.

public abstract bool IsFeatureAvailableOnDevice(FeatureType type);

Details

Checks whether the capabilities of the current device meet the requirements for advanced features such as virtual background and image enhancement.

Applicable scenarios

Before using advanced features, you can check whether the current device supports these features based on the call result. This helps to avoid performance degradation or unavailable features when enabling advanced features on low-end devices. Based on the return value of this method, you can decide whether to display or enable the corresponding feature button, or notify the user when the device's capabilities are insufficient.

Parameters

type
The type of the advanced feature, see FeatureType.

Returns

  • true: The current device supports the specified feature.
  • false: The current device does not support the specified feature.

IsSpeakerphoneEnabled

Checks whether the speakerphone is enabled.

public abstract bool IsSpeakerphoneEnabled();
Note:
  • This method is for Android and iOS only.
  • You can call this method either before or after joining a channel.

Returns

  • true: The speakerphone is enabled, and the audio plays from the speakerphone.
  • false: The speakerphone is not enabled, and the audio plays from devices other than the speakerphone. For example, the headset or earpiece.

JoinChannel [1/2]

Joins a channel.

public abstract int JoinChannel(string token, string channelId, string info = "", uint uid = 0);

Details

This method enables users to join a channel. Users in the same channel can talk to each other, and multiple users in the same channel can start a group chat. Users with different App IDs cannot call each other.

A successful call of this method triggers the following callbacks:

When the connection between the client and Agora's server is interrupted due to poor network conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins the channel, the SDK triggers the OnRejoinChannelSuccess callback on the local client.

Attention:
  • Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods.
  • If you choose the Testing Mode (using an App ID for authentication) for your project and call this method to join a channel, you will automatically exit the channel after 24 hours.

Parameters

token
The token generated on your server for authentication. See .
Note: If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel. See Secure authentication with tokens.
channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
info
(Optional) Reserved for future use.
uid
The user ID. This parameter is used to identify the user in the channel for real-time audio and video interaction. You need to set and manage user IDs yourself, and ensure that each user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user ID and OnJoinChannelSuccess returns it in the callback. Your application must record and maintain the returned user ID, because the SDK does not do so.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set to an integer, or the value of a member in ChannelMediaOptions is invalid. You need to pass in a valid parameter and join the channel again.
    • -3: Failes to initialize the IRtcEngine object. You need to reinitialize the IRtcEngine object.
    • -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine object before calling this method.
    • -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call this method to join the channel without calling StartEchoTest [3/3] to stop the test after calling StopEchoTest to start a call loop test. You need to call StopEchoTest before calling this method.
    • -17: The request to join the channel is rejected. The typical cause is that the user is in the channel. Agora recommends that you use the OnConnectionStateChanged callback to determine whether the user exists in the channel. Do not call this method to join the channel unless you receive the CONNECTION_STATE_DISCONNECTED(1) state.
    • -102: The channel name is invalid. You need to pass in a valid channelname in channelId to rejoin the channel.
    • -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel.

JoinChannel [2/2]

Joins a channel with media options.

public abstract int JoinChannel(string token, string channelId, uint uid,
                                ChannelMediaOptions options);

Details

This method enables users to join a channel. Users in the same channel can talk to each other, and multiple users in the same channel can start a group chat. Users with different App IDs cannot call each other.

A successful call of this method triggers the following callbacks:

When the connection between the client and Agora's server is interrupted due to poor network conditions, the SDK tries reconnecting to the server. When the local client successfully rejoins the channel, the SDK triggers the OnRejoinChannelSuccess callback on the local client.

Compared to JoinChannel [1/2], this method adds the options parameter to configure whether to automatically subscribe to all remote audio and video streams in the channel when the user joins the channel. By default, the user subscribes to the audio and video streams of all the other users in the channel, giving rise to usage and billings. To unsubscribe, set the options parameter or call the mute methods accordingly.

Attention:
  • This method allows users to join only one channel at a time.
  • Ensure that the app ID you use to generate the token is the same app ID that you pass in the Initialize method; otherwise, you may fail to join the channel by token.
  • If you choose the Testing Mode (using an App ID for authentication) for your project and call this method to join a channel, you will automatically exit the channel after 24 hours.

Parameters

token
The token generated on your server for authentication. See .
Note: If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel. See Secure authentication with tokens.
channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
uid
The user ID. This parameter is used to identify the user in the channel for real-time audio and video interaction. You need to set and manage user IDs yourself, and ensure that each user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user ID and OnJoinChannelSuccess returns it in the callback. Your application must record and maintain the returned user ID, because the SDK does not do so.
options
The channel media options. See ChannelMediaOptions.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set to an integer, or the value of a member in ChannelMediaOptions is invalid. You need to pass in a valid parameter and join the channel again.
    • -3: Failes to initialize the IRtcEngine object. You need to reinitialize the IRtcEngine object.
    • -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine object before calling this method.
    • -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call this method to join the channel without calling StartEchoTest [3/3] to stop the test after calling StopEchoTest to start a call loop test. You need to call StopEchoTest before calling this method.
    • -17: The request to join the channel is rejected. The typical cause is that the user is in the channel. Agora recommends that you use the OnConnectionStateChanged callback to determine whether the user exists in the channel. Do not call this method to join the channel unless you receive the CONNECTION_STATE_DISCONNECTED(1) state.
    • -102: The channel name is invalid. You need to pass in a valid channelname in channelId to rejoin the channel.
    • -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel.

JoinChannelWithUserAccount [1/2]

Joins a channel with a User Account and Token.

public abstract int JoinChannelWithUserAccount(string token, string channelId, string userAccount);

Details

This method allows a user to join the channel with the user account and a token. After the user successfully joins the channel, the SDK triggers the following callbacks:

Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods.

Attention:
  • To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.
  • If you choose the Testing Mode (using an App ID for authentication) for your project and call this method to join a channel, you will automatically exit the channel after 24 hours.

Parameters

token
The token generated on your server for authentication. See .
Note: If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel. See Secure authentication with tokens.
channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are as follows(89 in total):
  • The 26 lowercase English letters: a to z.
  • The 26 uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • -3: The initialization of the SDK fails. You can try to initialize the SDK again.
    • -5: The request is rejected.
    • -17: The request to join the channel is rejected. Since the SDK only supports users to join one IRtcEngine channel at a time; this error code will be returned when the user who has joined the IRtcEngine channel calls the join channel method in the IRtcEngine class again with a valid channel name.

JoinChannelWithUserAccount [2/2]

Joins the channel with a user account, and configures whether to automatically subscribe to audio or video streams after joining the channel.

public abstract int JoinChannelWithUserAccount(string token, string channelId, string userAccount,
            ChannelMediaOptions options);

Details

This method allows a user to join the channel with the user account. After the user successfully joins the channel, the SDK triggers the following callbacks:

Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods.

Attention:
  • To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.
  • If you choose the Testing Mode (using an App ID for authentication) for your project and call this method to join a channel, you will automatically exit the channel after 24 hours.

Parameters

token
The token generated on your server for authentication. See .
Note: If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel. See Secure authentication with tokens.
channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are as follows(89 in total):
  • The 26 lowercase English letters: a to z.
  • The 26 uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
options
The channel media options. See ChannelMediaOptions.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set to an integer, or the value of a member in ChannelMediaOptions is invalid. You need to pass in a valid parameter and join the channel again.
    • -3: Failes to initialize the IRtcEngine object. You need to reinitialize the IRtcEngine object.
    • -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine object before calling this method.
    • -8: The internal state of the IRtcEngine object is wrong. The typical cause is that you call this method to join the channel without calling StartEchoTest [3/3] to stop the test after calling StopEchoTest to start a call loop test. You need to call StopEchoTest before calling this method.
    • -17: The request to join the channel is rejected. The typical cause is that the user is in the channel. Agora recommends that you use the OnConnectionStateChanged callback to determine whether the user exists in the channel. Do not call this method to join the channel unless you receive the CONNECTION_STATE_DISCONNECTED(1) state.
    • -102: The channel name is invalid. You need to pass in a valid channelname in channelId to rejoin the channel.
    • -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel.

LeaveChannel [1/2]

Leaves a channel.

public abstract int LeaveChannel();

Details

This method releases all resources related to the session.

This method call is asynchronous. When this method returns, it does not necessarily mean that the user has left the channel.

After joining the channel, you must call this method or LeaveChannel [2/2] to end the call, otherwise, the next call cannot be started.

If you successfully call this method and leave the channel, the following callbacks are triggered:
  • The local client: OnLeaveChannel.
  • The remote client: OnUserOffline, if the user joining the channel is in the Communication profile, or is a host in the Live-broadcasting profile.
Attention:
  • If you call Dispose immediately after calling this method, the SDK does not trigger the OnLeaveChannel callback.
  • If you have called JoinChannelEx to join multiple channels, calling this method will leave the channels when calling JoinChannel [2/2] and JoinChannelEx at the same time.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -7: The SDK is not initialized.

LeaveChannel [2/2]

Sets channel options and leaves the channel.

public abstract int LeaveChannel(LeaveChannelOptions options); 

Details

This method will release all resources related to the session, leave the channel, that is, hang up or exit the call. This method can be called whether or not a call is currently in progress.

After joining the channel, you must call this method or to end the call, otherwise, the next call cannot be started.

This method call is asynchronous. When this method returns, it does not necessarily mean that the user has left the channel. After actually leaving the channel, the local user triggers the OnLeaveChannel callback; after the user in the communication scenario and the host in the live streaming scenario leave the channel, the remote user triggers the OnUserOffline callback.

Attention:
  • If you call Dispose immediately after calling this method, the SDK does not trigger the OnLeaveChannel callback.
  • If you have called JoinChannelEx to join multiple channels, calling this method will leave the channels when calling JoinChannel [2/2] and JoinChannelEx at the same time.

Parameters

options
The options for leaving the channel. See LeaveChannelOptions.

Returns

  • 0: Success.
  • < 0: Failure.

LoadExtensionProvider

Loads an extension.

public abstract int LoadExtensionProvider(string path, bool unload_after_use = false);

This method is used to add extensions external to the SDK (such as those from Extensions Marketplace and SDK extensions) to the SDK.

Call timing

Make sure the IRtcEngine is initialized before you call this method.

Restrictions

If you want to load multiple extensions, you need to call this method multiple times.

Attention: (For Windows and Android only)

Parameters

path
The extension library path and name. For example: /library/libagora_segmentation_extension.dll.
unload_after_use
Whether to uninstall the current extension when you no longer using it:
  • true: Uninstall the extension when the IRtcEngine is destroyed.
  • false: (Rcommended) Do not uninstall the extension until the process terminates.

Returns

  • 0: Success.
  • < 0: Failure.

MuteAllRemoteAudioStreams

Stops or resumes subscribing to the audio streams of all remote users.

public abstract int MuteAllRemoteAudioStreams(bool mute);

After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all remote users, including all subsequent users.

Attention:

By default, the SDK subscribes to the audio streams of all remote users when joining a channel. To modify this behavior, you can set autoSubscribeAudio to false when calling JoinChannel [2/2] to join the channel, which will cancel the subscription to the audio streams of all users upon joining the channel.

Call timing

Call this method after joining a channel.

Restrictions

If you call this method and then call EnableAudio or DisableAudio, the latest call will prevail.

Parameters

mute
Whether to stop subscribing to the audio streams of all remote users:
  • true: Stops subscribing to the audio streams of all remote users.
  • false: (Default) Subscribes to the audio streams of all remote users by default.

Returns

  • 0: Success.
  • < 0: Failure.

MuteAllRemoteVideoStreams

Stops or resumes subscribing to the video streams of all remote users.

public abstract int MuteAllRemoteVideoStreams(bool mute);

After successfully calling this method, the local user stops or resumes subscribing to the audio streams of all remote users, including all subsequent users.

Attention:

By default, the SDK subscribes to the video streams of all remote users when joining a channel. To modify this behavior, you can set autoSubscribeVideo tofalse when calling JoinChannel [2/2] to join the channel, which will cancel the subscription to the video streams of all users upon joining the channel.

Call timing

Call this method after joining a channel.

Restrictions

If you call this method and then call EnableVideo or DisableVideo, the latest call will prevail.

Parameters

mute
Whether to stop subscribing to the video streams of all remote users.
  • true: Stop subscribing to the video streams of all remote users.
  • false: (Default) Subscribe to the audio streams of all remote users by default.

Returns

  • 0: Success.
  • < 0: Failure.

MuteLocalAudioStream

Stops or resumes publishing the local audio stream.

public abstract int MuteLocalAudioStream(bool mute);

This method is used to control whether to publish the locally captured audio stream. If you call this method to stop publishing locally captured audio streams, the audio capturing device will still work and won't be affected.

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

mute
Whether to stop publishing the local audio stream:
  • true: Stops publishing the local audio stream.
  • false: (Default) Resumes publishing the local audio stream.

Returns

  • 0: Success.
  • < 0: Failure.

MuteLocalVideoStream

Stops or resumes publishing the local video stream.

public abstract int MuteLocalVideoStream(bool mute);

This method is used to control whether to publish the locally captured video stream. If you call this method to stop publishing locally captured video streams, the video capturing device will still work and won't be affected.

Compared to EnableLocalVideo(false), which can also cancel the publishing of local video stream by turning off the local video stream capture, this method responds faster.

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

mute
Whether to stop publishing the local video stream.
  • true: Stop publishing the local video stream.
  • false: (Default) Publish the local video stream.

Returns

  • 0: Success.
  • < 0: Failure.

MuteRecordingSignal

Whether to mute the recording signal.

public abstract int MuteRecordingSignal(bool mute);

Parameters

mute
  • true: The media file is muted.
  • false: (Default) Do not mute the recording signal.
Note: If you have already called AdjustRecordingSignalVolume to adjust the volume, then when you call this method and set it to true, the SDK will record the current volume and mute it. To restore the previous volume, call this method again and set it to false.

Returns

  • 0: Success.
  • < 0: Failure.

MuteRemoteAudioStream

Stops or resumes subscribing to the audio stream of a specified user.

public abstract int MuteRemoteAudioStream(uint uid, bool mute);

Call timing

Call this method after joining a channel.

Restrictions

None.

Parameters

uid
The user ID of the specified user.
mute
Whether to subscribe to the specified remote user's audio stream.
  • true: Stop subscribing to the audio stream of the specified user.
  • false: (Default) Subscribe to the audio stream of the specified user.

Returns

  • 0: Success.
  • < 0: Failure.

MuteRemoteVideoStream

Stops or resumes subscribing to the video stream of a specified user.

public abstract int MuteRemoteVideoStream(uint uid, bool mute);

Call timing

Call this method after joining a channel.

Restrictions

None.

Parameters

uid
The user ID of the specified user.
mute
Whether to subscribe to the specified remote user's video stream.
  • true: Stop subscribing to the video streams of the specified user.
  • false: (Default) Subscribe to the video stream of the specified user.

Returns

  • 0: Success.
  • < 0: Failure.

PauseAllChannelMediaRelay

Pauses the media stream relay to all target channels.

public abstract int PauseAllChannelMediaRelay();

Details

After the cross-channel media stream relay starts, you can call this method to pause relaying media streams to all target channels; after the pause, if you want to resume the relay, call ResumeAllChannelMediaRelay.

Attention: Call this method after StartOrUpdateChannelMediaRelay.

Returns

  • 0: Success.
  • < 0: Failure.

PauseAllEffects

Pauses all audio effects.

public abstract int PauseAllEffects();

Returns

  • 0: Success.
  • < 0: Failure.

PauseAudioMixing

Pauses playing and mixing the music file.

public abstract int PauseAudioMixing();

Details

Call this method after joining a channel.

Returns

  • 0: Success.
  • < 0: Failure.

PauseEffect

Pauses a specified audio effect file.

public abstract int PauseEffect(int soundId);

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.

Returns

  • 0: Success.
  • < 0: Failure.

PlayAllEffects

Plays all audio effect files.

public abstract int PlayAllEffects(int loopCount, double pitch, double pan, int gain, bool publish = false);

Details

After calling PreloadEffect multiple times to preload multiple audio effects into the memory, you can call this method to play all the specified audio effects for all users in the channel.

Parameters

loopCount
The number of times the audio effect loops:
  • -1: Play the audio effect files in an indefinite loop until you call StopEffect or StopAllEffects.
  • 0: Play the audio effect once.
  • 1: Play the audio effect twice.
pitch

The pitch of the audio effect. The value ranges between 0.5 and 2.0. The default value is 1.0 (original pitch). The lower the value, the lower the pitch.

pan
The spatial position of the audio effect. The value ranges between -1.0 and 1.0:
  • -1.0: The audio effect shows on the left.
  • 0: The audio effect shows ahead.
  • 1.0: The audio effect shows on the right.
gain

The volume of the audio effect. The value range is [0, 100]. The default value is 100 (original volume). The smaller the value, the lower the volume.

publish
Whether to publish the audio effect to the remote users:
  • true: Publish the audio effect to the remote users. Both the local user and remote users can hear the audio effect.
  • false: (Default) Do not publish the audio effect to the remote users. Only the local user can hear the audio effect.

Returns

  • 0: Success.
  • < 0: Failure.

PlayEffect

Plays the specified local or online audio effect file.

public abstract int PlayEffect(int soundId, string filePath, int loopCount, double pitch, double pan, int gain, bool publish = false, int startPos = 0);

Details

Attention: If you use this method to play an online audio effect file, Agora recommends that you cache the online audio effect file to your local device, call PreloadEffect to preload the cached audio effect file into memory, and then call this method to play the audio effect. Otherwise, you might encounter playback failures or no sound during playback due to loading timeouts or failures.

To play multiple audio effect files at the same time, call this method multiple times with different soundId and filePath. To achieve the optimal user experience, Agora recommends that do not playing more than three audio files at the same time. After the playback of an audio effect file completes, the SDK triggers the OnAudioEffectFinished callback.

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.
Attention: If you have preloaded an audio effect into memory by calling PreloadEffect, ensure that the value of this parameter is the same as that of soundId in PreloadEffect.
filePath

The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example, C:\music\audio.mp4. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. See supported audio formats.

Attention: If you have preloaded an audio effect into memory by calling PreloadEffect, ensure that the value of this parameter is the same as that of filePath in PreloadEffect.
loopCount
The number of times the audio effect loops.
  • ≥ 0: The number of playback times. For example, 1 means looping one time, which means playing the audio effect two times in total.
  • -1: Play the audio file in an infinite loop.
pitch
The pitch of the audio effect. The value range is 0.5 to 2.0. The default value is 1.0, which means the original pitch. The lower the value, the lower the pitch.
pan
The spatial position of the audio effect. The value ranges between -1.0 and 1.0:
  • -1.0: The audio effect is heard on the left of the user.
  • 0.0: The audio effect is heard in front of the user.
  • 1.0: The audio effect is heard on the right of the user.
gain
The volume of the audio effect. The value range is 0.0 to 100.0. The default value is 100.0, which means the original volume. The smaller the value, the lower the volume.
publish
Whether to publish the audio effect to the remote users:
  • true: Publish the audio effect to the remote users. Both the local user and remote users can hear the audio effect.
  • false: Do not publish the audio effect to the remote users. Only the local user can hear the audio effect.
startPos

The playback position (ms) of the audio effect file.

Returns

  • 0: Success.
  • < 0: Failure.

PreloadChannel

Preloads a channel with token, channelId, and uid.

public abstract int PreloadChannel(string token, string channelId, uint uid);

When audience members need to switch between different channels frequently, calling the method can help shortening the time of joining a channel, thus reducing the time it takes for audience members to hear and see the host.

If you join a preloaded channel, leave it and want to rejoin the same channel, you do not need to call this method unless the token for preloading the channel expires.

Note: Failing to preload a channel does not mean that you can't join a channel, nor will it increase the time of joining a channel.

Call timing

To improve the user experience of preloading channels, Agora recommends that before joining the channel, calling this method as early as possible once confirming the channel name and user information.

Restrictions

  • When calling this method, ensure you set the user role as audience and do not set the audio scenario as AUDIO_SCENARIO_CHORUS, otherwise, this method does not take effect.
  • You also need to make sure that the channel name, user ID and token passed in for preloading are the same as the values passed in when joinning the channel, otherwise, this method does not take effect.
  • One IRtcEngine instance supports preloading 20 channels at most. When exceeding this limit, the latest 20 preloaded channels take effect.

Parameters

token
The token generated on your server for authentication. See .
When the token for preloading channels expires, you can update the token based on the number of channels you preload.
  • When preloading one channel, calling this method to pass in the new token.
  • When preloading more than one channels:
    • If you use a wildcard token for all preloaded channels, call UpdatePreloadChannelToken to update the token.
      Note: When generating a wildcard token, ensure the user ID is not set as 0. See Secure authentication with tokens.
    • If you use different tokens to preload different channels, call this method to pass in your user ID, channel name and the new token.
channelId
The channel name that you want to preload. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
uid
The user ID. This parameter is used to identify the user in the channel for real-time audio and video interaction. You need to set and manage user IDs yourself, and ensure that each user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user ID and OnJoinChannelSuccess returns it in the callback. Your application must record and maintain the returned user ID, because the SDK does not do so.

Returns

  • 0: Success.
  • < 0: Failure.
    • -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine object before calling this method.
    • -102: The channel name is invalid. You need to pass in a valid channel name and join the channel again.

PreloadEffect

Preloads a specified audio effect file into the memory.

public abstract int PreloadEffect(int soundId, string filePath, int startPos = 0);

Details

To ensure smooth communication, It is recommended that you limit the size of the audio effect file. You can call this method to preload the audio effect before calling JoinChannel [2/2].

Note:

For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK support.

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.
filePath
File path:
  • Android: The file path, which needs to be accurate to the file name and suffix. Agora supports URL addresses, absolute paths, or file paths that start with /assets/. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: content://com.android.providers.media.documents/document/audio%3A14441
  • Windows: The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: C:\music\audio.mp4.
  • iOS or macOS: The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: /var/mobile/Containers/Data/audio.mp4.
startPos
The playback position (ms) of the audio effect file.

Returns

  • 0: Success.
  • < 0: Failure.

PullAudioFrame

Pulls the remote audio data.

public abstract int PullAudioFrame(AudioFrame frame);

Details

Before calling this method, call SetExternalAudioSink(enabled: true) to notify the app to enable and set the external audio rendering.

After a successful call of this method, the app pulls the decoded and mixed audio data for playback.

Attention:
  • Call this method after joining a channel.
  • Both this method and OnPlaybackAudioFrame callback can be used to get audio data after remote mixing. Note that after calling SetExternalAudioSink to enable external audio rendering, the app no longer receives data from the OnPlaybackAudioFrame callback. Therefore, you should choose between this method and the OnPlaybackAudioFrame callback based on your actual business requirements. The specific distinctions between them are as follows:
    • After calling this method, the app automatically pulls the audio data from the SDK. By setting the audio data parameters, the SDK adjusts the frame buffer to help the app handle latency, effectively avoiding audio playback jitter.
    • The SDK sends the audio data to the app through the OnPlaybackAudioFrame callback. Any delay in processing the audio frames may result in audio jitter.
  • This method is only used for retrieving audio data after remote mixing. If you need to get audio data from different audio processing stages such as capture and playback, you can register the corresponding callbacks by calling RegisterAudioFrameObserver.

Parameters

frame
Pointers to AudioFrame.

Returns

  • 0: Success.
  • < 0: Failure.

PushAudioFrame

Pushes the external audio frame.

public abstract int PushAudioFrame(AudioFrame frame, uint trackId = 0);

Details

Attention:
Before calling this method to push external audio data, perform the following steps:
  1. Call CreateCustomAudioTrack to create a custom audio track and get the audio track ID.
  2. Call JoinChannel [2/2] to join the channel. In ChannelMediaOptions, set publishCustomAduioTrackId to the audio track ID that you want to publish, and set publishCustomAudioTrack to true.

Parameters

frame
The external audio frame. See AudioFrame.
trackId
The audio track ID. If you want to publish a custom external audio source, set this parameter to the ID of the corresponding custom audio track you want to publish.

Returns

  • 0: Success.
  • < 0: Failure.

PushVideoFrame

Pushes the external raw video frame to the SDK through video tracks.

public abstract int PushVideoFrame(ExternalVideoFrame frame, uint videoTrackId = 0);

Details

To publish a custom video source, see the following steps:
  1. Call CreateCustomVideoTrack to create a video track and get the video track ID.
  2. Call JoinChannel [2/2] to join the channel. In ChannelMediaOptions, set customVideoTrackId to the video track ID that you want to publish, and set publishCustomVideoTrack to true.
  3. Call this method and specify videoTrackId as the video track ID set in step 2. You can then publish the corresponding custom video source in the channel.
DANGER: After calling this method, even if you stop pushing external video frames to the SDK, the custom video stream will still be counted as the video duration usage and incur charges. Agora recommends that you take appropriate measures based on the actual situation to avoid such video billing.
  • If you no longer need to capture external video data, you can call DestroyCustomVideoTrack to destroy the custom video track.
  • If you only want to use the external video data for local preview and not publish it in the channel, you can call MuteLocalVideoStream to cancel sending video stream or call UpdateChannelMediaOptions to set publishCustomVideoTrack to false.

Parameters

frame

The external raw video frame to be pushed. See ExternalVideoFrame.

videoTrackId
The video track ID returned by calling the CreateCustomVideoTrack method. The default value is 0.

Returns

  • 0: Success.
  • < 0: Failure.

QueryCameraFocalLengthCapability

Queries the focal length capability supported by the camera.

public abstract int QueryCameraFocalLengthCapability(ref FocalLengthInfo[] focalLengthInfos, ref int size);

Details

If you want to enable the wide-angle or ultra-wide-angle mode for camera capture, it is recommended to start by calling this method to check whether the device supports the required focal length capability. Then, adjust the camera's focal length configuration based on the query result by calling SetCameraCapturerConfiguration, ensuring the best camera capture performance.

Attention: This method is for Android and iOS only.

Parameters

focalLengthInfos
An output parameter. After the method is executed, output an array of FocalLengthInfo objects containing camera focal length information.
size
An output parameter. After the method is executed, output the number of focal length information items retrieved.

Returns

  • 0: Success.
  • < 0: Failure.

QueryCodecCapability

Queries the video codec capabilities of the SDK.

public abstract int QueryCodecCapability(ref CodecCapInfo[] codecInfo, ref int size);

Details

Parameters

codecInfo

Input and output parameter. An array representing the video codec capabilities of the SDK. See CodecCapInfo.

  • Input value: One CodecCapInfodefined by the user when executing this method, representing the video codec capability to be queried.
  • Output value: The CodecCapInfo after the method is executed, representing the actual video codec capabilities of the SDK.
size
Input and output parameter, represent the size of the CodecCapInfo array.
  • Input value: Size of the CodecCapInfo defined by the user when executing the method.
  • Output value: Size of the output CodecCapInfo after this method is executed.

Returns

  • 0: Success.
  • < 0: Failure.

QueryDeviceScore

Queries device score.

public abstract int QueryDeviceScore();

Details

Applicable scenarios

In high-definition or ultra-high-definition video scenarios, you can first call this method to query the device's score. If the returned score is low (for example, below 60), you need to lower the video resolution to avoid affecting the video experience. The minimum device score required for different business scenarios is varied. For specific score recommendations, please technical support.

Returns

  • >0: The method call succeeeds, the value is the current device's score, the range is [0,100], the larger the value, the stronger the device capability. Most devices are rated between 60 and 100.
  • < 0: Failure.

QueryScreenCaptureCapability

Queries the highest frame rate supported by the device during screen sharing.

public abstract int QueryScreenCaptureCapability();

Details

Applicable scenarios

This method is for Android and iOS only.

To ensure optimal screen sharing performance, particularly in enabling high frame rates like 60 fps, Agora recommends you to query the device's maximum supported frame rate using this method beforehand. This way, if the device cannot support such a high frame rate, you can adjust the screen sharing stream accordingly to avoid any negative impact on the sharing quality. If the device does not support high frame rate, you can reduce the frame rate of the screen sharing stream appropriately when sharing the screen to ensure that the sharing effect meets your expectation.

Returns

  • The highest frame rate supported by the device, if the method is called successfully. See SCREEN_CAPTURE_FRAMERATE_CAPABILITY.
  • < 0: Failure.

Rate

Allows a user to rate a call after the call ends.

public abstract int Rate(string callId, int rating, string description);

Details

Attention: Ensure that you call this method after leaving a channel.

Parameters

callId
The current call ID. You can get the call ID by calling GetCallId.
rating
The value is between 1 (the lowest score) and 5 (the highest score).
description
(Optional) A description of the call. The string length should be less than 800 bytes.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.

RegisterAudioFrameObserver

Registers an audio frame observer object.

public abstract int RegisterAudioFrameObserver(IAudioFrameObserver audioFrameObserver, AUDIO_FRAME_POSITION position, OBSERVER_MODE mode = OBSERVER_MODE.INTPTR);

Details

Call this method to register an audio frame observer object (register a callback). When you need the SDK to trigger OnMixedAudioFrame, OnRecordAudioFrame, OnPlaybackAudioFrame or OnEarMonitoringAudioFrame callback, you need to use this method to register the callbacks.

Attention: Ensure that you call this method before joining a channel.

Parameters

audioFrameObserver

The observer instance. See IAudioFrameObserver. Set the value as NULL to release the instance. Agora recommends calling this method after receiving OnLeaveChannel to release the audio observer object.

mode
The audio data callback mode. See OBSERVER_MODE.
position
The frame position of the audio observer.
  • AUDIO_FRAME_POSITION_PLAYBACK(0x0001): This position can observe the playback audio mixed by all remote users, corresponding to the OnPlaybackAudioFrame callback.
  • AUDIO_FRAME_POSITION_RECORD(0x0002): This position can observe the collected local user's audio, corresponding to the OnRecordAudioFrame callback.
  • AUDIO_FRAME_POSITION_MIXED(0x0004): This position can observe the playback audio mixed by the loacl user and all remote users, corresponding to the OnMixedAudioFrame callback.
  • AUDIO_FRAME_POSITION_BEFORE_MIXING(0x0008): This position can observe the audio of a single remote user before mixing, corresponding to the OnPlaybackAudioFrameBeforeMixing callback.
  • AUDIO_FRAME_POSITION_EAR_MONITORING(0x0010): This position can observe the in-ear monitoring audio of the local user, corresponding to the OnEarMonitoringAudioFrame callback.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterAudioEncodedFrameObserver

Registers an encoded audio observer.

public abstract int RegisterAudioEncodedFrameObserver(AudioEncodedFrameObserverConfig config, IAudioEncodedFrameObserver observer);

Details

Attention:
  • Call this method after joining a channel.
  • You can call this method or StartAudioRecording [3/3] to set the recording type and quality of audio files, but Agora does not recommend using this method and StartAudioRecording [3/3] at the same time. Only the method called later will take effect.

Parameters

config
Observer settings for the encoded audio. See AudioEncodedFrameObserverConfig.
observer
The encoded audio observer. See IAudioEncodedFrameObserver.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterAudioSpectrumObserver

Register an audio spectrum observer.

public abstract int RegisterAudioSpectrumObserver(IAudioSpectrumObserver observer);

Details

After successfully registering the audio spectrum observer and calling EnableAudioSpectrumMonitor to enable the audio spectrum monitoring, the SDK reports the callback that you implement in the IAudioSpectrumObserver class according to the time interval you set.

Attention: You can call this method either before or after joining a channel.

Parameters

observer

The audio spectrum observer. See IAudioSpectrumObserver.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterExtension

Registers an extension.

public abstract int RegisterExtension(string provider, string extension, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE);

For extensions external to the SDK (such as those from Extensions Marketplace and SDK Extensions), you need to load them before calling this method. Extensions internal to the SDK (those included in the full SDK package) are automatically loaded and registered after the initialization of IRtcEngine.

Call timing

  • Agora recommends you call this method after the initialization of IRtcEngine and before joining a channel.
  • For video extensions (such as the image enhancement extension), you need to call this method after enabling the video module by calling EnableVideo or EnableLocalVideo.
  • Before calling this method, you need to call LoadExtensionProvider to load the extension first.

Restrictions

  • If you want to register multiple extensions, you need to call this method multiple times.
  • The data processing order of different extensions in the SDK is determined by the order in which the extensions are registered. That is, the extension that is registered first will process the data first.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
type
Source type of the extension. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.
    • -3: The extension library is not loaded. Agora recommends that you check the storage location or the name of the dynamic library.

RegisterFaceInfoObserver

Registers a facial information observer.

public abstract int RegisterFaceInfoObserver(IFaceInfoObserver observer);

Details

You can call this method to register the OnFaceInfo callback to receive the facial information processed by Agora speech driven extension. When calling this method to register a facial information observer, you can register callbacks in the IFaceInfoObserver class as needed. After successfully registering the facial information observer, the SDK triggers the callback you have registered when it captures the facial information converted by the speech driven extension.

Attention:
  • Ensure that you call this method before joining a channel.
  • Before calling this method, you need to make sure that the speech driven extension has been enabled by calling EnableExtension.

Applicable scenarios

Facial information processed by the Agora speech driven extension is BS (Blend Shape) data that complies with ARkit standards. You can further process the BS data using third-party 3D rendering engines, such as driving avatar to make mouth movements corresponding to speech.

Parameters

observer
Facial information observer, see IFaceInfoObserver.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterLocalUserAccount

Registers a user account.

public abstract int RegisterLocalUserAccount(string appId, string userAccount);

Details

Once registered, the user account can be used to identify the local user when the user joins the channel. After the registration is successful, the user account can identify the identity of the local user, and the user can use it to join the channel.

After the user successfully registers a user account, the SDK triggers the OnLocalUserRegistered callback on the local client, reporting the user ID and account of the local user.

This method is optional. To join a channel with a user account, you can choose either of the following ways:
  • Call RegisterLocalUserAccount to create a user account, and then call JoinChannelWithUserAccount [2/2] to join the channel.
  • Call the JoinChannelWithUserAccount [2/2] method to join the channel.

The difference between the two ways is that the time elapsed between calling the RegisterLocalUserAccount method and joining the channel is shorter than directly calling JoinChannelWithUserAccount [2/2].

Attention:
  • Ensure that you set the userAccount parameter; otherwise, this method does not take effect.
  • Ensure that the userAccount is unique in the channel.
  • To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.

Parameters

appId
The App ID of your project on Agora Console.
userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are as follow(89 in total):
  • The 26 lowercase English letters: a to z.
  • The 26 uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Returns

  • 0: Success.
  • < 0: Failure.

RegisterMediaMetadataObserver

Registers the metadata observer.

public abstract int RegisterMediaMetadataObserver(IMetadataObserver observer, METADATA_TYPE type);

Details

You need to implement the IMetadataObserver class and specify the metadata type in this method. This method enables you to add synchronized metadata in the video stream for more diversified live interactive streaming, such as sending shopping links, digital coupons, and online quizzes.

Attention: Call this method before JoinChannel [2/2].

Parameters

observer
The metadata observer. See IMetadataObserver.
type

The metadata type. The SDK currently only supports VIDEO_METADATA. See METADATA_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterVideoEncodedFrameObserver

Registers a receiver object for the encoded video image.

public abstract int RegisterVideoEncodedFrameObserver(IVideoEncodedFrameObserver videoEncodedImageReceiver, OBSERVER_MODE mode = OBSERVER_MODE.INTPTR);

Details

If you only want to observe encoded video frames (such as h.264 format) without decoding and rendering the video, Agora recommends that you implement one IVideoEncodedFrameObserver class through this method.

If you want to obtain the original video data of some remote users (referred to as group A) and the encoded video data of other remote users (referred to as group B), you can refer to the following steps:
  1. Call RegisterVideoFrameObserver to register the raw video frame observer before joining the channel.
  2. Call RegisterVideoEncodedFrameObserver to register the encoded video frame observer before joining the channel.
  3. After joining the channel, get the user IDs of group B users through OnUserJoined, and then call SetRemoteVideoSubscriptionOptions to set the encodedFrameOnly of this group of users to true.
  4. Call MuteAllRemoteVideoStreams(false)to start receiving the video streams of all remote users. Then:
    • The raw video data of group A users can be obtained through the callback in IVideoFrameObserver, and the SDK renders the data by default.
    • The encoded video data of group B users can be obtained through the callback in IVideoEncodedFrameObserver.
Attention:
  • Call this method before joining a channel.

Parameters

videoEncodedImageReceiver
The video frame observer object. See IVideoEncodedFrameObserver.
mode
The video data callback mode. See OBSERVER_MODE.

Returns

  • 0: Success.
  • < 0: Failure.

RegisterVideoFrameObserver

Registers a raw video frame observer object.

public abstract int RegisterVideoFrameObserver(IVideoFrameObserver videoFrameObserver, VIDEO_OBSERVER_FRAME_TYPE formatPreference, VIDEO_OBSERVER_POSITION position, OBSERVER_MODE mode = OBSERVER_MODE.INTPTR);

Details

If you want to observe raw video frames (such as YUV or RGBA format), Agora recommends that you implement one IVideoFrameObserver class with this method.

When calling this method to register a video observer, you can register callbacks in the IVideoFrameObserver class as needed. After you successfully register the video frame observer, the SDK triggers the registered callbacks each time a video frame is received.

If you want to obtain the original video data of some remote users (referred to as group A) and the encoded video data of other remote users (referred to as group B), you can refer to the following steps:
  1. Call RegisterVideoFrameObserver to register the raw video frame observer before joining the channel.
  2. Call RegisterVideoEncodedFrameObserver to register the encoded video frame observer before joining the channel.
  3. After joining the channel, get the user IDs of group B users through OnUserJoined, and then call SetRemoteVideoSubscriptionOptions to set the encodedFrameOnly of this group of users to true.
  4. Call MuteAllRemoteVideoStreams(false)to start receiving the video streams of all remote users. Then:
    • The raw video data of group A users can be obtained through the callback in IVideoFrameObserver, and the SDK renders the data by default.
    • The encoded video data of group B users can be obtained through the callback in IVideoEncodedFrameObserver.
Attention:
  • Ensure that you call this method before joining a channel.
  • When handling the video data returned in the callbacks, pay attention to the changes in the width and height parameters, which may be adapted under the following circumstances:
    • When network conditions deteriorate, the video resolution decreases incrementally.
    • If the user adjusts the video profile, the resolution of the video returned in the callbacks also changes.

Parameters

videoFrameObserver
The observer instance. See IVideoFrameObserver. To release the instance, set the value as NULL.
mode
The video data callback mode. See OBSERVER_MODE.
formatPreference
The video frame type. See VIDEO_OBSERVER_FRAME_TYPE.
position
A bit mask that controls the frame position of the video observer. See VIDEO_MODULE_POSITION.

Returns

  • 0: Success.
  • < 0: Failure.

RenewToken

Renews the token.

public abstract int RenewToken(string token);

You can call this method to pass a new token to the SDK. A token will expire after a certain period of time, at which point the SDK will be unable to establish a connection with the server.

Call timing

In any of the following cases, Agora recommends that you generate a new token on your server and then call this method to renew your token:

Restrictions

None.

Parameters

token
The new token.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid. For example, the token is empty.
    • -7: The IRtcEngine object has not been initialized. You need to initialize the IRtcEngine object before calling this method.
    • 110: Invalid token. Ensure the following:
      • The user ID specified when generating the token is consistent with the user ID used when joining the channel.
      • The generated token is the same as the token passed in to join the channel.

ResumeAllEffects

Resumes playing all audio effect files.

public abstract int ResumeAllEffects();

Returns

  • 0: Success.
  • < 0: Failure.

ResumeAudioMixing

Resumes playing and mixing the music file.

public abstract int ResumeAudioMixing();

Details

This method resumes playing and mixing the music file. Call this method when you are in a channel.

Returns

  • 0: Success.
  • < 0: Failure.

ResumeEffect

Resumes playing a specified audio effect.

public abstract int ResumeEffect(int soundId);

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.

Returns

  • 0: Success.
  • < 0: Failure.

SelectAudioTrack [1/2]

Selects the audio track used during playback.

public abstract int SelectAudioTrack(int index);

Details

After getting the track index of the audio file, you can call this method to specify any track to play. For example, if different tracks of a multi-track file store songs in different languages, you can call this method to set the playback language.

Note:

Parameters

index
The audio track you want to specify. The value range is [0, GetAudioTrackCount()].

Returns

  • 0: Success.
  • < 0: Failure.

SelectMultiAudioTrack

Selects the audio tracks that you want to play on your local device and publish to the channel respectively.

public abstract int SelectMultiAudioTrack(int playoutTrackIndex, int publishTrackIndex);

Details

You can call this method to determine the audio track to be played on your local device and published to the channel.

Before calling this method, you need to open the media file with the OpenWithMediaSource method and set enableMultiAudioTrack in MediaSource as true.

Applicable scenarios

For example, in KTV scenarios, the host can choose to play the original sound locally and publish the accompaniment track to the channel.

Parameters

playoutTrackIndex
The index of audio tracks for local playback. You can obtain the index through GetStreamInfo.
publishTrackIndex
The index of audio tracks to be published in the channel. You can obtain the index through GetStreamInfo.

Returns

  • 0: Success.
  • < 0: Failure.

SendCustomReportMessage

Reports customized messages.

public abstract int SendCustomReportMessage(string id, string category, string @event, string label, int value);

Details

Agora supports reporting and analyzing customized messages. This function is in the beta stage with a free trial. The ability provided in its beta test version is reporting a maximum of 10 message pieces within 6 seconds, with each message piece not exceeding 256 bytes and each string not exceeding 100 bytes. To try out this function, contact support@agora.io and discuss the format of customized messages with us.

SendStreamMessage

Sends data stream messages.

public abstract int SendStreamMessage(int streamId, byte[] data, uint length);

Details

Sends data stream messages to all users in a channel. The SDK has the following restrictions on this method:
  • Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 KB.
  • Each client can send up to 6 KB of data per second.
  • Each user can have up to five data streams simultaneously.

A successful method call triggers the OnStreamMessage callback on the remote client, from which the remote user gets the stream message. A failed method call triggers the OnStreamMessageError callback on the remote client.

Attention:
  • Ensure that you call CreateDataStream [2/2] to create a data channel before calling this method.
  • In live streaming scenarios, this method only applies to hosts.

Parameters

streamId
The data stream ID. You can get the data stream ID by calling CreateDataStream [2/2].
data
The message to be sent.
length
The length of the data.

Returns

  • 0: Success.
  • < 0: Failure.

SetAdvancedAudioOptions

Sets audio advanced options.

public abstract int SetAdvancedAudioOptions(AdvancedAudioOptions options);

Details

If you have advanced audio processing requirements, such as capturing and sending stereo audio, you can call this method to set advanced audio options.

Attention: Call this method after calling JoinChannel [2/2], EnableAudio and EnableLocalAudio.

Parameters

options
The advanced options for audio. See AdvancedAudioOptions.

Returns

  • 0: Success.
  • < 0: Failure.

SetAINSMode

Sets whether to enable the AI ​​noise suppression function and set the noise suppression mode.

public abstract int SetAINSMode(bool enabled, AUDIO_AINS_MODE mode);

Details

You can call this method to enable AI noise suppression function. Once enabled, the SDK automatically detects and reduces stationary and non-stationary noise from your audio on the premise of ensuring the quality of human voice. Stationary noise refers to noise signal with constant average statistical properties and negligibly small fluctuations of level within the period of observation. Common sources of stationary noises are:
  • Television;
  • Air conditioner;
  • Machinery, etc.
Non-stationary noise refers to noise signal with huge fluctuations of level within the period of observation; common sources of non-stationary noises are:
  • Thunder;
  • Explosion;
  • Cracking, etc.
Note:
  • Agora does not recommend enabling this function on devices running Android 6.0 and below.

Applicable scenarios

In scenarios such as co-streaming, online education and video meeting, this function can detect and reduce background noises to improve experience.

Parameters

enabled
Whether to enable the AI noise suppression function:
  • true: Enable the AI noise suppression.
  • false: (Default) Disable the AI noise suppression.
mode

The AI noise suppression modes. See AUDIO_AINS_MODE.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioEffectParameters

Sets parameters for SDK preset audio effects.

public abstract int SetAudioEffectParameters(AUDIO_EFFECT_PRESET preset, int param1, int param2);

Details

Call this method to set the following parameters for the local user who sends an audio stream:
  • 3D voice effect: Sets the cycle period of the 3D voice effect.
  • Pitch correction effect: Sets the basic mode and tonic pitch of the pitch correction effect. Different songs have different modes and tonic pitches. Agora recommends bounding this method with interface elements to enable users to adjust the pitch correction interactively.

After setting the audio parameters, all users in the channel can hear the effect.

To achieve better vocal effects, it is recommended that you call the following APIs before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality audio scenario, namely AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] to set the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).
Attention:

Parameters

preset
The options for SDK preset audio effects:
  • ROOM_ACOUSTICS_3D_VOICE, 3D voice effect:
    • You need to set the profile parameter in SetAudioProfile [2/2] to AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before setting this enumerator; otherwise, the enumerator setting does not take effect.
    • If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear the anticipated voice effect.
  • PITCH_CORRECTION, Pitch correction effect:
param1
  • If you set preset to ROOM_ACOUSTICS_3D_VOICE, param1 sets the cycle period of the 3D voice effect. The value range is [1,60] and the unit is seconds. The default value is 10, indicating that the voice moves around you every 10 seconds.
  • If you set preset to PITCH_CORRECTION, param1 indicates the basic mode of the pitch correction effect:
    • 1: (Default) Natural major scale.
    • 2: Natural minor scale.
    • 3: Japanese pentatonic scale.
param2
  • If you set preset to ROOM_ACOUSTICS_3D_VOICE , you need to set param2 to 0.
  • If you set preset to PITCH_CORRECTION, param2 indicates the tonic pitch of the pitch correction effect:
    • 1: A
    • 2: A#
    • 3: B
    • 4: (Default) C
    • 5: C#
    • 6: D
    • 7: D#
    • 8: E
    • 9: F
    • 10: F#
    • 11: G
    • 12: G#

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioEffectPreset

Sets an SDK preset audio effect.

public abstract int SetAudioEffectPreset(AUDIO_EFFECT_PRESET preset);

Details

Call this method to set an SDK preset audio effect for the local user who sends an audio stream. This audio effect does not change the gender characteristics of the original voice. After setting an audio effect, all users in the channel can hear the effect.

To achieve better vocal effects, it is recommended that you call the following APIs before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality audio scenario, namely AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] to set the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).
Attention:
  • You can call this method either before or after joining a channel.
  • Do not set the profile parameter in SetAudioProfile [2/2] to AUDIO_PROFILE_SPEECH_STANDARD(1) or AUDIO_PROFILE_IOT(6), or the method does not take effect.
  • If you call SetAudioEffectPreset and set enumerators except for ROOM_ACOUSTICS_3D_VOICE or PITCH_CORRECTION, do not call SetAudioEffectParameters; otherwise, SetAudioEffectPreset is overridden.
  • After calling SetAudioEffectPreset, Agora does not recommend you to call the following methods, otherwise the effect set by SetAudioEffectPreset will be overwritten:
  • This method relies on the voice beautifier dynamic library libagora_audio_beauty_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

preset
The options for SDK preset audio effects. See AUDIO_EFFECT_PRESET.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioMixingDualMonoMode

Sets the channel mode of the current audio file.

public abstract int SetAudioMixingDualMonoMode(AUDIO_MIXING_DUAL_MONO_MODE mode);

Details

In a stereo music file, the left and right channels can store different audio data. According to your needs, you can set the channel mode to original mode, left channel mode, right channel mode, or mixed channel mode. For example, in the KTV scenario, the left channel of the music file stores the musical accompaniment, and the right channel stores the singing voice. If you only need to listen to the accompaniment, call this method to set the channel mode of the music file to left channel mode; if you need to listen to the accompaniment and the singing voice at the same time, call this method to set the channel mode to mixed channel mode.

Attention:

Parameters

mode
The channel mode. See AUDIO_MIXING_DUAL_MONO_MODE.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioMixingPlaybackSpeed

Sets the playback speed of the current audio file.

public abstract int SetAudioMixingPlaybackSpeed(int speed);

Details

Ensure you call this method after calling StartAudioMixing [2/2] receiving the OnAudioMixingStateChanged callback reporting the state as AUDIO_MIXING_STATE_PLAYING.

Parameters

speed
The playback speed. Agora recommends that you set this to a value between 50 and 400, defined as follows:
  • 50: Half the original speed.
  • 100: The original speed.
  • 400: 4 times the original speed.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioMixingPitch

Sets the pitch of the local music file.

public abstract int SetAudioMixingPitch(int pitch);

Details

When a local music file is mixed with a local human voice, call this method to set the pitch of the local music file only.

Attention: You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Parameters

pitch
Sets the pitch of the local music file by the chromatic scale. The default value is 0, which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioMixingPosition

Sets the audio mixing position.

public abstract int SetAudioMixingPosition(int pos);

Details

Call this method to set the playback position of the music file to a different starting position (the default plays from the beginning).

Attention: You need to call this method after calling StartAudioMixing [2/2] and receiving the OnAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Parameters

pos
Integer. The playback position (ms).

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioProfile [1/2]

Sets the audio profile and audio scenario.

public abstract int SetAudioProfile(AUDIO_PROFILE_TYPE profile, AUDIO_SCENARIO_TYPE scenario);
Deprecated:
This method is deprecated. If you need to set the audio profile, use SetAudioProfile [2/2]; if you need to set the audio scenario, use SetAudioScenario.

Applicable scenarios

This method is suitable for various audio scenarios. You can choose as needed. For example, in scenarios with high audio quality requirements such as music teaching, it is recommended to set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) and scenario to AUDIO_SCENARIO_GAME_STREAMING(3).

Call timing

You can call this method either before or after joining a channel.

Restrictions

Due to iOS system restrictions, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio scenario to AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK will switch to media volume to avoid this issue.

Parameters

profile

The audio profile, including the sampling rate, bitrate, encoding mode, and the number of channels. See AUDIO_PROFILE_TYPE.

scenario
The audio scenarios. Under different audio scenarios, the device uses different volume types. See AUDIO_SCENARIO_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioProfile [2/2]

Sets audio profiles.

public abstract int SetAudioProfile(AUDIO_PROFILE_TYPE profile);

If you need to set the audio scenario, you can either call SetAudioScenario, or Initialize and set the audioScenario in RtcEngineContext.

Applicable scenarios

This method is suitable for various audio scenarios. You can choose as needed. For example, in scenarios with high audio quality requirements such as music teaching, it is recommended to set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4).

Call timing

You can call this method either before or after joining a channel.

Restrictions

None.

Parameters

profile

The audio profile, including the sampling rate, bitrate, encoding mode, and the number of channels. See AUDIO_PROFILE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetAudioScenario

Sets audio scenarios.

public abstract int SetAudioScenario(AUDIO_SCENARIO_TYPE scenario);

Applicable scenarios

This method is suitable for various audio scenarios. You can choose as needed. For example, in scenarios such as music teaching that require high sound quality, it is recommended to set scenario to AUDIO_SCENARIO_GAME_STREAMING(3).

Call timing

You can call this method either before or after joining a channel.

Restrictions

Due to iOS system restrictions, some audio routes cannot be recognized in call volume mode. Therefore, if you need to use an external sound card, it is recommended to set the audio scenario to AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK will switch to media volume to avoid this issue.

Parameters

scenario
The audio scenarios. Under different audio scenarios, the device uses different volume types. See AUDIO_SCENARIO_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetBeautyEffectOptions

Sets the image enhancement options.

public abstract int SetBeautyEffectOptions(bool enabled, BeautyOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Details

Enables or disables image enhancement, and sets the options.

Note:
  • Call this method after calling EnableVideo or StartPreview [2/2].
  • This method relies on the image enhancement dynamic library libagora_clear_vision_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.
  • This feature has high requirements on device performance. When calling this method, the SDK automatically checks the capabilities of the current device.

Parameters

enabled
Whether to enable the image enhancement function:
  • true: Enable the image enhancement function.
  • false: (Default) Disable the image enhancement function.
options
The image enhancement options. See BeautyOptions.
type
Source type of the extension. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.
    • -4: The current device does not support this feature. Possible reasons include:
      • The current device capabilities do not meet the requirements for image enhancement. Agora recommends you replace it with a high-performance device.
      • The current device version is lower than Android 5.0 and does not support this feature. Agora recommends you replace the device or upgrade the operating system.

SetCameraAutoExposureFaceModeEnabled

Sets whether to enable auto exposure.

public abstract int SetCameraAutoExposureFaceModeEnabled(bool enabled);

Details

Attention:
  • This method applies to iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Parameters

enabled
Whether to enable auto exposure:
  • true: Enable auto exposure.
  • false: Disable auto exposure.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraAutoFocusFaceModeEnabled

Enables the camera auto-face focus function.

public abstract int SetCameraAutoFocusFaceModeEnabled(bool enabled);

Details

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Parameters

enabled
Whether to enable face autofocus:
  • true: Enable the camera auto-face focus function.
  • false: Disable face autofocus.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraCapturerConfiguration

Sets the camera capture configuration.

public abstract int SetCameraCapturerConfiguration(CameraCapturerConfiguration config);

Details

Attention:
  • This method is for Android and iOS only.
  • Call this method before enabling local camera capture, such as before calling StartPreview [2/2] and JoinChannel [2/2].
  • To adjust the camera focal length configuration, It is recommended to call QueryCameraFocalLengthCapability first to check the device's focal length capabilities, and then configure based on the query results.
  • Due to limitations on some Android devices, even if you set the focal length type according to the results returned in QueryCameraFocalLengthCapability, the settings may not take effect.

Parameters

config
The camera capture configuration. See CameraCapturerConfiguration.
Note: In this method, you do not need to set the deviceId parameter.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraDeviceOrientation

Sets the rotation angle of the captured video.

public abstract int SetCameraDeviceOrientation(VIDEO_SOURCE_TYPE type, VIDEO_ORIENTATION orientation);

Details

Attention:
  • This method applies to Windows only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • When the video capture device does not have the gravity sensing function, you can call this method to manually adjust the rotation angle of the captured video.

Parameters

type
The video source type. See VIDEO_SOURCE_TYPE.
orientation
The clockwise rotation angle. See VIDEO_ORIENTATION.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraExposureFactor

Sets the camera exposure value.

public abstract int SetCameraExposureFactor(float factor);

Details

Insufficient or excessive lighting in the shooting environment can affect the image quality of video capture. To achieve optimal video quality, you can use this method to adjust the camera's exposure value.

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • Before calling this method, Agora recommends calling IsCameraExposureSupported to check whether the current camera supports adjusting the exposure value.
  • By calling this method, you adjust the exposure value of the currently active camera, that is, the camera specified when calling SetCameraCapturerConfiguration.

Parameters

factor

The camera exposure value. The default value is 0, which means using the default exposure of the camera. The larger the value, the greater the exposure. When the video image is overexposed, you can reduce the exposure value; when the video image is underexposed and the dark details are lost, you can increase the exposure value. If the exposure value you specified is beyond the range supported by the device, the SDK will automatically adjust it to the actual supported range of the device.

On Android, the value range is [-20.0, 20.0]. On iOS, the value range is [-8.0, 8.0].

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraExposurePosition

Sets the camera exposure position.

public abstract int SetCameraExposurePosition(float positionXinView, float positionYinView);

Details

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • After a successful method call, the SDK triggers the OnCameraExposureAreaChanged callback.

Parameters

positionXinView
The horizontal coordinate of the touchpoint in the view.
positionYinView
The vertical coordinate of the touchpoint in the view.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraFocusPositionInPreview

Sets the camera manual focus position.

public abstract int SetCameraFocusPositionInPreview(float positionX, float positionY);

Details

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • After a successful method call, the SDK triggers the OnCameraFocusAreaChanged callback.

Parameters

positionX
The horizontal coordinate of the touchpoint in the view.
positionY
The vertical coordinate of the touchpoint in the view.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraStabilizationMode

Set the camera stabilization mode.

public abstract int SetCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode);
Attention:

This method applies to iOS only.

The camera stabilization mode is off by default. You need to call this method to turn it on and set the appropriate stabilization mode.

Applicable scenarios

When shooting on the move, in low light conditions, or with mobile devices, you can set the camera stabilization mode to reduce the impact of camera shake and get a more stable, clear picture.

Call timing

This method must be called after the camera is successfully enabled, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Restrictions

  • Camera stabilization only works for scenarios with a video resolution greater than 1280 x 720.
  • After enabling camera stabilization, the higher the camera stabilization level, the smaller the camera's field of view and the greater the camera's latency. To improve user experience, it is recommended that you set the mode parameter to CAMERA_STABILIZATION_MODE_LEVEL_1.

Parameters

mode
Camera stabilization mode. See CAMERA_STABILIZATION_MODE.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraTorchOn

Enables the camera flash.

public abstract int SetCameraTorchOn(bool isOn);

Details

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Parameters

isOn
Whether to turn on the camera flash:
  • true: Turn on the flash.
  • false: (Default) Turn off the flash.

Returns

  • 0: Success.
  • < 0: Failure.

SetCameraZoomFactor

Sets the camera zoom factor.

public abstract int SetCameraZoomFactor(float factor);

Details

For iOS devices equipped with multi-lens rear cameras, such as those featuring dual-camera (wide-angle and ultra-wide-angle) or triple-camera (wide-angle, ultra-wide-angle, and telephoto), you can call SetCameraCapturerConfiguration first to set the cameraFocalLengthType as CAMERA_FOCAL_LENGTH_DEFAULT (0) (standard lens). Then, adjust the camera zoom factor to a value less than 1.0. This configuration allows you to capture video with an ultra-wide-angle perspective.

Attention:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting result will take effect after the camera is successfully turned on, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Parameters

factor
The camera zoom factor. For devices that do not support ultra-wide-angle, the value ranges from 1.0 to the maximum zoom factor; for devices that support ultra-wide-angle, the value ranges from 0.5 to the maximum zoom factor. You can get the maximum zoom factor supported by the device by calling the GetCameraMaxZoomFactor method.

Returns

  • The camera zoom factor value, if successful.
  • < 0: if the method if failed.

SetChannelProfile

Sets the channel profile.

public abstract int SetChannelProfile(CHANNEL_PROFILE_TYPE profile);

Details

After initializing the SDK, the default channel profile is the live streaming profile. You can call this method to set the channel profile. The Agora SDK differentiates channel profiles and applies optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call and prioritizes video quality for interactive live video streaming.

Attention:
  • To ensure the quality of real-time communication, Agora recommends that all users in a channel use the same channel profile.
  • This method must be called and set before JoinChannel [2/2], and cannot be set again after joining the channel.

Parameters

profile

The channel profile. See CHANNEL_PROFILE_TYPE.

Returns

  • 0(ERR_OK): Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • -7: The SDK is not initialized.

SetClientRole [1/2]

Sets the client role.

public abstract int SetClientRole(CLIENT_ROLE_TYPE role);

Details

In the interactive live streaming profile, the SDK sets the user role as audience by default. You can call this method to set the user role as host.

You can call this method either before or after joining a channel.

If you call this method to switch the user role after joining a channel, the SDK automatically does the following:

Parameters

role

The user role. See CLIENT_ROLE_TYPE.

Note: If you set the user role as an audience member, you cannot publish audio and video streams in the channel. If you want to publish media streams in a channel during live streaming, ensure you set the user role as broadcaster.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -7: The SDK is not initialized.

SetClientRole [2/2]

Sets the user role and level in an interactive live streaming channel.

public abstract int SetClientRole(CLIENT_ROLE_TYPE role, ClientRoleOptions options);

Details

In the interactive live streaming profile, the SDK sets the user role as audience by default. You can call this method to set the user role as host.

You can call this method either before or after joining a channel.

If you call this method to switch the user role after joining a channel, the SDK automatically does the following:
The difference between this method and SetClientRole [1/2] is that this method can set the user level in addition to the user role.
  • The user role (role) determines the permissions that the SDK grants to a user, such as permission to send local streams, receive remote streams, and push streams to a CDN address.
  • The user level (level) determines the level of services that a user can enjoy within the permissions of the user's role. For example, an audience member can choose to receive remote streams with low latency or ultra-low latency. User level affects the pricing of services.
Attention: This method applies to the interactive live streaming profile (the profile parameter of SetChannelProfile is set as CHANNEL_PROFILE_LIVE_BROADCASTING) only.

Parameters

role
The user role in the interactive live streaming. See CLIENT_ROLE_TYPE.
options
The detailed options of a user, including the user level. See ClientRoleOptions.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).
    • -2: The parameter is invalid.
    • -5: The request is rejected.
    • -7: The SDK is not initialized.

SetCloudProxy

Sets up cloud proxy service.

public abstract int SetCloudProxy(CLOUD_PROXY_TYPE proxyType);

Details

When users' network access is restricted by a firewall, configure the firewall to allow specific IP addresses and ports provided by Agora; then, call this method to enable the cloud proxyType and set the cloud proxy type with the proxyType parameter.

After successfully connecting to the cloud proxy, the SDK triggers the OnConnectionStateChanged (CONNECTION_STATE_CONNECTING, CONNECTION_CHANGED_SETTING_PROXY_SERVER) callback.

To disable the cloud proxy that has been set, call the SetCloudProxy(NONE_PROXY).

To change the cloud proxy type that has been set, call the SetCloudProxy(NONE_PROXY) first, and then call the SetCloudProxy to set the proxyType you want.

Attention:
  • Agora recommends that you call this method after joining a channel.
  • When a user is behind a firewall and uses the Force UDP cloud proxy, the services for Media Push and cohosting across channels are not available.
  • When you use the Force TCP cloud proxy, note that an error would occur when calling the StartAudioMixing [2/2] method to play online music files in the HTTP protocol. The services for Media Push and cohosting across channels use the cloud proxy with the TCP protocol.

Parameters

proxyType

The type of the cloud proxy. See CLOUD_PROXY_TYPE.

This parameter is mandatory. The SDK reports an error if you do not pass in a value.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • -7: The SDK is not initialized.

SetColorEnhanceOptions

Sets color enhancement.

public abstract int SetColorEnhanceOptions(bool enabled, ColorEnhanceOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Details

The video images captured by the camera can have color distortion. The color enhancement feature intelligently adjusts video characteristics such as saturation and contrast to enhance the video color richness and color reproduction, making the video more vivid.

You can call this method to enable the color enhancement feature and set the options of the color enhancement effect.

Attention:
  • Call this method after calling EnableVideo.
  • The color enhancement feature has certain performance requirements on devices. With color enhancement turned on, Agora recommends that you change the color enhancement level to one that consumes less performance or turn off color enhancement if your device is experiencing severe heat problems.
  • Both this method and SetExtensionProperty can enable color enhancement:
    • When you use the SDK to capture video, Agora recommends this method (this method only works for video captured by the SDK).
    • When you use an external video source to implement custom video capture, or send an external video source to the SDK, Agora recommends using SetExtensionProperty.
  • This method relies on the image enhancement dynamic library libagora_clear_vision_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

enabled
Whether to enable color enhancement:
  • true Enable color enhancement.
  • false: (Default) Disable color enhancement.
options
The color enhancement options. See ColorEnhanceOptions.
type
The type of the video source. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetDefaultAudioRouteToSpeakerphone

Sets the default audio playback route.

public abstract int SetDefaultAudioRouteToSpeakerphone(bool defaultToSpeaker);

Details

Note:
  • This method is for Android and iOS only.
  • Ensure that you call this method before joining a channel. If you need to change the audio route after joining a channel, call SetEnableSpeakerphone.

Most mobile phones have two audio routes: an earpiece at the top, and a speakerphone at the bottom. The earpiece plays at a lower volume, and the speakerphone at a higher volume. When setting the default audio route, you determine whether audio playback comes through the earpiece or speakerphone when no external audio device is connected.

In different scenarios, the default audio routing of the system is also different. See the following:
  • Voice call: Earpiece.
  • Audio broadcast: Speakerphone.
  • Video call: Speakerphone.
  • Video broadcast: Speakerphone.

You can call this method to change the default audio route. After a successful method call, the SDK triggers the OnAudioRoutingChanged callback.

Note:

The system audio route changes when an external audio device, such as a headphone or a Bluetooth audio device, is connected. See Audio Route for detailed change principles.

Parameters

defaultToSpeaker
Whether to set the speakerphone as the default audio route:
  • true: Set the speakerphone as the default audio route.
  • false: Set the earpiece as the default audio route.

Returns

  • 0: Success.
  • < 0: Failure.

SetDualStreamMode [1/2]

Sets the dual-stream mode on the sender side.

public abstract int SetDualStreamMode(SIMULCAST_STREAM_MODE mode);

Details

The SDK defaults to enabling low-quality video stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sender side, which means the sender does not actively send low-quality video stream. The receiving end with the role of the host can initiate a low-quality video stream request by calling SetRemoteVideoStreamType, and upon receiving the request, the sending end automatically starts sending low-quality stream.
  • If you want to modify this behavior, you can call this method and set mode to DISABLE_SIMULCAST_STREAM (never send low-quality video streams) or ENABLE_SIMULCAST_STREAM (always send low-quality video streams).
  • If you want to restore the default behavior after making changes, you can call this method again with mode set to AUTO_SIMULCAST_STREAM.
Note: The difference and connection between this method and EnableDualStreamMode [1/2] is as follows:
  • When calling this method and setting mode to DISABLE_SIMULCAST_STREAM, it has the same effect as EnableDualStreamMode [1/2](false).
  • When calling this method and setting mode to ENABLE_SIMULCAST_STREAM, it has the same effect as EnableDualStreamMode [1/2](true).
  • Both methods can be called before and after joining a channel. If both methods are used, the settings in the method called later takes precedence.

Parameters

mode
The mode in which the video stream is sent. See SIMULCAST_STREAM_MODE.

Returns

  • 0: Success.
  • < 0: Failure.

SetDualStreamMode [2/2]

Sets dual-stream mode configuration on the sender side.

public abstract int SetDualStreamMode(SIMULCAST_STREAM_MODE mode, SimulcastStreamConfig streamConfig);

Details

The SDK defaults to enabling low-quality video stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sender side, which means the sender does not actively send low-quality video stream. The receiving end with the role of the host can initiate a low-quality video stream request by calling SetRemoteVideoStreamType, and upon receiving the request, the sending end automatically starts sending low-quality stream.
  • If you want to modify this behavior, you can call this method and set mode to DISABLE_SIMULCAST_STREAM (never send low-quality video streams) or ENABLE_SIMULCAST_STREAM (always send low-quality video streams).
  • If you want to restore the default behavior after making changes, you can call this method again with mode set to AUTO_SIMULCAST_STREAM.

The difference between this method and SetDualStreamMode [1/2] is that this method can also configure the low-quality video stream, and the SDK sends the stream according to the configuration in streamConfig.

Note: The difference and connection between this method and EnableDualStreamMode [2/2] is as follows:
  • When calling this method and setting mode to DISABLE_SIMULCAST_STREAM, it has the same effect as calling EnableDualStreamMode [2/2] and setting enabled to false.
  • When calling this method and setting mode to ENABLE_SIMULCAST_STREAM, it has the same effect as calling EnableDualStreamMode [2/2] and setting enabled to true.
  • Both methods can be called before and after joining a channel. If both methods are used, the settings in the method called later takes precedence.

Parameters

mode
The mode in which the video stream is sent. See SIMULCAST_STREAM_MODE.
streamConfig
The configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: When setting mode to DISABLE_SIMULCAST_STREAM, setting streamConfig will not take effect.

Returns

  • 0: Success.
  • < 0: Failure.

SetEarMonitoringAudioFrameParameters

Sets the format of the in-ear monitoring raw audio data.

public abstract int SetEarMonitoringAudioFrameParameters(int sampleRate, int channel, RAW_AUDIO_FRAME_OP_MODE_TYPE mode, int samplesPerCall);

Details

This method is used to set the in-ear monitoring audio data format reported by the OnEarMonitoringAudioFrame callback.

Attention:
  • Before calling this method, you need to call EnableInEarMonitoring, and set includeAudioFilters to EAR_MONITORING_FILTER_BUILT_IN_AUDIO_FILTERS or EAR_MONITORING_FILTER_NOISE_SUPPRESSION.
  • The SDK calculates the sampling interval based on the samplesPerCall, sampleRate and channel parameters set in this method.Sample interval (sec) = samplePerCall/(sampleRate × channel). Ensure that the sample interval ≥ 0.01 (s). The SDK triggers the OnEarMonitoringAudioFrame callback according to the sampling interval.

Parameters

sampleRate
The sample rate of the audio data reported in the OnEarMonitoringAudioFrame callback, which can be set as 8,000, 16,000, 32,000, 44,100, or 48,000 Hz.
channel
The number of audio channels reported in the OnEarMonitoringAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
mode

The use mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.

samplesPerCall
The number of data samples reported in the OnEarMonitoringAudioFrame callback, such as 1,024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

SetEffectPosition

Sets the playback position of an audio effect file.

public abstract int SetEffectPosition(int soundId, int pos);

Details

After a successful setting, the local audio effect file starts playing at the specified position.

Attention: Call this method after playEffect.

Parameters

soundId
The audio effect ID. The ID of each audio effect file is unique.
pos
The playback position (ms) of the audio effect file.

Returns

  • 0: Success.
  • < 0: Failure.

SetEffectsVolume

Sets the volume of the audio effects.

public abstract int SetEffectsVolume(int volume);

Details

Attention: Call this method after PlayEffect.

Parameters

volume
The playback volume. The value range is [0, 100]. The default value is 100, which represents the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

SetEnableSpeakerphone

Enables/Disables the audio route to the speakerphone.

public abstract int SetEnableSpeakerphone(bool speakerOn);

Details

If the default audio route of the SDK or the setting in SetDefaultAudioRouteToSpeakerphone cannot meet your requirements, you can call SetEnableSpeakerphone to switch the current audio route. After a successful method call, the SDK triggers the OnAudioRoutingChanged callback.

For the default audio route in different scenarios, see Audio Route.

This method only sets the audio route in the current channel and does not influence the default audio route. If the user leaves the current channel and joins another channel, the default audio route is used.

Attention:
  • This method is for Android and iOS only.
  • Call this method after joining a channel.
  • If the user uses an external audio playback device such as a Bluetooth or wired headset, this method does not take effect, and the SDK plays audio through the external device. When the user uses multiple external devices, the SDK plays audio through the last connected device.

Parameters

speakerOn
Sets whether to enable the speakerphone or earpiece:
  • true: Enable device state monitoring. The audio route is the speakerphone.
  • false: Disable device state monitoring. The audio route is the earpiece.

Returns

  • 0: Success.
  • < 0: Failure.

SetEncryptionMode

Sets the built-in encryption mode.

public abstract int SetEncryptionMode(string encryptionMode);

Details

Deprecated:
Use EnableEncryption instead.

The SDK supports built-in encryption schemes, AES-128-GCM is supported by default. Call this method to use other encryption modes. All users in the same channel must use the same encryption mode and secret. Refer to the information related to the AES encryption algorithm on the differences between the encryption modes.

Attention: Before calling this method, please call SetEncryptionSecret to enable the built-in encryption function.

Parameters

encryptionMode
The following encryption modes:
  • "aes-128-xts": 128-bit AES encryption, XTS mode.
  • "aes-128-ecb": 128-bit AES encryption, ECB mode.
  • "aes-256-xts": 256-bit AES encryption, XTS mode.
  • "sm4-128-ecb": 128-bit SM4 encryption, ECB mode.
  • "aes-128-gcm": 128-bit AES encryption, GCM mode.
  • "aes-256-gcm": 256-bit AES encryption, GCM mode.
  • "": When this parameter is set as null, the encryption mode is set as "aes-128-gcm" by default.

Returns

  • 0: Success.
  • < 0: Failure.

SetEncryptionSecret

Enables built-in encryption with an encryption password before users join a channel.

public abstract int SetEncryptionSecret(string secret);

Details

Deprecated:
Use EnableEncryption instead.

Before joining the channel, you need to call this method to set the secret parameter to enable the built-in encryption. All users in the same channel should use the same secret. The secret is automatically cleared once a user leaves the channel. If you do not specify the secret or secret is set as null, the built-in encryption is disabled.

Attention:
  • Do not use this method for Media Push.
  • For optimal transmission, ensure that the encrypted data size does not exceed the original data size + 16 bytes. 16 bytes is the maximum padding size for AES encryption.

Parameters

secret
The encryption password.

Returns

  • 0: Success.
  • < 0: Failure.

SetExtensionProperty

Sets the properties of the extension.

public abstract int SetExtensionProperty(string provider, string extension, string key, string value, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE);

After enabling the extension, you can call this method to set the properties of the extension.

Call timing

Call this mehtod after calling EnableExtension.

Restrictions

If you want to set properties for multiple extensions, you need to call this method multiple times.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
key
The key of the extension.
value
The value of the extension key.
type
Source type of the extension. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetExtensionProviderProperty

Sets the properties of the extension provider.

public abstract int SetExtensionProviderProperty(string provider, string key, string value);

You can call this method to set the attributes of the extension provider and initialize the relevant parameters according to the type of the provider.

Call timing

Call this method before EnableExtension and after RegisterExtension.

Restrictions

If you want to set the properties of the extension provider for multiple extensions, you need to call this method multiple times.

Parameters

provider
The name of the extension provider.
key
The key of the extension.
value
The value of the extension key.

Returns

  • 0: Success.
  • < 0: Failure.

SetExternalAudioSink

Sets the external audio sink.

public abstract int SetExternalAudioSink(bool enabled, int sampleRate, int channels);

Details

This method applies to scenarios where you want to use external audio data for playback. After you set the external audio sink, you can call PullAudioFrame to pull remote audio frames. The app can process the remote audio and play it with the audio effects that you want.

Parameters

enabled
Whether to enable or disable the external audio sink:
  • true: Enables the external audio sink.
  • false: (Default) Disables the external audio sink.
sampleRate

The sample rate (Hz) of the external audio sink, which can be set as 16000, 32000, 44100, or 48000.

channels
The number of audio channels of the external audio sink:
  • 1: Mono.
  • 2: Stereo.

Returns

  • 0: Success.
  • < 0: Failure.

SetExternalAudioSource

Sets the external audio source parameters.

public abstract int SetExternalAudioSource(bool enabled, int sampleRate, int channels, bool localPlayback = false, bool publish = true);

Details

Deprecated:
This method is deprecated, use CreateCustomAudioTrack instead.
Attention: Call this method before joining a channel.

Parameters

enabled
Whether to enable the external audio source:
  • true: Enable the external audio source.
  • false: (Default) Disable the external audio source.
sampleRate
The sample rate (Hz) of the external audio source which can be set as 8000, 16000, 32000, 44100, or 48000.
channels
The number of channels of the external audio source, which can be set as 1 (Mono) or 2 (Stereo).
localPlayback
Whether to play the external audio source:
  • true: Play the external audio source.
  • false: (Default) Do not play the external source.
publish
Whether to publish audio to the remote users:
  • true: (Default) Publish audio to the remote users.
  • false: Do not publish audio to the remote users.

Returns

  • 0: Success.
  • < 0: Failure.

SetExternalVideoSource

Configures the external video source.

public abstract int SetExternalVideoSource(bool enabled, bool useTexture, EXTERNAL_VIDEO_SOURCE_TYPE sourceType, SenderOptions encodedVideoOption);

Details

Attention: Call this method before joining a channel.

Parameters

enabled
Whether to use the external video source:
  • true: Use the external video source. The SDK prepares to accept the external video frame.
  • false: (Default) Do not use the external video source.
useTexture
Whether to use the external video frame in the Texture format.
  • true: Use the external video frame in the Texture format.
  • false: (Default) Do not use the external video frame in the Texture format.
sourceType
Whether the external video frame is encoded. See EXTERNAL_VIDEO_SOURCE_TYPE.
encodedVideoOption
Video encoding options. This parameter needs to be set if sourceType is ENCODED_VIDEO_FRAME. To set this parameter, contact technical support.

Returns

  • 0: Success.
  • < 0: Failure.

SetHeadphoneEQParameters

Sets the low- and high-frequency parameters of the headphone equalizer.

public abstract int SetHeadphoneEQParameters(int lowGain, int highGain);

Details

In a spatial audio effect scenario, if the preset headphone equalization effect is not achieved after calling the SetHeadphoneEQPreset method, you can further adjust the headphone equalization effect by calling this method.

Parameters

lowGain
The low-frequency parameters of the headphone equalizer. The value range is [-10,10]. The larger the value, the deeper the sound.
highGain
The high-frequency parameters of the headphone equalizer. The value range is [-10,10]. The larger the value, the sharper the sound.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).

SetHeadphoneEQPreset

Sets the preset headphone equalization effect.

public abstract int SetHeadphoneEQPreset(HEADPHONE_EQUALIZER_PRESET preset);

Details

This method is mainly used in spatial audio effect scenarios. You can select the preset headphone equalizer to listen to the audio to achieve the expected audio experience.

Note: If the headphones you use already have a good equalization effect, you may not get a significant improvement when you call this method, and could even diminish the experience.

Parameters

preset
The preset headphone equalization effect. See HEADPHONE_EQUALIZER_PRESET.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: A general error occurs (no specified reason).

SetInEarMonitoringVolume

Sets the volume of the in-ear monitor.

public abstract int SetInEarMonitoringVolume(int volume);

Call timing

It can be called either before or after joining the channel.

Restrictions

None.

Parameters

volume
The volume of the user. The value range is [0,400].
  • 0: Mute.
  • 100: (Default) The original volume.
  • 400: Four times the original volume (amplifying the audio signals by four times).

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: Invalid parameter settings, such as in-ear monitoring volume exceeding the valid range (< 0 or > 400).

SetLocalRenderMode [1/2]

Sets the local video display mode.

public abstract int SetLocalRenderMode(RENDER_MODE_TYPE renderMode);

Details

Deprecated:
This method is deprecated. Use SetLocalRenderMode [2/2] instead.

Call this method to set the local video display mode. This method can be called multiple times during a call to change the display mode.

Parameters

renderMode

The local video display mode. See RENDER_MODE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetLocalRenderMode [2/2]

Updates the display mode of the local video view.

public abstract int SetLocalRenderMode(RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode);

Details

After initializing the local video view, you can call this method to update its rendering and mirror modes. It affects only the video view that the local user sees, not the published local video stream.

Attention:
  • Ensure that you have called the SetupLocalVideo method to initialize the local video view before calling this method.
  • During a call, you can call this method as many times as necessary to update the display mode of the local video view.
  • This method only takes effect on the primary camera (PRIMARY_CAMERA_SOURCE). In scenarios involving custom video capture or the use of alternative video sources, you need to use SetupLocalVideo instead of this method.

Parameters

renderMode

The local video display mode. See RENDER_MODE_TYPE.

mirrorMode
The mirror mode of the local video view. See VIDEO_MIRROR_MODE_TYPE.
Attention: This parameter is only effective when rendering custom videos. If you want to mirror the video view, set the scaleX of the GameObject attached to the video view as -1 or +1.
Attention: If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.

Returns

  • 0: Success.
  • < 0: Failure.

SetLocalVoiceEqualization

Sets the local voice equalization effect.

public abstract int SetLocalVoiceEqualization(AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, int bandGain);

Details

Attention: You can call this method either before or after joining a channel.

Parameters

bandFrequency
The band frequency. The value ranges between 0 and 9; representing the respective 10-band center frequencies of the voice effects, including 31, 62, 125, 250, 500, 1k, 2k, 4k, 8k, and 16k Hz. See AUDIO_EQUALIZATION_BAND_FREQUENCY.
bandGain
The gain of each band in dB. The value ranges between -15 and 15. The default value is 0.

Returns

  • 0: Success.
  • < 0: Failure.

SetLocalVoicePitch

Changes the voice pitch of the local speaker.

public abstract int SetLocalVoicePitch(double pitch);

Details

Attention: You can call this method either before or after joining a channel.

Parameters

pitch
The local voice pitch. The value range is [0.5,2.0]. The lower the value, the lower the pitch. The default value is 1.0 (no change to the pitch).

Returns

  • 0: Success.
  • < 0: Failure.

SetLocalVoiceReverb

Sets the local voice reverberation.

public abstract int SetLocalVoiceReverb(AUDIO_REVERB_TYPE reverbKey, int value);

Details

The SDK provides an easier-to-use method, SetAudioEffectPreset, to directly implement preset reverb effects for such as pop, R&B, and KTV.

Note: You can call this method either before or after joining a channel.

Parameters

reverbKey
The reverberation key. Agora provides five reverberation keys, see AUDIO_REVERB_TYPE.
value
The value of the reverberation key.

Returns

  • 0: Success.
  • < 0: Failure.

SetLogFile

Sets the log file.

public abstract int SetLogFile(string filePath);

Details

Deprecated:
Use the mLogConfig parameter in Initialize method instead.

Specifies an SDK output log file. The log file records all log data for the SDK’s operation. Ensure that the directory for the log file exists and is writable.

Note:

Ensure that you call Initialize immediately after calling the IRtcEngine method, or the output log may not be complete.

Parameters

filePath
The complete path of the log files. These log files are encoded in UTF-8.

Returns

  • 0: Success.
  • < 0: Failure.

SetLogFileSize

Sets the log file size.

public abstract int SetLogFileSize(uint fileSizeInKBytes);

Details

Deprecated:
Use the logConfig parameter in Initialize instead.

By default, the SDK generates five SDK log files and five API call log files with the following rules:

  • The SDK log files are: agorasdk.log, agorasdk.1.log, agorasdk.2.log, agorasdk.3.log, and agorasdk.4.log.
  • The API call log files are: agoraapi.log, agoraapi.1.log, agoraapi.2.log, agoraapi.3.log, and agoraapi.4.log.
  • The default size of each SDK log file and API log file is 2,048 KB. These log files are encoded in UTF-8.
  • The SDK writes the latest logs in agorasdk.log or agoraapi.log.
  • When agorasdk.log is full, the SDK processes the log files in the following order:
    1. Delete the agorasdk.4.log file (if any).
    2. Rename agorasdk.3.log to agorasdk.4.log.
    3. Rename agorasdk.2.log to agorasdk.3.log.
    4. Rename agorasdk.1.log to agorasdk.2.log.
    5. Create a new agorasdk.log file.
  • The overwrite rules for the agoraapi.log file are the same as for agorasdk.log.
Note:

This method is used to set the size of the agorasdk.log file only and does not effect the agoraapi.log file.

Parameters

fileSizeInKBytes
The size (KB) of an agorasdk.log file. The value range is [128,20480]. The default value is 2,048 KB. If you set fileSizeInKByte smaller than 128 KB, the SDK automatically adjusts it to 128 KB; if you set fileSizeInKByte greater than 20,480 KB, the SDK automatically adjusts it to 20,480 KB.

Returns

  • 0: Success.
  • < 0: Failure.

SetLogFilter

Sets the log output level of the SDK.

public abstract int SetLogFilter(uint filter);

Details

Deprecated:
Use logConfig in Initialize instead.

Parameters

filter

The output log level of the SDK.

Returns

  • 0: Success.
  • < 0: Failure.

SetLogLevel

Sets the output log level of the SDK.

public abstract int SetLogLevel(LOG_LEVEL level);

Details

Deprecated:
This method is deprecated. Use RtcEngineContext instead to set the log output level.

Choose a level to see the logs preceding that level.

Parameters

level
The log level: LOG_LEVEL.

Returns

  • 0: Success.
  • < 0: Failure.

SetLoopbackDevice

Sets the loopback device.

public abstract int SetLoopbackDevice(string deviceId);

Details

The SDK uses the current playback device as the loopback device by default. If you want to specify another audio device as the loopback device, call this method, and set deviceId to the loopback device you want to specify.

You can call this method to change the audio route currently being used, but this does not change the default audio route. For example, if the default audio route is microphone, you call this method to set the audio route as a sound card before joinging a channel and then start a device test, the SDK conducts device test on the sound card. After the device test is completed and you join a channel, the SDK still uses the microphone for audio capturing.

Note:

This method is for Windows and macOS only.

The scenarios where this method is applicable are as follows:

Use app A to play music through a Bluetooth headset; when using app B for a video conference, play through the speakers.
  • If the loopback device is set as the Bluetooth headset, the SDK publishes the music in app A to the remote end.
  • If the loopback device is set as the speaker, the SDK does not publish the music in app A to the remote end.
  • If you set the loopback device as the Bluetooth headset, and then use a wired headset to play the music in app A, you need to call this method again, set the loopback device as the wired headset, and the SDK continues to publish the music in app A to remote end.

Parameters

deviceId

Specifies the loopback device of the SDK. You can get the device ID by calling EnumeratePlaybackDevices. Connecting or disconnecting the audio device does not change the value of deviceId.

Returns

  • 0: Success.
  • < 0: Failure.

SetLowlightEnhanceOptions

Sets low-light enhancement.

public abstract int SetLowlightEnhanceOptions(bool enabled, LowlightEnhanceOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Details

The low-light enhancement feature can adaptively adjust the brightness value of the video captured in situations with low or uneven lighting, such as backlit, cloudy, or dark scenes. It restores or highlights the image details and improves the overall visual effect of the video.

You can call this method to enable the color enhancement feature and set the options of the color enhancement effect.

Attention:
  • Call this method after calling EnableVideo.
  • Dark light enhancement has certain requirements for equipment performance. The low-light enhancement feature has certain performance requirements on devices. If your device overheats after you enable low-light enhancement, Agora recommends modifying the low-light enhancement options to a less performance-consuming level or disabling low-light enhancement entirely.
  • Both this method and SetExtensionProperty can turn on low-light enhancement:
    • When you use the SDK to capture video, Agora recommends this method (this method only works for video captured by the SDK).
    • When you use an external video source to implement custom video capture, or send an external video source to the SDK, Agora recommends using SetExtensionProperty.
  • This method relies on the image enhancement dynamic library libagora_clear_vision_extension.dll. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

enabled
Whether to enable low-light enhancement:
  • true: Enable low-light enhancement.
  • false: (Default) Disable low-light enhancement.
options
The low-light enhancement options. See LowlightEnhanceOptions.
type
The type of the video source. See MEDIA_SOURCE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetMixedAudioFrameParameters

Sets the audio data format reported by OnMixedAudioFrame.

public abstract int SetMixedAudioFrameParameters(int sampleRate, int channel, int samplesPerCall);

Parameters

sampleRate

The sample rate (Hz) of the audio data, which can be set as 8000, 16000, 32000, 44100, or 48000.

channel

The number of channels of the audio data, which can be set as 1(Mono) or 2(Stereo).

samplesPerCall

Sets the number of samples. In Media Push scenarios, set it as 1024.

Note:

The SDK triggers the OnMixedAudioFrame callback according to the sample interval. Sampleinterval (sec) = samplePerCall/(sampleRate × channel) Ensure that the value of sample interval more than or equal to 0.01.

Returns

  • 0: Success.
  • < 0: Failure.

SetParameters [1/2]

Provides technical preview functionalities or special customizations by configuring the SDK with JSON options.

public abstract int SetParameters(string key, object value);

Parameters

Pointer to the set parameters in a JSON string.
key
The key of the option.
value
The value of the key.

Returns

  • 0: Success.
  • < 0: Failure.

SetParameters [2/2]

Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options.

public abstract int SetParameters(string parameters);

Details

Contact technical support to get the JSON configuration method.

Parameters

parameters
Pointer to the set parameters in a JSON string.

Returns

  • 0: Success.
  • < 0: Failure.

SetPlaybackAudioFrameBeforeMixingParameters

Sets the audio data format reported by OnPlaybackAudioFrameBeforeMixing.

public abstract int SetPlaybackAudioFrameBeforeMixingParameters(int sampleRate, int channel);

Parameters

sampleRate

The sample rate (Hz) of the audio data, which can be set as 8000, 16000, 32000, 44100, or 48000.

channel

The number of channels of the audio data, which can be set as 1(Mono) or 2(Stereo).

Returns

  • 0: Success.
  • < 0: Failure.

SetPlaybackAudioFrameParameters

Sets the audio data format for playback.

public abstract int SetPlaybackAudioFrameParameters(int sampleRate, int channel,
            RAW_AUDIO_FRAME_OP_MODE_TYPE mode, int samplesPerCall);

Details

Sets the data format for the OnPlaybackAudioFrame callback.

Attention:
  • Ensure that you call this method before joining a channel.
  • The SDK calculates the sampling interval based on the samplesPerCall, sampleRate and channel parameters set in this method.Sample interval (sec) = samplePerCall/(sampleRate × channel). Ensure that the sample interval ≥ 0.01 (s). The SDK triggers the OnPlaybackAudioFrame callback according to the sampling interval.

Parameters

sampleRate
The sample rate returned in the OnPlaybackAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channel
The number of channels returned in the OnPlaybackAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
mode

The use mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.

samplesPerCall
The number of data samples returned in the OnPlaybackAudioFrame callback, such as 1024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

SetRecordingAudioFrameParameters

Sets the format of the captured raw audio data.

public abstract int SetRecordingAudioFrameParameters(int sampleRate, int channel, RAW_AUDIO_FRAME_OP_MODE_TYPE mode, int samplesPerCall);

Details

Sets the audio format for the OnRecordAudioFrame callback.

Attention:
  • Ensure that you call this method before joining a channel.
  • The SDK calculates the sampling interval based on the samplesPerCall, sampleRate and channel parameters set in this method.Sample interval (sec) = samplePerCall/(sampleRate × channel). Ensure that the sample interval ≥ 0.01 (s). The SDK triggers the OnRecordAudioFrame callback according to the sampling interval.

Parameters

sampleRate
The sample rate returned in the OnRecordAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channel
The number of channels returned in the OnRecordAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
mode

The use mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.

samplesPerCall
The number of data samples returned in the OnRecordAudioFrame callback, such as 1024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteDefaultVideoStreamType

Sets the default video stream type to subscribe to.

public abstract int SetRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE streamType);

Details

The SDK defaults to enabling low-quality video stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sending end, which means the sender does not actively send low-quality video stream. The receiver with the role of the host can initiate a low-quality video stream request by calling this method, and upon receiving the request, the sending end automatically starts sending the low-quality video stream.

The SDK will dynamically adjust the size of the corresponding video stream based on the size of the video window to save bandwidth and computing resources. The default aspect ratio of the low-quality video stream is the same as that of the high-quality video stream. According to the current aspect ratio of the high-quality video stream, the system will automatically allocate the resolution, frame rate, and bitrate of the low-quality video stream.

Attention:
  • Call this method before joining a channel. The SDK does not support changing the default subscribed video stream type after joining a channel.
  • If you call both this method and SetRemoteVideoStreamType, the setting of SetRemoteVideoStreamType takes effect.

Parameters

streamType

The default video-stream type. See VIDEO_STREAM_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteUserSpatialAudioParams

Sets the spatial audio effect parameters of the remote user.

public abstract int SetRemoteUserSpatialAudioParams(uint uid, SpatialAudioParams param);

Details

Call this method after EnableSpatialAudio. After successfully setting the spatial audio effect parameters of the remote user, the local user can hear the remote user with a sense of space.

Parameters

uid
The user ID. This parameter must be the same as the user ID passed in when the user joined the channel.
param
The spatial audio parameters. See SpatialAudioParams.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteVoicePosition

Sets the 2D position (the position on the horizontal plane) of the remote user's voice.

public abstract int SetRemoteVoicePosition(uint uid, double pan, double gain);

Details

This method sets the 2D position and volume of a remote user, so that the local user can easily hear and identify the remote user's position.

When the local user calls this method to set the voice position of a remote user, the voice difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a sense of space. This method applies to massive multiplayer online games, such as Battle Royale games.

Attention:
  • For this method to work, enable stereo panning for remote users by calling the EnableSoundPositionIndication method before joining a channel.
  • For the best voice positioning, Agora recommends using a wired headset.
  • Call this method after joining a channel.

Parameters

uid
The user ID of the remote user.
pan
The voice position of the remote user. The value ranges from -1.0 to 1.0:
  • 0.0: (Default) The remote voice comes from the front.
  • -1.0: The remote voice comes from the left.
  • 1.0: The remote voice comes from the right.
gain
The volume of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original volume of the remote user). The smaller the value, the lower the volume.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteRenderMode

Updates the display mode of the video view of a remote user.

public abstract int SetRemoteRenderMode(uint uid, RENDER_MODE_TYPE renderMode, VIDEO_MIRROR_MODE_TYPE mirrorMode);

Details

After initializing the video view of a remote user, you can call this method to update its rendering and mirror modes. This method affects only the video view that the local user sees.

Attention:
  • During a call, you can call this method as many times as necessary to update the display mode of the video view of a remote user.

Parameters

uid
The user ID of the remote user.
renderMode

The rendering mode of the remote user view. For details, see RENDER_MODE_TYPE.

mirrorMode

The mirror mode of the remote user view. See VIDEO_MIRROR_MODE_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteSubscribeFallbackOption

Sets the fallback option for the subscribed video stream based on the network conditions.

public abstract int SetRemoteSubscribeFallbackOption(STREAM_FALLBACK_OPTIONS option);

Details

An unstable network affects the audio and video quality in a video call or interactive live video streaming. If option is set as STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW or STREAM_FALLBACK_OPTION_AUDIO_ONLY, the SDK automatically switches the video from a high-quality stream to a low-quality stream or disables the video when the downlink network conditions cannot support both audio and video to guarantee the quality of the audio. Meanwhile, the SDK continuously monitors network quality and resumes subscribing to audio and video streams when the network quality improves.

When the subscribed video stream falls back to an audio-only stream, or recovers from an audio-only stream to an audio-video stream, the SDK triggers the OnRemoteSubscribeFallbackToAudioOnly callback.

Parameters

option
Fallback options for the subscribed stream. See STREAM_FALLBACK_OPTIONS.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteVideoStreamType

Sets the video stream type to subscribe to.

public abstract int SetRemoteVideoStreamType(uint uid, VIDEO_STREAM_TYPE streamType);

Details

The SDK defaults to enabling low-quality video stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sending end, which means the sender does not actively send low-quality video stream. The receiver with the role of the host can initiate a low-quality video stream request by calling this method, and upon receiving the request, the sending end automatically starts sending the low-quality video stream.

The SDK will dynamically adjust the size of the corresponding video stream based on the size of the video window to save bandwidth and computing resources. The default aspect ratio of the low-quality video stream is the same as that of the high-quality video stream. According to the current aspect ratio of the high-quality video stream, the system will automatically allocate the resolution, frame rate, and bitrate of the low-quality video stream.

Attention:
  • You can call this method either before or after joining a channel.
  • If the publisher has already called SetDualStreamMode [2/2] and set mode to DISABLE_SIMULCAST_STREAM (never send low-quality video stream), calling this method will not take effect, you should call SetDualStreamMode [2/2] again on the sending end and adjust the settings.
  • Calling this method on the receiving end of the audience role will not take effect.
  • If you call both SetRemoteVideoStreamType and SetRemoteDefaultVideoStreamType, the settings in SetRemoteVideoStreamType take effect.

Parameters

uid
The user ID.
streamType

The video stream type, see VIDEO_STREAM_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetRemoteVideoSubscriptionOptions

Options for subscribing to remote video streams.

 public abstract int SetRemoteVideoSubscriptionOptions(uint uid, VideoSubscriptionOptions options);

Details

When a remote user has enabled dual-stream mode, you can call this method to choose the option for subscribing to the video streams sent by the remote user.

  • If you only register one IVideoFrameObserver object, the SDK subscribes to the raw video data and encoded video data by default (the effect is equivalent to setting encodedFrameOnly to false).
  • If you only register one IVideoEncodedFrameObserver object, the SDK only subscribes to the encoded video data by default (the effect is equivalent to setting encodedFrameOnly to true).
  • If you register one IVideoFrameObserver object and one IVideoEncodedFrameObserver object successively, the SDK subscribes to the encoded video data by default (the effect is equivalent to setting encodedFrameOnly to false).
  • If you call this method first with the options parameter set, and then register one IVideoFrameObserver or IVideoEncodedFrameObserver object, you need to call this method again and set the options parameter as described in the above two items to get the desired results.
Note: Agora recommends the following steps:
  1. Set autoSubscribeVideo to false when calling JoinChannel [2/2] to join a channel.
  2. Call this method after receiving the OnUserJoined callback to set the subscription options for the specified remote user's video stream.
  3. Call the MuteRemoteVideoStream method to resume subscribing to the video stream of the specified remote user. If you set encodedFrameOnly to true in the previous step, the SDK triggers the OnEncodedVideoFrameReceived callback locally to report the received encoded video frame information.

Parameters

uid
The user ID of the remote user.
options
The video subscription options. See VideoSubscriptionOptions.

Returns

  • 0: Success.
  • < 0: Failure.

SetRouteInCommunicationMode

Selects the audio playback route in communication audio mode.

public abstract int SetRouteInCommunicationMode(int route);

Details

This method is used to switch the audio route from Bluetooth headphones to earpiece, wired headphones or speakers in communication audio mode (). After the method is called successfully, the SDK will trigger the OnAudioRoutingChanged callback to report the modified route.

Attention:

Parameters

route
The audio playback route you want to use:
  • -1: The default audio route.
  • 0: Headphones with microphone.
  • 1: Handset.
  • 2: Headphones without microphone.
  • 3: Device's built-in speaker.
  • 4: (Not supported yet) External speakers.
  • 5: Bluetooth headphones.
  • 6: USB device.

Returns

Without practical meaning.

SetScreenCaptureContentHint

Sets the content hint for screen sharing.

public abstract int SetScreenCaptureContentHint(VIDEO_CONTENT_HINT contentHint);

Details

A content hint suggests the type of the content being shared, so that the SDK applies different optimization algorithms to different types of content. If you don't call this method, the default content hint is CONTENT_HINT_NONE.

Attention: You can call this method either before or after you start screen sharing.

Parameters

contentHint
The content hint for screen sharing. See VIDEO_CONTENT_HINT.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • -8: The screen sharing state is invalid. Probably because you have shared other screens or windows. Try calling StopScreenCapture [1/2] to stop the current sharing and start sharing the screen again.

SetScreenCaptureScenario

Sets the screen sharing scenario.

public abstract int SetScreenCaptureScenario(SCREEN_SCENARIO_TYPE screenScenario);

Details

When you start screen sharing or window sharing, you can call this method to set the screen sharing scenario. The SDK adjusts the video quality and experience of the sharing according to the scenario.

Note: Agora recommends that you call this method before joining a channel.

Parameters

screenScenario
The screen sharing scenario. See SCREEN_SCENARIO_TYPE.

Returns

  • 0: Success.
  • < 0: Failure.

SetSubscribeAudioBlocklist

Set the blocklist of subscriptions for audio streams.

public abstract int SetSubscribeAudioBlocklist(uint[] uidList, int uidNumber);

Details

You can call this method to specify the audio streams of a user that you do not want to subscribe to.

Attention:
  • You can call this method either before or after joining a channel.
  • The blocklist is not affected by the setting in MuteRemoteAudioStream,MuteAllRemoteAudioStreams, and autoSubscribeAudio in ChannelMediaOptions.
  • Once the blocklist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
  • If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.

Parameters

uidList

The user ID list of users that you do not want to subscribe to.

If you want to specify the audio streams of a user that you do not want to subscribe to, add the user ID in this list. If you want to remove a user from the blocklist, you need to call the SetSubscribeAudioBlocklist method to update the user ID list; this means you only add the uid of users that you do not want to subscribe to in the new user ID list.

uidNumber
The number of users in the user ID list.

Returns

  • 0: Success.
  • < 0: Failure.

SetSubscribeAudioAllowlist

Sets the allowlist of subscriptions for audio streams.

public abstract int SetSubscribeAudioAllowlist(uint[] uidList, int uidNumber);

Details

You can call this method to specify the audio streams of a user that you want to subscribe to.

Note:
  • You can call this method either before or after joining a channel.
  • The allowlist is not affected by the setting in MuteRemoteAudioStream, MuteAllRemoteAudioStreams and autoSubscribeAudio in ChannelMediaOptions.
  • Once the allowlist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
  • If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.

Parameters

uidList

The user ID list of users that you want to subscribe to.

If you want to specify the audio streams of a user for subscription, add the user ID in this list. If you want to remove a user from the allowlist, you need to call the SetSubscribeAudioAllowlist method to update the user ID list; this means you only add the uid of users that you want to subscribe to in the new user ID list.

uidNumber
The number of users in the user ID list.

Returns

  • 0: Success.
  • < 0: Failure.

SetSubscribeVideoBlocklist

Set the blocklist of subscriptions for video streams.

public abstract int SetSubscribeVideoBlocklist(uint[] uidList, int uidNumber);

Details

You can call this method to specify the video streams of a user that you do not want to subscribe to.

Note:
  • You can call this method either before or after joining a channel.
  • The blocklist is not affected by the setting in MuteRemoteVideoStream, MuteAllRemoteVideoStreams and autoSubscribeAudio in ChannelMediaOptions.
  • Once the blocklist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
  • If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.

Parameters

uidList

The user ID list of users that you do not want to subscribe to.

If you want to specify the video streams of a user that you do not want to subscribe to, add the user ID of that user in this list. If you want to remove a user from the blocklist, you need to call the SetSubscribeVideoBlocklist method to update the user ID list; this means you only add the uid of users that you do not want to subscribe to in the new user ID list.

uidNumber
The number of users in the user ID list.

Returns

  • 0: Success.
  • < 0: Failure.

SetSubscribeVideoAllowlist

Set the allowlist of subscriptions for video streams.

public abstract int SetSubscribeVideoAllowlist(uint[] uidList, int uidNumber);

Details

You can call this method to specify the video streams of a user that you want to subscribe to.

Note:
  • You can call this method either before or after joining a channel.
  • The allowlist is not affected by the setting in MuteRemoteVideoStream, MuteAllRemoteVideoStreams and autoSubscribeAudio in ChannelMediaOptions.
  • Once the allowlist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
  • If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.

Parameters

uidList

The user ID list of users that you want to subscribe to.

If you want to specify the video streams of a user for subscription, add the user ID of that user in this list. If you want to remove a user from the allowlist, you need to call the SetSubscribeVideoAllowlist method to update the user ID list; this means you only add the uid of users that you want to subscribe to in the new user ID list.

uidNumber
The number of users in the user ID list.

Returns

  • 0: Success.
  • < 0: Failure.

SetupLocalVideo

Initializes the local video view.

public abstract int SetupLocalVideo(VideoCanvas canvas);

Details

This method initializes the video view of a local stream on the local device. It affects only the video view that the local user sees, not the published local video stream. Call this method to bind the local video stream to a video view (view) and to set the rendering and mirror modes of the video view.

After initialization, call this method to set the local video and then join the channel. The local video still binds to the view after you leave the channel. To unbind the local video from the view, set the view parameter as NULL.

In real-time interactive scenarios, if you need to simultaneously view multiple preview frames in the local video preview, and each frame is at a different observation position along the video link, you can repeatedly call this method to set different views and set different observation positions for each view. For example, by setting the video source to the camera and then configuring two views with position setting to POSITION_POST_CAPTURER_ORIGIN and POSITION_POST_CAPTURER, you can simultaneously preview the raw, unprocessed video frame and the video frame that has undergone preprocessing (image enhancement effects, virtual background, watermark) in the local video preview.

Attention:
  • If you need to implement native window rendering, use this method; if you only need to render video images in your Unity project, use the methods in the VideoSurface class instead.
  • You can call this method either before or after joining a channel.
  • To update the rendering or mirror mode of the local video view during a call, use the SetLocalRenderMode [2/2] method.

Parameters

canvas
The local video view and settings. See VideoCanvas.

Returns

  • 0: Success.
  • < 0: Failure.

SetupRemoteVideo

Initializes the video view of a remote user.

public abstract int SetupRemoteVideo(VideoCanvas canvas);