IRtcEngine

The base interface class of the RTC SDK that implements the core functions of real-time audio and video.

IRtcEngine provides the main methods for the App to call. You must call CreateAgoraRtcEngine to create an IRtcEngine object before calling other APIs.

InitEventHandler

Adds the main callback event.

public abstract int InitEventHandler(IRtcEngineEventHandler engineEventHandler);

The interface class IRtcEngineEventHandler is used by the SDK to send callback event notifications to the App. The App receives SDK event notifications by inheriting methods of this interface class. All methods of the interface class have default (empty) implementations. The App can choose to inherit only the events it cares about. In the callback methods, the App should not perform time-consuming operations or call APIs that may cause blocking (such as SendStreamMessage), as this may affect the operation of the SDK.

Parameters

engineEventHandler
The callback event to be added. See IRtcEngineEventHandler.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AddVideoWatermark [1/3]

Adds a local video watermark.

public abstract int AddVideoWatermark(RtcImage watermark);
Deprecated
Deprecated: This method is deprecated. Use AddVideoWatermark [3/3] instead.

This method adds a PNG image as a watermark to the local published live video stream. Users in the same live channel, CDN audience, and even capture devices can see or capture the watermark image. If you only want to add a watermark in CDN streaming, refer to the usage described in StartRtmpStreamWithTranscoding.

Note:
  • The definition of URL differs between local live streaming and CDN streaming. In local live streaming, the URL refers to the absolute/relative local path of the image on the local video; in CDN streaming, the URL refers to the address of the image on the CDN stream.
  • The source file format of the image to be added must be PNG. If the size of the PNG image differs from the size set in this method, the SDK will crop the PNG image to match the settings.
  • Only one watermark is supported in the live video stream. Adding a new watermark will replace the previous one.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AddVideoWatermark [2/3]

Adds a local video watermark.

public abstract int AddVideoWatermark(string watermarkUrl, WatermarkOptions options);
Deprecated
Deprecated: This method is deprecated. Use addVideoWatermark [3/3] instead.
This method adds a PNG image as a watermark to the local published live video stream. Users in the same live channel, CDN audience, and capture devices can see or capture the watermark image. Currently, only one watermark is supported in the live video stream. Adding a new watermark will replace the previous one. The watermark coordinates depend on the settings in SetVideoEncoderConfiguration:
  • If the video orientation (ORIENTATION_MODE) is fixed to landscape or adaptive landscape, landscape coordinates are used.
  • If the video orientation is fixed to portrait or adaptive portrait, portrait coordinates are used.
  • When setting watermark coordinates, the image area must not exceed the video dimensions set in SetVideoEncoderConfiguration, otherwise the excess will be cropped.
Note:
  • You must call this method after calling EnableVideo.
  • If you only want to add a watermark in CDN streaming, you can use this method or StartRtmpStreamWithTranscoding to set the watermark.
  • The watermark image must be in PNG format. This method supports all PNG pixel formats: RGBA, RGB, Palette, Gray, and Alpha_gray.
  • If the size of the PNG image differs from the size set in this method, the SDK will scale or crop the image to match the settings.
  • If local video is set to mirror mode, the local watermark will also be mirrored. To avoid mirrored watermark for local users, it is recommended not to use both mirror and watermark features together. Implement watermark at the application layer instead.

Parameters

watermarkUrl
The local path of the watermark image to be added. This method supports adding watermark images from absolute/relative local paths.
options
Settings for the watermark image. See WatermarkOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AddVideoWatermark [3/3]

Adds a watermark image to the local video stream.

public abstract int AddVideoWatermark(WatermarkConfig configs);
Since
Available since v4.6.2.

You can use this method to overlay a watermark image onto the local video stream, and configure its position, size, and visibility in the preview using WatermarkConfig.

Parameters

configs
Watermark configuration. See WatermarkConfig.

Return Values

  • 0: Success.
  • < 0: Failure.

AdjustAudioMixingPlayoutVolume

Adjusts the local playback volume of the music file.

public abstract int AdjustAudioMixingPlayoutVolume(int volume);

Timing

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

Parameters

volume
The volume of the music file. The range is [0,100], where 100 (default) is the original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustAudioMixingPublishVolume

Adjusts the remote playback volume of the music file.

public abstract int AdjustAudioMixingPublishVolume(int volume);

This method adjusts the playback volume of the mixed music file on the remote end.

Timing

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

Parameters

volume
The volume of the music file. The range is [0,100], where 100 (default) is the original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustAudioMixingVolume

Adjusts the playback volume of the music file.

public abstract int AdjustAudioMixingVolume(int volume);

This method adjusts the playback volume of the mixed music file on both the local and remote ends.

Note: Calling this method does not affect the playback volume of sound effects set by the PlayEffect method.

Timing

You need to call this method after StartAudioMixing [2/2].

Parameters

volume
The volume of the music file. The range is [0,100]. 100 (default) represents the original volume of the file.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustCustomAudioPlayoutVolume

Adjusts the playback volume of a custom audio capture track locally.

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

After calling this method to set the local playback volume of the audio, if you want to readjust the volume, you can call this method again.

Note: Before calling this method, make sure you have already called CreateCustomAudioTrack to create a custom audio capture track.

Parameters

trackId
Audio track ID. Set this parameter to the custom audio track ID returned by the CreateCustomAudioTrack method.
volume
Playback volume of the custom captured audio, ranging from [0,100]. 0 means mute, 100 means original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustCustomAudioPublishVolume

Adjusts the playback volume of the custom audio capture track on the remote end.

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

After calling this method to set the playback volume of the audio on the remote end, you can call it again to readjust the volume.

Note: Before calling this method, make sure you have already called the CreateCustomAudioTrack method to create a custom audio capture track.

Parameters

trackId
The audio track ID. Set this parameter to the custom audio track ID returned by the CreateCustomAudioTrack method.
volume
The playback volume of the custom captured audio, ranging from [0,100]. 0 means mute, and 100 means the original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustLoopbackSignalVolume

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

public abstract int AdjustLoopbackSignalVolume(int volume);

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

Parameters

volume
Volume range of the music file is 0~100. 100 (default) represents the original file volume.

Return Values

  • 0: The method call succeeds
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

AdjustPlaybackSignalVolume

Adjusts the playback volume of all remote users locally.

public abstract int AdjustPlaybackSignalVolume(int volume);

This method adjusts the signal volume of all remote users after mixing, as played locally. If you want to adjust the volume of a specific remote user locally, you are advised to call AdjustUserPlaybackSignalVolume.

Timing

Can be called before or after joining a channel.

Parameters

volume
Volume, range is [0,400].
  • 0: Mute.
  • 100: (Default) Original volume.
  • 400: 4 times the original volume, with built-in overflow protection.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustRecordingSignalVolume

Adjusts the volume of the recorded audio signal.

public abstract int AdjustRecordingSignalVolume(int volume);

If you only need to mute the audio signal, it is recommended to use MuteRecordingSignal.

Timing

Can be called before or after joining a channel.

Parameters

volume
Volume, range is [0,400].
  • 0: Mute.
  • 100: (Default) Original volume.
  • 400: Four times the original volume, with built-in overflow protection.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

AdjustUserPlaybackSignalVolume

Adjusts the playback volume of a specified remote user locally.

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

You can call this method during a call to adjust the playback volume of a specified remote user locally. To adjust the volume for multiple users, call this method multiple times.

Timing

Call this method after joining a channel.

Parameters

uid
Remote user ID.
volume
Volume, ranging from [0,400].
  • 0: Mute.
  • 100: (Default) Original volume.
  • 400: Four times the original volume, with built-in overflow protection.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

ClearVideoWatermarks

Removes added video watermarks.

public abstract int ClearVideoWatermarks();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

Complain

Report call quality issues.

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

This method allows users to report issues with call quality. It must be called after leaving the channel.

Parameters

callId
Call ID. You can obtain this parameter by calling GetCallId.
description
(Optional) Description of the call. The length should be less than 800 bytes.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically classified).
    • -2: Invalid parameter.
    • -7: IRtcEngine is not initialized before calling the method.

ConfigRhythmPlayer

Configures the virtual metronome.

public abstract int ConfigRhythmPlayer(AgoraRhythmPlayerConfig config);
Deprecated
Deprecated since v4.6.2.
  • After calling StartRhythmPlayer, you can call this method to reconfigure the virtual metronome.
  • Once the virtual metronome is enabled, the SDK starts playing the specified audio files from the beginning and controls the duration of each file based on the beatsPerMinute setting in AgoraRhythmPlayerConfig. For example, if beatsPerMinute is set to 60, the SDK plays 1 beat per second. If the file duration exceeds the beat duration, the SDK only plays the portion of the audio corresponding to the beat duration.
  • By default, the virtual metronome sound is not published to the remote. If you want remote users to hear the metronome, set publishRhythmPlayerTrack in ChannelMediaOptions to true after calling this method.

Timing

Can be called before or after joining a channel.

Parameters

config
Metronome configuration. See AgoraRhythmPlayerConfig.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

CreateAgoraRtcEngine

Creates an IRtcEngine object.

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

Currently, RTC SDK v4.x supports creating only one IRtcEngine object per App.

Return Values

IRtcEngine object.

CreateCustomVideoTrack

Creates a custom video track.

public abstract video_track_id_t CreateCustomVideoTrack();
When you need to publish a custom captured video in the channel, refer to the following steps:
  1. Call this method to create a video track and get the video track ID.
  2. When calling JoinChannel [2/2] to join the channel, set customVideoTrackId in ChannelMediaOptions to the video track ID you want to publish, and set publishCustomVideoTrack to true.
  3. Call PushVideoFrame and specify videoTrackId as the video track ID set in step 2 to publish the corresponding custom video source in the channel.

Return Values

  • The video track ID, if the method call succeeds.
  • 0xffffffff, if the method call fails. See Error Codes for details and resolution suggestions.

CreateDataStream [1/2]

Creates a data stream.

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

You can call this method to create a data stream and improve the reliability and ordering of data transmission.

Note: If you need a more comprehensive low-latency, high-concurrency, and scalable real-time messaging and state synchronization solution, we recommend using Real-time Messaging. During the lifecycle of IRtcEngine, each user can create up to 5 data streams. Data streams are destroyed when leaving the channel and must be recreated if needed.

Timing

This method can be called before or after joining the channel.

Parameters

streamId
An output parameter. ID of the created data stream.
reliable
Note: Make sure to set both reliable and ordered to true or both to false.
Whether to ensure data reliability, i.e., whether the receiver must receive the data within 5 seconds after it is sent:
  • true: The receiver will receive the data within 5 seconds, otherwise the OnStreamMessageError callback is triggered with the corresponding error information.
  • false: The receiver is not guaranteed to receive the data, and no error is reported even if the data is lost.
ordered
Whether to ensure data ordering, i.e., whether the receiver must receive data in the order sent:
  • true: The receiver receives data packets in the order sent by the sender.
  • false: The receiver is not guaranteed to receive data packets in the order sent by the sender.

Return Values

  • 0: Data stream created successfully.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

CreateDataStream [2/2]

Creates a data stream.

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

Compared with CreateDataStream [1/2], this method does not guarantee the reliability of data transmission. The receiver discards packets that are received more than 5 seconds after being sent.

Note: If you need a more comprehensive low-latency, high-concurrency, and scalable real-time messaging and state synchronization solution, we recommend using Real-time Messaging. During the lifecycle of IRtcEngine, each user can create up to 5 data streams. The data streams are destroyed when leaving the channel. To use them again, you need to recreate the data streams.

Timing

This method can be called before or after joining a channel.

Parameters

streamId
Output parameter. The ID of the created data stream.
config
Data stream configuration. See DataStreamConfig.

Return Values

  • 0: Data stream created successfully.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

CreateMediaPlayer

Creates a media player object.

public abstract IMediaPlayer CreateMediaPlayer();

Before calling other APIs under the IMediaPlayer class, you must first call this method to create a media player instance. If you need multiple instances, you can call this method multiple times.

Timing

This method can be called before or after joining a channel.

Parameters

delegate
Event handler for IRtcEngine. See IRtcEngineEventHandler.

Return Values

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

CreateVideoEffectObject

Creates an IVideoEffectObject video effect object.

public abstract IVideoEffectObject CreateVideoEffectObject(string bundlePath, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);
Since
Available since v4.6.2.

Parameters

bundlePath
The path to the video effect resource bundle.
type
The media source type. See MEDIA_SOURCE_TYPE.

Return Values

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 the CreateCustomVideoTrack method.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

DestroyMediaPlayer

Destroys the media player.

public abstract int DestroyMediaPlayer(IMediaPlayer mediaPlayer);

Parameters

mediaPlayer
IMediaPlayer object.

Return Values

  • ≥ 0: Success, returns the media player ID
  • < 0: Failure. See Error Codes for details and resolution suggestions.

DestroyVideoEffectObject

Destroys a video effect object.

public abstract int DestroyVideoEffectObject(IVideoEffectObject videoEffectObject);
Since
Available since v4.6.2.

Parameters

videoEffectObject
The video effect object to destroy. See IVideoEffectObject.

Return Values

  • 0: Success.
  • < 0: Failure.

DisableAudio

Disables the audio module.

public abstract int DisableAudio();

The audio module is enabled by default. You can call this method to disable it.

Note: This method resets the entire engine and has a slower response time. Therefore, Agora recommends using the following methods to control the audio module:

Timing

Can be called before or after joining a channel. Still effective after leaving the channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

DisableAudioSpectrumMonitor

Disables audio spectrum monitoring.

public abstract int DisableAudioSpectrumMonitor();

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

Note: This method can be called either before or after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

DisableVideo

Disables the video module.

public abstract int DisableVideo();

This method disables the video module.

Note:
  • This method sets the internal engine to a disabled state and remains effective after leaving the channel.
  • Calling this method resets the entire engine, which may result in a slower response. You can use the following methods to independently control specific video module features as needed:

Timing

Can be called before or after joining a channel:
  • If called before joining a channel, audio-only mode is enabled.
  • If called after joining a channel, it switches from video mode to audio-only mode. You can then call the EnableVideo method to enable video mode.

Return Values

  • 0: Method call succeeded.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

EnableAudio

Enables the audio module.

public abstract int EnableAudio();

The audio module is enabled by default. If you have disabled it using DisableAudio, you can call this method to re-enable it.

Note:

Timing

Can be called before or after joining a channel. Still effective after leaving the channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableAudioSpectrumMonitor

Enables audio spectrum monitoring.

public abstract int EnableAudioSpectrumMonitor(int intervalInMS = 100);

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

Note: This method can be called either before or after joining a channel.

Parameters

intervalInMS
The interval (in milliseconds) at which the SDK triggers the OnLocalAudioSpectrum and OnRemoteAudioSpectrum callbacks. Default is 100 ms. The value must not be less than 10 ms, otherwise the method call will fail.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter settings.

EnableAudioVolumeIndication

Enables audio volume indication.

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

This method allows the SDK to periodically report volume information of the local user and up to three remote users with the highest instantaneous volume to the app.

Timing

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

Parameters

interval
Sets the time interval of the volume indication:
  • ≤ 0: Disables the volume indication.
  • > 0: The interval (ms) at which the volume indication is returned. We recommend setting it to greater than 100 ms. The minimum value is 10 ms. If the value is less than 10 ms, you may not receive the OnAudioVolumeIndication callback.
smooth
The smoothing factor that sets the sensitivity of the volume indication. The value range is [0,10], and the recommended value is 3. The greater the value, the more sensitive the indication; the smaller the value, the smoother the indication.
reportVad
  • true: Enables the local voice activity detection (VAD). After it is enabled, the vad parameter in the OnAudioVolumeIndication callback reports whether voice is detected locally.
  • false: (Default) Disables the local VAD. Except for scenarios where the engine automatically performs local VAD, the vad parameter in the OnAudioVolumeIndication callback does not report whether voice is detected locally.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

EnableCameraCenterStage

Enables or disables the Center Stage feature.

public abstract int EnableCameraCenterStage(bool enabled);

The Center Stage feature is disabled by default. You need to call this method to enable it. To disable the feature, call this method again and set enabled to false.

Note: This method is only applicable to iOS and macOS. Due to high performance requirements, use this feature on the following or higher performance devices:
  • 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 (use iPhone as external camera for MacBook)
Agora recommends calling IsCameraCenterStageSupported before enabling this feature to check if the current device supports Center Stage.

Scenario

The Center Stage feature can be widely used in scenarios such as online meetings, live shows, and online education. Hosts can enable this feature to keep themselves centered in the frame whether they move or not, ensuring a better visual presentation.

Timing

This method must be called after the camera is successfully started, i.e., 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 the Center Stage feature:
  • true: Enable Center Stage.
  • false: Disable Center Stage.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.

EnableContentInspect

Enables/disables local snapshot upload.

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

After enabling local snapshot upload, the SDK captures and uploads snapshots of the local user's video based on the module type and frequency you set in ContentInspectConfig. Once the snapshots are captured, Agora's server sends a callback notification to your server via an HTTPS request and uploads all snapshots to your designated third-party cloud storage.

Note:
  • Before calling this method, ensure that the local snapshot upload service has been enabled in the Agora Console.
  • When using Agora's proprietary plugin for content inspection (CONTENT_INSPECT_SUPERVISION), you must integrate the local snapshot upload dynamic library libagora_content_inspect_extension.dll. Deleting this library will cause the local snapshot upload feature to fail.

Timing

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

Parameters

enabled
Sets whether to enable local snapshot upload:
  • true: Enable local snapshot upload.
  • false: Disable local snapshot upload.
config
Local snapshot upload configuration. See ContentInspectConfig.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableCustomAudioLocalPlayback

Sets whether to play the external audio source locally.

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

After calling this method to enable local playback of the externally captured audio source, you can call it again and set enabled to false to stop local playback. You can call AdjustCustomAudioPlayoutVolume to adjust the playback volume of the custom audio capture track locally.

Note: Before calling this method, make sure you have already called the CreateCustomAudioTrack method to create a custom audio capture track.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableDualStreamMode [1/2]

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

public abstract int EnableDualStreamMode(bool enabled);
Deprecated
Deprecated: Deprecated since v4.2.0. Use SetDualStreamMode [1/2] instead.
Dual-stream refers to high-quality (high resolution, high frame rate) and low-quality (low resolution, low frame rate) video streams:
  • High-quality stream: High resolution and high frame rate video stream.
  • Low-quality stream: Low resolution and low frame rate video stream.
After enabling dual-stream mode, you can call SetRemoteVideoStreamType on the receiving side to choose whether to receive the high-quality or low-quality video stream.
Note:
  • This method applies to all types of streams sent by the sender, including but not limited to camera-captured video, screen sharing, and custom captured video streams.
  • To enable dual-stream in multi-channel scenarios, call EnableDualStreamModeEx.
  • This method can be called 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.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableDualStreamMode [2/2]

Enables or disables dual-stream mode on the sender and sets the low-quality video stream.

public abstract int EnableDualStreamMode(bool enabled, SimulcastStreamConfig streamConfig);
Deprecated
Deprecated: Deprecated since v4.2.0. Use SetDualStreamMode [2/2] instead.
You can call this method on the sender to enable or disable dual-stream mode. Dual-stream refers to high-quality and low-quality video streams:
  • High-quality stream: High resolution and high frame rate video stream.
  • Low-quality stream: Low resolution and low frame rate video stream.
After enabling dual-stream mode, you can call SetRemoteVideoStreamType on the receiver to choose to receive the high-quality or low-quality video stream.
Note:
  • This method applies to all types of streams sent by the sender, including but not limited to camera-captured video streams, screen sharing streams, and custom captured video streams.
  • To enable video dual-stream in multi-channel scenarios, call the EnableDualStreamModeEx method.
  • This method can be called 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
Configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: When mode is set to DISABLE_SIMULCAST_STREAM, setting streamConfig has no effect.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

EnableEncryption

Enables or disables built-in encryption.

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

After a user leaves the channel, the SDK automatically disables encryption. To re-enable encryption, you need to call this method before the user rejoins the channel.

Note:
  • All users in the same channel must use the same encryption mode and key when calling this method.
  • When built-in encryption is enabled, the RTMP streaming feature cannot be used.

Scenario

Scenarios with high security requirements.

Timing

This method must be called before joining the channel.

Parameters

enabled
Whether to enable built-in encryption:
  • true: Enable built-in encryption.
  • false: (default) Disable built-in encryption.
config
Configure the built-in encryption mode and key. See EncryptionConfig.

Return Values

  • 0: Success.
  • < 0: Failure
    • -2: Invalid parameter. You need to specify the parameter again.
    • -4: Incorrect encryption mode or failed to load external encryption library. Check the enum value or reload the external encryption library.
    • -7: SDK is not initialized. You need to create the IRtcEngine object and complete initialization before calling the API.

EnableExtension

Enables/disables an extension.

public abstract int EnableExtension(string provider, string extension, bool enable = true, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE);
Note:
  • To enable multiple extensions, call this method multiple times.
  • After this method is successfully called, no other extensions can be loaded.

Timing

It is recommended to call this method after joining a channel.

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
The media source type of the extension. See MEDIA_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -3: The extension dynamic library was not loaded. Agora recommends checking whether the library is placed in the expected location or whether the library name is correct.

EnableFaceDetection

Enables/disables local face detection.

public abstract int EnableFaceDetection(bool enabled);

Timing

This method must be called after the camera starts (e.g., by calling StartPreview [2/2] or EnableVideo).

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableInEarMonitoring

Enables in-ear monitoring.

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

This method enables or disables in-ear monitoring.

Note: Users must use headphones (wired or Bluetooth) to hear the in-ear monitoring effect.

Timing

Can be called before or after joining a channel.

Parameters

enabled
Enable/disable in-ear monitoring:
  • true: Enable in-ear monitoring.
  • false: (Default) Disable in-ear monitoring.
includeAudioFilters
The type of audio filter for in-ear monitoring. See EAR_MONITORING_FILTER_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -8: Please ensure the current audio route is Bluetooth or headset.

EnableInstantMediaRendering

Enables accelerated audio and video frame rendering.

public abstract int EnableInstantMediaRendering();

After successfully calling this method, the SDK enables accelerated rendering for both video and audio, which speeds up the first frame rendering and audio output after a user joins the channel.

Note: Both broadcaster and audience need to call this method to enable accelerated audio and video frame rendering to experience the feature. Once this method is successfully called, the only way to disable accelerated rendering is to destroy the IRtcEngine object by calling Dispose.

Scenario

Agora recommends enabling this mode for audience users in live streaming scenarios.

Timing

This method must be called before joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -7: IRtcEngine is not initialized when calling the method.

EnableLocalAudio

Enables or disables local audio capture.

public abstract int EnableLocalAudio(bool enabled);
When a user joins a channel, audio is enabled by default. This method can disable or re-enable local audio, i.e., stop or restart local audio capture. The difference between this method and MuteLocalAudioStream is:
  • EnableLocalAudio: Enables or disables local audio capture and processing. When you disable or enable local capture using EnableLocalAudio, local playback of remote audio will briefly interrupt.
  • MuteLocalAudioStream: Stops or resumes sending the local audio stream without affecting the capture status.

Scenario

This method does not affect receiving and playing remote audio streams. enableLocalAudio(false) is suitable for scenarios where you only want to receive remote audio without sending locally captured audio.

Timing

Can be called before or after joining a channel. If called before joining, it only sets the device state; it takes effect immediately after joining the channel.

Parameters

enabled
  • true: Re-enable local audio, i.e., start local audio capture (default);
  • false: Disable local audio, i.e., stop local audio capture.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableLocalVideo

Enables or disables local video capture.

public abstract int EnableLocalVideo(bool enabled);

This method disables or re-enables local video capture without affecting the reception of remote video. After calling EnableVideo, local video capture is enabled by default. If you call EnableLocalVideo(false) in the channel to disable local video capture, it also stops publishing the video stream in the channel. To re-enable it, call EnableLocalVideo(true), then call UpdateChannelMediaOptions and set the options parameter to publish the locally captured video stream to the channel. After successfully enabling or disabling local video capture, the remote side triggers the OnRemoteVideoStateChanged callback.

Note:
  • This method can be called before or after joining a channel, but settings made before joining only take effect after joining.
  • This method sets the internal engine to an enabled state and remains effective after leaving the channel.

Parameters

enabled
Whether to enable local video capture.
  • true: (default) Enable local video capture.
  • false: Disable local video capture. After disabling, the remote user will not receive the local user's video stream; however, the local user can still receive the remote user's video stream. When set to false, this method does not require the local device to have a camera.

Return Values

  • 0: Method call succeeded.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

EnableLoopbackRecording

Enables loopback recording.

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

After enabling loopback recording, the sound played by the sound card will be mixed into the local audio stream and can be sent to the remote end.

Note:
  • This method is only applicable to macOS and Windows platforms.
  • It can be called before or after joining a channel.
  • If you call DisableAudio to disable the audio module, loopback recording will also be disabled. To re-enable loopback recording, you must call EnableAudio to enable the audio module, then call EnableLoopbackRecording again.

Parameters

enabled
Whether to enable loopback recording:
  • true: Enable loopback recording; the system sound > output interface displays the virtual sound card name.
  • false: (Default) Disable loopback recording; the system sound > output interface does not display the virtual sound card name.
deviceName
  • macOS: The device name of the virtual sound card. Default is empty, which means using the AgoraALD virtual sound card for recording.
  • Windows: The device name of the sound card. Default is empty, which means using the built-in sound card of the device for recording.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableMultiCamera

Enables or disables multi-camera capture.

public abstract int EnableMultiCamera(bool enabled, CameraCapturerConfiguration config);
In scenarios where one camera is already capturing video, Agora recommends the following steps to enable multi-camera capture and publish video:
  1. Call this method to enable multi-camera capture.
  2. Call StartPreview [2/2] to start local video preview.
  3. Call StartCameraCapture and set sourceType to specify the second camera for capture.
  4. Call JoinChannelEx and set publishSecondaryCameraTrack to true to publish the second camera’s video stream in the channel.
To disable multi-camera capture:
  1. Call StopCameraCapture.
  2. Call this method and set enabled to false.
This method is for iOS only.When using multi-camera video capture, ensure the system version is 13.0 or later.The minimum supported iOS devices for multi-camera capture are:
  • iPhone XR
  • iPhone XS
  • iPhone XS Max
  • iPad Pro (3rd generation and above)
Note: You can call this method before or after StartPreview [2/2] to enable multi-camera capture:
  • If called before StartPreview [2/2], the local video preview shows feeds from both cameras simultaneously.
  • If called after StartPreview [2/2], the SDK stops the current camera capture, then starts both the original and second camera. The preview may briefly go black before recovering automatically.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableSoundPositionIndication

Enables/disables stereo sound for remote users.

public abstract int EnableSoundPositionIndication(bool enabled);

To use SetRemoteVoicePosition to implement spatial audio positioning, make sure to call this method before joining the channel to enable stereo sound for remote users.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableSpatialAudio

Enables or disables spatial audio.

public abstract int EnableSpatialAudio(bool enabled);

After enabling spatial audio, you can call SetRemoteUserSpatialAudioParams to set spatial audio parameters for remote users.

Note:
  • This method can be called before or after joining a channel.
  • This method depends on the spatial audio dynamic library libagora_spatial_audio_extension.dll. Removing this library will prevent the feature from working properly.

Parameters

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

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.

EnableVideo

Enables the video module.

public abstract int EnableVideo();

The video module is disabled by default and must be enabled by calling this method. To disable the video module later, call the DisableVideo method.

Note:
  • This method sets the internal engine to an enabled state and remains effective after leaving the channel.
  • Calling this method resets the entire engine, which may result in a slower response. You can use the following methods to independently control specific video module features as needed:
  • When this method is called in a channel, it resets the settings of EnableLocalVideo, MuteRemoteVideoStream, and MuteAllRemoteVideoStreams, so use with caution.

Timing

This method can be called before or after joining a channel:
  • If called before joining a channel, the video module is enabled.
  • If called during an audio-only call, the call automatically switches to a video call.

Return Values

  • 0: Method call succeeded.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

EnableVideoImageSource

Enables or disables placeholder image streaming.

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

When publishing a video stream, you can call this method to use a custom image to replace the current video stream for streaming. After enabling this feature, you can customize the placeholder image using the ImageTrackOptions parameter. When you disable the placeholder feature, remote users will continue to see your current video stream.

Timing

It is recommended to call this method after joining the channel.

Parameters

enable
Whether to enable placeholder image streaming:
  • true: Enable placeholder streaming.
  • false: (default) Disable placeholder streaming.
options
Placeholder image settings. See ImageTrackOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableVirtualBackground

Enables/disables virtual background.

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

The virtual background feature allows replacing the original background of the local user with a static image, dynamic video, blurred background, or segmenting the portrait from the background to achieve picture-in-picture. Once enabled successfully, all users in the channel can see the customized background. Call this method after EnableVideo or StartPreview [2/2].

Note:
  • Using video as a virtual background may lead to continuous memory increase and could cause app crashes. Therefore, reduce the resolution and frame rate of the video whenever possible.
  • This feature requires high device performance. When you call this method, the SDK automatically checks the device capability. It is recommended to use devices with the following chipsets:
    • Snapdragon 700 series 750G or above
    • Snapdragon 800 series 835 or above
    • MediaTek Dimensity 700 series 720 or above
    • Kirin 800 series 810 or above
    • Kirin 900 series 980 or above
    • Devices with i5 CPU or better
    • Devices with A9 chip or later, including:
      • iPhone 6S or later
      • iPad Air 3rd generation or later
      • iPad 5th generation or later
      • iPad Pro 1st generation or later
      • iPad mini 5th generation or later
  • It is recommended to use this feature under the following conditions:
    • Use a high-definition camera and ensure uniform lighting.
    • The scene contains few objects, the portrait is half-body and mostly unobstructed, the background color is simple and differs from the user’s clothing.
  • This method depends on the virtual background dynamic library libagora_segmentation_extension.dll. If this library is deleted, the feature cannot be enabled properly.

Parameters

enabled
Whether to enable virtual background:
  • true: Enable virtual background.
  • false: Disable virtual background.
backgroundSource
Customized background. See VirtualBackgroundSource. To adapt the resolution of the custom background image to the SDK's video capture resolution, the SDK scales and crops the image while maintaining its aspect ratio.
segproperty
Processing properties for the background image. See SegmentationProperty.
type
Media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -4: The device does not meet the performance requirements for virtual background. Consider using a higher-performance device.

EnableVoiceAITuner

Enables or disables the AI tuner feature.

public abstract int EnableVoiceAITuner(bool enabled, VOICE_AI_TUNER_TYPE type);

The AI tuner feature enhances voice quality and adjusts voice tone style.

Scenario

Social and entertainment scenarios with high audio quality requirements, such as online karaoke, online podcasts, and live shows.

Timing

Can be called before or after joining a channel.

Parameters

enabled
Whether to enable the AI tuner feature:
  • true: Enable the AI tuner feature.
  • false: (Default) Disable the AI tuner feature.
type
AI tuner effect type. See VOICE_AI_TUNER_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

EnableWebSdkInteroperability

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

public abstract int EnableWebSdkInteroperability(bool enabled);
Deprecated
Deprecated: This method is deprecated. The SDK automatically enables interoperability with the Web SDK, so you do not need to call this method.

This method enables or disables interoperability with the Web SDK. If a user joins the channel using the Web SDK, make sure to call this method; otherwise, the Web user will see a black screen for the Native user's video. This method is only applicable in live broadcast scenarios. In communication scenarios, interoperability is enabled by default.

Parameters

enabled
Whether to enable interoperability with the Web SDK:
  • true: Enable interoperability.
  • false: (Default) Disable interoperability.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioDeviceInfo

Gets audio device information.

public abstract int GetAudioDeviceInfo(ref DeviceInfoMobile deviceInfo);

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

Note:
  • This method is for Android only.
  • This method can be called both before and after joining a channel.

Parameters

deviceInfo
Audio device information. See DeviceInfoMobile.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioMixingCurrentPosition

Gets the playback progress of the music file.

public abstract int GetAudioMixingCurrentPosition();

This method gets the current playback progress of the music file, in milliseconds.

Note:
  • 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, make sure the interval between calls is greater than 500 ms.

Return Values

  • ≥ 0: Success. Returns the current playback progress of the music file (ms). 0 indicates the music file has not started playing.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioMixingDuration

Gets the total duration of the music file.

public abstract int GetAudioMixingDuration();

This method gets the total duration of the music file, in milliseconds.

Timing

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

Return Values

  • ≥ 0: Success. Returns the duration of the music file.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioMixingPlayoutVolume

Gets the local playback volume of the music file.

public abstract int GetAudioMixingPlayoutVolume();

You can call this method to get the local playback volume of the mixed music file, which helps troubleshoot volume-related issues.

Timing

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

Return Values

  • ≥ 0: Success. Returns the volume value, range is [0,100].
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioMixingPublishVolume

Gets the remote playback volume of the music file.

public abstract int GetAudioMixingPublishVolume();

This API helps developers troubleshoot volume-related issues.

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

Return Values

  • ≥ 0: Success. Returns the volume value, range is [0,100].
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetAudioTrackCount

Gets the audio track index of the current music file.

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

Return Values

  • On success, returns the audio track index of the current music file.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetCallId

Gets the call ID.

public abstract int GetCallId(ref string callId);

Each time the client joins a channel, it generates a corresponding callId to identify the current call. You can call this method to get the callId parameter, and then pass it in when calling methods such as Rate and Complain.

Timing

You need to call this method after joining a channel.

Parameters

callId
An output parameter. The current call ID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetCameraMaxZoomFactor

Gets the maximum zoom factor supported by the camera.

public abstract float GetCameraMaxZoomFactor();
Note:
  • This method is for Android and iOS only.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state is LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

The maximum zoom factor supported by the device camera.

GetConnectionState

Gets the current network connection state.

public abstract CONNECTION_STATE_TYPE GetConnectionState();

Timing

Can be called before or after joining a channel.

Return Values

The current network connection state. See CONNECTION_STATE_TYPE.

GetCurrentMonotonicTimeInMs

Gets the current Monotonic Time of the SDK.

public abstract long GetCurrentMonotonicTimeInMs();

Monotonic Time refers to a monotonically increasing time sequence whose value increases over time. The unit is milliseconds. In scenarios such as custom video or audio capture, to ensure audio-video synchronization, Agora recommends that you call this method to get the current Monotonic Time of the SDK, and then pass this value into the timestamp parameter of the captured VideoFrame or AudioFrame.

Timing

Can be called before or after joining a channel.

Return Values

  • ≥ 0: Success. Returns the current Monotonic Time (in milliseconds) of the SDK.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetEffectCurrentPosition

Gets the playback progress of the specified sound effect file.

public abstract int GetEffectCurrentPosition(int soundId);
Note: You must call this method after PlayEffect.

Parameters

soundId
The ID of the sound effect. Each sound effect has a unique ID.

Return Values

  • If the method call succeeds, returns the playback progress (in milliseconds) of the specified sound effect file.
  • < 0: Failure. See Error Codes for details and troubleshooting.

GetEffectDuration

Gets the total duration of the specified sound effect file.

public abstract int GetEffectDuration(string filePath);
Note: You must call this method after joining a channel.

Parameters

filePath
File path:
  • Android: File path, including the file name and extension. Supports URL of online files, URI of local files, absolute path, or path starting with /assets/. Accessing local files via absolute path may cause permission issues. It is recommended to use URI to access local files. For example: content://com.android.providers.media.documents/document/audio%3A14441.
  • Windows: Absolute path or URL of the audio file, including the file name and extension. For example: C:\music\audio.mp4.
  • iOS or macOS: Absolute path or URL of the audio file, including the file name and extension. For example: /var/mobile/Containers/Data/audio.mp4.

Return Values

  • If the method call succeeds, returns the duration (in milliseconds) of the specified sound effect file.
  • < 0: Failure. See Error Codes for details and troubleshooting.

GetEffectsVolume

Gets the playback volume of audio effects.

public abstract int GetEffectsVolume();

The volume range is 0~100. 100 (default) represents the original file volume.

Note: You need to call this method after PlayEffect.

Return Values

  • The volume of the audio effect.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

GetErrorDescription

Gets the warning or error description.

public abstract string GetErrorDescription(int code);

Parameters

code
The error code reported by the SDK.

Return Values

The specific error description.

GetExtensionProperty

Gets detailed information of the extension.

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);

Timing

Can be called before or after joining a channel.

Parameters

provider
Output parameter. The name of the extension provider.
extension
Output parameter. The name of the extension.
key
Output parameter. The key of the extension property.
value
Output parameter. The value corresponding to the extension property key.
type
The media source type of the extension. See MEDIA_SOURCE_TYPE.
buf_len
The maximum length of the extension property JSON string. Maximum value: 512 bytes.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetFaceShapeAreaOptions

Gets the face shaping area options.

public abstract int GetFaceShapeAreaOptions(FACE_SHAPE_AREA shapeArea, ref FaceShapeAreaOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Call this method to get the current parameter settings for the face shaping area.

Scenario

When users open the facial area and intensity adjustment menu in the app, you can call this method to get the current options and update the UI accordingly.

Timing

Call this method after EnableVideo.

Parameters

shapeArea
Face shaping area. See FACE_SHAPE_AREA.
options
Face shaping area options. See FaceShapeAreaOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetFaceShapeBeautyOptions

Gets the face shaping effect options.

public abstract int GetFaceShapeBeautyOptions(ref FaceShapeBeautyOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Call this method to get the current parameter settings for face shaping effects.

Scenario

When users open the facial beauty style and intensity menu in the app, you can call this method to get the current options and update the UI accordingly.

Timing

Call this method after EnableVideo.

Parameters

options
Face shaping style options. See FaceShapeBeautyOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetNativeHandler

Gets the C++ handle of the Native SDK.

public abstract int GetNativeHandler(ref IntPtr nativeHandler);

This method gets the C++ handle of the Native SDK engine, used in special scenarios including registering audio and video callbacks.

Parameters

nativeHandler
An output parameter. The native handle of the SDK engine.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetNetworkType

Gets the local network connection type.

public abstract int GetNetworkType();

You can call this method at any time to get the current network type in use.

Note: This method can be called before or after joining a channel.

Return Values

  • ≥ 0: Success. Returns the local network connection type.
    • 0: Network disconnected.
    • 1: Network type is LAN.
    • 2: Network type is Wi-Fi (including hotspot).
    • 3: Network type is 2G mobile network.
    • 4: Network type is 3G mobile network.
    • 5: Network type is 4G mobile network.
    • 6: Network type is 5G mobile network.
  • < 0: Failure. Returns an error code.
    • -1: Unknown network connection type.

GetNtpWallTimeInMs

Gets the current NTP (Network Time Protocol) time.

public abstract UInt64 GetNtpWallTimeInMs();

In real-time chorus scenarios, especially when the downlink is inconsistent across receiving ends due to network issues, you can call this method to get the current NTP time as the reference time to align lyrics and music across multiple receivers, enabling chorus synchronization.

Return Values

The Unix timestamp (in milliseconds) of the current NTP time.

GetScreenCaptureSources

Gets the list of shareable screen and window objects.

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

Before screen or window sharing, you can call this method to get a list of shareable screen and window objects. This allows users to select a display or window to share based on the thumbnails in the list. The list includes important information such as window ID and screen ID. After obtaining the ID, you can call StartScreenCaptureByWindowId or StartScreenCaptureByDisplayId to start sharing.

Note: This method is for macOS and Windows only.

Parameters

thumbSize
Target size (in pixels) of the screen or window thumbnail. The SDK scales the original image to match the longest side of the target size while maintaining the aspect ratio. For example, if the original image is 400 × 300 and thumbSize is 100 × 100, the thumbnail size will be 100 × 75. If the target size is larger than the original image, the SDK returns the original image without scaling.
iconSize
Target size (in pixels) of the application icon. The SDK scales the original image to match the longest side of the target size while maintaining the aspect ratio. For example, if the original image is 400 × 300 and iconSize is 100 × 100, the icon size will be 100 × 75. If the target size is larger than the original image, the SDK returns the original image without scaling.
includeScreen
Whether the SDK returns screen information in addition to window information:
  • true: Returns both screen and window information.
  • false: Returns only window information.

Return Values

ScreenCaptureSourceInfo array.

GetUserInfoByUid

Gets user information by UID.

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

After a remote user joins the channel, the SDK retrieves the UID and User Account of the remote user, then caches a mapping table of UID and User Account, and triggers the OnUserInfoUpdated callback locally. After receiving the callback, call this method with the UID to get the UserInfo object containing the specified user's User Account.

Timing

Call this method after receiving the OnUserInfoUpdated callback.

Parameters

uid
User ID.
userInfo
Input and output parameter. The UserInfo object identifying the user:
  • Input: A UserInfo object.
  • Output: A UserInfo object containing the user's User Account and UID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetUserInfoByUserAccount

Gets user information by User Account.

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

After a remote user joins the channel, the SDK retrieves the UID and User Account of the remote user, then caches a mapping table of UID and User Account, and triggers the OnUserInfoUpdated callback locally. After receiving the callback, call this method with the User Account to get the UserInfo object containing the specified user's UID.

Timing

Call this method after receiving the OnUserInfoUpdated callback.

Parameters

userAccount
User Account.
userInfo
Input and output parameter. The UserInfo object identifying the user:
  • Input: A UserInfo object.
  • Output: A UserInfo object containing the user's User Account and UID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

GetVersion

Gets the SDK version.

public abstract string GetVersion(ref int build);

Parameters

build
Build number.

Return Values

The current SDK version number in string format.

GetVolumeOfEffect

Gets the playback volume of the specified audio effect.

public abstract int GetVolumeOfEffect(int soundId);

Parameters

soundId
The ID of the audio effect.

Return Values

  • ≥ 0: Method call succeeds and returns the playback volume. The volume range is [0,100]. 100 represents the original volume.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

Initialize

Initializes IRtcEngine.

public abstract int Initialize(RtcEngineContext context);
Note: All interface functions of the IRtcEngine class are asynchronous by default unless otherwise specified. It is recommended to call the interfaces on the same thread. The SDK only supports creating one IRtcEngine instance per App.

Parameters

context
Configuration for the IRtcEngine instance. See RtcEngineContext.

Return Values

  • 0: Success.
  • < 0: Failure.
    • -1: General error (not specifically classified).
    • -2: Invalid parameter.
    • -7: SDK initialization failed.
    • -22: Resource allocation failed. This error occurs when the App consumes too many resources or system resources are exhausted, causing the SDK to fail in allocating resources.
    • -101: Invalid App ID.

IsCameraAutoExposureFaceModeSupported

Checks whether the device supports auto exposure.

public abstract bool IsCameraAutoExposureFaceModeSupported();

Return Values

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

IsCameraAutoFocusFaceModeSupported

Checks whether the device supports face auto focus.

public abstract bool IsCameraAutoFocusFaceModeSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

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

IsCameraCenterStageSupported

Checks whether the camera supports Center Stage.

public abstract bool IsCameraCenterStageSupported();

Before calling EnableCameraCenterStage to enable Center Stage, it is recommended to call this method to check whether the current device supports this feature.

Note: This method is only applicable to iOS and macOS.

Timing

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

Return Values

  • true: The current camera supports Center Stage.
  • false: The current camera does not support Center Stage.

IsCameraExposurePositionSupported

Checks whether the device supports manual exposure.

public abstract bool IsCameraExposurePositionSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

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

IsCameraExposureSupported

Checks whether the current camera supports exposure adjustment.

public abstract bool IsCameraExposureSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • It is recommended to call this method before using SetCameraExposureFactor to adjust the exposure factor.
  • This method checks whether the currently used camera supports exposure adjustment, which is the camera specified when calling SetCameraCapturerConfiguration.

Return Values

  • true: The method call succeeds.
  • false: The method call fails. See Error Codes for details and resolution suggestions.

IsCameraFaceDetectSupported

Checks whether the device camera supports face detection.

public abstract bool IsCameraFaceDetectSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

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

IsCameraFocusSupported

Checks whether the device supports manual focus.

public abstract bool IsCameraFocusSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

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

IsCameraTorchSupported

Checks whether the device supports torch mode.

public abstract bool IsCameraTorchSupported();
Note:
  • This method is only applicable to Android and iOS.
  • You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • Generally, the app uses the front camera by default. If the front camera does not support torch mode, calling this method will return false. To check whether the rear camera supports torch mode, switch the camera using SwitchCamera before calling this method.
  • On iPads with system version 15, even if IsCameraTorchSupported returns true, due to system issues, you may still fail to enable the torch using SetCameraTorchOn.

Return Values

  • true: The device supports torch mode.
  • false: The device does not support torch mode.

IsCameraZoomSupported

Checks whether the device supports camera zoom.

public abstract bool IsCameraZoomSupported();
Note: This method is only applicable to Android and iOS.

Timing

You must call this method after the SDK triggers the OnLocalVideoStateChanged callback and the local video state returns LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

  • 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);

Checks whether the current device meets the requirements for advanced features such as virtual background and beauty effects.

Scenario

Before using advanced audio and video features, you can check whether the current device supports them to avoid performance degradation or feature unavailability on low-end devices. Based on the return value of this method, you can decide whether to show or enable the corresponding feature buttons, or prompt users with appropriate messages when the device capability is insufficient.

Parameters

type
The type of advanced feature. See FeatureType.

Return Values

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

IsSpeakerphoneEnabled

Checks whether the speakerphone is enabled.

public abstract bool IsSpeakerphoneEnabled();
Note: This method is for Android and iOS only.

Timing

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

Return Values

  • true: The speakerphone is enabled, and audio is routed to the speaker.
  • false: The speakerphone is not enabled, and audio is routed to a non-speaker device (earpiece, headset, etc.).

JoinChannel [1/2]

Joins a channel.

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

After joining a channel, by default users subscribe to all other users' audio and video streams in the channel, which generates usage and affects billing. To unsubscribe, use the corresponding mute methods.

Note:
  • This method only supports joining one channel at a time.
  • Apps using different App IDs cannot communicate with each other.
  • Before joining a channel, ensure that the App ID used to generate the Token and the one used in Initialize are the same. Otherwise, joining the channel using the Token will fail.

Timing

Call this method after Initialize.

Parameters

token
A dynamic key generated on the server for authentication. See Token Authentication.
Note:
  • (Recommended) If your project enables security mode (i.e., uses APP ID + Token for authentication), this parameter is required.
  • If your project only enables debug mode (i.e., uses APP ID for authentication), you can join the channel without providing a Token. You will be automatically disconnected after 24 hours.
  • If you need to join multiple channels or frequently switch between channels, Agora recommends using a wildcard Token to avoid requesting a new Token from the server for each new channel. See Wildcard Token.
channelId
Channel name. This parameter identifies the channel for real-time audio and video interaction. Users with the same App ID and channel name will join the same channel. The parameter must be a string of up to 64 bytes. Supported character set (89 characters total):
  • 26 lowercase letters a~z
  • 26 uppercase letters A~Z
  • 10 digits 0~9
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
info
(Optional) Reserved parameter.
uid
User ID. This parameter identifies the user in the real-time audio and video interaction channel. You must set and manage the user ID yourself and ensure that each user ID is unique within the same channel. The parameter is a 32-bit unsigned integer. Recommended range: 1 to 2^32-1. If not specified (i.e., set to 0), the SDK automatically assigns one and returns it in the OnJoinChannelSuccess callback. The application layer must store and maintain this value as the SDK does not.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter. For example, using an illegal Token, uid not set as an integer, or invalid ChannelMediaOptions values. Provide valid parameters and rejoin the channel.
    • -3: IRtcEngine initialization failed. Reinitialize the IRtcEngine object.
    • -7: IRtcEngine not initialized. Initialize IRtcEngine before calling this method.
    • -8: Internal state error of IRtcEngine. Possible cause: calling this method after StartEchoTest without calling StopEchoTest. Call StopEchoTest before this method.
    • -17: Join channel rejected. Possible cause: user already in the channel. Use OnConnectionStateChanged to check if the user is in the channel. Unless receiving CONNECTION_STATE_DISCONNECTED (1), do not call this method again.
    • -102: Invalid channel name. Provide a valid channelId and rejoin the channel.
    • -121: Invalid user ID. Provide a valid uid and rejoin the channel.

JoinChannel [2/2]

Sets media options and joins a channel.

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

Compared to JoinChannel [1/2], this method adds the options parameter to set media options, such as whether to publish audio and video streams in the channel. Whether a user automatically subscribes to all remote audio and video streams in the channel upon joining. By default, the user subscribes to all other users' audio and video streams in the channel, which incurs usage and affects billing. If you want to unsubscribe, you can do so by setting the options parameter or using the corresponding mute methods.

Note:
  • This method only supports joining one channel at a time.
  • Apps with different App IDs cannot communicate with each other.
  • Before joining a channel, make sure the App ID used to generate the Token is the same as the one used to initialize the engine with the Initialize method; otherwise, joining the channel with the Token will fail.

Timing

This method must be called after Initialize.

Parameters

token
A dynamic key generated on your server for authentication. See Token Authentication.
Note:
  • (Recommended) If your project has enabled secure mode (i.e., using APP ID + Token for authentication), this parameter is required.
  • If your project is in debug mode only (i.e., using APP ID for authentication), you can join the channel without providing a Token. The user will automatically leave the channel after 24 hours.
  • If you need to join multiple channels simultaneously or switch channels frequently, Agora recommends using a wildcard Token to avoid requesting a new Token from your server each time you join a new channel. See Using Wildcard Token.
channelId
Channel name. This parameter identifies the channel for real-time audio and video interaction. Users with the same App ID and channel name will join the same channel. The parameter must be a string of up to 64 bytes. Supported character set (89 characters total):
  • 26 lowercase English letters a~z
  • 26 uppercase English letters A~Z
  • 10 digits 0~9
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
uid
User ID. This parameter identifies the user in the real-time audio and video interaction channel. You must set and manage the user ID yourself and ensure that each user ID is unique within the same channel. This parameter is a 32-bit unsigned integer. Recommended range: 1 to 2^32-1. If not specified (i.e., set to 0), the SDK automatically assigns one and returns it in the OnJoinChannelSuccess callback. The application layer must remember and manage this return value; the SDK does not maintain it.
options
Channel media configuration options. See ChannelMediaOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting advice.
    • -2: Invalid parameters. For example, using an invalid Token, uid not set as an integer, or invalid values in ChannelMediaOptions. You need to provide valid parameters and rejoin the channel.
    • -3: IRtcEngine initialization failed. You need to reinitialize the IRtcEngine object.
    • -7: IRtcEngine is not initialized. You must successfully initialize IRtcEngine before calling this method.
    • -8: Internal state error in IRtcEngine. Possible cause: calling this method to join a channel after StartEchoTest without calling StopEchoTest. You need to call StopEchoTest before this method.
    • -17: This method call was rejected. Possible cause: the user is already in the channel. Use the OnConnectionStateChanged callback to check the connection state. Do not call this method again unless you receive CONNECTION_STATE_DISCONNECTED (1).
    • -102: Invalid channel name. You need to provide a valid channelId and rejoin the channel.
    • -121: Invalid user ID. You need to provide a valid uid and rejoin the channel.

JoinChannelWithUserAccount [1/2]

Joins a channel using a User Account and Token.

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

Before calling this method, if you have not called RegisterLocalUserAccount to register a User Account, the SDK will automatically create one for you when you call this method to join a channel. Calling RegisterLocalUserAccount before joining can reduce the time required to enter the channel. After successfully joining a channel, the user subscribes to all other users' audio and video streams by default, which incurs usage and affects billing. If you want to unsubscribe, you can do so by calling the corresponding mute methods.

Note: To ensure communication quality, use the same type of identifier (UID or User Account) for all users in a channel. If users join via the Web SDK, make sure they use the same identifier type.
  • This method only supports joining one channel at a time.
  • Apps with different App IDs cannot communicate with each other.
  • Before joining a channel, make sure the App ID used to generate the Token is the same as the one used to initialize the engine with the Initialize method; otherwise, joining the channel with the Token will fail.

Timing

This method must be called after Initialize.

Parameters

token
A dynamic key generated on your server for authentication. See Token Authentication.
Note:
  • (Recommended) If your project has enabled secure mode (i.e., using APP ID + Token for authentication), this parameter is required.
  • If your project is in debug mode only (i.e., using APP ID for authentication), you can join the channel without providing a Token. The user will automatically leave the channel after 24 hours.
  • If you need to join multiple channels simultaneously or switch channels frequently, Agora recommends using a wildcard Token to avoid requesting a new Token from your server each time you join a new channel. See Using Wildcard Token.
userAccount
User Account. This parameter identifies the user in the real-time audio and video interaction channel. You must set and manage the User Account yourself and ensure that each User Account is unique within the same channel. This parameter is required, must not exceed 255 bytes, and cannot be null. Supported character set (89 characters total):
  • 26 lowercase English letters a-z
  • 26 uppercase English letters A-Z
  • 10 digits 0-9
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting advice.
    • -2: Invalid parameters. For example, using an invalid Token, uid not set as an integer, or invalid values in ChannelMediaOptions. You need to provide valid parameters and rejoin the channel.
    • -3: IRtcEngine initialization failed. You need to reinitialize the IRtcEngine object.
    • -7: IRtcEngine is not initialized. You must successfully initialize IRtcEngine before calling this method.
    • -8: Internal state error in IRtcEngine. Possible cause: calling this method to join a channel after StartEchoTest without calling StopEchoTest. You need to call StopEchoTest before this method.
    • -17: This method call was rejected. Possible cause: the user is already in the channel. Use the OnConnectionStateChanged callback to check the connection state. Do not call this method again unless you receive CONNECTION_STATE_DISCONNECTED (1).
    • -102: Invalid channel name. You need to provide a valid channelId and rejoin the channel.
    • -121: Invalid user ID. You need to provide a valid uid and rejoin the channel.

JoinChannelWithUserAccount [2/2]

Joins a channel using a User Account and Token, and sets channel media options.

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

Before calling this method, if you have not called RegisterLocalUserAccount to register a User Account, the SDK automatically creates one for you when joining the channel. Calling RegisterLocalUserAccount before this method can shorten the time to join the channel. Compared with JoinChannelWithUserAccount [1/2], this method adds the options parameter, which allows you to set media options when joining the channel, such as whether to publish audio and video streams. By default, a user subscribes to all other users' audio and video streams in the channel, which incurs usage and affects billing. If you want to unsubscribe, you can do so via the options parameter or corresponding mute methods.

Note: To ensure communication quality, make sure to use the same type of user identity in the channel. That is, use either UID or User Account consistently within the same channel. If users join via the Web SDK, ensure they use the same identity type.
  • This method only supports joining one channel at a time.
  • Apps with different App IDs cannot communicate with each other.
  • Before joining a channel, ensure the App ID used to generate the Token is the same as the one used in the Initialize method. Otherwise, joining the channel with the Token will fail.

Timing

This method must be called after Initialize.

Parameters

token
A dynamic key generated on your server for authentication. See Token Authentication.
Note:
  • (Recommended) If your project enables security mode (i.e., uses APP ID + Token for authentication), this parameter is required.
  • If your project is in debug mode only (i.e., uses APP ID for authentication), you can join the channel without a Token. You will automatically leave the channel after 24 hours.
  • If you need to join multiple channels or switch between them frequently, Agora recommends using a wildcard Token to avoid requesting a new Token from your server each time. See Using Wildcard Token.
userAccount
The User Account of the user. This parameter identifies the user in the real-time audio and video interaction channel. You need to set and manage the User Account yourself and ensure each user in the same channel has a unique User Account. This parameter is required. Maximum length is 255 bytes and cannot be null. Supported character set (89 characters total):
  • 26 lowercase English letters a-z
  • 26 uppercase English letters A-Z
  • 10 digits 0-9
  • Space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
options
Channel media configuration options. See ChannelMediaOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and suggestions.
    • -2: Invalid parameter. For example, an invalid Token, uid is not an integer, or ChannelMediaOptions contains invalid values. Provide valid parameters and rejoin the channel.
    • -3: IRtcEngine initialization failed. Reinitialize the IRtcEngine object.
    • -7: IRtcEngine not initialized. Initialize it before calling this method.
    • -8: Internal state error of IRtcEngine. Possible cause: calling this method after StartEchoTest without calling StopEchoTest. Call StopEchoTest before this method.
    • -17: Join channel request rejected. Possible cause: user already in channel. Use OnConnectionStateChanged to check. Do not call this method again unless receiving CONNECTION_STATE_DISCONNECTED(1).
    • -102: Invalid channel name. Provide a valid channel name in channelId and rejoin.
    • -121: Invalid user ID. Provide a valid UID and rejoin.

LeaveChannel [1/2]

Leaves the channel.

public abstract int LeaveChannel();

After calling this method, the SDK stops audio and video interactions, leaves the current channel, and releases all session-related resources. You must call this method after successfully joining a channel to end the call, otherwise you cannot start a new one.

Note:
  • This method is asynchronous. The return does not mean you have actually left the channel.
  • If you have joined multiple channels using JoinChannelEx, calling this method leaves all joined channels.
If you call Dispose immediately after this method, the SDK will not trigger the OnLeaveChannel callback.

Timing

Call this method after joining a channel.

Parameters

leaveChannelBlock
Callback after successfully leaving the channel, providing call statistics. See RtcStats.

Return Values

  • 0(ERR_OK): Success.
  • < 0: Failure. See Error Codes for details and suggestions.
    • -1: General error (not specifically classified).
    • -2: Invalid parameter.
    • -7: SDK not initialized.

LeaveChannel [2/2]

Sets channel options and leaves the channel.

public abstract int LeaveChannel(LeaveChannelOptions options);

After calling this method, the SDK stops audio and video interactions, leaves the current channel, and releases all session-related resources. You must call this method or LeaveChannel [1/2] after successfully joining a channel to end the call, otherwise you cannot start a new one. If you have joined multiple channels using JoinChannelEx, calling this method leaves all joined channels.

Note: This method is asynchronous. The return does not mean you have actually left the channel. If you call Dispose immediately after this method, the SDK will not trigger the OnLeaveChannel callback.

Timing

Call this method after joining a channel.

Parameters

options
Options for leaving the channel. See LeaveChannelOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and suggestions.

LoadExtensionProvider

Loads an extension.

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

This method adds external SDK extensions (such as Marketplace extensions and SDK extension plugins) to the SDK.

Note: To load multiple extensions, call this method multiple times. This method applies to Windows and Android only.

Timing

Call this method immediately after initializing IRtcEngine.

Parameters

path
The path and name of the extension dynamic library. For example: /library/libagora_segmentation_extension.dll.
unload_after_use
Whether to automatically unload the extension after use:
  • true: Automatically unloads the extension when IRtcEngine is destroyed.
  • false: Does not automatically unload the extension until the process exits (recommended).

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteAllRemoteAudioStreams

Stops or resumes subscribing to all remote users' audio streams.

public abstract int MuteAllRemoteAudioStreams(bool mute);

After successfully calling this method, the local user stops or resumes subscribing to all remote users' audio streams, including those who join the channel after this method is called.

Note: By default, the SDK subscribes to all remote users' audio streams when joining a channel. To change this behavior, you can set autoSubscribeAudio to false when calling JoinChannel [2/2] to join the channel, which disables audio stream subscription at join time. If you call EnableAudio or DisableAudio after this method, the latter call takes effect.

Timing

This method must be called after joining a channel.

Parameters

mute
Whether to stop subscribing to all remote users' audio streams:
  • true: Stop subscribing to all remote users' audio streams.
  • false: (Default) Subscribe to all remote users' audio streams.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteAllRemoteVideoStreams

Stops or resumes subscribing to all remote users' video streams.

public abstract int MuteAllRemoteVideoStreams(bool mute);

After successfully calling this method, the local user stops or resumes subscribing to all remote users' video streams, including those who join the channel after this method is called.

Note: By default, the SDK subscribes to all remote users' video streams when joining a channel. To change this behavior, you can set autoSubscribeVideo to false when calling JoinChannel [2/2] to join the channel, which disables video stream subscription at join time. If you call EnableVideo or DisableVideo after this method, the latter call takes effect.

Timing

This method must be called after joining a channel.

Parameters

mute
Whether to stop subscribing to all remote users' video streams.
  • true: Stop subscribing to all users' video streams.
  • false: (Default) Subscribe to all users' video streams.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteLocalAudioStream

Stops or resumes publishing the local audio stream.

public abstract int MuteLocalAudioStream(bool mute);

This method controls whether to publish the locally captured audio stream. Not publishing the local audio stream does not disable the audio capture device, so it does not affect the audio capture status.

Timing

Can be called before or after joining the channel.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteLocalVideoStream

Stops or resumes publishing the local video stream.

public abstract int MuteLocalVideoStream(bool mute);

This method controls whether to publish the locally captured video stream. Not publishing the local video stream does not disable the video capture device, so it does not affect the video capture status. Compared to calling EnableLocalVideo(false) to stop local video capture and thus stop publishing, this method responds faster.

Timing

Can be called before or after joining the channel.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteRecordingSignal

Mutes or unmutes the recording signal.

public abstract int MuteRecordingSignal(bool mute);
If you have already called AdjustRecordingSignalVolume to adjust the recording signal volume, calling this method with true will cause the SDK to:
  1. Record the adjusted volume.
  2. Mute the recording signal.
When you call this method again with false, the recording signal will be restored to the volume recorded by the SDK before muting.

Timing

Can be called before or after joining a channel.

Parameters

mute
  • true: Mute.
  • false: (Default) Original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteRemoteAudioStream

Stops or resumes subscribing to the specified remote user's audio stream.

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

Timing

This method must be called after joining the channel.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

MuteRemoteVideoStream

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

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

Timing

You must call this method after joining the channel.

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

PauseAllChannelMediaRelay

Pauses media stream forwarding to all destination channels.

public abstract int PauseAllChannelMediaRelay();

After starting to forward media streams across channels, if you need to pause forwarding to all channels, you can call this method. To resume forwarding, call the ResumeAllChannelMediaRelay method.

Note: You must call this method after calling StartOrUpdateChannelMediaRelay to start cross-channel media stream forwarding.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -5: This method call was rejected. No cross-channel media stream forwarding is currently in progress.

PauseAllEffects

Pauses playback of all audio effects.

public abstract int PauseAllEffects();

Return Values

  • 0: Method call succeeds.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

PauseAudioMixing

Pauses the playback of the music file.

public abstract int PauseAudioMixing();

After calling the StartAudioMixing [2/2] method to play a music file, if you want to pause playback, call this method. If you want to stop playback, call StopAudioMixing.

Timing

You need to call this method after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

PauseEffect

Pauses playback of the audio effect.

public abstract int PauseEffect(int soundId);

Parameters

soundId
The ID of the audio effect. Each audio effect has a unique ID.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

PlayAllEffects

Plays all audio effects.

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

After calling PreloadEffect multiple times to preload several audio effects, you can call this method to play all preloaded audio effects.

Parameters

loopCount
The number of times the audio effect loops:
  • -1: Loops indefinitely until StopEffect or StopAllEffects is called.
  • 0: Plays the audio effect once.
  • 1: Plays the audio effect twice.
pitch
The pitch of the audio effect. The range is [0.5,2.0]. Default is 1.0, which represents the original pitch. The smaller the value, the lower the pitch.
pan
The spatial position of the audio effect. The range is [-1.0,1.0]:
  • -1.0: Audio appears on the left.
  • 0: Audio appears in the center.
  • 1.0: Audio appears on the right.
gain
The volume of the audio effect. The range is [0,100]. 100 is the default and represents the original volume. The smaller the value, the lower the volume.
publish
Whether to publish the audio effect to remote users:
  • true: Publishes the audio effect to remote users. Both local and remote users can hear it.
  • false: (Default) Does not publish the audio effect to remote users. Only the local user can hear it.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

PlayEffect

Plays the specified local or online audio effect.

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

You can call this method multiple times with different soundID and filePath values to play multiple audio effects simultaneously. For optimal user experience, it is recommended not to play more than 3 audio effects at the same time.

Note: If you need to play an online audio effect, Agora recommends caching the online file to the local device, preloading it into memory using PreloadEffect, and then calling this method to play it. Otherwise, playback may fail or be silent due to loading timeouts or failures.

Timing

This method can be called before or after joining a channel.

Parameters

soundId
The ID of the audio effect. Each audio effect has a unique ID.
Note: If you have loaded the audio effect into memory using PreloadEffect, ensure this parameter matches the soundId set in PreloadEffect.
filePath
The file path to play. Supports online URLs and absolute paths to local files, including the file name and extension. Supported audio formats include MP3, AAC, M4A, MP4, WAV, 3GP, etc.
Note: If you have loaded the audio effect into memory using PreloadEffect, ensure this parameter matches the filePath set in PreloadEffect.
loopCount
The number of times the audio effect loops.
  • ≥ 0: Number of loops. For example, 1 means loop once, i.e., play twice in total.
  • -1: Loop indefinitely.
pitch
The pitch of the audio effect. The range is [0.5,2.0]. Default is 1.0, which represents the original pitch. The smaller the value, the lower the pitch.
pan
The spatial position of the audio effect. The range is [-1.0,1.0], for example:
  • -1.0: Audio appears on the left
  • 0.0: Audio appears in the center
  • 1.0: Audio appears on the right
gain
The volume of the audio effect. The range is [0.0,100.0]. Default is 100.0, which represents the original volume. The smaller the value, the lower the volume.
publish
Whether to publish the audio effect to remote users:
  • true: Publishes the audio effect to remote users. Both local and remote users can hear it.
  • false: Does not publish the audio effect to remote users. Only the local user can hear it.
startPos
The playback position of the audio effect in milliseconds.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

PreloadChannel

Preloads a channel using token, channelId, and uid.

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

Calling this method can reduce the time it takes for a viewer to join a channel when frequently switching channels, thereby shortening the time to hear the first frame of audio or see the first frame of video from the host and improving the viewer's video experience. If the channel has already been successfully preloaded, and the viewer leaves and rejoins the same channel, as long as the Token used during preloading is still valid, preloading does not need to be performed again.

Note: If preloading fails, it does not affect the subsequent normal channel join process, nor does it increase the time to join the channel.
  • When calling this method, make sure the user role is set to audience and the audio scenario is not set to chorus (AUDIO_SCENARIO_CHORUS), otherwise preloading will not take effect.
  • Ensure that the channel name, user ID, and Token passed in during preloading are the same as those used when joining the channel later, otherwise preloading will not take effect.
  • Currently, one IRtcEngine instance supports preloading up to 20 channels. If this limit is exceeded, only the most recently preloaded 20 channels take effect.

Timing

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

Parameters

token
A dynamic key generated on your server for authentication. See Token Authentication. When the Token expires, depending on the number of preloaded channels, you can provide a new Token in different ways:
  • Preloading a single channel: call this method with the new Token.
  • Preloading multiple channels:
    • If you use a wildcard Token, call UpdatePreloadChannelToken to update the Token for all preloaded channels. When generating a wildcard Token, the user ID must not be 0. See Using Wildcard Tokens.
    • If you use different Tokens: call this method with your user ID, corresponding channel name, and the updated Token.
channelId
The name of the channel to preload. This parameter identifies the channel for real-time audio and video interaction. Users with the same App ID and channel name will enter the same channel for interaction. This parameter is a string up to 64 bytes in length. The supported character set (89 characters total) includes:
  • 26 lowercase letters a–z
  • 26 uppercase letters A–Z
  • 10 digits 0–9
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
uid
User ID. This parameter identifies the user in the real-time audio and video interaction channel. You need to set and manage the user ID yourself and ensure that each user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. Recommended range: 1 to 2^32 - 1. If not specified (i.e., set to 0), the SDK will automatically assign one and return it in the OnJoinChannelSuccess callback. The application must store and maintain this return value, as the SDK does not manage it.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.
    • -102: Invalid channel name. You need to provide a valid channel name and rejoin the channel.

PreloadChannelWithUserAccount

Preloads a channel using token, channelId, and userAccount.

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

Calling this method can reduce the time it takes for a viewer to join a channel when frequently switching channels, thereby shortening the time to hear the first frame of audio or see the first frame of video from the host and improving the viewer's video experience. If the channel has already been successfully preloaded, and the viewer leaves and rejoins the same channel, as long as the Token used during preloading is still valid, preloading does not need to be performed again.

Note: If preloading fails, it does not affect the subsequent normal channel join process, nor does it increase the time to join the channel.
  • When calling this method, make sure the user role is set to audience and the audio scenario is not set to chorus (AUDIO_SCENARIO_CHORUS), otherwise preloading will not take effect.
  • Ensure that the channel name, user userAccount, and Token passed in during preloading are the same as those used when joining the channel later, otherwise preloading will not take effect.
  • Currently, one IRtcEngine instance supports preloading up to 20 channels. If this limit is exceeded, only the most recently preloaded 20 channels take effect.

Timing

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

Parameters

token
A dynamic key generated on your server for authentication. See Token Authentication. When the Token expires, depending on the number of preloaded channels, you can provide a new Token in different ways:
  • Preloading a single channel: call this method with the new Token.
  • Preloading multiple channels:
    • If you use a wildcard Token, call UpdatePreloadChannelToken to update the Token for all preloaded channels. When generating a wildcard Token, the user ID must not be 0. See Using Wildcard Tokens.
    • If you use different Tokens: call this method with your user ID, corresponding channel name, and the updated Token.
channelId
The name of the channel to preload. This parameter identifies the channel for real-time audio and video interaction. Users with the same App ID and channel name will enter the same channel for interaction. This parameter is a string up to 64 bytes in length. The supported character set (89 characters total) includes:
  • 26 lowercase letters a–z
  • 26 uppercase letters A–Z
  • 10 digits 0–9
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
userAccount
User userAccount. This parameter identifies the user in the real-time audio and video interaction channel. You need to set and manage the userAccount yourself and ensure that each userAccount in the same channel is unique. This parameter is required, must not exceed 255 bytes, and cannot be NULL. The supported character set (89 characters total) includes:
  • 26 lowercase letters a–z
  • 26 uppercase letters A–Z
  • 10 digits 0–9
  • space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter. For example, userAccount is empty. You need to provide a valid parameter and rejoin the channel.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.
    • -102: Invalid channel name. You need to provide a valid channel name and rejoin the channel.

PreloadEffect

Loads the audio effect into memory.

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

To ensure smooth communication, pay attention to the size of the preloaded audio effect file. Supported audio formats for preloading can be found in What audio formats does the RTC SDK support for playback.

Timing

Agora recommends calling this method before joining a channel.

Parameters

soundId
The ID of the audio effect. Each audio effect has a unique ID.
filePath
File path:
  • Android: File path including file name and extension. Supports online URLs, local file URI, absolute paths, or paths starting with /assets/. Accessing local files via absolute paths may cause permission issues. It is recommended to use URI, e.g., content://com.android.providers.media.documents/document/audio%3A14441.
  • Windows: Absolute path or URL of the audio file, including file name and extension. For example, C:\music\audio.mp4.
  • iOS or macOS: Absolute path or URL of the audio file, including file name and extension. For example, /var/mobile/Containers/Data/audio.mp4.
startPos
The start position for loading the audio effect, in milliseconds.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

QueryCameraFocalLengthCapability

Queries the focal length capabilities supported by the camera.

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

To enable wide-angle or ultra-wide-angle camera modes, it is recommended to call this method first to check whether the device supports the corresponding focal length capabilities. Then, based on the result, call SetCameraCapturerConfiguration to adjust the focal length configuration for optimal camera capture performance.

Note: This method is only applicable to Android and iOS.

Parameters

focalLengthInfos
Output parameter. After execution, returns an array of FocalLengthInfo objects containing the camera focal length information.
size
Output parameter. After execution, returns the number of focal length entries found.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

QueryCodecCapability

Queries the video codec capabilities supported by the SDK.

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

Parameters

codecInfo
Input and output parameter, representing the array of video codec capabilities supported by the SDK. See CodecCapInfo.
  • Input: The CodecCapInfo defined by the user when calling this method, indicating the video codec capabilities to query.
  • Output: The CodecCapInfo returned after the method execution, indicating the actual video codec capabilities supported by the SDK.
size
Input and output parameter, indicating the size of the CodecCapInfo array.
  • Input: The size of CodecCapInfo defined by the user when calling this method.
  • Output: The size of CodecCapInfo returned after the method execution.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

QueryDeviceScore

Queries the device score level.

public abstract int QueryDeviceScore();

Scenario

In high-definition or ultra-high-definition video scenarios, you can first call this method to query the device score. If the returned score is low (e.g., below 60), you should lower the video resolution accordingly to avoid affecting the video experience. The minimum device score requirement varies by business scenario. For specific recommendations, please contact technical support.

Return Values

  • > 0: The method call succeeds. The value indicates the current device score level, ranging from [0,100]. A higher value indicates better device capability. Most devices score between 60 and 100.
  • < 0: The method call fails.

QueryScreenCaptureCapability

Queries the maximum supported frame rate for screen sharing on the device.

public abstract int QueryScreenCaptureCapability();

Scenario

In screen sharing scenarios, if you want to enable high frame rates (e.g., 60 fps) but are unsure whether the device supports it, you can call this method to query the maximum frame rate supported by the device. If high frame rates are not supported, you can lower the frame rate of the screen sharing stream accordingly to ensure the expected sharing experience.

Return Values

Rate

Rates the call.

public abstract int Rate(string callId, int rating, string description);
Note: You must call this method after the user leaves the channel.

Parameters

callId
Call ID. You can get this parameter by calling GetCallId.
rating
Rating for the call, ranging from 1 (lowest) to 5 (highest).
description
(Optional) Description of the call. The length should be less than 800 bytes.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically categorized).
    • -2: Invalid parameter.

RegisterAudioEncodedFrameObserver

Registers an audio encoded frame observer.

public abstract int RegisterAudioEncodedFrameObserver(AudioEncodedFrameObserverConfig config, IAudioEncodedFrameObserver observer);
Note:
  • Call this method after joining a channel.
  • Since this method and StartAudioRecording [3/3] both configure audio content and quality, it is not recommended to use them together. Otherwise, only the one called later takes effect.

Parameters

config
Observer configuration for encoded audio. See AudioEncodedFrameObserverConfig.
observer
Observer for encoded audio. See IAudioEncodedFrameObserver.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

RegisterAudioSpectrumObserver

Registers an audio spectrum observer.

public abstract int RegisterAudioSpectrumObserver(IAudioSpectrumObserver observer);

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

Note: This method can be called either before or after joining a channel.

Parameters

observer
Audio spectrum observer. See IAudioSpectrumObserver.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

RegisterExtension

Registers an extension.

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

For external SDK extensions (such as Marketplace extensions and SDK extension plugins), after loading the extension, you need to call this method to register it. Internal SDK extensions (included in the SDK package) are automatically loaded and registered after IRtcEngine is initialized, and do not require this method.

Note:
  • To register multiple extensions, call this method multiple times.
  • The order in which different extensions process data in the SDK is determined by the registration order. That is, extensions registered earlier process data first.

Timing

  • It is recommended to call this method after initializing IRtcEngine and before joining a channel.
  • For video-related extensions (such as beauty filters), call this method before enabling the video module (EnableVideo/EnableLocalVideo).
  • Before calling this method, you need to call LoadExtensionProvider to load the extension.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
type
The media source type of the extension. See MEDIA_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -3: The extension dynamic library was not loaded. Agora recommends checking whether the library is placed in the expected location or whether the library name is correct.

RegisterLocalUserAccount

Registers a local user userAccount.

public abstract int RegisterLocalUserAccount(string appId, string userAccount);
This method registers a userAccount for the local user. Once registered successfully, the userAccount can be used to identify the local user and join a channel. This method is optional. If you want users to join a channel using a userAccount, you can choose either of the following approaches:
Note:
  • Ensure the userAccount set in this method is unique within the channel.
  • To ensure communication quality, make sure all users in the same channel use the same type of identifier (either UID or userAccount). If users join via Web SDK, ensure they use the same type as well.

Parameters

appId
The App ID of your project registered in the console.
userAccount
User userAccount. This parameter identifies the user in the real-time audio and video interaction channel. You need to set and manage the userAccount yourself and ensure that each userAccount in the same channel is unique. This parameter is required, must not exceed 255 bytes, and cannot be NULL. The supported character set (89 characters total) includes:
  • 26 lowercase letters a–z
  • 26 uppercase letters A–Z
  • 10 digits 0–9
  • space
  • "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

RegisterMediaMetadataObserver

Registers a media metadata observer to receive or send metadata.

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

You need to implement the IMetadataObserver class and specify the metadata type in this method. This method allows you to add synchronized metadata to the video stream for interactive live streaming scenarios, such as sending shopping links, e-coupons, or online quizzes.

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

Parameters

observer
The metadata observer. See IMetadataObserver.
type
The metadata type. Currently only VIDEO_METADATA is supported. See METADATA_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

Dispose

Destroys the IRtcEngine object.

public abstract void Dispose(bool sync = false);

This method releases all resources used by the SDK. Some Apps only use real-time audio and video communication when needed and release resources when not needed. This method is suitable for such scenarios. After calling this method, you can no longer use other SDK methods or callbacks. To use real-time audio and video communication again, you must call CreateAgoraRtcEngine and Initialize in sequence to create a new IRtcEngine object.

Note:
  • This method is a synchronous call. You must wait for the IRtcEngine resources to be released before performing other operations (e.g., creating a new IRtcEngine object). Therefore, it is recommended to call this method in a sub-thread to avoid blocking the main thread.
  • It is not recommended to call Dispose inside SDK callbacks. Otherwise, since the SDK waits for the callback to return before reclaiming related object resources, it may cause a deadlock.

Parameters

sync
Whether this method is called synchronously:
  • true: The method is synchronous.
  • false: The method is asynchronous. Currently, only synchronous calls are supported. Do not set this parameter to this value.

RemoveVideoWatermark

Removes a watermark image from the local video.

public abstract int RemoveVideoWatermark(string id);
Since
Available since v4.6.2.

This method removes the previously added watermark image from the local video stream based on the specified unique ID.

Parameters

id
The ID of the watermark to be removed. This value must be the same as the ID used when the watermark was added.

Return Values

  • 0: Success.
  • < 0: Failure.

RenewToken

Renews the Token.

public abstract int RenewToken(string token);

This method is used to renew the Token. The Token will expire after a certain period, at which point the SDK will be unable to connect to the server.

Timing

In any of the following situations, Agora recommends that your server regenerate a Token and then call this method to pass in the new Token:

Parameters

token
The newly generated Token.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter. For example, the Token is empty.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.
    • -110: Invalid Token. Please ensure:
      • The user ID specified when generating the Token matches the one used to join the channel,
      • The generated Token matches the one used to join the channel.

ResumeAllChannelMediaRelay

Resumes media stream forwarding to all destination channels.

public abstract int ResumeAllChannelMediaRelay();

After calling the PauseAllChannelMediaRelay method, if you need to resume forwarding to all destination channels, you can call this method.

Note: You must call this method after PauseAllChannelMediaRelay.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -5: This method call was rejected. No cross-channel media stream forwarding is currently paused.

ResumeAllEffects

Resumes playback of all audio effect files.

public abstract int ResumeAllEffects();

After you call PauseAllEffects to pause all audio effect files, you can call this method to resume playback.

Timing

This method must be called after PauseAllEffects.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

ResumeAudioMixing

Resumes the playback of the music file.

public abstract int ResumeAudioMixing();

After calling PauseAudioMixing to pause the playback of a music file, call this method to resume playback.

Timing

You need to call this method after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

ResumeEffect

Resumes playback of the specified audio effect file.

public abstract int ResumeEffect(int soundId);

Parameters

soundId
The ID of the audio effect. Each audio effect has a unique ID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SelectAudioTrack [1/2]

Specifies the audio track to play in the current music file.

public abstract int SelectAudioTrack(int index);

After retrieving the number of audio tracks in the music file, you can call this method to specify any track for playback. For example, if different tracks in a multi-track file contain songs in different languages, you can call this method to set the playback language of the music file.

Note:

Parameters

index
The specified audio track to play. The value must be greater than or equal to 0 and less than the return value of GetAudioTrackCount.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SendCustomReportMessage

Sends a custom report message.

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

Agora provides custom data reporting and analytics services. This service is currently in a free beta period. During the beta, you can report up to 10 data entries within 6 seconds. Each custom data entry must not exceed 256 bytes, and each string must not exceed 100 bytes. To try this service, please [contact sales](mailto:support@agora.io) to enable it and agree on the custom data format.

SendMetadata

Sends media metadata.

public abstract int SendMetadata(Metadata metadata, VIDEO_SOURCE_TYPE source_type);

If the media metadata is successfully sent, the receiver receives the OnMetadataReceived callback.

Parameters

metadata
Media metadata. See Metadata.
source_type
Type of the video source. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.

SendStreamMessage

Sends a data stream.

public abstract int SendStreamMessage(int streamId, byte[] data, uint length);
After calling CreateDataStream [2/2], you can call this method to send data stream messages to all users in the channel. The SDK imposes the following restrictions on this method:
  • Each client in the channel can have up to 5 data channels simultaneously, and the total sending bitrate shared by all data channels is limited to 30 KB/s.
  • Each data channel can send up to 60 packets per second, with each packet up to 1 KB in size.
After the method is successfully called, the remote end triggers the OnStreamMessage callback, where remote users can retrieve the received stream message; if the call fails, the remote end triggers the OnStreamMessageError callback.
Note: If you need a more comprehensive low-latency, high-concurrency, and scalable real-time messaging and state synchronization solution, we recommend using Real-time Messaging.
  • This method must be called after joining a channel and after calling CreateDataStream [2/2] to create the data channel.
  • This method applies to broadcaster users only.

Parameters

streamId
Data stream ID. You can obtain it through CreateDataStream [2/2].
data
The data to be sent.
length
Length of the data.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.

SetAINSMode

Enables or disables the AI noise reduction feature and sets the noise reduction mode.

public abstract int SetAINSMode(bool enabled, AUDIO_AINS_MODE mode);
You can call this method to enable the AI noise reduction feature. This feature intelligently detects and reduces various steady-state and non-steady-state noises in the surrounding environment while ensuring voice quality, making the voice clearer. Steady-state noise refers to noise with the same frequency at any point in time. Common steady-state noises include:
  • TV noise
  • Air conditioner noise
  • Factory machine noise
Non-steady-state noise refers to noise that changes rapidly over time. Common non-steady-state noises include:
  • Thunder
  • Explosion sounds
  • Cracking sounds
Note:
  • This method depends on the AI noise reduction dynamic library. If the library is removed, the feature cannot be enabled properly. See Plugin List for the library name.
  • It is currently not recommended to enable this feature on devices running Android 6.0 or lower.

Scenario

In scenarios such as voice chat, online education, and online meetings, if the surrounding environment is noisy, the AI noise reduction feature can identify and reduce both steady and non-steady noises while preserving voice quality, thereby improving audio quality and user experience.

Timing

This method can be called before or after joining a channel.

Parameters

enabled
Whether to enable the AI noise reduction feature:
  • true: Enable the AI noise reduction feature.
  • false: (Default) Disable the AI noise reduction feature.
mode
Noise reduction mode. See AUDIO_AINS_MODE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAdvancedAudioOptions

Sets advanced audio options.

public abstract int SetAdvancedAudioOptions(AdvancedAudioOptions options);

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

Note: You need to call this method before JoinChannel [2/2], EnableAudio, and EnableLocalAudio.

Parameters

options
Advanced audio options. See AdvancedAudioOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioEffectParameters

Sets parameters for SDK preset voice effects.

public abstract int SetAudioEffectParameters(AUDIO_EFFECT_PRESET preset, int param1, int param2);
Call this method to configure the following for local sending users:
  • 3D voice effect: Set the surround cycle for the 3D voice effect.
  • Pitch correction effect: Set the base scale and main pitch. To allow users to adjust pitch correction easily, it is recommended to bind the base scale and main pitch options to your app's UI elements.
After setting, all users in the channel can hear the effect.To achieve better voice effects, it is recommended to do the following before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality, i.e., AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] and set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).
Note:

Parameters

preset
SDK preset effects. Supported values:
  • ROOM_ACOUSTICS_3D_VOICE: 3D voice effect.
    • Before using this enum, you must set the profile parameter of SetAudioProfile [2/2] to AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5), otherwise the setting is invalid.
    • To hear the expected effect, users must use audio playback devices that support stereo.
  • PITCH_CORRECTION: Pitch correction effect.
param1
  • If preset is set to ROOM_ACOUSTICS_3D_VOICE, then param1 specifies the surround cycle in seconds. Value range: [1,60]. Default is 10, meaning the voice surrounds 360 degrees in 10 seconds.
  • If preset is set to PITCH_CORRECTION, then param1 specifies the base scale:
    • 1: (Default) Major scale.
    • 2: Minor scale.
    • 3: Japanese scale.
param2
  • If preset is set to ROOM_ACOUSTICS_3D_VOICE, set param2 to 0.
  • If preset is set to PITCH_CORRECTION, then param2 specifies the main pitch:
    • 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#

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioEffectPreset

Sets SDK preset voice effects.

public abstract int SetAudioEffectPreset(AUDIO_EFFECT_PRESET preset);

Call this method to set SDK preset voice effects for local sending users without altering the gender characteristics of the original voice. Once set, all users in the channel can hear the effect.

Note:

Timing

Can be called before or after joining a channel. To achieve better voice effects, it is recommended to do the following before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality, i.e., AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] and set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).

Parameters

preset
Preset effect options. See AUDIO_EFFECT_PRESET.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioMixingDualMonoMode

Sets the channel mode of the current audio file.

public abstract int SetAudioMixingDualMonoMode(AUDIO_MIXING_DUAL_MONO_MODE mode);

In stereo audio files, the left and right channels can store different audio data. Depending on your needs, you can set the channel mode to original, left channel, right channel, or mixed mode.

Note: This method applies to stereo audio files only.

Scenario

In KTV scenarios, the left channel of an audio file stores the accompaniment, and the right channel stores the original vocals. You can configure as follows:
  • To hear only the accompaniment, set the channel mode to left.
  • To hear both accompaniment and vocals, set the channel mode to mixed.

Timing

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

Parameters

mode
The channel mode. See AUDIO_MIXING_DUAL_MONO_MODE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioMixingPitch

Adjusts the pitch of the music file played locally.

public abstract int SetAudioMixingPitch(int pitch);

When mixing local vocals with a music file, you can call this method to adjust only the pitch of the music file.

Timing

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

Parameters

pitch
Adjusts the pitch of the music file played locally in semitone steps. The default value is 0, meaning no adjustment. The range is [-12,12]. Each adjacent value differs by one semitone. The greater the absolute value, the more the pitch is raised or lowered.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioMixingPlaybackSpeed

Sets the playback speed of the current music file.

public abstract int SetAudioMixingPlaybackSpeed(int speed);

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

Parameters

speed
The playback speed of the music file. Recommended range is [50,400], where:
  • 50: 0.5x speed.
  • 100: original speed.
  • 400: 4x speed.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioMixingPosition

Sets the playback position of the music file.

public abstract int SetAudioMixingPosition(int pos);

This method sets the playback position of the audio file so that you can play it from a specific point instead of from the beginning.

Timing

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

Parameters

pos
Integer. The position on the progress bar in milliseconds.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetAudioProfile [1/2]

Sets the audio encoding profile and scenario.

public abstract int SetAudioProfile(AUDIO_PROFILE_TYPE profile, AUDIO_SCENARIO_TYPE scenario);
Deprecated
Deprecated: This method is deprecated. To set the audio encoding profile, use SetAudioProfile [2/2]; to set the audio scenario, use SetAudioScenario.
Note: Due to iOS system limitations, some audio routes cannot be recognized in the call volume mode. Therefore, if you want to use an external sound card, it is recommended to set the audio scenario to the high-quality scenario AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK switches to media volume to avoid the issue.

Scenario

This method applies to various audio scenarios. You can choose as needed. For example, in scenarios that require high audio quality such as music education, it is recommended to set profile to AudioProfileMusicHighQuality (4) and scenario to AudioScenarioGameStreaming (3).

Timing

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

Parameters

profile
The audio encoding profile, including sample rate, bitrate, encoding mode, and number of channels. See AUDIO_PROFILE_TYPE.
scenario
The audio scenario. The volume type of the device varies by scenario. See AUDIO_SCENARIO_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetAudioProfile [2/2]

Sets the audio encoding profile.

public abstract int SetAudioProfile(AUDIO_PROFILE_TYPE profile);

If you want to set the audio scenario, you can call the SetAudioScenario method directly, or call Initialize and set the audioScenario field in the RtcEngineContext structure.

Scenario

This method applies to various audio scenarios. You can choose as needed. For example, in scenarios requiring high audio quality such as music teaching, set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4).

Timing

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetAudioScenario

Sets the audio scenario.

public abstract int SetAudioScenario(AUDIO_SCENARIO_TYPE scenario);
Note: Due to iOS system limitations, some audio routes cannot be recognized in the call volume mode. Therefore, if you want to use an external sound card, it is recommended to set the audio scenario to the high-quality scenario AUDIO_SCENARIO_GAME_STREAMING(3). In this scenario, the SDK switches to media volume to avoid the issue.

Scenario

This method applies to various audio scenarios. You can choose as needed. For example, in scenarios that require high audio quality such as music education, it is recommended to set scenario to AudioScenarioGameStreaming (3).

Timing

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

Parameters

scenario
The audio scenario. The volume type of the device varies by scenario. See AUDIO_SCENARIO_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetAudioSessionOperationRestriction

Sets the SDK's operation permissions for the Audio Session.

public abstract int SetAudioSessionOperationRestriction(AUDIO_SESSION_OPERATION_RESTRICTION restriction);

By default, both the SDK and the app have permissions to operate the Audio Session. If you only want the app to operate the Audio Session, you can call this method to restrict the SDK's permissions. You can call this method before or after joining a channel. Once called, the restriction takes effect when the SDK needs to change the Audio Session.

Note:
  • This method is only applicable on iOS.
  • This method does not restrict the app's permission to operate the Audio Session.

Parameters

restriction
The SDK's operation permissions for the Audio Session. See AUDIO_SESSION_OPERATION_RESTRICTION. This parameter is a bit mask, with each bit representing a permission.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetBeautyEffectOptions

Sets beauty effect options.

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

Enables the local beauty effect and sets the beauty effect options.

Note:
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Removing this library will cause this feature to fail.
  • This feature has high performance requirements for the device. When calling this method, the SDK automatically checks the current device capabilities.

Timing

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

Parameters

enabled
Whether to enable the beauty effect:
  • true: Enable the beauty effect.
  • false: (default) Disable the beauty effect.
options
Beauty options. See BeautyOptions for details.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -4: The current device does not support this feature. Possible reasons include:
      • The current device does not meet the performance requirements for using beauty effects. Consider using a higher-performance device.
      • The current device version is lower than Android 5.0 and does not support this operation. Consider changing the device or upgrading the OS.

SetCameraAutoExposureFaceModeEnabled

Enables or disables the auto exposure feature.

public abstract int SetCameraAutoExposureFaceModeEnabled(bool enabled);

Parameters

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

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraAutoFocusFaceModeEnabled

Enables or disables face auto focus.

public abstract int SetCameraAutoFocusFaceModeEnabled(bool enabled);

By default, the SDK disables face auto focus on Android and enables it on iOS. To manually configure face auto focus, call this method.

Note: This method is for Android and iOS only.

Timing

You must call this method 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 auto focus:
  • true: Enable face auto focus.
  • false: Disable face auto focus.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraCapturerConfiguration

Sets the camera capture configuration.

public abstract int SetCameraCapturerConfiguration(CameraCapturerConfiguration config);
Note: Before adjusting the camera focal length configuration, it is recommended to call QueryCameraFocalLengthCapability to query the supported focal length capabilities of the device, and then configure accordingly. Due to limitations on some Android devices, even if the focal length type is set according to the result of QueryCameraFocalLengthCapability, the setting may not take effect.

Timing

You must call this method before starting local camera capture, such as before calling StartPreview [2/2] and JoinChannel [2/2].

Parameters

config
Camera capture configuration. See CameraCapturerConfiguration.
Note: You do not need to set the deviceId parameter in this method.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraDeviceOrientation

Sets the rotation angle of the captured video.

public abstract int SetCameraDeviceOrientation(VIDEO_SOURCE_TYPE type, VIDEO_ORIENTATION orientation);
Note:
  • (Windows only)
  • This method must be called after EnableVideo. The setting takes effect after the camera is successfully turned on, i.e., when the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • If the video capture device does not have a gravity sensor, you can call this method to manually adjust the rotation angle of the captured video.

Parameters

type
Video source type. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraExposureFactor

Sets the exposure factor of the current camera.

public abstract int SetCameraExposureFactor(float factor);

Poor or overly bright lighting conditions affect the quality of video capture. To achieve better video results, you can use this method to adjust the camera's exposure factor.

Note:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting takes effect after the camera is successfully enabled, i.e., after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • It is recommended to call IsCameraExposureSupported first to check whether the current camera supports adjusting the exposure factor.
  • When you call this method, it sets the exposure factor for the currently used camera, i.e., the one specified in SetCameraCapturerConfiguration.

Parameters

factor
Exposure factor of the camera. The default value is 0, which means using the camera's default exposure. The larger the value, the greater the exposure. If the video is overexposed, you can reduce the exposure factor; if the video is underexposed and lacks detail in dark areas, you can increase the exposure factor. If the specified value exceeds the device's supported range, the SDK automatically adjusts it to a supported value. On Android, the range is [-20.0, 20.0]; on iOS, the range is [-8.0, 8.0].

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraExposurePosition

Sets the manual exposure position.

public abstract int SetCameraExposurePosition(float positionXinView, float positionYinView);
Note:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting takes effect after the camera is successfully enabled, i.e., after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • After successfully calling this method, the local client triggers the OnCameraExposureAreaChanged callback.

Parameters

positionXinView
The X coordinate of the touch point relative to the view.
positionYinView
The Y coordinate of the touch point relative to the view.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraFocusPositionInPreview

Sets the manual focus position and triggers focus.

public abstract int SetCameraFocusPositionInPreview(float positionX, float positionY);
Note:
  • This method is for Android and iOS only.
  • You must call this method after EnableVideo. The setting takes effect after the camera is successfully enabled, i.e., after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).
  • After successfully calling this method, the local client triggers the OnCameraFocusAreaChanged callback.

Parameters

positionX
The X coordinate of the touch point relative to the view.
positionY
The Y coordinate of the touch point relative to the view.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraStabilizationMode

Sets the camera stabilization mode.

public abstract int SetCameraStabilizationMode(CAMERA_STABILIZATION_MODE mode);

Camera stabilization is disabled by default. You need to call this method to enable it and set the appropriate stabilization mode.

Note: This method is only applicable to iOS.
  • Camera stabilization only works when the video resolution is higher than 1280 × 720.
  • The higher the stabilization level, the narrower the camera's field of view and the greater the camera delay. To ensure user experience, it is recommended to set the mode parameter to CAMERA_STABILIZATION_MODE_LEVEL_1.

Scenario

In scenarios such as mobile shooting, low-light environments, or handheld shooting, you can set the camera stabilization mode to reduce the impact of camera shake and obtain more stable and clearer images.

Timing

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

Parameters

mode
Camera stabilization mode. See CAMERA_STABILIZATION_MODE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraTorchOn

Sets whether to turn on the flashlight.

public abstract int SetCameraTorchOn(bool isOn);
Note:
  • This method is applicable to Android and iOS only.
  • You must call this method after EnableVideo. The setting takes effect after the camera is successfully started, 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 flashlight:
  • true: Turn on the flashlight.
  • false: (default) Turn off the flashlight.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetCameraZoomFactor

Sets the camera zoom factor.

public abstract int SetCameraZoomFactor(float factor);

Some iOS devices have composite rear cameras consisting of multiple lenses, such as dual-camera (wide and ultra-wide) or triple-camera (wide, ultra-wide, and telephoto). For such composite lenses with ultra-wide capability, you can call SetCameraCapturerConfiguration to set cameraFocalLengthType to CAMERA_FOCAL_LENGTH_DEFAULT (0) (standard lens), and then call this method to set the zoom factor to a value less than 1.0 to achieve an ultra-wide-angle effect.

Note:
  • This method is applicable to Android and iOS only.
  • You must call this method after EnableVideo. The setting takes effect after the camera is successfully started, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Parameters

factor
Camera zoom factor. For devices that do not support ultra-wide-angle, the range is from 1.0 to the maximum zoom factor. For devices that support ultra-wide-angle, the range is from 0.5 to the maximum zoom factor. You can call GetCameraMaxZoomFactor to get the maximum supported zoom factor.

Return Values

  • On success: Returns the set factor value.
  • On failure: Return value < 0.

SetChannelProfile

Sets the channel profile.

public abstract int SetChannelProfile(CHANNEL_PROFILE_TYPE profile);

You can call this method to set the channel profile. The SDK applies different optimization strategies for different scenarios. For example, in live streaming, the SDK prioritizes video quality. The default channel profile after SDK initialization is live streaming.

Note: To ensure real-time audio and video quality, users in the same channel must use the same channel profile.

Timing

This method must be called before joining a channel.

Parameters

profile
The channel profile. See CHANNEL_PROFILE_TYPE.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter.
    • -7: The SDK is not initialized.

SetClientRole [1/2]

Sets the user role.

public abstract int SetClientRole(CLIENT_ROLE_TYPE role);

By default, the SDK sets the user role to audience. You can call this method to set the user role to broadcaster. The user role (role) determines the permissions at the SDK level, including whether the user can publish streams.

Note: When calling this method outside the channel and setting the user role to BROADCASTER, the local OnClientRoleChanged callback is not triggered.

Timing

This method can be called before or after joining a channel. If you call this method before joining the channel to set the user role to broadcaster and call SetEnable to enable video rendering, local video preview will automatically start upon joining the channel. If you call this method after joining the channel to switch user roles and the call succeeds, the SDK automatically calls MuteLocalAudioStream and MuteLocalVideoStream to update the publishing state of audio and video streams.

Parameters

role
The user role. See CLIENT_ROLE_TYPE.
Note: Users with the audience role cannot publish audio or video streams in the channel. To publish streams in a live streaming scenario, ensure the user role is switched to broadcaster.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically categorized).
    • -2: Invalid parameter.
    • -7: The SDK is not initialized.

SetClientRole [2/2]

Sets the user role and audience latency level in live streaming.

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

By default, the SDK sets the user role to audience. You can call this method to set the user role to broadcaster. The user role (role) determines the user's permissions at the SDK level, such as whether the user can publish streams. Compared to SetClientRole [1/2], this method also supports setting the audience latency level (audienceLatencyLevel). audienceLatencyLevel must be used together with role to determine the level of service a user can enjoy within their permission scope. For example, for audience users, whether to receive low-latency or ultra-low-latency video streams. Different latency levels affect billing. See Billing Strategy.

Note: When the user role is set to broadcaster, the audience latency level only supports AUDIENCE_LATENCY_LEVEL_ULTRA_LOW_LATENCY. When calling this method before joining the channel and setting role to BROADCASTER, the local OnClientRoleChanged callback is not triggered.

Timing

This method can be called before or after joining a channel. If you call this method before joining the channel to set the user role to broadcaster and call SetEnable to enable video rendering, local video preview will automatically start upon joining the channel. If you call this method after joining the channel to switch user roles and the call succeeds, the SDK automatically calls MuteLocalAudioStream and MuteLocalVideoStream to update the publishing state of audio and video streams.

Parameters

role
The user role. See CLIENT_ROLE_TYPE.
Note: Users with the audience role cannot publish audio or video streams in the channel. To publish streams in a live streaming scenario, ensure the user role is switched to broadcaster.
options
User-specific settings, including user level. See ClientRoleOptions.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically categorized).
    • -2: Invalid parameter.
    • -5: The call was rejected.
    • -7: The SDK is not initialized.

SetCloudProxy

Sets the cloud proxy service.

public abstract int SetCloudProxy(CLOUD_PROXY_TYPE proxyType);

When the user's network access is restricted by a firewall, you need to add the IP and port numbers provided by Agora to the firewall whitelist, then call this method to enable the cloud proxy and set the proxy type via the proxyType parameter. After successfully connecting to the cloud proxy, the SDK triggers the OnConnectionStateChanged (CONNECTION_STATE_CONNECTING, CONNECTION_CHANGED_SETTING_PROXY_SERVER) callback. If you want to disable the currently set Force UDP or Force TCP cloud proxy, call SetCloudProxy(NONE_PROXY). If you want to change the currently set cloud proxy type, call SetCloudProxy(NONE_PROXY) first, then call SetCloudProxy again and pass in your desired proxyType value.

Note:
  • It is recommended to call this method outside the channel.
  • If the user is in a network environment with an internal firewall, the features of CDN live streaming and media stream relay across channels are not available when using the Force UDP cloud proxy.
  • When using the Force UDP cloud proxy, the StartAudioMixing [2/2] method cannot play online audio files over HTTP. The features of CDN live streaming and media stream relay across channels use the TCP cloud proxy.

Parameters

proxyType
Cloud proxy type. See CLOUD_PROXY_TYPE. This parameter is required. If you do not assign a value, the SDK will report an error.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter.
    • -7: SDK not initialized.

SetColorEnhanceOptions

Sets the color enhancement feature.

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

Video captured by the camera may suffer from color distortion. The color enhancement feature can improve the richness and fidelity of video colors by intelligently adjusting video attributes such as saturation and contrast, making the video more vivid. You can call this method to enable the color enhancement feature and set the color enhancement effect.

Note:
  • Call this method after EnableVideo.
  • Color enhancement has certain performance requirements. If the device experiences issues such as overheating after enabling this feature, it is recommended to reduce the enhancement level to a less performance-intensive setting or disable the feature.
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Removing this library will cause this feature to fail.

Parameters

enabled
Whether to enable the color enhancement feature:
  • true: Enable color enhancement.
  • false: (default) Disable color enhancement.
options
Color enhancement options used to configure the effect. See ColorEnhanceOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetDefaultAudioRouteToSpeakerphone

Sets the default audio route.

public abstract int SetDefaultAudioRouteToSpeakerphone(bool defaultToSpeaker);
Mobile devices typically have two audio routes: the earpiece at the top with lower volume, and the speaker at the bottom with higher volume. Setting the default audio route determines whether the system uses the earpiece or speaker to play audio when no external device is connected. The system's default audio route varies by scenario:
  • Voice call: Earpiece
  • Voice live streaming: Speaker
  • Video call: Speaker
  • Video live streaming: Speaker
Calling this API allows you to change the default audio route.
Note: This method is for Android and iOS only. After setting the default audio route using this method, the actual audio route may change depending on whether an external audio device (wired or Bluetooth headset) is connected. for details.

Timing

You must call this method before joining a channel. To switch audio routes after joining a channel, call SetEnableSpeakerphone.

Parameters

defaultToSpeaker
Whether to use the speaker as the default audio route:
  • true: Set the default audio route to speaker.
  • false: Set the default audio route to earpiece.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetDirectCdnStreamingAudioConfiguration

Sets the audio encoding configuration for pushing streams directly to the CDN from the host.

public abstract int SetDirectCdnStreamingAudioConfiguration(AUDIO_PROFILE_TYPE profile);
Deprecated
Deprecated since v4.6.2.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetDirectCdnStreamingVideoConfiguration

Sets the video encoding properties when the host pushes the stream directly to the CDN.

public abstract int SetDirectCdnStreamingVideoConfiguration(VideoEncoderConfiguration config);
Deprecated
Deprecated since v4.6.2.

This method is only effective for video captured by the camera, screen sharing, or custom video sources. That is, it applies to video captured when publishCameraTrack or publishCustomVideoTrack is set to true in DirectCdnStreamingMediaOptions. If the resolution you set exceeds the range supported by your camera device, the SDK adapts based on your settings and captures, encodes, and pushes the stream using the closest resolution with the same aspect ratio as your setting. You can get the actual resolution of the pushed video stream via the OnDirectCdnStreamingStats callback.

Parameters

config
Video encoding configuration. See VideoEncoderConfiguration.
Note: When pushing the stream directly to the CDN, the SDK currently only supports setting ORIENTATION_MODE to landscape (ORIENTATION_MODE_FIXED_LANDSCAPE) or portrait (ORIENTATION_MODE_FIXED_PORTRAIT) mode.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

SetDualStreamMode [1/2]

Sets the dual-stream mode on the sender.

public abstract int SetDualStreamMode(SIMULCAST_STREAM_MODE mode);
By default, the SDK enables adaptive low-quality stream mode (AUTO_SIMULCAST_STREAM) on the sender, meaning the sender does not actively send low-quality streams. Receivers with host identity can call SetRemoteVideoStreamType to request a low-quality stream, and the sender starts sending it upon receiving the request.
  • If you want to change this behavior, call this method and set mode to DISABLE_SIMULCAST_STREAM (never send low-quality stream) or ENABLE_SIMULCAST_STREAM (always send low-quality stream).
  • If you want to revert to the default behavior after changing it, call this method again and set mode to AUTO_SIMULCAST_STREAM.
Note: The differences and relationships between this method and EnableDualStreamMode [1/2] are as follows:
  • Calling this method and setting mode to DISABLE_SIMULCAST_STREAM has the same effect as setting EnableDualStreamMode [1/2] to false.
  • Calling this method and setting mode to ENABLE_SIMULCAST_STREAM has the same effect as setting EnableDualStreamMode [1/2] to true.
  • Both methods can be called before or after joining a channel. If both are used, the settings from the later call take effect.

Parameters

mode
The mode for sending video streams. See SIMULCAST_STREAM_MODE.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

SetDualStreamMode [2/2]

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

public abstract int SetDualStreamMode(SIMULCAST_STREAM_MODE mode, SimulcastStreamConfig streamConfig);
By default, the SDK enables adaptive low-quality stream mode (AUTO_SIMULCAST_STREAM) on the sender, meaning the sender does not actively send low-quality streams. Receivers with host identity can call SetRemoteVideoStreamType to request a low-quality stream, and the sender starts sending it upon receiving the request.
  • If you want to change this behavior, call this method and set mode to DISABLE_SIMULCAST_STREAM (never send low-quality stream) or ENABLE_SIMULCAST_STREAM (always send low-quality stream).
  • If you want to revert to the default behavior after changing it, call this method again and set mode to AUTO_SIMULCAST_STREAM.
Compared to SetDualStreamMode [1/2], this method also allows you to configure the low-quality video stream. The SDK sends the low-quality stream based on the configuration in streamConfig.
Note: The differences and relationships between this method and EnableDualStreamMode [2/2] are as follows:
  • Calling this method and setting mode to DISABLE_SIMULCAST_STREAM has the same effect as calling EnableDualStreamMode [2/2] with enabled set to false.
  • Calling this method and setting mode to ENABLE_SIMULCAST_STREAM has the same effect as calling EnableDualStreamMode [2/2] with enabled set to true.
  • Both methods can be called before or after joining a channel. If both are used, the settings from the later call take effect.

Parameters

mode
The mode for sending video streams. See SIMULCAST_STREAM_MODE.
streamConfig
Configuration of the low-quality video stream. See SimulcastStreamConfig.
Note: When mode is set to DISABLE_SIMULCAST_STREAM, setting streamConfig has no effect.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

SetEarMonitoringAudioFrameParameters

Sets the data format for the OnEarMonitoringAudioFrame callback.

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

This method sets the data format for the OnEarMonitoringAudioFrame callback.

Note:
  • 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 using the samplesPerCall, sampleRate, and channel parameters in this method. The formula is: sampling interval = samplesPerCall / (sampleRate × channel). Make sure the sampling interval is no less than 0.01 seconds. The SDK triggers the OnEarMonitoringAudioFrame callback based on this sampling interval.

Parameters

sampleRate
The sampling rate (Hz) of the audio reported in OnEarMonitoringAudioFrame. Can be set to 8000, 16000, 32000, 44100, or 48000.
channel
The number of channels of the audio reported in OnEarMonitoringAudioFrame. Can be set to 1 or 2:
  • 1: Mono.
  • 2: Stereo.
mode
The operation mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
samplesPerCall
The number of audio samples reported in OnEarMonitoringAudioFrame, typically 1024 in RTMP streaming scenarios.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and suggested solutions.

SetEffectPosition

Sets the playback position of the specified audio effect file.

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

After successful setting, the local audio effect file will start playing from the specified position.

Note: This method must be called after playEffect.

Parameters

soundId
The ID of the audio effect. Each audio effect has a unique ID.
pos
The playback position of the audio effect file, in milliseconds.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetEffectsVolume

Sets the playback volume of audio effect files.

public abstract int SetEffectsVolume(int volume);

Timing

This method must be called after PlayEffect.

Parameters

volume
Playback volume. The range is [0,100]. The default value is 100, which means the original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetEnableSpeakerphone

Enables or disables speakerphone playback.

public abstract int SetEnableSpeakerphone(bool speakerOn);

For the SDK's default audio routes in different scenarios,.

Note: This method is for Android and iOS only.
  • This method only sets the audio route used by the user in the current channel. It does not affect the SDK's default audio route. When the user leaves the current channel and joins a new one, the SDK's default audio route is used again.
  • If the user uses external audio playback devices such as Bluetooth or wired headsets, this method has no effect. Audio will only be played through the external device. If multiple external devices are connected, audio is played through the most recently connected one.

Scenario

If the SDK's default audio route or the setting of setDefaultAudioRouteToSpeakerphone does not meet your needs, you can call this method to switch the current audio route.

Timing

You must call this method after joining a channel.

Parameters

speakerOn
Whether to enable speakerphone playback:
  • true: Enable. Audio route is speaker.
  • false: Disable. Audio route is earpiece.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetExtensionProperty

Sets the extension property.

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

After enabling an extension, you can call this method to set its properties.

Note: To set properties for multiple extensions, call this method multiple times.

Timing

Call this method after calling EnableExtension to enable the extension.

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
key
The key of the extension property.
value
The value corresponding to the extension property key.
type
The media source type of the extension. See MEDIA_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

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 properties of the extension provider and initialize related parameters based on the provider type.

Note: To set properties for multiple extension providers, call this method multiple times.

Timing

Call this method after RegisterExtension and before EnableExtension.

Parameters

provider
The name of the extension provider.
key
The key of the extension property.
value
The value corresponding to the extension property key.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetExternalMediaProjection

Sets an external MediaProjection to capture screen video stream.

public abstract int SetExternalMediaProjection(IntPtr mediaProjection);

After successfully calling this method, the external MediaProjection you set will replace the one requested by the SDK to capture the screen video stream. When screen sharing stops or IRtcEngine is destroyed, the SDK automatically releases the MediaProjection.

Note: This method is for Android only. You must request MediaProjection permission before calling this method.

Scenario

If you are capable of obtaining MediaProjection yourself, you can use your own MediaProjection to replace the one obtained by the SDK. Here are two usage scenarios:
  • On customized system devices, you can avoid system pop-ups (which require user permission for screen capture) and directly start screen capture.
  • In a screen sharing process with one or more subprocesses, this avoids errors caused by creating objects in subprocesses that may lead to capture failure.

Timing

This method must be called before StartScreenCapture [1/2].

Parameters

mediaProjection
A MediaProjection object used to capture the screen video stream.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetExternalRemoteEglContext

Sets the EGL context for rendering remote video streams.

public abstract int SetExternalRemoteEglContext(IntPtr eglContext);

By calling this method, developers can replace the SDK's default internal remote EGL context, making it easier to manage a unified EGL context. When the engine is destroyed, the SDK automatically releases the EGL context.

Note: This method is only applicable to Android.

Scenario

This method is applicable in scenarios where remote video rendering is done using video data in Texture format.

Timing

You need to call this method before joining the channel.

Parameters

eglContext
The EGL context object used for rendering remote video streams.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetFaceShapeAreaOptions

Sets face shaping area options and specifies the media source.

public abstract int SetFaceShapeAreaOptions(FaceShapeAreaOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

If the preset face shaping effect implemented in the SetFaceShapeBeautyOptions method does not meet expectations, you can use this method to set the face shaping area options and fine-tune each part of the face individually for more refined effects.

Note: Face shaping is a value-added service. For billing details, see Billing Strategy.
  • On Android, this method applies to Android 4.4 and later only.
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Removing this library will cause this feature to fail.
  • This feature has high performance requirements for the device. When calling this method, the SDK automatically checks the current device capabilities.

Timing

Call this method after SetFaceShapeBeautyOptions.

Parameters

options
Face shaping area options. See FaceShapeAreaOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When using the camera to capture local video, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -4: The current device does not support this feature. Possible reasons include:
      • The current device does not meet the performance requirements for using beauty effects. Consider using a higher-performance device.
      • The current device version is lower than Android 4.4 and does not support this operation. Consider changing the device or upgrading the OS.

SetFaceShapeBeautyOptions

Sets face shaping effect options and specifies the media source.

public abstract int SetFaceShapeBeautyOptions(bool enabled, FaceShapeBeautyOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

Call this method to enhance facial features using preset parameters to achieve effects such as face slimming, eye enlarging, and nose slimming in one go. You can also fine-tune the intensity of the overall enhancement.

Note: Face shaping is a value-added service. For billing details, see Billing Strategy.
  • On Android, this method applies to Android 4.4 and later versions only.
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Deleting this library will cause the feature to fail.
  • This feature requires high device performance. When you call this method, the SDK automatically checks the device capabilities.

Timing

Call this method after EnableVideo.

Parameters

enabled
Whether to enable the face shaping effect:
  • true: Enable face shaping.
  • false: (Default) Disable face shaping.
options
Face shaping style options. See FaceShapeBeautyOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When capturing local video using the camera, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -4: The current device does not support this feature. Possible reasons include:
      • The device does not meet the performance requirements for beauty effects. Consider using a higher-performance device.
      • The device runs a version lower than Android 4.4, which does not support this operation. Consider upgrading the OS or using a different device.

SetFilterEffectOptions

Sets filter effect options and specifies the media source.

public abstract int SetFilterEffectOptions(bool enabled, FilterEffectOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);
Note:
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Deleting this library will cause the feature to fail.
  • This feature requires high device performance. When you call this method, the SDK automatically checks the device capabilities.

Timing

Call this method after EnableVideo.

Parameters

enabled
Whether to enable the filter effect:
  • true: Enable filter effect.
  • false: (Default) Disable filter effect.
options
Filter options. See FilterEffectOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When capturing local video using the camera, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetHeadphoneEQParameters

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

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

In spatial audio scenarios, if the preset headphone equalizer effect set by calling SetHeadphoneEQPreset does not meet expectations, you can further adjust the headphone equalizer effect by calling this method.

Parameters

lowGain
Low frequency parameter of the headphone equalizer. Value range: [-10,10]. The higher the value, the deeper the sound.
highGain
High frequency parameter of the headphone equalizer. Value range: [-10,10]. The higher the value, the sharper the sound.

Return Values

  • 0: Success.
  • < 0: Failure
    • -1: General error (not specifically categorized).

SetHeadphoneEQPreset

Sets a preset headphone equalizer effect.

public abstract int SetHeadphoneEQPreset(HEADPHONE_EQUALIZER_PRESET preset);

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

Note: If your headphones already have a good equalizer effect, calling this method may not significantly improve the experience and may even degrade it.

Parameters

preset
Preset headphone equalizer effect. See HEADPHONE_EQUALIZER_PRESET.

Return Values

  • 0: Success.
  • < 0: Failure
    • -1: General error (not specifically categorized).

SetInEarMonitoringVolume

Sets the in-ear monitoring volume.

public abstract int SetInEarMonitoringVolume(int volume);

Timing

Can be called before or after joining a channel.

Parameters

volume
Volume, range is [0,400].
  • 0: Mute.
  • 100: (Default) Original volume.
  • 400: Four times the original volume, with built-in overflow protection.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter setting, e.g., in-ear monitoring volume is out of range (< 0 or > 400).

SetLocalRenderMode [1/2]

Sets the local view display mode.

public abstract int SetLocalRenderMode(RENDER_MODE_TYPE renderMode);
Deprecated
Deprecated: This method is deprecated. Use SetLocalRenderMode [2/2] instead.

This method sets the local view display mode. The app can call this method multiple times to change the display mode.

Parameters

renderMode
Local view display mode. See RENDER_MODE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalRenderMode [2/2]

Updates the local view display mode.

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

After initializing the local user view, you can call this method to update the rendering and mirror mode of the local user view. This method only affects what the local user sees and does not affect the publishing of the local video.

Timing

  • Call this method after calling SetupLocalVideo to initialize the local view.
  • You can call this method multiple times during a call to update the local user view display mode.

Parameters

renderMode
Local view display mode. See RENDER_MODE_TYPE.
mirrorMode
Mirror mode of the local view. See VIDEO_MIRROR_MODE_TYPE.
Note: This parameter only takes effect when the SDK handles rendering. If you want to set view mirroring, you can set the GameObject's scaleX to -1 or +1. If you use the front camera, the local user view mirror mode is enabled by default; if you use the rear camera, it is disabled by default.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalRenderTargetFps

Sets the maximum frame rate for local video rendering.

public abstract int SetLocalRenderTargetFps(VIDEO_SOURCE_TYPE sourceType, int targetFps);

Scenario

In scenarios with low frame rate requirements for video rendering (e.g., screen sharing, online education), you can call this method to set the maximum frame rate for local video rendering. The SDK will try to match the actual rendering frame rate to this value to reduce CPU usage and improve system performance.

Timing

This method can be called before or after joining a channel.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.
targetFps
Maximum rendering frame rate (fps). Supported values: 1, 7, 10, 15, 24, 30, 60.
Note: Set this parameter to a value lower than the actual video frame rate. Otherwise, the setting will not take effect.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVideoDataSourcePosition

Sets the observation position of the local video frame.

public abstract int SetLocalVideoDataSourcePosition(VIDEO_MODULE_POSITION position);
Note: This method only supports observing local video data rendered through VideoSurface and its subclasses.

Timing

This method must be called before creating the first VideoSurface view.

Parameters

position
Observation position of the video frame. See VIDEO_MODULE_POSITION.
Note:
  • Currently, this method only supports setting the observation position to POSITION_POST_CAPTURER or POSITION_PRE_ENCODER.
  • Video frames obtained at POSITION_POST_CAPTURER are uncropped and have higher frame rates, while frames at POSITION_PRE_ENCODER are cropped before sending and have frame rates less than or equal to the camera capture rate.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVideoMirrorMode

Sets the local video mirror mode.

public abstract int SetLocalVideoMirrorMode(VIDEO_MIRROR_MODE_TYPE mirrorMode);
Deprecated
Deprecated: This method is deprecated.

Parameters

mirrorMode
Local video mirror mode. See VIDEO_MIRROR_MODE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVoiceEqualization

Sets the local voice equalization.

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

Timing

Can be called before and after joining a channel.

Parameters

bandFrequency
Index of the band frequency. The value range is [0,9], representing 10 bands of the equalizer. The corresponding center frequencies are [31, 62, 125, 250, 500, 1k, 2k, 4k, 8k, 16k] Hz. See AUDIO_EQUALIZATION_BAND_FREQUENCY.
bandGain
Gain of each band in dB. The value range is [-15,15], with a default of 0.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVoiceFormant

Sets the formant ratio to change the voice timbre.

public abstract int SetLocalVoiceFormant(double formantRatio);

The formant ratio is a parameter that affects the timbre of the voice. A smaller value results in a deeper sound, while a larger value results in a sharper sound. After setting the formant ratio, all users in the channel can hear the effect. If you want to change both the timbre and pitch, Agora recommends using SetLocalVoicePitch together.

Scenario

In scenarios like voice live streaming, voice chat rooms, and karaoke rooms, you can call this method to set the local voice's formant ratio to change the timbre.

Timing

Can be called before and after joining a channel.

Parameters

formantRatio
Formant ratio, value range [-1.0, 1.0]. Default is 0.0, which means no change to the original timbre.
Note: Agora recommends using values in the range [-0.4, 0.6]. Values outside this range may result in poor audio quality.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVoicePitch

Sets the local voice pitch.

public abstract int SetLocalVoicePitch(double pitch);

Timing

Can be called before and after joining a channel.

Parameters

pitch
Voice frequency. Can be set within the range [0.5, 2.0]. The smaller the value, the lower the pitch. The default value is 1.0, which means no pitch change.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLocalVoiceReverb

Sets the local audio reverb.

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

The SDK provides a simpler method SetAudioEffectPreset to directly apply preset reverb effects such as Pop, R&B, and KTV.

Note: This method can be called before and after joining a channel.

Parameters

reverbKey
Reverb effect key. This method supports 5 reverb effect keys. See AUDIO_REVERB_TYPE.
value
Value corresponding to each reverb effect key.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLogFile

Sets the log file.

public abstract int SetLogFile(string filePath);
Deprecated
Deprecated: This method is deprecated. Please set the log file path via the context parameter when calling Initialize.

Sets the output log file for the SDK. All logs generated during SDK runtime will be written to this file.

Note: The app must ensure that the specified directory exists and is writable.

Timing

This method must be called immediately after Initialize, otherwise the output logs may be incomplete.

Parameters

filePath
Full path of the log file. The log file is UTF-8 encoded.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLogFileSize

Sets the size of the SDK output log file.

public abstract int SetLogFileSize(uint fileSizeInKBytes);
Deprecated
Deprecated: This method is deprecated. Please use the logConfig parameter in Initialize to set the log file size.
By default, the SDK generates 5 SDK log files and 5 API call log files, as follows:
  • SDK log file names: agorasdk.log, agorasdk.1.log, agorasdk.2.log, agorasdk.3.log, agorasdk.4.log.
  • API call log file names: agoraapi.log, agoraapi.1.log, agoraapi.2.log, agoraapi.3.log, agoraapi.4.log.
  • Each SDK log file has a default size of 2,048 KB; each API call log file also has a default size of 2,048 KB. All log files are UTF-8 encoded.
  • The latest logs are always written to agorasdk.log and agoraapi.log.
  • When agorasdk.log is full, the SDK performs the following operations:
    1. Delete the agorasdk.4.log file (if it exists).
    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 agoraapi.log are the same as for agorasdk.log.
Note: This method only sets the size of the agorasdk.log file and does not affect agoraapi.log.

Parameters

fileSizeInKBytes
Size of a single agorasdk.log file in KB. The valid range is [128,20480], and the default value is 2,048 KB. If you set fileSizeInKByte to less than 128 KB, the SDK automatically adjusts it to 128 KB; if you set it to more than 20,480 KB, the SDK automatically adjusts it to 20,480 KB.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLogFilter

Sets the log output level.

public abstract int SetLogFilter(uint filter);
Deprecated
Deprecated: Please use logConfig in Initialize instead.

Parameters

filter
Log filter level.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLogLevel

Sets the SDK log output level.

public abstract int SetLogLevel(LOG_LEVEL level);
Deprecated
Deprecated: This method is deprecated. Please set the log output level via the context parameter when calling Initialize.

Select a level to see log information of that level.

Parameters

level
Log level. See LOG_LEVEL.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetLowlightEnhanceOptions

Sets the low-light enhancement feature.

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

You can call this method to enable the low-light enhancement feature and set its effect.

Note:
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Deleting this library will cause the feature to fail.
  • Low-light enhancement requires certain device performance. If the device overheats after enabling this feature, it is recommended to reduce the enhancement level or disable the feature.
  • To achieve high-quality low-light enhancement (LOW_LIGHT_ENHANCE_LEVEL_HIGH_QUALITY), you must first call SetVideoDenoiserOptions to enable video denoising. The specific mapping is as follows:
    • When low-light enhancement is in auto mode (LOW_LIGHT_ENHANCE_AUTO), video denoising must be set to high quality (VIDEO_DENOISER_LEVEL_HIGH_QUALITY) and auto mode (VIDEO_DENOISER_AUTO).
    • When low-light enhancement is in manual mode (LOW_LIGHT_ENHANCE_MANUAL), video denoising must be set to high quality (VIDEO_DENOISER_LEVEL_HIGH_QUALITY) and manual mode (VIDEO_DENOISER_MANUAL).

Scenario

Low-light enhancement can adaptively adjust the video brightness in low-light conditions (such as backlight, cloudy days, or dark scenes) and uneven lighting environments to restore or highlight image details and improve the overall visual quality.

Timing

Call this method after EnableVideo.

Parameters

enabled
Whether to enable low-light enhancement:
  • true: Enable low-light enhancement.
  • false: (Default) Disable low-light enhancement.
options
Low-light enhancement options for setting the effect. See LowlightEnhanceOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When capturing local video using the camera, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetMaxMetadataSize

Sets the maximum size of media metadata.

public abstract int SetMaxMetadataSize(int size);

After calling RegisterMediaMetadataObserver, you can call this method to set the maximum size of media metadata.

Parameters

size
Maximum size of the media metadata.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.

SetMixedAudioFrameParameters

Sets the raw audio data format after mixing the captured and playback audio.

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

The SDK calculates the sampling interval using the samplesPerCall, sampleRate, and channel parameters in this method. The formula is: sampling interval = samplesPerCall / (sampleRate × channel). Make sure the sampling interval is no less than 0.01 seconds. The SDK triggers the OnMixedAudioFrame callback based on this sampling interval.

Timing

You need to call this method before joining a channel.

Parameters

sampleRate
The sampling rate (Hz) of the audio data. Can be set to 8000, 16000, 32000, 44100, or 48000.
channel
The number of channels of the audio data. Can be set to 1 or 2:
  • 1: Mono.
  • 2: Stereo.
samplesPerCall
The number of audio samples. Typically 1024 in RTMP streaming scenarios.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and suggested solutions.

SetParameters [1/2]

The SDK's JSON configuration used for technical preview or custom features.

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

Parameters

key
Key value.
value
Value.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetPlaybackAudioFrameBeforeMixingParameters [1/2]

Sets the raw audio playback data format before mixing.

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

The SDK triggers the OnPlaybackAudioFrameBeforeMixing callback based on this sampling interval.

Timing

You need to call this method before joining a channel.

Parameters

sampleRate
The sampling rate (Hz) of the audio data. Can be set to 8000, 16000, 32000, 44100, or 48000.
channel
The number of channels of the audio data. Can be set to 1 or 2:
  • 1: Mono.
  • 2: Stereo.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and suggested solutions.

SetPlaybackAudioFrameBeforeMixingParameters [2/2]

Sets the raw audio playback data format before mixing.

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

The SDK triggers the OnPlaybackAudioFrameBeforeMixing callback based on this sampling interval.

Timing

You need to call this method before joining a channel.

Parameters

sampleRate
The sampling rate (Hz) of the audio data. Can be set to 8000, 16000, 32000, 44100, or 48000.
channel
The number of channels of the audio data. Can be set to 1 or 2:
  • 1: Mono.
  • 2: Stereo.
samplesPerCall
Sets the number of audio samples returned in the onPlaybackAudioFrameBeforeMixing callback. In RTMP streaming scenarios, it is recommended to set this to 1024.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and suggested solutions.

SetPlaybackAudioFrameParameters

Sets the format of the playback raw audio data.

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

The SDK calculates the sampling interval using the samplesPerCall, sampleRate, and channel parameters in this method. The formula is: sampling interval = samplesPerCall / (sampleRate × channel). Make sure the sampling interval is no less than 0.01 seconds. The SDK triggers the OnPlaybackAudioFrame callback based on this sampling interval.

Timing

You must call this method before joining a channel.

Parameters

sampleRate
The sample rate (Hz) of the audio data. You can set it to 8000, 16000, 24000, 32000, 44100, or 48000.
channel
The number of audio channels. You can set it to 1 or 2:
  • 1: Mono.
  • 2: Stereo.
mode
The operation mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
samplesPerCall
The number of audio samples per call, typically 1024 in scenarios such as CDN streaming.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetRecordingAudioFrameParameters

Sets the format of the recorded raw audio data.

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

The SDK calculates the sampling interval using the samplesPerCall, sampleRate, and channel parameters in this method. The formula is: sampling interval = samplesPerCall / (sampleRate × channel). Make sure the sampling interval is no less than 0.01 seconds. The SDK triggers the OnRecordAudioFrame callback based on this sampling interval.

Timing

You must call this method before joining a channel.

Parameters

sampleRate
The sample rate (Hz) of the audio data. You can set it to 8000, 16000, 32000, 44100, or 48000.
channel
The number of audio channels. You can set it to 1 or 2:
  • 1: Mono.
  • 2: Stereo.
mode
The operation mode of the audio frame. See RAW_AUDIO_FRAME_OP_MODE_TYPE.
samplesPerCall
The number of audio samples per call, typically 1024 in scenarios such as CDN streaming.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

SetRemoteDefaultVideoStreamType

Sets the default video stream type to subscribe to.

public abstract int SetRemoteDefaultVideoStreamType(VIDEO_STREAM_TYPE streamType);
Depending on the sender's default behavior and the specific configuration of SetDualStreamMode [2/2], the receiver's behavior when calling this method is as follows:
  • By default, the SDK enables small stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sender side, meaning the sender only sends the high-quality stream. Only receivers with host roles can call this method to request the low-quality stream. Once the sender receives the request, it starts sending the low-quality stream automatically. At this point, all users in the channel can call this method to switch to the low-quality stream subscription mode.
  • If the sender calls SetDualStreamMode [2/2] and sets mode to DISABLE_SIMULCAST_STREAM (never send low-quality stream), this method has no effect.
  • If the sender calls SetDualStreamMode [2/2] and sets mode to ENABLE_SIMULCAST_STREAM (always send low-quality stream), both host and audience roles on the receiver side can call this method to switch to low-quality stream subscription mode.
When receiving a low-quality video stream, the SDK dynamically adjusts the video stream size based on the size of the video window to save bandwidth and computing resources. The aspect ratio of the low-quality stream is the same as that of the high-quality stream. Based on the current high-quality stream's aspect ratio, the system automatically assigns resolution, frame rate, and bitrate for the low-quality stream.
Note: If you call both this method and SetRemoteVideoStreamType, the SDK uses the configuration in SetRemoteVideoStreamType.

Timing

This method can only be called before joining a channel. The SDK does not support changing the default video stream type after joining a channel.

Parameters

streamType
The default video stream type to subscribe to: VIDEO_STREAM_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteRenderMode

Updates the remote view display mode.

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

After initializing the remote user view, you can call this method to update the rendering and mirror mode of the remote user view as displayed locally. This method only affects what the local user sees.

Note:
  • You can call this method multiple times during a call to update the remote user view display mode.

Parameters

uid
Remote user ID.
renderMode
Rendering mode of the remote user view. See RENDER_MODE_TYPE.
mirrorMode
Mirror mode of the remote user view. See VIDEO_MIRROR_MODE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteRenderTargetFps

Sets the maximum frame rate for remote video rendering.

public abstract int SetRemoteRenderTargetFps(int targetFps);

Scenario

In scenarios where high video rendering frame rate is not required (e.g., screen sharing, online education), or when the remote user is using mid- to low-end devices, you can call this method to set the maximum frame rate for remote video rendering. The SDK will try to match the actual rendering frame rate to this value to reduce CPU usage and improve system performance.

Timing

This method can be called before or after joining a channel.

Parameters

targetFps
Maximum rendering frame rate (fps). Supported values: 1, 7, 10, 15, 24, 30, 60.
Note: Set this parameter to a value lower than the actual video frame rate. Otherwise, the setting will not take effect.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteSubscribeFallbackOption

Sets the fallback option for subscribed audio and video streams under poor network conditions.

public abstract int SetRemoteSubscribeFallbackOption(STREAM_FALLBACK_OPTIONS option);

In poor network conditions, the quality of real-time audio and video communication deteriorates. You can call this method and set option to STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW or STREAM_FALLBACK_OPTION_AUDIO_ONLY. The SDK will switch the video stream to a lower stream or disable the video stream when the downlink network is poor and the audio/video quality is severely affected, ensuring audio quality. Meanwhile, the SDK continuously monitors network conditions and resumes subscription to audio and video streams when the network improves. When the subscribed stream falls back to audio only or recovers from audio to audio and video, the SDK triggers the OnRemoteSubscribeFallbackToAudioOnly callback.

Parameters

option
Fallback option for the subscribed stream. See STREAM_FALLBACK_OPTIONS.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteUserSpatialAudioParams

Sets the spatial audio parameters for a remote user.

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

This method must be called after EnableSpatialAudio. After successfully setting the spatial audio parameters for the remote user, the local user will hear the remote user with spatial effects.

Parameters

uid
User ID. Must match the user ID used when joining the channel.
param
Spatial audio parameters. See SpatialAudioParams.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteVideoStreamType

Sets the video stream type to subscribe to.

public abstract int SetRemoteVideoStreamType(uint uid, VIDEO_STREAM_TYPE streamType);
Depending on the sender's default behavior and the specific configuration of SetDualStreamMode [2/2], the receiver's behavior when calling this method is as follows:
  • By default, the SDK enables small stream adaptive mode (AUTO_SIMULCAST_STREAM) on the sender side, meaning the sender only sends the high-quality stream. Only receivers with host roles can call this method to request the low-quality stream. Once the sender receives the request, it starts sending the low-quality stream automatically. At this point, all users in the channel can call this method to switch to the low-quality stream subscription mode.
  • If the sender calls SetDualStreamMode [2/2] and sets mode to DISABLE_SIMULCAST_STREAM (never send low-quality stream), this method has no effect.
  • If the sender calls SetDualStreamMode [2/2] and sets mode to ENABLE_SIMULCAST_STREAM (always send low-quality stream), both host and audience roles on the receiver side can call this method to switch to low-quality stream subscription mode.
When receiving a low-quality video stream, the SDK dynamically adjusts the video stream size based on the size of the video window to save bandwidth and computing resources. The aspect ratio of the low-quality stream is the same as that of the high-quality stream. Based on the current high-quality stream's aspect ratio, the system automatically assigns resolution, frame rate, and bitrate for the low-quality stream.
Note:
  • This method can be called before or after joining a channel.
  • If you call both this method and SetRemoteDefaultVideoStreamType, the SDK uses the configuration in this method.

Parameters

uid
User ID.
streamType
Video stream type: VIDEO_STREAM_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteVideoSubscriptionOptions

Sets the subscription options for the remote video stream.

public abstract int SetRemoteVideoSubscriptionOptions(uint uid, VideoSubscriptionOptions options);
When the remote user sends dual streams, you can call this method to set the subscription options for the remote video stream. The SDK's default subscription behavior for remote video streams depends on the type of video observer registered:
  • If IVideoFrameObserver is registered, both raw and encoded data are subscribed to by default.
  • If IVideoEncodedFrameObserver is registered, only encoded data is subscribed to by default.
  • If both observers are registered, the default follows the one registered later. For example, if IVideoFrameObserver is registered later, both raw and encoded data are subscribed to by default.
If you want to change the default behavior above or set different subscription options for different uids, you can call this method.

Parameters

uid
The remote user ID.
options
Subscription settings for the video stream. See VideoSubscriptionOptions.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRemoteVoicePosition

Sets the 2D position of a remote user's voice, i.e., horizontal plane position.

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

Sets the 2D position and volume of a remote user's voice to help the local user perceive directionality. By calling this API to set the position of a remote user's voice, the difference between the left and right audio channels creates a sense of direction, allowing the user to determine the real-time position of the remote user. In multiplayer online games, such as battle royale games, this method can effectively enhance the spatial awareness of game characters and simulate real scenarios.

Note:
  • Before using this method, call EnableSoundPositionIndication to enable stereo sound for remote users.
  • For the best listening experience, it is recommended to use wired headphones when using this method.
  • This method must be called after joining a channel.

Parameters

uid
The ID of the remote user
pan
Sets the 2D position of the remote user's voice. Range: [-1.0, 1.0]:
  • (Default) 0.0: Voice appears in front.
  • -1.0: Voice appears on the left.
  • 1.0: Voice appears on the right.
gain
Sets the volume of the remote user's voice. Range: [0.0, 100.0], default is 100.0, indicating the user's original volume. The smaller the value, the lower the volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetRouteInCommunicationMode

Selects the audio route in communication volume mode.

public abstract int SetRouteInCommunicationMode(int route);

This method is used in communication volume mode (MODE_IN_COMMUNICATION) to switch the audio route from a Bluetooth headset to the earpiece, wired headset, or speaker.

Note: This method is for Android only. Using this method together with SetEnableSpeakerphone may cause conflicts. Agora recommends using SetRouteInCommunicationMode alone.

Timing

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

Parameters

route
The desired audio route:
  • -1: System default audio route.
  • 0: Headset with microphone.
  • 1: Earpiece.
  • 2: Headset without microphone.
  • 3: Built-in speaker.
  • 4: (Not supported yet) External speaker.
  • 5: Bluetooth headset.
  • 6: USB device.

Return Values

No practical significance.

SetScreenCaptureContentHint

Sets the content type for screen sharing.

public abstract int SetScreenCaptureContentHint(VIDEO_CONTENT_HINT contentHint);

The SDK uses different algorithms to optimize the sharing experience based on the content type. If you do not call this method, the SDK sets the content type to CONTENT_HINT_NONE by default.

Note: This method can be called before or after starting screen sharing.

Parameters

contentHint
The content type for screen sharing. See VIDEO_CONTENT_HINT.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameter.
    • -8: Invalid screen sharing state. Possibly because you are already sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing and then restart screen sharing.

SetScreenCaptureScenario

Sets the screen sharing scenario.

public abstract int SetScreenCaptureScenario(SCREEN_SCENARIO_TYPE screenScenario);

When starting screen or window sharing, you can call this method to set the screen sharing scenario. The SDK adjusts the quality of the shared content based on the scenario.

Note: Agora recommends calling this method before joining a channel.

Parameters

screenScenario
The screen sharing scenario. See SCREEN_SCENARIO_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetSubscribeAudioAllowlist

Sets the audio subscription allowlist.

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

You can call this method to specify the audio streams you want to subscribe to.

Note:
  • You can call this method either before or after joining a channel.
  • The audio subscription allowlist is not affected by MuteRemoteAudioStream, MuteAllRemoteAudioStreams, or the autoSubscribeAudio setting in ChannelMediaOptions.
  • After setting the allowlist, it remains effective even if you leave and rejoin the channel.
  • If a user is in both the audio subscription allowlist and blocklist, only the blocklist takes effect.

Parameters

uidList
The list of user IDs in the audio subscription allowlist. If you want to subscribe to the audio stream of a specific user, add the user's ID to this list. To remove a user from the allowlist, you need to call SetSubscribeAudioAllowlist again with an updated list that does not include the uid of the user you want to remove.
uidNumber
The number of users in the allowlist.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetSubscribeAudioBlocklist

Sets the audio subscription blocklist.

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

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

Note:
  • You can call this method before or after joining a channel.
  • The audio subscription blocklist is not affected by MuteRemoteAudioStream, MuteAllRemoteAudioStreams, or autoSubscribeAudio in ChannelMediaOptions.
  • After setting the blocklist, it remains effective even if you leave and rejoin the channel.
  • If a user appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.

Parameters

uidList
The list of user IDs in the audio subscription blocklist. If you want to block the audio stream from a specific user, add the user's ID to this list. To remove a user from the blocklist, you need to call SetSubscribeAudioBlocklist again to update the list so that it no longer includes the user's uid.
uidNumber
The number of users in the audio subscription blocklist.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetSubscribeVideoAllowlist

Sets the video subscription allowlist.

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

You can call this method to specify the video streams you want to subscribe to.

Note:
  • You can call this method before or after joining a channel.
  • The video subscription allowlist is not affected by MuteRemoteVideoStream, MuteAllRemoteVideoStreams, or autoSubscribeVideo in ChannelMediaOptions.
  • After setting the allowlist, it remains effective even if you leave and rejoin the channel.
  • If a user appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.

Parameters

uidList
The list of user IDs in the video subscription allowlist. If you want to subscribe only to the video stream from a specific user, add the user's ID to this list. To remove a user from the allowlist, you need to call SetSubscribeVideoAllowlist again to update the video subscription allowlist so that it no longer includes the user's uid.
uidNumber
The number of users in the video subscription allowlist.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetSubscribeVideoBlocklist

Sets the video subscription blocklist.

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

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

Note:
  • You can call this method before or after joining a channel.
  • The video subscription blocklist is not affected by MuteRemoteVideoStream, MuteAllRemoteVideoStreams, or autoSubscribeVideo in ChannelMediaOptions.
  • After setting the blocklist, it remains effective even if you leave and rejoin the channel.
  • If a user appears in both the audio subscription blocklist and allowlist, only the blocklist takes effect.

Parameters

uidList
The list of user IDs in the video subscription blocklist. If you want to block the video stream from a specific user, add the user's ID to this list. To remove a user from the blocklist, you need to call SetSubscribeVideoBlocklist again to update the list so that it no longer includes the user's uid.
uidNumber
The number of users in the video subscription blocklist.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetVideoDenoiserOptions

Sets the video denoising feature.

public abstract int SetVideoDenoiserOptions(bool enabled, VideoDenoiserOptions options, MEDIA_SOURCE_TYPE type = MEDIA_SOURCE_TYPE.PRIMARY_CAMERA_SOURCE);

You can call this method to enable the video denoising feature and set its effect.

Note: If the denoising strength provided by this method does not meet your needs, Agora recommends that you call the SetBeautyEffectOptions method to enable the beauty smoothing feature for better video denoising. Recommended BeautyOptions settings for strong denoising effect:
  • lighteningContrastLevel: LIGHTENING_CONTRAST_NORMAL
  • lighteningLevel: 0.0
  • smoothnessLevel: 0.5
  • rednessLevel: 0.0
  • sharpnessLevel: 0.1
  • This method depends on the video enhancement dynamic library libagora_clear_vision_extension.dll. Deleting this library will cause the feature to fail.
  • Video denoising requires certain device performance. If the device overheats after enabling this feature, it is recommended to reduce the denoising level or disable the feature.

Scenario

Poor lighting and low-end video capture devices can cause noticeable noise in video images, affecting video quality. In real-time interactive scenarios, video noise can also consume bitrate resources during encoding and reduce encoding efficiency.

Timing

Call this method after EnableVideo.

Parameters

enabled
Whether to enable video denoising:
  • true: Enable video denoising.
  • false: (Default) Disable video denoising.
options
Video denoising options for setting the effect. See VideoDenoiserOptions.
type
The media source type to which the effect is applied. See MEDIA_SOURCE_TYPE.
Note: In this method, this parameter only supports the following two settings:
  • When capturing local video using the camera, keep the default value PRIMARY_CAMERA_SOURCE.
  • To use custom captured video, set this parameter to CUSTOM_VIDEO_SOURCE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetVideoEncoderConfiguration

Sets the video encoding properties.

public abstract int SetVideoEncoderConfiguration(VideoEncoderConfiguration config);

Sets the encoding properties for the local video. Each video encoding configuration corresponds to a set of video-related parameters, including resolution, frame rate, and bitrate.

Note:
  • The config parameter of this method specifies the maximum values achievable under ideal network conditions. If the network condition is poor, the video engine may not use this config to render the local video and will automatically downgrade to a suitable video parameter setting.

Timing

This method can be called before or after joining a channel. If the user does not need to reset the video encoding configuration after joining the channel, it is recommended to call this method before EnableVideo to speed up the time to the first frame.

Parameters

config
Video encoding parameter configuration. See VideoEncoderConfiguration.

Return Values

  • 0: Method call succeeded.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.

SetVideoScenario

Sets the video application scenario.

public abstract int SetVideoScenario(VIDEO_APPLICATION_SCENARIO_TYPE scenarioType);

After successfully setting the video application scenario using this method, the SDK enables best practice strategies based on the specified scenario, automatically adjusting key performance indicators to optimize video experience quality.

Note: This method must be called before joining a channel.

Parameters

scenarioType
Video application scenario. See VIDEO_APPLICATION_SCENARIO_TYPE. APPLICATION_SCENARIO_MEETING (1) is suitable for meeting scenarios. If the user has called SetDualStreamMode [2/2] to set the low stream to never send (DISABLE_SIMULCAST_STREAM), the meeting scenario does not support dynamic switching of the low stream. This enum value is only applicable to broadcaster vs broadcaster scenarios. The SDK enables the following strategies for this scenario:
  • For meetings with high bitrate requirements for the low stream, multiple weak network resistance technologies are automatically enabled to enhance the low stream's resistance and ensure smoothness when subscribing to multiple streams.
  • Real-time monitoring of the number of subscribers to the high stream, dynamically adjusting the high stream configuration:
    • When no one subscribes to the high stream, the bitrate and frame rate of the high stream are automatically reduced to save uplink bandwidth and consumption.
    • When someone subscribes to the high stream, it resets to the VideoEncoderConfiguration from the most recent SetVideoEncoderConfiguration call. If no configuration was previously set, the following defaults are used:
      • Video resolution: 1280 × 720 for desktop; 960 × 540 for mobile
      • Frame rate: 15 fps
      • Bitrate: 1600 Kbps for desktop; 1000 Kbps for mobile
  • Real-time monitoring of the number of subscribers to the low stream, dynamically enabling or disabling the low stream:
    • When no one subscribes to the low stream, it is automatically disabled to save uplink bandwidth and consumption.
    • When someone subscribes to the low stream, it is enabled and reset to the SimulcastStreamConfig from the most recent SetDualStreamMode [2/2] call. If no configuration was previously set, the following defaults are used:
      • Video resolution: 480 × 272
      • Frame rate: 15 fps
      • Bitrate: 500 Kbps
APPLICATION_SCENARIO_1V1 (2) is suitable for 1v1 video call scenarios. The SDK optimizes strategies for low latency and high-quality experience, improving video quality, first frame rendering, latency on mid- and low-end devices, and smoothness under weak networks.APPLICATION_SCENARIO_LIVESHOW (3) is suitable for showroom live streaming scenarios. For this scenario's high demands on first frame rendering time and image clarity, the SDK optimizes strategies such as enabling audio and video frame accelerated rendering by default to improve first frame experience, removing the need to call EnableInstantMediaRendering, and enabling B-frames by default to ensure high image quality and transmission efficiency. It also enhances video quality and smoothness under weak networks and on low-end devices.

Return Values

  • 0: Method call succeeded.
  • < 0: Method call failed. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically categorized).
    • -4: Setting the video scenario is not supported. This may be because the current SDK is audio-only.
    • -7: The IRtcEngine object has not been initialized. You must initialize the IRtcEngine object successfully before calling this method.

SetVoiceBeautifierParameters

Sets the parameters for preset voice beautifier effects.

public abstract int SetVoiceBeautifierParameters(VOICE_BEAUTIFIER_PRESET preset, int param1, int param2);
Call this method to set the gender characteristics and reverb effect for the singing beautifier. This method applies to the local publishing user. After setting, all users in the channel can hear the effect. To achieve better vocal effects, it is recommended to perform the following before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality, i.e., AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] to set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).
Note:

Parameters

preset
Preset effect:
  • SINGING_BEAUTIFIER: Singing beautifier.
param1
Gender characteristic of the singing voice:
  • 1: Male voice.
  • 2: Female voice.
param2
Reverb effect of the singing voice:
  • 1: Small room reverb.
  • 2: Large room reverb.
  • 3: Hall reverb.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetVoiceBeautifierPreset

Sets the preset voice beautifier effect.

public abstract int SetVoiceBeautifierPreset(VOICE_BEAUTIFIER_PRESET preset);

Call this method to set a preset vocal beautifier effect for the local publishing user. After setting the beautifier effect, all users in the channel can hear the effect. You can set different beautifier effects for users based on different scenarios.

Note:

Timing

Can be called before and after joining a channel. To achieve better vocal effects, it is recommended to perform the following before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality, i.e., AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] to set profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).

Parameters

preset
Preset beautifier effect option. See VOICE_BEAUTIFIER_PRESET.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetVoiceConversionPreset

Sets a preset voice conversion effect.

public abstract int SetVoiceConversionPreset(VOICE_CONVERSION_PRESET preset);

Call this method to set a preset voice conversion effect provided by the SDK for the local user who is sending audio. Once set, all users in the channel can hear the effect. You can apply different voice conversion effects depending on the scenario.

Note:

Timing

Can be called before or after joining a channel. To achieve better voice effects, it is recommended to perform the following operations before calling this method:
  • Call SetAudioScenario to set the audio scenario to high-quality, i.e., AUDIO_SCENARIO_GAME_STREAMING(3).
  • Call SetAudioProfile [2/2] to set the profile to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).

Parameters

preset
The preset voice conversion effect option: VOICE_CONVERSION_PRESET.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetVolumeOfEffect

Sets the playback volume of the specified audio effect file.

public abstract int SetVolumeOfEffect(int soundId, int volume);

Timing

This method must be called after PlayEffect.

Parameters

soundId
The ID of the specified audio effect. Each audio effect has a unique ID.
volume
Playback volume. The range is [0,100]. The default value is 100, which means the original volume.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetupLocalVideo

Initializes the local view.

public abstract int SetupLocalVideo(VideoCanvas canvas);

This method initializes the local view and sets the display properties of the local user's video. It only affects the video image seen by the local user and does not affect the publishing of the local video. Calling this method binds the display window (view) of the local video stream and sets the rendering and mirror mode of the local user view. The binding remains effective after leaving the channel. To stop rendering or unbind, you can call this method and set the view parameter to NULL to stop rendering and clear the rendering cache.

Note:
  • In Flutter, you do not need to call this method manually. Use AgoraVideoView to render local and remote views.
  • If you want to render images in a native window, call this method; if you only need to render images within a Unity project, you can use the VideoSurface class directly.
  • If you only want to update the rendering or mirror mode of the local user view during a call, use the SetLocalRenderMode [2/2] method.

Scenario

In app development, this method is typically called after initialization to configure local video, and then join the channel. If you want to display multiple preview views in the local video preview, each showing different observation points in the video pipeline, you can call this method multiple times with different view values and set different observation positions for each. For example, set the video source to camera and assign two view values with position set to PositionPostCapturerOrigin and PositionPostCapturer respectively, to simultaneously preview the raw video and the processed video (beauty effects, virtual background, watermark) locally.

Timing

This method can be called before or after joining the channel.

Parameters

canvas
Local video display properties. See VideoCanvas.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

SetupRemoteVideo

Initializes the remote user view.

public abstract int SetupRemoteVideo(VideoCanvas canvas);

This method binds the remote user and the display view, and sets the rendering and mirror mode of the remote user view when displayed locally. It only affects the video image seen by the local user. You need to specify the user ID of the remote video when calling this method. It is generally recommended to set it before joining the channel. If you cannot obtain the remote user's ID before joining the channel, you can call this method upon receiving the OnUserJoined callback. To unbind a remote user's view, call this method and set view to null. After leaving the channel, the SDK will clear the binding of the remote user view. In mobile custom composite layout scenarios, you can call this method and set a separate view for each sub-video stream of the composite video stream for rendering.

Note:
  • If you want to render images in a native window, call this method; if you only need to render images within a Unity project, you can use the VideoSurface class directly.
  • If you want to update the rendering or mirror mode of the remote user view during a call, use the SetRemoteRenderMode method.
  • When using the recording service, since it does not send video streams, the app does not need to bind a view for it. If the app cannot identify the recording service, it can bind the remote user view upon receiving the OnFirstRemoteVideoDecoded callback.

Parameters

canvas
Remote video display properties. See VideoCanvas.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartAudioMixing [1/2]

Starts playing a music file.

public abstract int StartAudioMixing(string filePath, bool loopback, int cycle);

For supported audio file formats, see What audio formats does the RTC SDK support for playback. If the local music file does not exist, the file format is not supported, or the online music file URL is inaccessible, the SDK reports AUDIO_MIXING_REASON_CAN_NOT_OPEN.

Note:
  • Using this method to play short sound effect files may result in playback failure. To play sound effects, use PlayEffect instead.
  • If you need to call this method multiple times, ensure the interval between calls is greater than 500 ms.
  • When calling this method on Android, note the following:
    • Ensure the device runs Android 4.2 or above, with API Level not lower than 16.
    • If playing an online music file, avoid using redirect URLs. Redirects may not work on some devices.
    • If calling this method on an emulator, ensure the music file is located under /sdcard/ and is in MP3 format.

Timing

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

Parameters

filePath
The path to the file to play. Supports URLs for online files and absolute paths for local files, including the file name and extension. Supported formats include MP3, AAC, M4A, MP4, WAV, 3GP, etc.
Note: If you have preloaded the sound effect into memory using PreloadEffect, ensure this parameter matches the filePath specified in PreloadEffect.
loopback
Whether to play the music file locally only:
  • true: Play locally only. Only the local user hears the music.
  • false: Publish the music to remote users. Both local and remote users hear the music.
cycle
The number of times to play the music file.
  • > 0: Number of times to play. For example, 1 means play once.
  • -1: Loop playback indefinitely.

Return Values

  • 0: Success.
  • < 0: Failure:
    • -1: General error (unspecified).
    • -2: Invalid parameter.
    • -3: SDK not ready:
      • Check if the audio module is enabled.
      • Check the integrity of the assembly.
      • IRtcEngine initialization failed. Reinitialize IRtcEngine.

StartAudioMixing [2/2]

Starts playing a music file.

public abstract int StartAudioMixing(string filePath, bool loopback, int cycle, int startPos);

For supported audio file formats, see Which audio file formats does the RTC SDK support. If the local music file does not exist, the file format is not supported, or the online music file URL is inaccessible, the SDK reports AUDIO_MIXING_REASON_CAN_NOT_OPEN.

Note:
  • Using this method to play short sound effect files may result in playback failure. To play sound effects, use PlayEffect instead.
  • If you need to call this method multiple times, ensure that the interval between calls is greater than 500 ms.
  • When calling this method on Android, note the following:
    • Ensure that the device runs Android 4.2 or later, and the API Level is at least 16.
    • If playing an online music file, avoid using a redirect URL. Redirect URLs may not work on some devices.
    • If calling this method on an emulator, ensure the music file is located in the /sdcard/ directory and is in MP3 format.

Timing

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

Parameters

filePath
File path:
  • Android: File path, including the file name and extension. Supports URL of online files, URI of local files, absolute path, or path starting with /assets/. Accessing local files via absolute path may cause permission issues. It is recommended to use URI to access local files. For example: content://com.android.providers.media.documents/document/audio%3A14441.
  • Windows: Absolute path or URL of the audio file, including the file name and extension. For example: C:\music\audio.mp4.
  • iOS or macOS: Absolute path or URL of the audio file, including the file name and extension. For example: /var/mobile/Containers/Data/audio.mp4.
loopback
Whether to play the music file only locally:
  • true: Plays the music file locally only. Only the local user can hear the music.
  • false: Publishes the music file to remote users. Both local and remote users can hear the music.
cycle
Number of times the music file is played.
  • > 0: Number of times to play. For example, 1 means play once.
  • -1: Play in an infinite loop.
startPos
The playback position of the music file, in milliseconds.

Return Values

  • 0: Success.
  • < 0: Failure:
    • -1: General error (not specifically classified).
    • -2: Invalid parameter.
    • -3: SDK not ready:
      • Check if the audio module is enabled.
      • Check the integrity of the assembly.
      • IRtcEngine failed to initialize. Reinitialize IRtcEngine.

StartCameraCapture

Starts video capture using the camera.

public abstract int StartCameraCapture(VIDEO_SOURCE_TYPE sourceType, CameraCapturerConfiguration config);

You can call this method to start multiple camera captures simultaneously by specifying sourceType.

Note: On iOS, to enable multiple camera captures, you must call EnableMultiCamera and set enabled to true before calling this method.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.
Note:
  • iOS devices support up to 2 video streams from camera capture (requires devices with multiple cameras or external camera support).
  • Android devices support up to 4 video streams from camera capture (requires devices with multiple cameras or external camera support).
  • Desktop supports up to 4 video streams from camera capture.
config
Video capture configuration. See CameraCapturerConfiguration.
Note: On iOS, this parameter has no effect. Use the config parameter in EnableMultiCamera to configure video capture.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartDirectCdnStreaming

Starts pushing the stream directly to the CDN from the host.

public abstract int StartDirectCdnStreaming(string publishUrl, DirectCdnStreamingMediaOptions options);
Deprecated
Deprecated since v4.6.2.
The SDK does not support pushing to the same URL multiple times simultaneously. Media option notes: The SDK does not support setting both publishCameraTrack and publishCustomVideoTrack to true, nor does it support setting both publishMicrophoneTrack and publishCustomAudioTrack to true. You can configure the media options (DirectCdnStreamingMediaOptions) based on your scenario. For example: If you want to push custom audio and video streams from the host, configure the media options as follows:
  • Set publishCustomAudioTrack to true and call PushAudioFrame
  • Set publishCustomVideoTrack to true and call PushVideoFrame
  • Ensure publishCameraTrack is false (default)
  • Ensure publishMicrophoneTrack is false (default)
Since v4.2.0, the SDK supports pushing audio-only streams. You can set publishCustomAudioTrack or publishMicrophoneTrack to true in DirectCdnStreamingMediaOptions and call PushAudioFrame to push audio-only streams.

Parameters

publishUrl
CDN streaming URL.
options
Media options for the host. See DirectCdnStreamingMediaOptions.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

StartEchoTest

Starts an audio and video loop test.

public abstract int StartEchoTest(EchoTestConfiguration config);

To test whether local audio and video transmission is functioning properly, you can call this method to perform an audio and video loop test. This tests whether the system's audio/video devices and the user's uplink/downlink network are functioning correctly. After starting the test, the user should speak or face the camera. The audio or video will be played back in about 2 seconds. If audio plays back correctly, the system's audio devices and the user's network are functioning properly. If video plays back correctly, the system's video devices and the user's network are functioning properly.

Note:
  • When calling this method in a channel, ensure that no audio/video stream is being published.
  • After calling this method, you must call StopEchoTest to end the test. Otherwise, the user will not be able to perform the next loop test or join a channel.
  • In a live broadcast scenario, only the host can call this method.

Timing

This method can be called before or after joining a channel.

Parameters

config
Configuration for the audio and video loop test. See EchoTestConfiguration.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartLastmileProbeTest

Starts last-mile network quality probe before a call.

public abstract int StartLastmileProbeTest(LastmileProbeConfig config);

Performs a last-mile network quality probe before a call, providing feedback on uplink and downlink bandwidth, packet loss, jitter, and round-trip time.

Timing

This method must be called before joining a channel. Do not call other methods before receiving the OnLastmileQuality and OnLastmileProbeResult callbacks, or this method may fail due to frequent API operations.

Parameters

config
Last-mile network probe configuration. See LastmileProbeConfig.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartLocalAudioMixer

Starts local audio mixing.

public abstract int StartLocalAudioMixer(LocalAudioMixerConfiguration config);
This method supports merging multiple audio streams locally into a single audio stream. For example: merge audio from the local microphone, media player, sound card, and remote audio streams into one, and then publish the mixed audio stream to the channel.
  • To mix locally captured audio streams, set publishMixedAudioTrack in ChannelMediaOptions to true to publish the mixed audio stream to the channel.
  • To mix remote audio streams, ensure the remote audio streams are published in the channel and have been subscribed to.
Note: To ensure audio quality, it is recommended that no more than 10 audio streams participate in local mixing.

Scenario

You can enable this feature in the following scenarios:
  • Used with local video compositing, to synchronize and publish the audio streams related to the composed video.
  • In live streaming, users receive audio streams from the channel, mix them locally, and forward them to another channel.
  • In education, teachers can mix audio from interactions with students locally and forward the mixed stream to another channel.

Timing

This method can be called before or after joining a channel.

Parameters

config
Configuration for local audio mixing. See LocalAudioMixerConfiguration.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.

StartLocalVideoTranscoder

Starts local video transcoding.

public abstract int StartLocalVideoTranscoder(LocalTranscoderConfiguration config);

After calling this method, you can merge multiple video streams into a single stream locally. For example, merge camera-captured video, screen sharing, media player video, remote video, video files, images, etc., into one video stream, and then publish the merged stream to the channel.

Note:
  • Local video transcoding consumes high CPU resources. Agora recommends using this feature on high-performance devices.
  • If you want to transcode locally captured video streams, the SDK supports the following combinations:
    • On Windows: up to 4 camera streams + 4 screen sharing streams.
    • On macOS: up to 4 camera streams + 1 screen sharing stream.
    • On Android and iOS: up to 2 camera streams (requires dual camera support or external camera) + 1 screen sharing stream.
  • When configuring the transcoding layout, ensure that the layer ID of the camera stream capturing the portrait is greater than that of the screen sharing stream. Otherwise, the portrait may be covered and not appear in the final merged stream.

Scenario

You can enable local video mixing in scenarios such as remote meetings, live streaming, and online education. This allows users to conveniently view and manage multiple video feeds, and supports features like picture-in-picture. Here is a typical scenario for implementing picture-in-picture:
  1. Call enableVirtualBackground and set the custom background to BackgroundNone, i.e., separate the portrait from the background in the camera-captured video.
  2. Call startScreenCaptureBySourceType to start capturing the screen sharing video stream.
  3. Call this method and set the portrait video source as one of the sources in the local mixing configuration to achieve picture-in-picture in the final mixed video.

Timing

Parameters

config
Configuration for local video transcoding. See LocalTranscoderConfiguration.
Note:
  • The maximum resolution for each video stream in the transcoding is 4096 × 2160. Exceeding this limit will cause transcoding to fail.
  • The maximum resolution of the merged video stream is 4096 × 2160.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartMediaRenderingTracing

Starts video frame rendering tracing.

public abstract int StartMediaRenderingTracing();

After successfully calling this method, the SDK uses the time of the call as the starting point and reports video frame rendering information through the OnVideoRenderingTracingResult callback.

Note:
  • If you do not call this method, the SDK uses the time of calling JoinChannel [2/2] to join the channel as the default starting point and automatically starts tracing video rendering events. You can call this method at an appropriate time based on your business scenario to perform custom tracing.
  • After leaving the current channel, the SDK automatically resets the starting point to the time of the next channel join.

Scenario

Agora recommends using this method together with UI elements in your app (such as buttons or sliders) to measure the time to first frame rendering from the user's perspective. For example, call this method when the user clicks the Join Channel button, and then use the onVideoRenderingTracingResult callback to obtain the duration of each stage in the video rendering process, allowing you to optimize each stage accordingly.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -7: IRtcEngine is not initialized when the method is called.

StartOrUpdateChannelMediaRelay

Starts or updates cross-channel media stream forwarding.

public abstract int StartOrUpdateChannelMediaRelay(ChannelMediaRelayConfiguration configuration);
The first successful call to this method starts forwarding media streams across channels. To forward streams to multiple destination channels or leave a current forwarding channel, you can call this method again to add or remove destination channels. This feature supports forwarding to up to 6 destination channels. After a successful call, the SDK triggers the OnChannelMediaRelayStateChanged callback to report the current state of cross-channel media stream forwarding. Common states include:
  • If the OnChannelMediaRelayStateChanged callback reports RELAY_STATE_RUNNING (2) and RELAY_OK (0), it means the SDK has started forwarding media streams between the source and destination channels.
  • If the callback reports RELAY_STATE_FAILURE (3), it means an error occurred during cross-channel media stream forwarding.
Note:
  • Call this method after successfully joining a channel.
  • In a live streaming scenario, only users with the host role can call this method.
  • Cross-channel media stream forwarding requires contacting technical support to enable.
  • This feature does not support String-type UIDs.

Parameters

configuration
Configuration for cross-channel media stream forwarding. See ChannelMediaRelayConfiguration.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -1: General error (not specifically classified).
    • -2: Invalid parameter.
    • -8: Internal state error. Possibly because the user role is not host.

StartPreview [1/2]

Starts video preview.

public abstract int StartPreview();

This method starts the local video preview.

Note:
  • Local preview enables mirror mode by default.
  • After leaving the channel, the local preview remains active. You need to call StopPreview [1/2] to stop the local preview.

Timing

You must call this method after EnableVideo.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartPreview [2/2]

Starts video preview and specifies the video source.

public abstract int StartPreview(VIDEO_SOURCE_TYPE sourceType);

This method starts the local video preview and specifies the video source to appear in the preview.

Note:
  • Local preview enables mirror mode by default.
  • After leaving the channel, the local preview remains active. You need to call StopPreview [1/2] to stop the local preview.

Timing

You must call this method after EnableVideo.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StartRhythmPlayer

Starts the virtual metronome.

public abstract int StartRhythmPlayer(string sound1, string sound2, AgoraRhythmPlayerConfig config);
Deprecated
Deprecated since v4.6.2.
  • Once the virtual metronome is enabled, the SDK starts playing the specified audio files from the beginning and controls the duration of each file based on the beatsPerMinute setting in AgoraRhythmPlayerConfig. For example, if beatsPerMinute is set to 60, the SDK plays 1 beat per second. If the file duration exceeds the beat duration, the SDK only plays the portion of the audio corresponding to the beat duration.
  • By default, the virtual metronome sound is not published to the remote. If you want remote users to hear the metronome, set publishRhythmPlayerTrack in ChannelMediaOptions to true after calling this method.

Scenario

In music or physical education scenarios, instructors often use a metronome to help students practice with the correct rhythm. A measure consists of strong and weak beats, with the first beat of each measure being the strong beat and the rest being weak beats.

Timing

Can be called before or after joining a channel.

Parameters

sound1
The absolute path or URL of the strong beat file, including the file name and extension. For example, C:\music\audio.mp4. Supported audio formats are listed in What audio formats does the RTC SDK support.
sound2
The absolute path or URL of the weak beat file, including the file name and extension. For example, C:\music\audio.mp4. Supported audio formats are listed in What audio formats does the RTC SDK support.
config
Metronome configuration. See AgoraRhythmPlayerConfig.

Return Values

  • 0: Success.
  • < 0: Failure
    • -22: Audio file not found. Please provide correct sound1 and sound2.

StartRtmpStreamWithTranscoding

Starts RTMP streaming with transcoding settings.

public abstract int StartRtmpStreamWithTranscoding(string url, LiveTranscoding transcoding);

Agora recommends using a more comprehensive server-side streaming feature. See Implement server-side streaming. By calling this method, you can push live audio and video streams to the specified RTMP address and set transcoding parameters. This method can only push to one address at a time. If you need to push to multiple addresses, call this method multiple times. Each stream represents a streaming task. The default maximum number of concurrent tasks is 200, meaning you can run up to 200 streaming tasks simultaneously under one Agora project. For higher quotas, please contact technical support. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming state.

Note:
  • Call this method after joining a channel.
  • Only hosts in a live broadcast scenario can call this method.
  • If the streaming fails and you want to restart it, make sure to call StopRtmpStream before calling this method again, otherwise the SDK returns the same error code as the last failure.

Parameters

url
The RTMP or RTMPS streaming URL. The character length must not exceed 1024 bytes. Chinese characters and other special characters are not supported.
transcoding
The transcoding settings for RTMP streaming. See LiveTranscoding.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid URL or transcoding parameters. Please check your URL or parameter settings.
    • -7: The SDK was not initialized before calling this method.
    • -19: The RTMP URL is already in use. Please use another RTMP URL.

StartRtmpStreamWithoutTranscoding

Starts RTMP streaming without transcoding.

public abstract int StartRtmpStreamWithoutTranscoding(string url);

Agora recommends using a more comprehensive server-side streaming feature. See Implement server-side streaming. By calling this method, you can push live audio and video streams to the specified RTMP address. This method can only push to one address at a time. If you need to push to multiple addresses, call this method multiple times. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming state.

Note:
  • Call this method after joining a channel.
  • Only hosts in a live broadcast scenario can call this method.
  • If the streaming fails and you want to restart it, make sure to call StopRtmpStream before calling this method again, otherwise the SDK returns the same error code as the last failure.

Parameters

url
The RTMP or RTMPS streaming URL. The character length must not exceed 1024 bytes. Chinese characters and other special characters are not supported.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -2: Invalid URL or transcoding parameters. Please check your URL or parameter settings.
    • -7: The SDK was not initialized before calling this method.
    • -19: The RTMP URL is already in use. Please use another RTMP URL.

StartScreenCapture [1/2]

Starts screen capture.

public abstract int StartScreenCapture(ScreenCaptureParameters2 captureParams);
Note:
  • This method applies to Android and iOS only.
  • The billing standard for the screen sharing stream is based on the dimensions value in ScreenVideoParameters:
    • If you do not pass a value, billing is based on 1280 × 720.
    • If you pass a value, billing is based on the value you provide.
  • On iOS, screen sharing is supported on iOS 12.0 and above only.
  • On iOS, if you use custom audio capture instead of SDK audio capture, to prevent screen sharing from stopping when the app goes to the background, it is recommended to add keep-alive logic to your app.
  • On iOS, this feature requires high device performance. It is recommended to use it on iPhone X and later models.
  • On iOS, this method depends on the screen sharing dynamic library AgoraReplayKitExtension.xcframework. Removing this library will cause screen sharing to fail.
  • On Android, if the user does not grant screen capture permission to the app, the SDK will report the OnPermissionError(2) callback.
  • On Android 9 and later, to prevent the app from being killed when going to the background, it is recommended to add the foreground service permission android.permission.FOREGROUND_SERVICE in the /app/Manifests/AndroidManifest.xml file.
  • Due to Android performance limitations, screen sharing is not supported on Android TV.
  • Due to Android system limitations, when using Huawei phones for screen sharing, to avoid crashes, do not change the video encoding resolution of the screen sharing stream during sharing.
  • Due to Android system limitations, some Xiaomi phones do not support capturing system audio during screen sharing.
  • To improve the success rate of capturing system audio during screen sharing, it is recommended to set the audio scenario to AUDIO_SCENARIO_GAME_STREAMING using the SetAudioScenario method before joining the channel.

Scenario

In screen sharing scenarios, you need to call this method to start capturing screen video streams. For implementation details, see Screen Sharing.

Timing

This method can be called before or after joining a channel, with the following differences:
  • If you call this method before joining the channel, then call JoinChannel [2/2] and set publishScreenCaptureVideo to true, screen sharing starts.
  • If you call this method after joining the channel, then call UpdateChannelMediaOptions and set publishScreenCaptureVideo to true, screen sharing starts.

Parameters

captureParams
Configuration of encoding parameters for screen sharing. See ScreenCaptureParameters2.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2 (iOS): Parameter is null.
    • -2 (Android): System version too low. Ensure the Android API level is at least 21.
    • -3 (Android): Unable to capture system audio. Ensure the Android API level is at least 29.

StartScreenCapture [2/2]

Starts screen capture and specifies the video source.

public abstract int StartScreenCapture(VIDEO_SOURCE_TYPE sourceType, ScreenCaptureConfiguration config);
Note: This method applies to macOS and Windows only.
  • If you call this method to start screen capture, you need to call StopScreenCapture [2/2] to stop it.
  • On Windows, up to 4 screen capture video streams are supported.
  • On macOS, only 1 screen capture video stream is supported.

Scenario

In screen sharing scenarios, you need to call this method to start capturing screen video streams. The SDK provides several methods to start screen capture. Choose based on your use case:
  • startScreenCaptureByDisplayId/startScreenCaptureByWindowId: Supports capturing a single screen or window, suitable for sharing a single screen.
  • startScreenCaptureBySourceType: Supports specifying multiple video sources to capture multiple screen sharing streams, used for local compositing or multi-channel publishing scenarios.

Timing

This method can be called before or after joining a channel, with the following differences:
  • If you call this method before joining the channel, then call JoinChannel [2/2] and set publishScreenCaptureVideo to true, screen sharing starts.
  • If you call this method after joining the channel, then call UpdateChannelMediaOptions and set publishScreenCaptureVideo to true, screen sharing starts.

Parameters

sourceType
Type of video source. See VIDEO_SOURCE_TYPE.
Note: On macOS, only VIDEO_SOURCE_SCREEN (2) is supported for this parameter.
config
Screen capture configuration. See ScreenCaptureConfiguration.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

StartScreenCaptureByDisplayId

Starts capturing the video stream of the specified screen.

public abstract int StartScreenCaptureByDisplayId(uint displayId, Rectangle regionRect, ScreenCaptureParameters captureParams);

Captures the video stream of a screen or a region of the screen.

Note: This method applies to Windows and macOS only.

Scenario

In screen sharing scenarios, you need to call this method to start capturing screen video streams. For implementation details, see Screen Sharing.

Timing

This method can be called before or after joining a channel, with the following differences:
  • If you call this method before joining the channel, then call JoinChannel [2/2] and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.
  • If you call this method after joining the channel, then call UpdateChannelMediaOptions and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.

Parameters

displayId
Specifies the ID of the screen to be shared.
Note: On Windows, if you want to share two screens (main + secondary), you can set displayId to -1 when calling this method.
regionRect
(Optional) Specifies the region to be shared relative to the entire screen. To share the full screen, set to nil. See Rectangle.
captureParams
Configuration parameters for screen sharing. The default video encoding resolution is 1920 × 1080, i.e., 2,073,600 pixels. This pixel count is used for billing. See ScreenCaptureParameters.
Note: The video properties of the screen sharing stream should be set only through this parameter and are unrelated to SetVideoEncoderConfiguration.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameters.
    • -8: Invalid screen sharing state. You may already be sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing before starting again.

StartScreenCaptureByScreenRect

Starts capturing the video stream of a specified screen region.

public abstract int StartScreenCaptureByScreenRect(Rectangle screenRect, Rectangle regionRect,
            ScreenCaptureParameters captureParams);
Deprecated
Deprecated: This method is deprecated. Use StartScreenCaptureByDisplayId instead. If you need to enable screen sharing when an external display is connected, it is strongly recommended to use StartScreenCaptureByDisplayId.
Shares a screen or a region of the screen. You need to specify the screen region to share in this method. This method can be called before or after joining a channel, with the following differences:
  • If you call this method before joining the channel, then call JoinChannel [2/2] and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.
  • If you call this method after joining the channel, then call UpdateChannelMediaOptions and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.
Note: This method applies to Windows only.

Parameters

screenRect
Specifies the position of the screen to be shared relative to the virtual screen.
regionRect
(Optional) Specifies the region to be shared relative to the entire screen. If not set, the entire screen is shared. See Rectangle. If the specified region exceeds the screen boundaries, only the content within the screen is shared. If width or height is set to 0, the entire screen is shared.
captureParams
Configuration of encoding parameters for screen sharing. The default resolution is 1920 x 1080, i.e., 2,073,600 pixels. This pixel count is used for billing. See ScreenCaptureParameters.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid parameters.
    • -8: Invalid screen sharing state. You may already be sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing before starting again.

StartScreenCaptureByWindowId

Starts capturing the video stream of the specified window.

public abstract int StartScreenCaptureByWindowId(long windowId, Rectangle regionRect, ScreenCaptureParameters captureParams);
Shares a window or a portion of it. You need to specify the window ID to be shared in this method. This method supports sharing Universal Windows Platform (UWP) application windows. Agora has tested mainstream UWP applications using the latest SDK, with the following results:
OS Version Application Compatible Version Supported
Windows 10 Chrome 76.0.3809.100 No
Office Word 18.1903.1152.0 Yes
Office Excel 18.1903.1152.0 No
Office PPT 18.1903.1152.0 Yes
WPS Word 11.1.0.9145 Yes
WPS Excel 11.1.0.9145 Yes
WPS PPT 11.1.0.9145 Yes
Built-in Media Player All versions Yes
Windows 8 Chrome All versions Yes
Office Word All versions Yes
Office Excel All versions Yes
Office PPT All versions Yes
WPS Word 11.1.0.9098 Yes
WPS Excel 11.1.0.9098 Yes
WPS PPT 11.1.0.9098 Yes
Built-in Media Player All versions Yes
Windows 7 Chrome 73.0.3683.103 No
Office Word All versions Yes
Office Excel All versions Yes
Office PPT All versions Yes
WPS Word 11.1.0.9098 No
WPS Excel 11.1.0.9098 No
WPS PPT 11.1.0.9098 Yes
Built-in Media Player All versions No
Note: This method is only applicable to macOS and Windows platforms. The SDK's window sharing feature relies on WGC (Windows Graphics Capture) or GDI (Graphics Device Interface). On systems earlier than Windows 10 2004, WGC cannot disable mouse capture, so when sharing a window on such systems, captureMouseCursor(false) may not take effect. See ScreenCaptureParameters.

Scenario

In screen sharing scenarios, you need to call this method to start capturing the screen video stream. For implementation details, see Screen Sharing.

Timing

This method can be called before or after joining a channel, with the following differences:
  • If you call this method before joining a channel, then call JoinChannel [2/2] and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.
  • If you call this method after joining a channel, then call UpdateChannelMediaOptions and set publishScreenTrack or publishSecondaryScreenTrack to true, screen sharing starts.

Parameters

windowId
Specifies the ID of the window to be shared.
regionRect
(Optional) Specifies the position of the region to be shared relative to the entire screen. If not set, the entire screen is shared. See Rectangle. If the specified region exceeds the window boundaries, only the content within the window is shared; if the width or height is 0, the entire window is shared.
captureParams
Configuration parameters for screen sharing. The default resolution is 1920 x 1080, i.e., 2,073,600 pixels. This pixel count is used for billing. See ScreenCaptureParameters.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: The input parameter is invalid.
    • -8: The screen sharing state is invalid. This may occur if you are already sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing and then restart screen sharing.

StopAllEffects

Stops playback of all audio effect files.

public abstract int StopAllEffects();

When you no longer need to play audio effect files, you can call this method to stop playback. If you only need to pause, call PauseAllEffects.

Timing

This method must be called after PlayEffect.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopAudioMixing

Stops playing the music file.

public abstract int StopAudioMixing();

After calling the StartAudioMixing [2/2] method to play a music file, call this method to stop playback. To pause playback, call PauseAudioMixing.

Timing

You must call this method after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

StopCameraCapture

Stops video capture using the camera.

public abstract int StopCameraCapture(VIDEO_SOURCE_TYPE sourceType);

After calling StartCameraCapture to start one or more video streams from camera capture, you can call this method and specify sourceType to stop one or more of them.

Note: On iOS, to disable multiple camera captures, you must call EnableMultiCamera and set enabled to false after calling this method. If you are using the local composite feature, stopping the first camera capture using this method will interrupt the local composition.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopChannelMediaRelay

Stops cross-channel media stream forwarding. Once stopped, the host leaves all destination channels.

public abstract int StopChannelMediaRelay();

After a successful call to this method, the SDK triggers the OnChannelMediaRelayStateChanged callback. If it reports RELAY_STATE_IDLE (0) and RELAY_OK (0), it indicates that media stream forwarding has stopped.

Note: If the method call fails, the SDK will trigger the OnChannelMediaRelayStateChanged callback and report the status code RELAY_ERROR_SERVER_NO_RESPONSE (2) or RELAY_ERROR_SERVER_CONNECTION_LOST (8). You can call the LeaveChannel [2/2] method to leave the channel, and cross-channel media stream forwarding will stop automatically.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -5: This method call was rejected. No cross-channel media stream forwarding is currently in progress.

StopDirectCdnStreaming

Stops pushing the stream directly to the CDN from the host.

public abstract int StopDirectCdnStreaming();
Deprecated
Deprecated since v4.6.2.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

StopEchoTest

Stops the audio loop test.

public abstract int StopEchoTest();

After calling StartEchoTest, you must call this method to end the test. Otherwise, the user will not be able to perform the next audio and video loop test or join a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.
    • -5(ERR_REFUSED): Failed to stop the test. The test may not be running.

StopEffect

Stops playback of the specified audio effect file.

public abstract int StopEffect(int soundId);

When you no longer need to play a specific audio effect file, you can call this method to stop playback. If you only need to pause, call PauseEffect.

Timing

This method must be called after PlayEffect.

Parameters

soundId
The ID of the specified audio effect file. Each audio effect file has a unique ID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopLastmileProbeTest

Stops the last-mile network quality probe before a call.

public abstract int StopLastmileProbeTest();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopLocalAudioMixer

Stops local audio mixing.

public abstract int StopLocalAudioMixer();

After calling StartLocalAudioMixer, if you want to stop local audio mixing, call this method.

Timing

This method must be called after StartLocalAudioMixer.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.

StopPreview [1/2]

Stops video preview.

public abstract int StopPreview();

Scenario

After calling StartPreview [1/2] to start the preview, call this method if you want to stop the local video preview.

Timing

Call this method before joining or after leaving a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopPreview [2/2]

Stops video preview.

public abstract int StopPreview(VIDEO_SOURCE_TYPE sourceType);

Scenario

After calling startPreview to start preview, if you want to stop the local video preview, call this method.

Timing

Call this method before joining or after leaving a channel.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopRhythmPlayer

Stops the virtual metronome.

public abstract int StopRhythmPlayer();

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

Note: (Android and iOS only)

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopRtmpStream

Stops the RTMP stream.

public abstract int StopRtmpStream(string url);

Agora recommends using a more complete server-side streaming service. See Implement Server-Side RTMP Streaming. Call this method to stop the live stream at the specified RTMP streaming URL. This method can only stop one stream at a time. To stop multiple streams, call this method multiple times. After calling this method, the SDK triggers the OnRtmpStreamingStateChanged callback locally to report the streaming status.

Parameters

url
The RTMP streaming URL. Must be in RTMP or RTMPS format. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

StopScreenCapture [1/2]

Stops screen capture.

public abstract int StopScreenCapture();

Scenario

If you call startScreenCaptureBySourceType, startScreenCaptureByWindowId, or startScreenCaptureByDisplayId to start screen capture, you need to call this method to stop it.

Timing

This method can be called before or after joining a channel.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

StopScreenCapture [2/2]

Stops screen capture for the specified video source.

public abstract int StopScreenCapture(VIDEO_SOURCE_TYPE sourceType);
Note: This method is only applicable to macOS and Windows platforms.

Scenario

If you call startScreenCaptureBySourceType to start one or more screen captures, you need to call this method to stop screen capture and specify the screen via the sourceType parameter.

Timing

This method can be called before or after joining a channel.

Parameters

sourceType
The type of video source. See VIDEO_SOURCE_TYPE.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.

SwitchCamera

Switches between front and rear cameras.

public abstract int SwitchCamera();

You can call this method during app runtime to dynamically switch cameras based on the actual availability without restarting the video stream or reconfiguring the video source.

Note: This method is applicable to Android and iOS only. This method only switches the camera for the first video stream captured by the camera, i.e., the video source set to VIDEO_SOURCE_CAMERA (0) when calling StartCameraCapture.

Timing

You must call this method after the camera is successfully started, that is, after the SDK triggers the OnLocalVideoStateChanged callback and returns the local video state as LOCAL_VIDEO_STREAM_STATE_CAPTURING (1).

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

TakeSnapshot [1/2]

Captures a video snapshot.

public abstract int TakeSnapshot(uint uid, string filePath);

This method captures a snapshot of the specified user's video stream, generates a JPG image, and saves it to the specified path.

Note:
  • This method is asynchronous. When the call returns, the SDK has not yet completed the snapshot.
  • When used for local video snapshots, it captures the video stream specified in ChannelMediaOptions.
  • If the video has been post-processed (e.g., with watermark or beautification), the snapshot will include the effects.

Timing

Call this method after joining a channel.

Parameters

uid
User ID. Set to 0 to capture a snapshot of the local user's video.
filePath
Note: Make sure the directory exists and is writable.
Local path to save the snapshot, including file name and format. For example:
  • Windows: C:\Users\<user_name>\AppData\Local\Agora\<process_name>\example.jpg
  • iOS: /App Sandbox/Library/Caches/example.jpg
  • macOS: ~/Library/Logs/example.jpg
  • Android: /storage/emulated/0/Android/data/<package name>/files/example.jpg

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

TakeSnapshot [2/2]

Captures a video snapshot at a specified observation point.

public abstract int TakeSnapshot(uint uid, SnapshotConfig config);

This method captures a snapshot of the specified user's video stream, generates a JPG image, and saves it to the specified path.

Note:
  • This method is asynchronous. When the call returns, the SDK has not yet completed the snapshot.
  • When used for local video snapshots, it captures the video stream specified in ChannelMediaOptions.

Timing

Call this method after joining a channel.

Parameters

uid
User ID. Set to 0 to capture a snapshot of the local user's video.
config
Snapshot configuration. See SnapshotConfig.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UnloadAllEffects

Releases all preloaded audio effect files from memory.

public abstract int UnloadAllEffects();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UnloadEffect

Releases a preloaded audio effect file from memory.

public abstract int UnloadEffect(int soundId);

After calling PreloadEffect to load an audio effect file into memory, you can call this method to release it.

Timing

This method can be called before or after joining a channel.

Parameters

soundId
The ID of the specified audio effect file. Each audio effect file has a unique ID.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UnRegisterAudioEncodedFrameObserver

Unregisters the audio encoded frame observer.

public abstract int UnRegisterAudioEncodedFrameObserver();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UnRegisterAudioFrameObserver

Unregisters the audio frame observer.

public abstract int UnRegisterAudioFrameObserver();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and troubleshooting.

UnregisterAudioSpectrumObserver

Unregisters the audio spectrum observer.

public abstract int UnregisterAudioSpectrumObserver();

After calling RegisterAudioSpectrumObserver, if you want to unregister the audio spectrum observer, call this method.

Note: This method can be called either before or after joining a channel.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UnregisterMediaMetadataObserver

Unregisters the media metadata observer.

public abstract int UnregisterMediaMetadataObserver();

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UpdateChannelMediaOptions

Updates channel media options after joining the channel.

public abstract int UpdateChannelMediaOptions(ChannelMediaOptions options);

Parameters

options
Channel media options. See ChannelMediaOptions.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: Invalid ChannelMediaOptions member values. For example, using an invalid token or setting an invalid user role. You need to provide valid parameters.
    • -7: The IRtcEngine object is not initialized. You must successfully initialize the IRtcEngine object before calling this method.
    • -8: Internal state error of the IRtcEngine object. This may be because the user is not in the channel. It is recommended to use the OnConnectionStateChanged callback to determine whether the user is in the channel. If you receive CONNECTION_STATE_DISCONNECTED (1) or CONNECTION_STATE_FAILED (5), it means the user is not in the channel. You need to call JoinChannel [2/2] before calling this method.

UpdateLocalAudioMixerConfiguration

Updates the configuration for local audio mixing.

public abstract int UpdateLocalAudioMixerConfiguration(LocalAudioMixerConfiguration config);

After calling StartLocalAudioMixer, if you want to update the configuration for local audio mixing, call this method.

Note: To ensure audio quality, it is recommended that no more than 10 audio streams participate in local mixing.

Timing

This method must be called after StartLocalAudioMixer.

Parameters

config
Configuration for local audio mixing. See LocalAudioMixerConfiguration.

Return Values

  • 0: Method call succeeds.
  • < 0: Method call fails. See Error Codes for details and resolution suggestions.
    • -7: The IRtcEngine object is not initialized. You need to initialize the IRtcEngine object successfully before calling this method.

UpdateLocalTranscoderConfiguration

Updates local video transcoding configuration.

public abstract int UpdateLocalTranscoderConfiguration(LocalTranscoderConfiguration config);

After calling StartLocalVideoTranscoder, call this method to update the local video transcoding configuration.

Note: If you want to update the type of local video source used for transcoding, such as adding a second camera or screen capture, call this method after StartCameraCapture or StartScreenCapture [2/2].

Parameters

config
Configuration for local video transcoding. See LocalTranscoderConfiguration.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UpdatePreloadChannelToken

Updates the wildcard token for the preloaded channel.

public abstract int UpdatePreloadChannelToken(string token);

You need to manage the lifecycle of the wildcard token yourself. When the wildcard token expires, you need to generate a new one on your server and pass it in using this method.

Scenario

In scenarios where frequent channel switching or multiple channels are needed, using a wildcard token avoids repeated token requests when switching channels, which speeds up the switching process and reduces the load on your token server.

Parameters

token
The new token.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: The input parameter is invalid. For example, an invalid token is used. You need to provide valid parameters and rejoin the channel.
    • -7: The IRtcEngine object is not initialized. You must successfully initialize the IRtcEngine object before calling this method.

UpdateRtmpTranscoding

Updates the RTMP transcoding configuration.

public abstract int UpdateRtmpTranscoding(LiveTranscoding transcoding);

Agora recommends using a more complete server-side streaming service. See Implement Server-Side RTMP Streaming. After enabling transcoding streaming, you can dynamically update the transcoding configuration based on your scenario. After the transcoding configuration is updated, the SDK triggers the OnTranscodingUpdated callback.

Parameters

transcoding
The RTMP transcoding configuration. See LiveTranscoding.

Return Values

  • 0: Success.
  • < 0: Failure. See Error Codes for details and resolution suggestions.

UpdateScreenCapture

Updates the configuration parameters for screen capture.

public abstract int UpdateScreenCapture(ScreenCaptureParameters2 captureParams);
If system audio was not captured when screen sharing started and you want to update the configuration to publish system audio, follow these steps:
  1. Call this method and set captureAudio to true.
  2. Call UpdateChannelMediaOptions and set publishScreenCaptureAudio to true to publish the captured audio.
Note:
  • This method is only applicable to Android and iOS platforms.
  • On iOS, screen sharing is only supported on iOS 12.0 and later.

Parameters

captureParams
Encoding configuration parameters for screen sharing. See ScreenCaptureParameters2.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails.
    • -2: The input parameter is invalid.
    • -8: The screen sharing state is invalid. This may occur if you are already sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing and then restart screen sharing.

UpdateScreenCaptureParameters

Updates the configuration parameters for screen capture.

public abstract int UpdateScreenCaptureParameters(ScreenCaptureParameters captureParams);
Note:
  • This method is only applicable to Windows and macOS platforms.
  • Call this method after starting screen or window sharing.

Parameters

captureParams
Encoding configuration parameters for screen sharing. See ScreenCaptureParameters.
Note: The video properties of the screen sharing stream should be set only through this parameter and are unrelated to SetVideoEncoderConfiguration.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: The input parameter is invalid.
    • -8: The screen sharing state is invalid. This may occur if you are already sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing and then restart screen sharing.

UpdateScreenCaptureRegion

Updates the region for screen capture.

public abstract int UpdateScreenCaptureRegion(Rectangle regionRect);
Note: Call this method after starting screen or window sharing.

Parameters

regionRect
The position of the region to be shared relative to the entire screen or window. If not set, the entire screen or window is shared. See Rectangle. If the specified region exceeds the screen or window boundaries, only the content within the screen or window is shared; if width or height is set to 0, the entire screen or window is shared.

Return Values

  • 0: The method call succeeds.
  • < 0: The method call fails. See Error Codes for details and resolution suggestions.
    • -2: The input parameter is invalid.
    • -8: The screen sharing state is invalid. This may occur if you are already sharing another screen or window. Try calling StopScreenCapture [1/2] to stop the current sharing and then restart screen sharing.