RtcEngine

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

RtcEngine provides the main methods that your app can call.

addHandler

Adds event handlers.

public void addHandler(IRtcEngineEventHandler handler) {
    mInstance.addHandler(handler);
}

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

Parameters

handler
Callback events to be added. For details, see IRtcEngineEventHandler.

addVideoWatermark [1/2]

Adds a watermark image to the local video.

public abstract int addVideoWatermark(AgoraImage watermark);
Deprecated:
This method is deprecated. Use addVideoWatermark [2/2] instead.

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

addVideoWatermark [2/2]

Adds a watermark image to the local video.

public abstract int addVideoWatermark(String watermarkUrl, WatermarkOptions options);

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

The watermark coordinatesare dependent on the settings in the setVideoEncoderConfiguration method:
  • If the orientation mode of the encoding video (ORIENTATION_MODE) is fixed landscape mode or the adaptive landscape mode, the watermark uses the landscape orientation.
  • If the orientation mode of the encoding video (ORIENTATION_MODE) is fixed portrait mode or the adaptive portrait mode, the watermark uses the portrait orientation.
  • When setting the watermark position, the region must be less than thesetVideoEncoderConfiguration dimensions set in the method; otherwise, the watermark image will be cropped.
Attention:
  • Ensure that call this method after enableVideo.
  • If you only want to add a watermark to the Media Push, you can call this method or the setLiveTranscoding method.
  • This method supports adding a watermark image in the PNG file format only. Supported pixel formats of the PNG image are RGBA, RGB, Palette, Gray, and Alpha_gray.
  • If the dimensions of the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings.
  • If you have enabledthe local video preview by calling the startPreview [1/2] method, you can use the visibleInPreview member to set whether or not the watermark is visible in the preview.
  • If you have enabled the mirror mode for the local video, the watermark on the local video is also mirrored. To avoid mirroring the watermark, Agora recommends that you do not use the mirror and watermark functions for the local video at the same time. You can implement the watermark function in your application layer.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustAudioMixingPlayoutVolume

Adjusts the volume of audio mixing for local playback.

public abstract int adjustAudioMixingPlayoutVolume(int volume);
Attention: Call this method after calling startAudioMixing [2/2] and receiving the onAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustAudioMixingPublishVolume

Adjusts the volume of audio mixing for publishing.

public abstract int adjustAudioMixingPublishVolume(int volume);

This method adjusts the audio mixing volume on the remote clients.

Attention:

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustAudioMixingPublishVolume

Adjusts the volume of audio mixing for publishing.

public abstract int adjustAudioMixingPublishVolume(int volume);

This method adjusts the audio mixing volume on the remote clients.

Attention:

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustCustomAudioPublishVolume

Adjusts the volume of the custom external audio source when it is published in the channel.

public abstract int adjustCustomAudioPublishVolume(int sourceId, int volume);
Attention: Ensure you have called the setExternalAudioSource [2/2] method to create an external audio track before calling this method.

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

Parameters

sourceId
The ID of external audio source. If you want to publish a custom external audio source, set this parameter to the ID of the corresponding custom audio track you want to publish.
volume
The volume of the audio source. The value can range from 0 to 100. 0 means mute; 100 means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

adjustAudioMixingVolume

Adjusts the volume during audio mixing.

public abstract int adjustAudioMixingVolume(int volume);

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

Attention:

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustPlaybackSignalVolume

Adjusts the playback signal volume of all remote users.

public abstract int adjustPlaybackSignalVolume(int volume);
Attention:
  • This method adjusts the playback volume that is the mixed volume of all remote users.
  • You can call this method either before or after joining a channel.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustRecordingSignalVolume

Adjusts the capturing signal volume.

public abstract int adjustRecordingSignalVolume(int volume);
Attention:

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

adjustUserPlaybackSignalVolume

Adjusts the playback signal volume of a specified remote user.

public abstract int adjustUserPlaybackSignalVolume(int uid, int volume);

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

Attention:
  • Call this method after joining a channel.
  • The playback volume here refers to the mixed volume of a specified remote user.

Parameters

uid
The user ID of the remote user.
volume
Audio mixing volume. The value ranges between 0 and 100. The default value is 100, which means the original volume.

Returns

  • 0: Success.
  • < 0: Failure.

clearVideoWatermarks

Removes the watermark image from the video stream.

public abstract int clearVideoWatermarks();

Returns

  • 0: Success.
  • < 0: Failure.

complain

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

public abstract int complain(String callId, String description);

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • 3: The SDK is not ready. Possible reasons include the following:
      • The initialization of RtcEngine fails. Reinitialize the RtcEngine.
      • No user has joined the channel when the method is called. Please check your code logic.
      • The user has not left the channel when the rate or complain method is called. Please check your code logic.
      • The audio module is disabled. The program is not complete.

configRhythmPlayer

Configures the virtual metronome.

public abstract int configRhythmPlayer(AgoraRhythmPlayerConfig config);

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

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

Parameters

config
The metronome configuration. See AgoraRhythmPlayerConfig.

Returns

  • 0: Success.
  • < 0: Failure.

create [1/2]

Creates and initializes RtcEngine.

public static synchronized RtcEngine create(
      Context context, String appId, IRtcEngineEventHandler handler) throws Exception {}

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

Attention:
  • Before calling other APIs, you must call this method to create the RtcEngine object.
  • You can create the RtcEngine instance either by calling this method or by calling create [2/2]. The difference between create [2/2] and this method is that create [2/2] supports more configurations when creating the RtcEngine instance, for example, specifying the region for connection and setting the log files.
  • The SDK supports creating only one RtcEngine instance for an app.

Parameters

context

The context of Android Activity.

appId
The App ID issued by Agora for your project. Only users in apps with the same App ID can join the same channel and communicate with each other. An App ID can only be used to create one RtcEngine instance. To change your App ID, call destroy to destroy the current RtcEngine instance, and then create a new one.
handler
The event handler for RtcEngine. See IRtcEngineEventHandler.

Returns

  • The RtcEngine instance, if the method call succeeds.
  • An error code, if the call fails,.

Exception

Exception
Fails to create the instance.

create [2/2]

Creates and initializes RtcEngine.

public static synchronized RtcEngine create(RtcEngineConfig config) throws Exception {}

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

Attention:
  • Before calling other APIs, you must call this method to create the RtcEngine object.
  • You can create the RtcEngine instance either by calling this method or by calling create [1/2]. The difference between create [1/2] and this method is that this method supports more configurations when creating the RtcEngine instance, for example, specifying the region for connection and setting the log files.
  • The SDK supports creating only one RtcEngine instance for an app.

Parameters

config

Configurations for the RtcEngine instance. See RtcEngineConfig.

Returns

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

Returns

  • The RtcEngine instance, if the method call succeeds.
  • An error code, if the call fails,.

Exception

Exception
Fails to create the instance.

createDataStream [1/2]

Creates a data stream.

public abstract int createDataStream(boolean reliable, boolean ordered);

Each user can create up to five data streams during the lifecycle of RtcEngine.

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

Parameters

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

Returns

  • ID of the created data stream, if the method call succeeds.
  • < 0: Failure.

createDataStream [2/2]

Creates a data stream.

public abstract int createDataStream(DataStreamConfig config);

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

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

Parameters

config
The configurations for the data stream. See DataStreamConfig.

Returns

  • ID of the created data stream, if the method call succeeds.
  • < 0: Failure.

createMediaPlayer

Creates a media player instance.

public abstract IMediaPlayer createMediaPlayer();

Returns

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

CreateRendererView

Creates a RendererView.

public static SurfaceView CreateRendererView(Context context) {
    return new SurfaceView(context);
Deprecated:
This method is deprecated. Use the Android native method SurfaceView instead.

This method returns the SurfaceView type. The operation and layout of the view are managed by the app, and the Agora SDK renders the view provided by the app. The video display view must be created using this method instead of directly calling SurfaceView.

To use a SurfaceView, call this method; to use a TextureView, call CreateTextureView.
Attention: Call this in the main thread.

Parameters

context
The context of the Android Activity.

Returns

SurfaceView

CreateTextureView

Creates a TextureView.

public static TextureView CreateTextureView(Context context) {
    return new TextureView(context);
Deprecated:
This method is deprecated. Use the Android native method TextureView instead.

You can call this method to create a TextureView, which is suitable for scenarios that require scaling, rotation, and parallel coordinate translation of video images, such as screen sharing. The operation and layout of the view are managed by the app, and the Agora SDK renders the view provided by the app.

To use a TextureView, call this method; to use a SurfaceView, call CreateRendererView.
Attention: Call this in the main thread.

Parameters

context
The context of the Android Activity.

Returns

TextureView

createCustomVideoTrack

Creates a customized video track.

public abstract int createCustomVideoTrack();
When you need to publish multiple custom captured videos in the channel, you can refer to the following steps:
  1. Call this method to create a video track and get the video track ID.
  2. In each channel's ChannelMediaOptions, set the customVideoTrackId parameter to the ID of the video track you want to publish, and set publishCustomVideoTrack to true.
  3. If you call pushExternalVideoFrameEx [2/2], and specify customVideoTrackId as the videoTrackId set in step 2, you can publish the corresponding custom video source in multiple channels.

Returns

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

destroyCustomVideoTrack

Destroys the specified video track.

public abstract int destroyCustomVideoTrack(int video_track_id);

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

destroy

Releases the RtcEngine instance.

public static synchronized void destroy() {
                if (mInstance == null)
                return;
                mInstance.doDestroy();
                mInstance = null;
                System.gc();
                }
            

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

After a successful method call, you can no longer use any method or callback in the SDK anymore. If you want to use the real-time communication functions again, you must call create [2/2] to create a new RtcEngine instance.

Attention: If you want to create a new RtcEngine instance after destroying the current one, ensure that you wait till the destroy method execution to complete.

disableAudio

Disables the audio module.

public abstract int disableAudio();
Attention:
  • This method disables the internal engine and can be called anytime after initialization. It is still valid after one leaves channel.
  • This method resets the internal engine and takes some time to take effect. Agora recommends using the following API methods to control the audio modules separately:

Returns

  • 0: Success.
  • < 0: Failure.

disableAudioSpectrumMonitor

Disables audio spectrum monitoring.

public abstract int disableAudioSpectrumMonitor();

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

Attention:

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

Returns

  • 0: Success.
  • < 0: Failure.

disableVideo

Disables the video module.

public abstract int disableVideo();

This method disables video. You can call this method either before or after joining a channel. If you call it before joining a channel, an audio call starts when you join the channel. If you call it after joining a channel, a video call switches to an audio call. Call enableVideo to enable video.

A successful call of this method triggers the onUserEnableVideo (false) callback on the remote client.

Attention:
  • This method affects the internal engine and can be called after leaving the channel.
  • This method resets the internal engine and takes some time to take effect. Agora recommends using the following API methods to control the video engine modules separately:

Returns

  • 0: Success.
  • < 0: Failure.

enableAudio

Enables the audio module.

public abstract int enableAudio();

The audio mode is enabled by default.

Attention:
  • This method enables the internal engine and can be called anytime after initialization. It is still valid after one leaves channel.
  • This method enables the audio module and takes some time to take effect. Agora recommends using the following API methods to control the audio module separately:

Returns

  • 0: Success.
  • < 0: Failure.

enableAudioQualityIndication

Enabled the audio quality notification callback.

public abstract int enableAudioQualityIndication(boolean enabled);
Deprecated:
Deprecated as of v2.4.1.

Parameters

enabled
Whether to enable or disable the audio quality callback.
  • true: Enable the audio quality notification callback.
  • false: (Default) Disable the audio quality notification callback.

Returns

  • 0: Success.
  • < 0: Failure.

enableAudioSpectrumMonitor

Turns on audio spectrum monitoring.

public abstract int enableAudioSpectrumMonitor(int intervalInMS);

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

Attention:

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

Parameters

intervalInMS

The interval (in milliseconds) at which the SDK triggers the onLocalAudioSpectrum and onRemoteAudioSpectrum callbacks. The default value is 100. Do not set this parameter to less than 10 milliseconds, otherwise the calling of this method fails.

Returns

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

enableAudioVolumeIndication

Enables the reporting of users' volume indication.

public abstract int enableAudioVolumeIndication(int interval, int smooth, boolean reportVad);

This method enables the SDK to regularly report the volume information of the local user who sends a stream and remote users (up to three) whose instantaneous volumes are the highest to the app. Once you call this method and users send streams in the channel, the SDK triggers the onAudioVolumeIndication callback at the time interval set in this method.

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

Parameters

interval
Sets the time interval between two consecutive volume indications:
  • ≤ 0: Disables the volume indication.
  • > 0: Time interval (ms) between two consecutive volume indications. You need to set this parameter to an integer multiple of 200. If the value is lower than 200, the SDK automatically adjusts the value to 200.
smooth
The smoothing factor sets the sensitivity of the audio volume indicator. The value ranges between 0 and 10. The recommended value is 3. The greater the value, the more sensitive the indicator.
reportVad
  • true: Enable the voice activity detection of the local user. Once it is enabled,the vad parameter of the onAudioVolumeIndication callback reports the voice activity status of the local user.
  • false: (Default) Disable the voice activity detection of the local user. Once it is disabled, the vad parameter of the onAudioVolumeIndication callback does not report the voice activity status of the local user, except for the scenario where the engine automatically detects the voice activity of the local user.

Returns

  • 0: Success.
  • < 0: Failure.

enableContentInspect

Enables or disables video screenshot and upload.

public abstract int enableContentInspect(boolean enabled, ContentInspectConfig config);

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

Note:
  • Before calling this method, ensure that you contact contact technical support to enbale Agora video screenshot and upload service.
  • This method relies on the video content moderation library libagora_ci_extension.so. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

enabled
Whether to enable video screenshot and upload:
  • true: Enables video screenshot and upload.
  • false: Disables video screenshot and upload.
config
Configuration of video screenshot and upload. See ContentInspectConfig.

Returns

  • 0: Success.
  • < 0: Failure.

enableDualStreamMode [1/2]

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

public abstract int enableDualStreamMode(boolean enabled);
Dual streams are a hybrid of a high-quality video stream and a low-quality video stream:
  • High-quality video stream: High bitrate, high resolution.
  • Low-quality video stream: Low bitrate, low resolution.

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

enableDualStreamMode [2/2]

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

public abstract int enableDualStreamMode(boolean enabled, SimulcastStreamConfig streamConfig);
You can call this method to enable or disable the dual-stream mode on the publisher side. Dual streams are a hybrid of a high-quality video stream and a low-quality video stream:
  • High-quality video stream: High bitrate, high resolution.
  • Low-quality video stream: Low bitrate, low resolution.

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

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

Parameters

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

The configuration of the low-quality video stream. See SimulcastStreamConfig.

Returns

  • 0: Success.
  • < 0: Failure.

enableEncryption

Enables/Disables the built-in encryption.

public abstract int enableEncryption(boolean enabled, EncryptionConfig config);

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

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

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

Parameters

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

Returns

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

enableExtension

Enables/Disables extensions.

public abstract int enableExtension(String provider, String extension, boolean enable);

Ensure that you call this method before joining a channel.

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

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.

Returns

  • 0: Success.
  • < 0: Failure.

enableFaceDetection

Enables/Disables face detection for the local user.

public abstract int enableFaceDetection(boolean enabled);

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

Once face detection is enabled, the SDK triggers the onFacePositionChanged callback to report the face information of the local user, which includes the following:
  • The width and height of the local video.
  • The position of the human face in the local view.
  • The distance between the human face and the screen.

This method needs to be called after the camera is started (for example, by calling startPreview [1/2] or joinChannel [2/2]).

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

enableInEarMonitoring [1/2]

Enables in-ear monitoring.

public abstract int enableInEarMonitoring(boolean enabled);

This method enables or disables in-ear monitoring.

Attention:
  • Users must use wired earphones to hear their own voices.
  • You can call this method either before or after joining a channel.

Parameters

enabled
Enables in-ear monitoring.
  • true: Enables in-ear monitoring.
  • false: (Default) Disables in-ear monitoring.

Returns

  • 0: Success.
  • < 0: Failure.

enableInEarMonitoring [2/2]

Enables in-ear monitoring.

public abstract int enableInEarMonitoring(boolean enabled, int includeAudioFilters);

This method enables or disables in-ear monitoring.

Attention:
  • Users must use wired earphones to hear their own voices.
  • You can call this method either before or after joining a channel.

Parameters

enabled
Enables or disables in-ear monitoring.
  • true: Enables in-ear monitoring.
  • false: (Default) Disables in-ear monitoring.
includeAudioFilters
The audio filter of in-ear monitoring:
  • EAR_MONITORING_FILTER_NONE(1 << 0): Do not add an audio filter to the in-ear monitor.
  • EAR_MONITORING_FILTER_BUILT_IN_AUDIO_FILTERS(1 << 1): Add an audio filter to the in-ear monitor. If you implement functions such as voice beautifier and audio effect, users can hear the voice after adding these effects.
  • EAR_MONITORING_FILTER_NOISE_SUPPRESSION(1 << 2): Enable noise suppression to the in-ear monitor.
    You can use the bitwise OR operator (|) to specify multiple audio filters.
    Attention: If you set the enabled parameter to false, you do not need to set the includeAudioFilters parameter.

Returns

  • 0: Success.
  • < 0: Failure.

enableLocalAudio

Enables/Disables the local audio capture.

public abstract int enableLocalAudio(boolean enabled);

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

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

Once the local audio function is disabled or re-enabled, the SDK triggers the onLocalAudioStateChanged callback, which reports LOCAL_AUDIO_STREAM_STATE_STOPPED (0) or LOCAL_AUDIO_STREAM_STATE_RECORDING (1).
Attention:
  • This method is different from the muteLocalAudioStream method:
    • enableLocalAudio: Disables/Re-enables the local audio capturing and processing. If you disable or re-enable local audio capturing using the enableLocalAudio method, the local user might hear a pause in the remote audio playback.
    • muteLocalAudioStream: Sends/Stops sending the local audio streams.
  • You can call this method either before or after joining a channel. Calling it before joining a channel only sets the device state, and it takes effect immediately after you join the channel.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

enableLocalVideo

Enables/Disables the local video capture.

public abstract int enableLocalVideo(boolean enabled);

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

After calling enableVideo, the local video capturer is enabled by default. You can call enableLocalVideo(false) to disable the local video capturer. If you want to re-enable the local video, call enableLocalVideo(true).

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

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

Parameters

enabled

Whether to enable the local video capture.

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

Returns

  • 0: Success.
  • < 0: Failure.

enableRemoteSuperResolution

Enables/Disables the super resolution algorithm for a remote user's video stream.

public abstract int enableRemoteSuperResolution(int uid, boolean enable);

This function can effectively improve the resolution of the remote video picture seen by the local user, that is, the width and height (pixels) of the video received by the specified remote user are enlarged to 2 times original size.

After calling this method, you can confirm whether super resolution is successfully enabled through the remote video stream statistics (RemoteVideoStats) in the onRemoteVideoStats callback:
  • If the parameter superResolutionType >0: Super resolution is enabled.
  • If the parameter superResolutionType =0: Super resolution is not enabled.
CAUTION:

The super resolution feature requires extra system resources. To balance the visual experience and system consumption, this feature can only be enabled for a single remote user. If the local user uses super resolution on Android, the original resolution of the remote user's video cannot exceed 640 × 360 pixels.

Attention:
  • This method relies on the super resolution dynamic library libagora_super_resolution_extension.so. If the dynamic library is deleted, the function cannot be enabled normally.
  • Because this method has certain system performance requirements, Agora recommends that you use the following devices or better:
    • Android:
      • VIVO: V1821A, NEX S, 1914A, 1916A, 1962A, 1824BA, X60, X60 Pro
      • OPPO: PCCM00, Find X3
      • OnePlus: A6000
      • Xiaomi: Mi 8, Mi 9, Mi 10, Mi 11, MIX3, Redmi K20 Pro
      • SAMSUNG: SM-G9600, SM-G9650, SM-N9600, SM-G9708, SM-G960U, SM-G9750, S20, S21
      • HUAWEI: SEA-AL00, ELE-AL00, VOG-AL00, YAL-AL10, HMA-AL00, EVR-AN00, nova 4, nova 5 Pro, nova 6 5G, nova 7 5G, Mate 30, Mate 30 Pro, Mate 40, Mate 40 Pro, P40, P40 Pro, Huawei M6, MatePad 10.8

Parameters

uid
The user ID of the remote user.
enable
Whether to enable super resolution for the remote user’s video:
  • true:Enable super resolution.
  • false: Disable super resolution.

Returns

  • 0: Success.
  • < 0: Failure.

enableSoundPositionIndication

Enables/Disables stereo panning for remote users.

public abstract int enableSoundPositionIndication(boolean enabled);

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

enableVideo

Enables the video module.

public abstract int enableVideo();

Call this method either before joining a channel or during a call. If this method is called before joining a channel, the call starts in the video mode. Call disableVideo to disable the video mode.

A successful call of this method triggers the onRemoteVideoStateChanged callback on the remote client.

Attention:
  • This method enables the internal engine and is valid after leaving the channel.
  • This method resets the internal engine and takes some time to take effect. Agora recommends using the following API methods to control the video engine modules separately:

Returns

  • 0: Success.
  • < 0: Failure.

enableVideoImageSource

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

public abstract int enableVideoImageSource(boolean enabled, ImageTrackOptions options);
Attention: Agora recommends that you call this method after joining a channel.

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

enableVirtualBackground

Enables/Disables the virtual background.

public abstract int enableVirtualBackground(
      boolean enabled, VirtualBackgroundSource backgroundSource);

The virtual background function allows you to replace the original background image of the local user or to blur the background. After successfully enabling the virtual background function, all users in the channel can see the customized background.

Call this method before calling enableVideo or startPreview [1/2].

Attention:
  • This function requires a high-performance device. Agora recommends that you use this function on devices with the following chips:
    • Snapdragon 700 series 750G and later
    • Snapdragon 800 series 835 and later
    • Dimensity 700 series 720 and later
    • Kirin 800 series 810 and later
    • Kirin 900 series 980 and later
  • Agora recommends that you use this function in scenarios that meet the following conditions:
    • A high-definition camera device is used, and the environment is uniformly lit.
    • There are few objects in the captured video. Portraits are half-length and unobstructed. Ensure that the background is a solid color that is different from the color of the user's clothing.

Parameters

enabled
Whether to enable virtual background:
  • true: Enable virtual background.
  • false: Disable virtual background.
backgroundSource
The custom background image. See VirtualBackgroundSource. To adapt the resolution of the custom background image to that of the video captured by the SDK, the SDK scales and crops the custom background image while ensuring that the content of the custom background image is not distorted.
segproperty
Processing properties for background images. See SegmentationProperty.

Returns

  • 0: Success.
  • < 0: Failure.
    • -1: The custom background image does not exist. Check the value of source in VirtualBackgroundSource.
    • -2: The color format of the custom background image is invalid. Check the value of color in VirtualBackgroundSource.
    • -3: The device does not support virtual background.

enableWebSdkInteroperability

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

public abstract int enableWebSdkInteroperability(boolean enabled);
Deprecated:
The SDK automatically enables interoperability with the Web SDK, so you no longer need to call this method.

This method enables or disables interoperability with the Agora Web SDK. If the channel has Web SDK users, ensure that you call this method, or the video of the Native user will be a black screen for the Web user.

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

getAudioDeviceInfo

Gets the audio device information.

public abstract DeviceInfo getAudioDeviceInfo();

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

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

Returns

The DeviceInfo object that identifies the audio device information.
  • Not null: Success.
  • Null: Failure.

getAudioMixingCurrentPosition

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

public abstract int getAudioMixingCurrentPosition();

Retrieves the playback position (ms) of the audio.

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

Returns

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

getAudioMixingDuration

Retrieves the duration (ms) of the music file.

public abstract int getAudioMixingDuration();

Retrieves the total duration (ms) of the audio file.

Attention:

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

Returns

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

getAudioMixingPlayoutVolume

Retrieves the audio mixing volume for local playback.

public abstract int getAudioMixingPlayoutVolume();

This method retrieves the audio mixing volume for local playback. You can use it to troubleshoot audio volume related issues.

Attention:

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

Returns

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

getAudioMixingPublishVolume

Retrieves the audio mixing volume for publishing.

public abstract int getAudioMixingPublishVolume();

This method helps to troubleshoot audio volume‑related issues.

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

Returns

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

getAudioTrackCount

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

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

Returns

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

getCallId

Retrieves the call ID.

public abstract String getCallId();

When a user joins a channel on a client, a callId is generated to identify the call from the client. Some methods, such as rate and complain, must be called after the call ends to submit feedback to the SDK. These methods require the callId parameter.

Attention: Call this method after joining a channel.

Returns

The current call ID.

getCameraMaxZoomFactor

Gets the maximum zoom ratio supported by the camera.

public abstract float getCameraMaxZoomFactor();
Attention:

Returns

The maximum zoom factor.

getConnectionState

Gets the current connection state of the SDK.

public abstract RtcConnection.CONNECTION_STATE_TYPE getConnectionState();

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

Returns

The current connection state.

getEffectCurrentPosition

Retrieves the playback position of the audio effect file.

public int getEffectCurrentPosition(int soundId);
Attention: Call this method after the playEffect [2/2] method.

Parameters

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

Returns

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

getEffectDuration

Retrieves the duration of the audio effect file.

public abstract int getEffectDuration(String filePath);
Attention: Call this method after joining a channel.

Parameters

filePath
File path:
  • Android: The file path, which needs to be accurate to the file name and suffix. Agora supports using a URI address, an absolute path, or a path that starts with /assets/. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: content://com.android.providers.media.documents/document/audio%3A14441.

Returns

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

getErrorDescription

Gets the warning or error description.

public static String getErrorDescription(int error)

Parameters

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

Returns

The specific error or warning description.

getExtensionProperty [1/2]

Gets detailed information of the extensions.

public abstract String getExtensionProperty(String provider, String extension, String key);

Parameters

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

Returns

  • The extension information, if the method call succeeds.
  • An empty string, if the method call fails.

getExtensionProperty [2/2]

Gets detailed information of the extensions.

public abstract String getExtensionProperty(
      String provider, String extension, String key, Constants.MediaSourceType sourceType);

Parameters

provider
The name of the extension provider.
extension
The name of the extension.
key
The key of the extension.
sourceType
Source type of the extension. See MediaSourceType.

Returns

  • The extension information, if the method call succeeds.
  • An empty string, if the method call fails.

getNativeHandle

Gets the C++ handle of the Native SDK.

public abstract long getNativeHandle();

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

Returns

The native handle of the SDK.

getNetworkType

Gets the type of the local network connection.

public abstract int getNetworkType();
Since
v4.0.1

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

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

Returns

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

getUserInfoByUid

Gets the user information by passing in the user ID.

public abstract int getUserInfoByUid(int uid, UserInfo userInfo);

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

getUserInfoByUserAccount

Gets the user information by passing in the User Account.

public abstract int getUserInfoByUserAccount(String userAccount, UserInfo userInfo);

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

getSdkVersion

Gets the SDK version.

public static String getSdkVersion()

Parameters

Returns

The SDK version number. The format is a string.

isCameraAutoFocusFaceModeSupported

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

public abstract boolean isCameraAutoFocusFaceModeSupported();
Attention:

Returns

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

isCameraExposurePositionSupported

Checks whether the device supports manual exposure.

public abstract boolean isCameraExposurePositionSupported();
Attention:

Returns

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

isCameraFaceDetectSupported

Checks whether the device camera supports face detection.

public abstract boolean isCameraFaceDetectSupported();

Returns

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

isCameraFocusSupported

Check whether the device supports the manual focus function.

public abstract boolean isCameraFocusSupported();
Attention:

Returns

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

isCameraTorchSupported

Checks whether the device supports camera flash.

public abstract boolean isCameraTorchSupported();
Attention:
  • Call this method after enabling the local camera, for example, by calling joinChannel [2/2], enableVideo, or enableLocalVideo,depending on which method you use to turn on your local camera.
  • The app enables the front camera by default. If your front camera does not support enabling the flash, this method returns false. If you want to check whether the rear camera supports the flash function, call switchCamera before this method.

Returns

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

isCameraZoomSupported

Checks whether the device supports camera zoom.

public abstract boolean isCameraZoomSupported();
Attention:

Returns

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

isSpeakerphoneEnabled

Checks whether the speakerphone is enabled.

public abstract boolean isSpeakerphoneEnabled();

Returns

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

isTextureEncodeSupported

Check whether the video supports the Texture encoding.

public abstract boolean isTextureEncodeSupported();

Returns

  • true: Supports the Texture encoding.
  • false: Does not support the Texture encoding.

joinChannel [1/2]

Joins a channel.

public abstract int joinChannel(
    String token, String channelName, String optionalInfo, int optionalUid);

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

A successful call of this method triggers the following callbacks:

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

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

Parameters

token
The token generated on your server for authentication. See .
channelId
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&amp;", "(", ")", "+", "-", ":", ";", "&lt;", "= ", ".", "&gt;", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
optionalInfo
(Optional) Reserved for future use.
optionalUid
The user ID. This parameter is used to identify the user in the channel for real-time audio and video interaction. You need to set and manage user IDs yourself, and ensure that each user ID in the same channel is unique. This parameter is a 32-bit unsigned integer. The value range is 1 to 232-1. If the user ID is not assigned (or set to 0), the SDK assigns a random user ID and returns it in the onJoinChannelSuccess callback. Your application must record and maintain the returned user ID, because the SDK does not do so.

Returns

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

joinChannel [2/2]

Joins a channel with media options.

public abstract int joinChannel(
      String token, String channelId, int uid, ChannelMediaOptions options);

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

A successful call of this method triggers the following callbacks:

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

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

Attention:
  • This method allows users to join only one channel at a time.
  • Ensure that the app ID you use to generate the token is the same app ID that you pass in the create [2/2] method; otherwise, you may fail to join the channel by token.

Parameters

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

Returns

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

joinChannelWithUserAccount [1/2]

Joins a channel with a User Account and Token.

public abstract int joinChannelWithUserAccount(
                    String token, String channelName, String userAccount);
This method allows a user to join the channel with the user account and a token. After the user successfully joins the channel, the SDK triggers the following callbacks:

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

Attention: To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.

Parameters

token
The token generated on your server for authentication. See .
channelName
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&amp;", "(", ")", "+", "-", ":", ";", "&lt;", "= ", ".", "&gt;", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are (89 in total):
  • The 26 lowercase English letters: a to z.
  • The 26 uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&amp;", "(", ")", "+", "-", ":", ";", "&lt;", "= ", ".", "&gt;", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","

Returns

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

joinChannelWithUserAccount [2/2]

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

public abstract int joinChannelWithUserAccount(
                    String token, String channelName, String userAccount, ChannelMediaOptions options);
This method allows a user to join the channel with the user account. After the user successfully joins the channel, the SDK triggers the following callbacks:

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

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

Attention: To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.

Parameters

token
The token generated on your server for authentication. See .
channelName
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&amp;", "(", ")", "+", "-", ":", ";", "&lt;", "= ", ".", "&gt;", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
userAccount
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as NULL. Supported characters are (89 in total):
  • The 26 lowercase English letters: a to z.
  • The 26 uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • Space
  • "!", "#", "$", "%", "&amp;", "(", ")", "+", "-", ":", ";", "&lt;", "= ", ".", "&gt;", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
options
The channel media options. See ChannelMediaOptions.

Returns

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

leaveChannel [1/2]

Leaves a channel.

public abstract int leaveChannel();

This method releases all resources related to the session.

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

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

If you successfully call this method and leave the channel, the following callbacks are triggered:
  • The local client: onLeaveChannel.
  • The remote client: onUserOffline, if the user joining the channel is in the Communication profile, or is a host in the Live-broadcasting profile.
Attention:
  • If you call destroy immediately after calling this method, the SDK does not trigger the onLeaveChannel callback.

Returns

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

leaveChannel [2/2]

Leaves a channel.

public abstract int leaveChannel(LeaveChannelOptions options);

This method lets the user leave the channel, for example, by hanging up or exiting the call.

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

No matter whether you are currently in a call or not, you can call this method without side effects. This method releases all resources related to the session.

This method call is asynchronous. When this method returns, it does not necessarily mean that the user has left the channel. After you leave the channel, the SDK triggers the onLeaveChannel callback.

A successful call of this method triggers the following callbacks: The local client: onLeaveChannel. The remote client: onUserOffline, if the user joining the channel is in the COMMUNICATION profile, or is a host in the LIVE_BROADCASTING profile.

Attention:
  • If you call destroy immediately after calling this method, the SDK does not trigger the onLeaveChannel callback.

Parameters

options
The options for leaving the channel. See LeaveChannelOptions.

Returns

  • 0: Success.
  • < 0: Failure.

muteAllRemoteAudioStreams

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

public abstract int muteAllRemoteAudioStreams(boolean muted);

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

Attention:
  • Call this method after joining a channel.
  • If you do not want to subscribe the audio streams of remote users before joining a channel, you can call joinChannel [2/2] and set autoSubscribeAudio as false.
  • See recommended settings in Set the Subscribing State.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

muteAllRemoteVideoStreams

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

public abstract int muteAllRemoteVideoStreams(boolean muted);

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

Attention:
  • Call this method after joining a channel.
  • If you do not want to subscribe the video streams of remote users before joining a channel, you can call joinChannel [2/2] and set autoSubscribeVideo as false.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

muteLocalAudioStream

Stops or resumes publishing the local audio stream.

public abstract int muteLocalAudioStream(boolean muted);
Attention: This method does not affect any ongoing audio recording, because it does not disable the audio capture device.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

muteLocalVideoStream

Stops or resumes publishing the local video stream.

public abstract int muteLocalVideoStream(boolean muted);

A successful call of this method triggers the onUserMuteVideo callback on the remote client.

Attention:
  • This method executes faster than the enableLocalVideo(false) method, which controls the sending of the local video stream.
  • This method does not affect any ongoing video recording, because it does not disable the camera.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

muteRecordingSignal

Whether to mute the recording signal.

public abstract int muteRecordingSignal(boolean muted);

Parameters

muted
  • true: Mute the recording signal.
  • false: (Default) Do not mute the recording signal.

Returns

  • 0: Success.
  • < 0: Failure.

muteRemoteAudioStream

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

public abstract int muteRemoteAudioStream(int uid, boolean muted);
Attention:
  • Call this method after joining a channel.

Parameters

uid
The user ID of the specified user.
muted
Whether to stop subscribing to the audio stream of the specified user.
  • true: Unsubscribe from the specified user's audio stream.
  • false: (Default) Subscribes to the specified user's audio stream.

Returns

  • 0: Success.
  • < 0: Failure.

muteRemoteVideoStream

Cancels or resumes subscribing to the specified remote user's video stream.

public abstract int muteRemoteVideoStream(int userId, boolean muted);
Attention:
  • Call this method after joining a channel.

Parameters

userId
The user ID of the specified user.
muted
Whether to subscribe to the specified remote user's video stream.
  • true: Unsubscribe from the specified user's video stream.
  • false: (Default) Subscribes to the specified user's video stream.

Returns

  • 0: Success.
  • < 0: Failure.

pauseAllChannelMediaRelay

Pauses the media stream relay to all destination channels.

public abstract int pauseAllChannelMediaRelay();

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

After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback to report whether the media stream relay is successfully paused.

Attention: Call this method after the startChannelMediaRelay method.

Returns

  • 0: Success.
  • < 0: Failure.

pauseAudioMixing

Pauses playing the music file.

public abstract int pauseAudioMixing();

Call this method after joining a channel.

Returns

  • 0: Success.
  • < 0: Failure.

pullPlaybackAudioFrame [1/2]

Pulls the remote audio data.

public abstract int pullPlaybackAudioFrame(byte[] data, int lengthInByte);

Before calling this method, you need to call setExternalAudioSink to notify the app to enable and set the external rendering.

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

Attention:
  • This method only supports pulling data from custom audio source. If you need to pull the data captured by the SDK, do not call this method.
  • Call this method after joining a channel.
  • Once you enable the external audio sink, the app will not retrieve any audio data from the onPlaybackAudioFrame callback.
  • The difference between this method and the onPlaybackAudioFrame callback is as follows:
    • The SDK sends the audio data to the app through the onPlaybackAudioFrame callback. Any delay in processing the audio frames may result in audio jitter.
    • After a successful method call, the app automatically pulls the audio data from the SDK. After setting the audio data parameters, the SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback.

Parameters

data
The remote audio data to be pulled. The data type is byte[].
lengthInByte
The data length (byte). The value of this parameter is related to the audio duration, and the values of the sampleRate and channels parameters that you set in setExternalAudioSink. lengthInByte = sampleRate/1000 × 2 × channels × audio duration (ms).

Returns

  • 0: Success.
  • < 0: Failure.

pullPlaybackAudioFrame [2/2]

Pulls the remote audio data.

public abstract int pullPlaybackAudioFrame(ByteBuffer data, int lengthInByte);

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

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

Attention:
  • Call this method after joining a channel.
  • The difference between this method and the onPlaybackAudioFrame callback is as follows:
    • onPlaybackAudioFrame: The SDK sends the audio data to the app through this callback. Any delay in processing the audio frames may result in audio jitter.
    • pullPlaybackAudioFrame [1/2]: The app pulls the remote audio data. After setting the audio data parameters, the SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback.

Parameters

data
The remote audio data to be pulled. The data type is ByteBuffer.
lengthInByte
The length (in bytes) of the remote audio data. The value of this parameter is related to the audio duration,and the values of the sampleRate and channels parameters that you set in setExternalAudioSink. lengthInByte = sampleRate/1000 × 2 × channels × audio duration (ms).

Returns

  • 0: Success.
  • < 0: Failure.

pushExternalAudioFrame [1/2]

Pushes the external audio frame.

public abstract int pushExternalAudioFrame(byte[] data, long timestamp);

Parameters

data
External audio data.
timestamp
The timestamp (ms) of the external audio frame. It is required. You can use it to restore the order of the captured audio frame, or synchronize audio and video frames in video-related scenarios (including scenarios where external video sources are used).

Returns

  • 0: Success.
  • < 0: Failure.

pushExternalAudioFrame [2/2]

Pushes the external audio frames to the SDK.

public abstract int pushExternalAudioFrame(ByteBuffer data, long timestamp, int sourceId);
Attention:

Make sure you set the publishCustomAudioTrack in the ChannelMediaOptions as true before calling this method.

Parameters

data
External audio data.
timestamp
The timestamp (ms) of the external audio frame. It is required. You can use it to restore the order of the captured audio frame, or synchronize audio and video frames in video-related scenarios (including scenarios where external video sources are used).
sourceId
The ID of external audio source. If you want to publish a custom external audio source, set this parameter to the ID of the corresponding custom audio track you want to publish.

Returns

  • 0: Success.
  • < 0: Failure.

pushExternalVideoFrame [1/2]

Pushes the external raw video frame to the SDK.

public abstract boolean pushExternalVideoFrame(AgoraVideoFrame frame);
Deprecated:
If you need to push video frames in I422 format, you need to use this method; otherwise, use pushExternalVideoFrame [2/2] instead.

To push the unencoded external raw video frame to the SDK, call setExternalVideoSource, set enabled as true, and set encodedFrame as false.

You can push the video frame either by calling this method or by calling pushExternalVideoFrame [2/2]. The difference is that the pushExternalVideoFrame [1/2] method does not support video data in texture format.

Parameters

frame

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

Returns

  • true: Pushes the external raw video frame to the SDK successfully.
  • false: Fails to push external raw video frame to the SDK.

pushExternalVideoFrame [2/2]

Pushes the external video frame.

public abstract boolean pushExternalVideoFrame(VideoFrame frame);

This method actively encapsulates the video frame data with the VideoFrame class and passes it to the SDK. Call the setExternalVideoSource method and set enable as true before calling this method; otherwise, a failure returns after calling this method.

You can push the video frame either by calling this method or by calling pushExternalVideoFrame [1/2]. The difference is that the pushExternalVideoFrame [2/2] method supports video data in texture format.

Parameters

frame
Video frame to be pushed. See VideoFrame.

Returns

  • true: Pushes the external raw video frame to the SDK successfully.
  • false: Fails to push external raw video frame to the SDK.

rate

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

public abstract int rate(String callId, int rating, String description);
Attention: Ensure that you call this method after leaving a channel.

Parameters

callId
The current call ID. You can get the call ID by calling getCallId.
rating
The rating of the call. The value is between 1 (lowest score) and 5 (highest score). If you set a value out of this range, the SDK returns the -2 (ERR_INVALID_ARGUMENT) error.
description
(Optional) A description of the call. The string length should be less than 800 bytes.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2 (ERR_INVALID_ARGUMENT).
    • -3 (ERR_NOT_READY).

registerAudioEncodedFrameObserver

Registers an encoded audio observer.

public abstract int registerAudioEncodedFrameObserver(
      AudioEncodedFrameObserverConfig config, IAudioEncodedFrameObserver observer);
Attention:
  • Call this method after joining a channel.
  • You can call this method or the startAudioRecording [2/2] method to set the audio content and audio quality. Agora recommends not using this method and startAudioRecording [2/2] at the same time; otherwise, only the method called later takes effect.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

registerAudioFrameObserver

Registers an audio frame observer object.

public abstract int registerAudioFrameObserver(IAudioFrameObserver observer);

Call this method to register an audio frame observer object (register a callback). When you need the SDK to trigger onMixedAudioFrame, onRecordAudioFrame, onPlaybackAudioFrame or onEarMonitoringAudioFrame callback, you need to use this method to register the callbacks.

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

Parameters

observer

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

Returns

  • 0: Success.
  • < 0: Failure.

registerAudioSpectrumObserver

Registers an audio spectrum observer.

public abstract int registerAudioSpectrumObserver(IAudioSpectrumObserver observer);

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

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

Parameters

observer

The Audio spectrum observer. See IAudioSpectrumObserver.

Returns

  • 0: Success.
  • < 0: Failure.

registerLocalUserAccount

Registers a user account.

public abstract int registerLocalUserAccount(String appId, String userAccount);

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

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

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

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

registerMediaMetadataObserver

Registers the metadata observer.

public abstract int registerMediaMetadataObserver(IMetadataObserver observer, int type);

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

A successful call of this method triggers the getMaxMetadataSize callback.

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

Parameters

observer
The metadata observer. See IMetadataObserver.
type

The metadata type. The SDK currently only supports VIDEO_METADATA.

Returns

  • 0: Success.
  • < 0: Failure.

registerVideoFrameObserver

Registers a video frame observer object.

public abstract int registerVideoFrameObserver(IVideoFrameObserver observer);

You need to implement the IVideoFrameObserver class in this method and register callbacks according to your scenarios. After you successfully register the video frame observer, the SDK triggers the registered callbacks each time a video frame is received.

Attention:
  • When handling the video data returned in the callbacks, pay attention to the changes in the width and height parameters, which may be adapted under the following circumstances:
    • When the network condition deteriorates, the video resolution decreases incrementally.
    • If the user adjusts the video profile, the resolution of the video returned in the callbacks also changes.
  • Ensure that you call this method before joining a channel.

Parameters

observer
The observer object instance. See IVideoFrameObserver. To release the instance, set the value as NULL.

Returns

  • 0: Success.
  • < 0: Failure.

destroy

Releases the RtcEngine instance.

public static synchronized void destroy() {
                if (mInstance == null)
                return;
                mInstance.doDestroy();
                mInstance = null;
                System.gc();
                }
            

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

After a successful method call, you can no longer use any method or callback in the SDK anymore. If you want to use the real-time communication functions again, you must call create [2/2] to create a new RtcEngine instance.

Attention: If you want to create a new RtcEngine instance after destroying the current one, ensure that you wait till the destroy method execution to complete.

removeHandler

Removes the specified IRtcEngineEventHandler instance.

public void removeHandler(IRtcEngineEventHandler handler) {
    mInstance.removeHandler((IAgoraEventHandler) handler);
  }

This method removes the specified callback handler. For callback events that you want to listen for only once, call this method to remove the relevant callback handler after you have received them.

Parameters

handler
The callback handler to be deleted. See IRtcEngineEventHandler.

renewToken

Gets a new token when the current token expires after a period of time.

public abstract int renewToken(String token);
You can use this method to pass a new token to the SDK. A token expires after a certain period of time. In the following two cases, the app should call this method to pass in a new token. Failure to do so will result in the SDK disconnecting from the server.

Parameters

token
The new token.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid. For example, the token is invalid. You need to fill in a valid parameter.
    • -7: The RtcEngine object has not been initialized. You need to initialize the RtcEngine object before calling this method.

resumeAllChannelMediaRelay

Resumes the media stream relay to all destination channels.

public abstract int resumeAllChannelMediaRelay();

After calling the pauseAllChannelMediaRelay method, you can call this method to resume relaying media streams to all destination channels.

After a successful method call, the SDK triggers the onChannelMediaRelayEvent callback to report whether the media stream relay is successfully resumed.

Attention: Call this method after the pauseAllChannelMediaRelay method.

Returns

  • 0: Success.
  • < 0: Failure.

resumeAudioMixing

Resumes playing and mixing the music file.

public abstract int resumeAudioMixing();

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

Returns

  • 0: Success.
  • < 0: Failure.

selectAudioTrack

Selects the audio track used during playback.

 public abstract int selectAudioTrack(int audioIndex);

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

Note:

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

sendCustomReportMessage

Reports customized messages.

public abstract int sendCustomReportMessage(
      String id, String category, String event, String label, int value);

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

sendStreamMessage

Sends data stream messages.

public abstract int sendStreamMessage(int streamId, byte[] message);
Sends data stream messages to all users in a channel. The SDK has the following restrictions on this method:
  • Up to 30 packets can be sent per second in a channel with each packet having a maximum size of 1 KB.
  • Each client can send up to 6 KB of data per second.
  • Each user can have up to five data streams simultaneously.

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setAdvancedAudioOptions

Sets audio advanced options.

public abstract int SetAdvancedAudioOptions(AdvancedAudioOptions options);

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

Attention:

Parameters

options
The advanced options for audio. See AdvancedAudioOptions.

Returns

  • 0: Success.
  • < 0: Failure.

setAudioEffectParameters

Sets parameters for SDK preset audio effects.

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

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

Attention:

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setAudioEffectPreset

Sets an SDK preset audio effect.

public abstract int setAudioEffectPreset(int preset);

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

To get better audio effect quality, Agora recommends calling setAudioProfile [1/2] and setting the scenario parameter as AUDIO_SCENARIO_GAME_STREAMING (3) before calling this method.

Attention:
  • You can call this method either before or after joining a channel.
  • Do not set the profile parameter in setAudioProfile [1/2] to SPEECH_STANDARD(1), or the method does not take effect.
  • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
  • If you call setAudioEffectPreset and set enumerators except for ROOM_ACOUSTICS_3D_VOICE or PITCH_CORRECTION, do not call setAudioEffectParameters; otherwise, setAudioEffectPreset is overridden.
  • After calling setAudioEffectPreset, Agora recommends not calling the following methods, or the settings in setAudioEffectPreset are overridden:
  • This method relies on the voice beautifier dynamic library libagora_audio_beauty_extension.so. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

preset
Preset voice effects.
  • AUDIO_EFFECT_OFF: Turn off audio effects and use the original voice.
  • ROOM_ACOUSTICS_KTV: The reverberation style typical of a KTV venue.
  • ROOM_ACOUSTICS_VOCAL_CONCERT: The reverberation style typical of a concert hall.
  • ROOM_ACOUSTICS_STUDIO: The reverberation style typical of a recording studio.
  • ROOM_ACOUSTICS_PHONOGRAPH: The reverberation style typical of the vintage phonograph.
  • ROOM_ACOUSTICS_VIRTUAL_STEREO: A virtual stereo effect that renders monophonic audio as stereo audio. Before using this preset, set the profile parameter of setAudioProfile [1/2] to MUSIC_HIGH_QUALITY or MUSIC_HIGH_QUALITY_STEREO; otherwise, the preset setting is invalid.
  • ROOM_ACOUSTICS_SPACIAL: A more spatial audio effect.
  • ROOM_ACOUSTICS_ETHEREAL: A more ethereal audio effect.
  • ROOM_ACOUSTICS_3D_VOICE: A 3D voice effect that makes the voice appear to be moving around the user. The default movement cycle is 10 seconds. After setting this effect, you can call setAudioEffectParameters to modify the movement period.
    • Before using this preset, set the profile parameter of setAudioProfile [1/2] to MUSIC_STANDARD_STEREO or MUSIC_HIGH_QUALITY_STEREO; otherwise, the preset setting is invalid.
    • If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_UNCLE: The reverberation style typical of an uncle's voice. Agora recommends using this preset to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_OLDMAN: The voice of an old man. Agora recommends using this preset to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_BOY: The voice of a boy. Agora recommends using this preset to process a male-sounding voice; otherwise, you may not hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_SISTER: The voice of a young woman. Agora recommends using this preset to process a female-sounding voice; otherwise, you may not hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_GIRL: The voice of a girl. Agora recommends using this preset to process a female-sounding voice; otherwise, you may not hear the anticipated voice effect.
  • VOICE_CHANGER_EFFECT_PIGKING: The voice of Pig King, a character in Journey to the West who has a voice like a growling bear.
  • VOICE_CHANGER_EFFECT_HULK: The voice of the Hulk.
  • STYLE_TRANSFORMATION_RNB: The reverberation style typical of R&B music. Before using this preset, set the profile parameter of setAudioProfile [1/2] to MUSIC_HIGH_QUALITY or MUSIC_HIGH_QUALITY_STEREO; otherwise, the preset setting is invalid.
  • STYLE_TRANSFORMATION_POPULAR: The reverberation style typical of popular music. Before using this preset, set the profile parameter of setAudioProfile [1/2] to MUSIC_HIGH_QUALITY or MUSIC_HIGH_QUALITY_STEREO; otherwise, the preset setting is invalid.
  • PITCH_CORRECTION: A pitch correction effect that corrects the user's pitch based on the pitch of the natural C major scale. After setting this voice effect, you can call setAudioEffectParameters to adjust the basic mode of tuning and the pitch of the main tone.

Returns

  • 0: Success.
  • < 0: Failure.

setAudioMixingDualMonoMode

Sets the channel mode of the current audio file.

public abstract int setAudioMixingDualMonoMode(Constants.AudioMixingDualMonoMode mode);

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

Attention:

Parameters

mode
The channel mode. See AudioMixingDualMonoMode.

Returns

  • 0: Success.
  • < 0: Failure.

setAudioMixingPitch

Sets the pitch of the local music file.

public abstract int setAudioMixingPitch(int pitch);

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setAudioMixingPosition

Sets the audio mixing position.

public abstract int setAudioMixingPosition(int pos);

Call this method to set the playback position of the music file to a different starting position, rather than playing the file from the beginning.

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

Parameters

pos
Integer. The playback position (ms).

Returns

  • 0: Success.
  • < 0: Failure.

setAudioProfile [1/2]

Sets the audio profile and audio scenario.

public abstract int setAudioProfile(int profile, int scenario);
Deprecated:
This method is deprecated. If you need to set the audio profile, use setAudioProfile [2/2]; if you need to set the audio scenario, use setAudioScenario.
Attention:
  • You can call this method either before or after joining a channel.
  • In scenarios requiring high-quality audio, such as online music tutoring, Agora recommends you set profile as MUSIC_HIGH_QUALITY(4)and scenario as AUDIO_SCENARIO_GAME_STREAMING(3).

Parameters

profile
The audio profile, including the sampling rate, bitrate, encoding mode, and the number of channels.
  • DEFAULT(0): The default value.
    • For the interactive streaming profile: A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps.
    • For the communication profile: A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • SPEECH_STANDARD(1): A sampling rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • MUSIC_STANDARD(2): A sampling rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps.
  • MUSIC_STANDARD_STEREO(3): A sampling rate of 48 kHz, music encoding, stereo, and a bitrate of up to 80 Kbps.
  • MUSIC_HIGH_QUALITY(4): A sampling rate of 48 kHz, music encoding, mono, and a bitrate of up to 96 Kbps.
  • MUSIC_HIGH_QUALITY_STEREO(5): A sampling rate of 48 kHz, music encoding, stereo, and a bitrate of up to 128 Kbps.
scenario
The audio scenarios. Under different audio scenarios, the device uses different volume types.
  • AUDIO_SCENARIO_DEFAULT(0): Automatic scenario match, where the SDK chooses the appropriate audio quality according to the user role and audio route.
  • AUDIO_SCENARIO_GAME_STREAMING(3): High-quality audio scenario, where users mainly play music.
  • AUDIO_SCENARIO_CHATROOM(5): Chatroom scenario, where users need to frequently switch the user role or mute and unmute the microphone. In this scenario, audience members receive a pop-up window to request permission of using microphones.
  • AUDIO_SCENARIO_CHORUS(7): Real-time chorus scenario, where users have good network conditions and require ultra-low latency.
    Attention: Before using this enumeration, you need to call getAudioDeviceInfo to get whether the audio device supports ultra-low-latency capture and playback. Only on audio devices that support ultra-low latency (isLowLatencyAudioSupported = true) can you experience ultra-low latency.
  • AUDIO_SCENARIO_MEETING(8): Meeting scenario that mainly involves the human voice.

Returns

  • 0: Success.
  • < 0: Failure.

setAudioProfile [2/2]

Sets the audio parameters and application scenarios.

public synchronized int setAudioProfile(int profile)
Attention:
  • You can call this method either before or after joining a channel.
  • In scenarios requiring high-quality audio, such as online music tutoring, Agora recommends you set profile as MUSIC_HIGH_QUALITY (4).
  • If you want to set the audio scenario, call create [2/2] and set mAudioScenario in the RtcEngineConfig struct.

Parameters

profile
The audio profile, including the sampling rate, bitrate, encoding mode, and the number of channels.
  • DEFAULT(0): The default value.
    • For the interactive streaming profile: A sample rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps.
    • For the communication profile: A sample rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • SPEECH_STANDARD(1): A sampling rate of 32 kHz, audio encoding, mono, and a bitrate of up to 18 Kbps.
  • MUSIC_STANDARD(2): A sampling rate of 48 kHz, music encoding, mono, and a bitrate of up to 64 Kbps.
  • MUSIC_STANDARD_STEREO(3): A sampling rate of 48 kHz, music encoding, stereo, and a bitrate of up to 80 Kbps.
  • MUSIC_HIGH_QUALITY(4): A sampling rate of 48 kHz, music encoding, mono, and a bitrate of up to 96 Kbps.
  • MUSIC_HIGH_QUALITY_STEREO(5): A sampling rate of 48 kHz, music encoding, stereo, and a bitrate of up to 128 Kbps.

Returns

  • 0: Success.
  • < 0: Failure.

setAudioScenario

Sets audio scenarios.

public abstract int setAudioScenario(int scenario);
Note: You can call this method either before or after joining a channel.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setBeautyEffectOptions

Sets the image enhancement options.

public abstract int setBeautyEffectOptions(boolean enabled, BeautyOptions options);

Enables or disables image enhancement, and sets the options.

Note:
  • Call this method before calling enableVideo or startPreview [1/2].
  • This method only applies to Android 5.0 or later.
  • This method relies on the video enhancement dynamic library libagora_clear_vision_extension.so. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.
    • ERR_NOT_SUPPORTED(4): The system version is earlier than Android 5.0, which does not support this function.

setCameraAutoFocusFaceModeEnabled

Sets whether to enable face autofocus.

public abstract int setCameraAutoFocusFaceModeEnabled(boolean enabled);

The SDK disables face autofocus by default. To set face autofocus, call this method.

Attention:

Parameters

enabled
Whether to enable face autofocus:
  • true: Enable face autofocus.
  • false: Disable face autofocus.

Returns

  • 0: Success.
  • < 0: Failure.

setCameraExposurePosition

Sets the camera exposure position.

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

This method needs to be called after the camera is started (for example, by calling startPreview [1/2] or joinChannel [2/2]).

After a successful method call, the SDK triggers the onCameraExposureAreaChanged callback.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setCameraFocusPositionInPreview

Sets the camera manual focus position.

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

This method needs to be called after the camera is started (for example, by calling startPreview [1/2] or joinChannel [2/2]). After a successful method call, the SDK triggers the onCameraFocusAreaChanged callback.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setCameraTorchOn

Enables the camera flash.

public abstract int setCameraTorchOn(boolean isOn);
Attention:

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setCameraZoomFactor

Sets the camera zoom ratio.

public abstract int setCameraZoomFactor(float factor);
Attention:

Parameters

factor
The camera zoom ratio. The value ranges between 1.0 and the maximum zoom supported by the device. You can get the maximum zoom ratio supported by the device by calling the getCameraMaxZoomFactor method.

Returns

  • The camera zoom factor value, if successful.
  • < 0: Failure.

setChannelProfile

Sets the channel profile.

public abstract int setChannelProfile(int profile);

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

Attention:
  • To ensure the quality of real-time communication, Agora recommends that all users in a channel use the same channel profile.
  • This method must be called and set before joinChannel [2/2], and cannot be set again after joining the channel.
  • The default audio route and video encoding bitrate are different in different channel profiles. For details, see setDefaultAudioRouteToSpeakerphone and setVideoEncoderConfiguration.

Parameters

profile
The channel profile.
  • CHANNEL_PROFILE_COMMUNICATION(0): Communication. Use this profile when there are only two users in the channel.
  • CHANNEL_PROFILE_LIVE_BROADCASTING(1): Live streaming. Use this profile when there are more than two users in the channel.
  • CHANNEL_PROFILE_GAME(2): This profile is deprecated.
  • CHANNEL_PROFILE_CLOUD_GAMING(3): Interaction. The scenario is optimized for latency. Use this profile if the use case requires frequent interactions between users.

Returns

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

setClientRole [1/2]

Sets the client role.

public abstract int setClientRole(int role);

You can call this method either before or after joining the channel to set the user role as audience or host.

If you call this method to set the user's role as the host before joining the channel and set the local video property through the setupLocalVideo method, the local video preview is automatically enabled when the user joins the channel.

If you call this method to switch the user role after joining the channel, the SDK triggers the following callbacks:

Parameters

role
The user role:
  • CLIENT_ROLE_BROADCASTER(1): Host.
  • CLIENT_ROLE_AUDIENCE(2): Audience.

Returns

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

setClientRole [2/2]

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

public abstract int setClientRole(int role, ClientRoleOptions options);

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

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

If you call this method to set the user's role as the host before joining the channel and set the local video property through the setupLocalVideo method, the local video preview is automatically enabled when the user joins the channel.

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

Parameters

role
The user role in the interactive live streaming.
  • CLIENT_ROLE_BROADCASTER(1): Host. A host can both send and receive streams.
  • CLIENT_ROLE_AUDIENCE(2): (Default) Audience. An audience member can only receive streams.
options
The detailed options of a user, including the user level. See ClientRoleOptions.

Returns

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

setCloudProxy

Sets the Agora cloud proxy service.

public abstract int setCloudProxy(int proxyType);

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

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

To disable the cloud proxy that has been set, call the setCloudProxy (TRANSPORT_TYPE_NONE_PROXY).

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

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

Parameters

proxyType
Type of the cloud proxy.
  • TRANSPORT_TYPE_NONE_PROXY(0): The automatic mode. The SDK has this mode enabled by default. In this mode, the SDK attempts a direct connection to SD-RTN™ and automatically switches to TCP/TLS 443 if the attempt fails.
  • TRANSPORT_TYPE_UDP_PROXY(1): The cloud proxy for the UDP protocol, that is, the Force UDP cloud proxy mode. In this mode, the SDK always transmits data over UDP.
  • TRANSPORT_TYPE_TCP_PROXY(2): The cloud proxy for the TCP (encryption) protocol, that is, the Force TCP cloud proxy mode. In this mode, the SDK always transmits data over TCP/TLS 443.

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

Returns

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

setColorEnhanceOptions

Sets color enhancement.

public abstract int setColorEnhanceOptions(boolean enabled, ColorEnhanceOptions options);

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

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

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

Parameters

enabled
Whether to enable color enhancement:
  • true Enable color enhancement.
  • false: (Default) Disable color enhancement.
options
The color enhancement options. See ColorEnhanceOptions.

Returns

  • 0: Success.
  • < 0: Failure.

setDefaultAudioRouteToSpeakerphone

Sets the default audio playback route.

public abstract int setDefaultAudioRoutetoSpeakerphone(boolean defaultToSpeaker);

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

Depending on the scenario, Agora uses different default audio routes. See the following:
  • Voice call: Earpiece.
  • Audio broadcast: Speakerphone.
  • Video call: Speakerphone.
  • Video broadcast: Speakerphone.

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

Note:

The system audio route changes when an external audio device, such as a headphone or a Bluetooth audio device, is connected. See Principles for Changing the Audio Route.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setDualStreamMode [1/2]

Sets dual-stream mode on the sender side.

public abstract int setDualStreamMode(Constants.SimulcastStreamMode mode);
Since
v4.0.1

The SDK enables the low-quality video stream auto mode on the sender by default, which is equivalent to calling this method and setting the mode to AUTO_SIMULCAST_STREAM. If you want to modify this behavior, you can call this method and modify the mode to DISABLE_SIMULCAST_STREAM(always never send low-quality video streams) or ENABLE_SIMULCAST_STREAM (always send low-quality video streams).

Note: The difference and connection between this method and enableDualStreamMode [1/2] is as follows:
  • When calling this method and setting mode to DISABLE_SIMULCAST_STREAM, it has the same effect as enableDualStreamMode [1/2](false).
  • When calling this method and setting mode to ENABLE_SIMULCAST_STREAM, it has the same effect as enableDualStreamMode [1/2](true).
  • Both methods can be called before and after joining a channel. If they are used at the same time, the settings in the method called later shall prevail.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setDualStreamMode [2/2]

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

public abstract int setDualStreamMode(
      Constants.SimulcastStreamMode mode, SimulcastStreamConfig streamConfig);
Since
v4.0.1

The SDK enables the low-quality video stream auto mode on the sender by default, which is equivalent to calling this method and setting the mode to AUTO_SIMULCAST_STREAM. If you want to modify this behavior, you can call this method and modify the mode to DISABLE_SIMULCAST_STREAM(always never send low-quality video streams) or ENABLE_SIMULCAST_STREAM (always send low-quality video streams).

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

Note: The difference and connection between this method and enableDualStreamMode [1/2] is as follows:
  • When calling this method and setting mode to DISABLE_SIMULCAST_STREAM, it has the same effect as enableDualStreamMode [1/2](false).
  • When calling this method and setting mode to ENABLE_SIMULCAST_STREAM, it has the same effect as enableDualStreamMode [1/2](true).
  • Both methods can be called before and after joining a channel. If they are used at the same time, the settings in the method called later shall prevail.

Parameters

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

The configuration of the low-quality video stream. See SimulcastStreamConfig.

Returns

  • 0: Success.
  • < 0: Failure.

setEffectPosition

Sets the playback position of an audio effect file.

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

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

Attention: Call this method after playEffect.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setEarMonitoringAudioFrameParameters

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

public abstract int setEarMonitoringAudioFrameParameters(
    int sampleRate, int channel, int mode, int samplesPerCall);

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

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

Parameters

sampleRate
The sample rate of the audio data reported in the onEarMonitoringAudioFrame callback, which can be set as 8,000, 16,000, 32,000, 44,100, or 48,000 Hz.
channel
The number of audio channels reported in the onEarMonitoringAudioFrame callback.
  • 1: Mono.
  • 2: Stereo.
mode
The use mode of the audio frame:
  • RAW_AUDIO_FRAME_OP_MODE_READ_ONLY(0): Read-only mode. Users only read the audio data without modifying anything. For example, when users acquire the data with the Agora SDK, then push the RTMP streams.
  • RAW_AUDIO_FRAME_OP_MODE_READ_WRITE(2): Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, when users have their own audio-effect processing module and perform some voice pre-processing, such as a voice change.
samplesPerCall
The number of data samples reported in the onEarMonitoringAudioFrame callback, such as 1,024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

setEnableSpeakerphone

Enables/Disables the audio route to the speakerphone.

public abstract int setEnableSpeakerphone(boolean enabled);

After a successful method call, the SDK triggers the onAudioRouteChanged callback.

You can call this method before joining a channel, when in a channel, or after leaving a channel. However, Agora recommends calling this method only when you are in a channel to change the audio route temporarily.

Attention:
  • If you do not have a clear requirement for transient settings, Agora recommends calling setDefaultAudioRouteToSpeakerphone to set the audio route.
  • Any user behavior or audio-related API call might change the transient setting of setEnableSpeakerphone. See Audio Route for detailed change principles.

Parameters

enabled
Whether to set the speakerphone as the default audio route:
  • true: Set the speakerphone as the audio route temporarily.
  • false: Do not set the speakerphone as the audio route.

Returns

  • 0: Success.
  • < 0: Failure.

setEncryptionMode

Sets the built-in encryption mode.

public abstract int setEncryptionMode(String encryptionMode);
Deprecated:
Use enableEncryption instead.

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setEncryptionSecret

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

public abstract int setEncryptionSecret(String secret);
Deprecated:
This method is deprecated. Use enableEncryption instead.

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

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

Parameters

secret
The encryption password.

Returns

  • 0: Success.
  • < 0: Failure.

setExtensionProperty

Sets the properties of the extension.

public abstract int setExtensionProperty(
      String provider, String extension, String key, String value);

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setExtensionProviderProperty

Sets the properties of the extension provider.

public abstract int setExtensionProviderProperty(String provider, String key, String value);

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

Attention:

Call this method after enableExtension, and before enabling the audio (enableAudio/enableLocalAudio) or the video (enableVideo/enableLocalVideo).

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setExternalAudioSink

Sets the external audio sink.

public abstract int setExternalAudioSink(boolean enabled, int sampleRate, int channels);

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

Parameters

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

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

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

Returns

  • 0: Success.
  • < 0: Failure.

setExternalAudioSource [1/2]

Sets the external audio source.

public abstract int setExternalAudioSource(boolean enabled, int sampleRate, int channels);

Call this method before calling joinChannel [1/2] and startPreview [1/2].

Parameters

enabled
  • true: Enable the external audio source.
  • false: (Default) Disable the external audio source.
sampleRate
The sample rate (Hz) of the external audio source, which can be set as 8000, 16000, 32000, 44100, or 48000.
channels
The number of audio channels of the external audio source:
  • 1: Mono.
  • 2: Stereo.

Returns

  • 0: Success.
  • < 0: Failure.

setExternalAudioSource [2/2]

Sets the external audio source parameters.

public abstract int setExternalAudioSource(boolean enabled, int sampleRate, int channels,
      int sourceNumber, boolean localPlayback, boolean publish);
Attention: Call this method before joining a channel.

Parameters

enabled
Whether to enable the external audio source:
  • true: Enable the external audio source.
  • false: (Default) Disable the external audio source.
sampleRate
The sample rate (Hz) of the external audio source, which can be set as 8000, 16000, 32000, 44100, or 48000.
channels
The number of channels of the external audio source, which can be set as 1 (Mono) or 2 (Stereo).
sourceNumber
The number of external audio sources. The value of this parameter should be larger than 0. The SDK creates a corresponding number of custom audio tracks based on this parameter value and names the audio tracks starting from 0. In ChannelMediaOptions, you can set publishCustomAudioSourceId to the ID of the audio track you want to publish.
localPlayback
Whether to play the external audio source:
  • true: Play the external audio source.
  • false: (Default) Do not play the external source.
publish
Whether to publish audio to the remote users:
  • true: (Default) Publish audio to the remote users.
  • false: Do not publish audio to the remote users

Returns

  • 0: Success.
  • < 0: Failure.

setExternalVideoSource

Configures the external video source.

public abstract int setExternalVideoSource(
    boolean enable, boolean useTexture, Constants.ExternalVideoSourceType sourceType);
Attention: Call this method before joining a channel.

Parameters

enable
Whether to use the external video source:
  • true: Use the external video source. The SDK prepares to accept the external video frame.
  • false: (Default) Do not use the external video source.
useTexture
Whether to use the external video frame in the Texture format.
  • true: Use the external video frame in the Texture format.
  • false: (Default) Do not use the external video frame in the Texture format.
sourceType
Whether to encode the external video frame, see ExternalVideoSourceType.

Returns

  • 0: Success.
  • < 0: Failure.

setHeadphoneEQPreset

Set the preset headphone equalization effect.

public abstract int setHeadphoneEQPreset(int preset);
Since
v4.0.1

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

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

Parameters

preset
The preset headphone equalization effect. See HEADPHONE_EQUALIZER_PRESET.

Returns

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

setInEarMonitoringVolume

Sets the volume of the in-ear monitor.

public abstract int setInEarMonitoringVolume(int volume);
Attention:
  • Users must use wired earphones to hear their own voices.
  • You can call this method either before or after joining a channel.

Parameters

volume
The volume of the in-ear monitor. The value ranges between 0 and 100. The default value is 100.

Returns

  • 0: Success.
  • < 0: Failure.

setLocalRenderMode [1/2]

Sets the local video display mode.


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

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

Parameters

renderMode
The local video display mode.
  • RENDER_MODE_HIDDEN(1): Hidden mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
  • RENDER_MODE_ADAPTIVE(3): This mode is deprecated.

Returns

  • 0: Success.
  • < 0: Failure.

setLocalRenderMode [2/2]

Updates the display mode of the local video view.

public abstract int setLocalRenderMode(int renderMode, int mirrorMode);

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

Attention:
  • Ensure that you have called the setupLocalVideo method to initialize the local video view before calling this method.
  • During a call, you can call this method as many times as necessary to update the display mode of the local video view.

Parameters

renderMode
The local video display mode.
  • RENDER_MODE_HIDDEN(1): Hidden mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
  • RENDER_MODE_ADAPTIVE(3): This mode is deprecated.
mirrorMode
For the local user:
  • MIRROR_MODE_AUTO(0): (Default) The mirror mode determined by the SDK. If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.
  • MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • MIRROR_MODE_DISABLED(2): Disable the mirror mode.
Attention: If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.

Returns

  • 0: Success.
  • < 0: Failure.

setLocalVideoMirrorMode

Sets the local video mirror mode.

public abstract int setLocalVideoMirrorMode(int mode);
Deprecated:
This method is deprecated.
Use setupLocalVideo or setLocalRenderMode [2/2] instead.

Parameters

mode
  • MIRROR_MODE_AUTO(0): (Default) The mirror mode determined by the SDK. If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.
  • MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • MIRROR_MODE_DISABLED(2): Disable the mirror mode.

Returns

  • 0: Success.
  • < 0: Failure.

setLocalVoiceEqualization

Sets the local voice equalization effect.

public abstract int setLocalVoiceEqualization(
      Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, int bandGain);
Attention: You can call this method either before or after joining a channel.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setLocalVoicePitch

Changes the voice pitch of the local speaker.

public abstract int setLocalVoicePitch(double pitch);
Attention: You can call this method either before or after joining a channel.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setLocalVoiceReverb

Sets the local voice reverberation.

public abstract int setLocalVoiceReverb(Constants.AUDIO_REVERB_TYPE reverbKey, int value);

The SDK also provides the setAudioEffectPreset method, which allows you to directly implement preset reverb effects for such as pop, R&B, and KTV.

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

Parameters

reverbKey
The reverberation key. Agora provides five reverberation keys; see AUDIO_REVERB_TYPE for details.
value
The value of the reverberation key.

Returns

  • 0: Success.
  • < 0: Failure.

setLocalVoiceReverbPreset

Sets the local voice reverberation option, including the virtual stereo.

public abstract int setLocalVoiceReverbPreset(int reverbPreset);
Deprecated:
Use setAudioEffectPreset or setVoiceBeautifierPreset instead.

This method sets the local voice reverberation for users in a COMMUNICATION channel or hosts in a LIVE_BROADCASTING channel. After successfully calling this method, all users in the channel can hear the voice with reverberation.

Attention:
  • When using the enumeration value prefixed with AUDIO_REVERB_FX, ensure that you set the profile parameter in setAudioProfile [1/2] to MUSIC_HIGH_QUALITY (4) or MUSIC_HIGH_QUALITY_STEREO (5) before calling this method. Otherwise, the method setting is invalid.
  • When calling the AUDIO_VIRTUAL_STEREO method, Agora recommends setting the profile parameter in setAudioProfile [1/2] as MUSIC_HIGH_QUALITY_STEREO (5).
  • This method works best with the human voice, and Agora does not recommend using it for audio containing music and a human voice.
  • You can call this method either before or after joining a channel.

Parameters

reverbPreset
The local voice reverberation option. To achieve better voice effects, Agora recommends the enumeration whose name begins with AUDIO_REVERB_FX.
  • AUDIO_REVERB_OFF: (Default) Turn off local voice reverberation, that is, to use the original voice.
  • AUDIO_REVERB_FX_KTV: The reverberation style typical of a KTV venue (enhanced).
  • AUDIO_REVERB_FX_VOCAL_CONCERT: The reverberation style typical of a concert hall (enhanced).
  • AUDIO_REVERB_FX_UNCLE: The reverberation style typical of an uncle's voice.
  • AUDIO_REVERB_FX_SISTER: The reverberation style typical of a little sister's voice.
  • AUDIO_REVERB_FX_STUDIO: The reverberation style typical of a recording studio (enhanced).
  • AUDIO_REVERB_FX_POPULAR: The reverberation style typical of popular music (enhanced).
  • AUDIO_REVERB_FX_RNB: The reverberation style typical of R&B music (enhanced).
  • AUDIO_REVERB_FX_PHONOGRAPH: The reverberation style typical of the vintage phonograph.

Returns

  • 0: Success.
  • < 0: Failure.

setLogFile

Sets the log file.

public abstract int setLogFile(String filePath);
Deprecated:
Use the mLogConfig parameter in create [2/2] method instead.

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

Note:

Ensure that you call this method immediately after calling the create [2/2] method to initialize the RtcEngine, or the output log may not be complete.

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setLogFileSize

Sets the log file size.

public abstract int setLogFileSize(long fileSizeInKBytes);
Deprecated:
Use the logConfig parameter in create [2/2] instead.

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

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

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

Parameters

fileSizeInKBytes

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

Returns

  • 0: Success.
  • < 0: Failure.

setLogFilter

Sets the log output level of the SDK.

public abstract int setLogFilter(int filter);
Deprecated:
Use logConfig in create [2/2] instead.

This method sets the output log level of the SDK. You can use one or a combination of the log filter levels. The log level follows the sequence of LOG_FILTER_OFF, LOG_FILTER_CRITICAL, LOG_FILTER_ERROR, LOG_FILTER_WARN, LOG_FILTER_INFO, and LOG_FILTER_DEBUG. Choose a level to see the logs preceding that level.

If, for example, you set the log level to LOG_FILTER_WARN, you see the logs within levels LOG_FILTER_CRITICAL, LOG_FILTER_ERROR, and LOG_FILTER_WARN.

Parameters

filter
The output log level of the SDK.
  • LOG_FILTER_OFF(0): Do not output any log information.
  • LOG_FILTER_DEBUG(0x080f): Output all log information. Set your log filter to this level if you want to get the most complete log file.
  • LOG_FILTER_INFO(0x0f): Output LOG_FILTER_CRITICAL, LOG_FILTER_ERROR, LOG_FILTER_WARN, and LOG_FILTER_INFO level log information. We recommend setting your log filter to this level.
  • LOG_FILTER_WARN(0x0e): Output LOG_FILTER_CRITICAL, LOG_FILTER_ERROR, and LOG_FILTER_WARN level log information.
  • LOG_FILTER_ERROR(0x0c): Output LOG_FILTER_CRITICAL and LOG_FILTER_ERROR level log information.
  • LOG_FILTER_CRITICAL(0x08): Output LOG_FILTER_CRITICAL level log information.

Returns

  • 0: Success.
  • < 0: Failure.

setLogLevel

Sets the output log level of the SDK.

public abstract int setLogLevel(int level);
Deprecated:
This method is deprecated. Use RtcEngineConfig instead to set the log output level.

Choose a level to see the logs preceding that level.

Parameters

level
The log level: LogLevel.

Returns

  • 0: Success.
  • < 0: Failure.

setLowlightEnhanceOptions

Sets low-light enhancement.

public abstract int setLowlightEnhanceOptions(boolean enabled, LowLightEnhanceOptions options);

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

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

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

Parameters

enabled
Whether to enable low-light enhancement function:
  • true: Enable low-light enhancement function.
  • false: (Default) Disable low-light enhancement function.
options
The low-light enhancement options. See LowlightEnhanceOptions.

Returns

  • 0: Success.
  • < 0: Failure.

setMixedAudioFrameParameters

Sets the audio data format reported by onMixedAudioFrame.

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

Parameters

sampleRate

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

channel

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

samplesPerCall

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

Note:

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

Returns

  • 0: Success.
  • < 0: Failure.

setParameters

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

public abstract int setParameters(String parameters);

Contact support@agora.io for details about JSON options.

Parameters

parameters
Pointer to the set parameters in a JSON string.

Returns

  • 0: Success.
  • < 0: Failure.

setPlaybackAudioFrameBeforeMixingParameters

Sets the audio data format reported by onPlaybackAudioFrameBeforeMixing.

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

Parameters

sampleRate

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

channel

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

Returns

  • 0: Success.
  • < 0: Failure.

setPlaybackAudioFrameParameters

Sets the audio data format for playback.

public abstract int setPlaybackAudioFrameParameters(
      int sampleRate, int channel, int mode, int samplesPerCall);

Sets the data format for the onPlaybackAudioFrame callback.

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

Parameters

sampleRate
The sample rate returned in the onPlaybackAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channel
The number of channels returned in the onPlaybackAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
mode
The use mode of the audio frame:
  • RAW_AUDIO_FRAME_OP_MODE_READ_ONLY(0): Read-only mode. Users only read the audio data without modifying anything. For example, when users acquire the data with the Agora SDK, then push the RTMP streams.
  • RAW_AUDIO_FRAME_OP_MODE_READ_WRITE(2): Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, when users have their own audio-effect processing module and perform some voice pre-processing, such as a voice change.
samplesPerCall
The number of data samples returned in the onPlaybackAudioFrame callback, such as 1024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

setRecordingAudioFrameParameters

Sets the format of the captured raw audio data.

public abstract int setRecordingAudioFrameParameters(
      int sampleRate, int channel, int mode, int samplesPerCall);

Sets the audio format for the onRecordAudioFrame callback.

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

Parameters

sampleRate
The sample rate returned in the onRecordAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channel
The number of channels returned in the onRecordAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
mode
The use mode of the audio frame:
  • RAW_AUDIO_FRAME_OP_MODE_READ_ONLY(0): Read-only mode. Users only read the audio data without modifying anything. For example, when users acquire the data with the Agora SDK, then push the RTMP streams.
  • RAW_AUDIO_FRAME_OP_MODE_READ_WRITE(2): Read and write mode: Users read the data from AudioFrame, modify it, and then play it. For example, when users have their own audio-effect processing module and perform some voice pre-processing, such as a voice change.
samplesPerCall
The number of data samples returned in the onRecordAudioFrame callback, such as 1024 for the Media Push.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteDefaultVideoStreamType

Sets the default stream type of subscrption for remote video streams.

public abstract int setRemoteDefaultVideoStreamType(int streamType);

Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode [2/2] (false), the receiver can choose to receive either the high-quality video stream or the low-quality video stream. The high-quality video stream has a higher resolution and bitrate, and the low-quality video stream has a lower resolution and bitrate.

By default, users receive the high-quality video stream. Call this method if you want to switch to the low-quality video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources. The aspect ratio of the low-quality video stream is the same as the high-quality video stream. Once the resolution of the high-quality video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-quality video stream.

The SDK enables the low-quality video stream auto mode on the sender by default (not actively sending low-quality video streams). The host at the receiving end can call this method to initiate a low-quality video stream stream request on the receiving end, and the sender automatically switches to the low-quality video stream mode after receiving the request.

The result of this method returns in the onApiCallExecuted callback.

Attention:
  • Call this method before joining a channel. Agora does not support changing the default subscribed video stream type after joining a channel.
  • If you call both this method and setRemoteVideoStreamType, the SDK applies the settings in the setRemoteVideoStreamType method.

Parameters

streamType
The default video-stream type:
  • VIDEO_STREAM_HIGH(0): High-quality stream, that is, a high-resolution and high-bitrate video stream.
  • VIDEO_STREAM_LOW(1): Low-quality stream, that is, a low-resolution and low-bitrate video stream.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteRenderMode [1/2]

Sets the video display mode of a specified remote user.

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

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

Parameters

userId
The user ID of the remote user.
renderMode
The rendering mode of the remote user view.
  • RENDER_MODE_HIDDEN(1): Hidden mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteRenderMode [2/2]

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

public abstract int setRemoteRenderMode(int userId, int renderMode, int mirrorMode);

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

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

Parameters

userId
The user ID of the remote user.
renderMode
The rendering mode of the remote user view.
  • RENDER_MODE_HIDDEN(1): Hidden mode. Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): Fit mode. Uniformly scale the video until one of its dimension fits the boundary (zoomed to fit). Areas that are not filled due to the disparity in the aspect ratio are filled with black.
  • RENDER_MODE_ADAPTIVE(3): This mode is deprecated.
mirrorMode
The mirror mode of the remote user view.
  • MIRROR_MODE_AUTO(0): (Default) The mirror mode determined by the SDK. If you use a front camera, the SDK enables the mirror mode by default; if you use a rear camera, the SDK disables the mirror mode by default.
  • MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • MIRROR_MODE_DISABLED(2): Disable the mirror mode.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteSubscribeFallbackOption

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

public abstract int setRemoteSubscribeFallbackOption(int option);

When the network is not ideal, the quality of live audio and video can be degraded. If option is set as STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW or STREAM_FALLBACK_OPTION_AUDIO_ONLY, the SDK automatically switches the video from a high-quality stream to a low-quality stream or disables the video when the downlink network conditions cannot support both audio and video to guarantee the quality of the audio. The SDK monitors the network quality and restores the video stream when the network conditions improve.

When the remote video stream falls back to audio-only or when the audio-only stream switches back to the video, the SDK triggers the onRemoteSubscribeFallbackToAudioOnly callback.

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

Parameters

option
The fallback option for the remotely subscribed video stream. The default value is STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW(1).
  • STREAM_FALLBACK_OPTION_DISABLED(0): No fallback behavior for the local/remote video stream when the uplink/downlink network conditions are poor. The quality of the stream is not guaranteed.
  • STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW(1): Under poor downlink network conditions, the remote video stream, to which you subscribe, falls back to the low-quality (low resolution and low bitrate) video stream. This option is only valid forsetRemoteSubscribeFallbackOption .
  • STREAM_FALLBACK_OPTION_AUDIO_ONLY(2): Under poor uplink/downlink network conditions, the remote video stream, to which you subscribe, first falls back to the low-quality (low resolution and low bitrate) video stream; and then to an audio-only stream if the network conditions worsen.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteVideoStreamType

Sets the stream type of the remote video.

public abstract int setRemoteVideoStreamType(int uid, int streamType);

Under limited network conditions, if the publisher has not disabled the dual-stream mode using enableDualStreamMode [2/2](false), the receiver can choose to receive either the high-quality video stream or the low-quality video stream. The high-quality video stream has a higher resolution and bitrate, and the low-quality video stream has a lower resolution and bitrate.

By default, users receive the high-quality video stream. Call this method if you want to switch to the low-quality video stream. This method allows the app to adjust the corresponding video stream type based on the size of the video window to reduce the bandwidth and resources. The aspect ratio of the low-quality video stream is the same as the high-quality video stream. Once the resolution of the high-quality video stream is set, the system automatically sets the resolution, frame rate, and bitrate of the low-quality video stream.

The SDK enables the low-quality video stream auto mode on the sender by default (not actively sending low-quality video streams). The host at the receiving end can call this method to initiate a low-quality video stream stream request on the receiving end, and the sender automatically switches to the low-quality video stream mode after receiving the request.

The result of this method returns in the onApiCallExecuted callback.

Attention: You can call this method either before or after joining a channel. If you call both setRemoteVideoStreamType and setRemoteDefaultVideoStreamType, the setting of setRemoteVideoStreamType takes effect.

Parameters

uid
The user ID.
streamType
The video stream type:
  • 0: High-quality video stream.
  • 1: Low-quality video stream.

Returns

  • 0: Success.
  • < 0: Failure.

setRemoteVoicePosition

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

public abstract int setRemoteVoicePosition(int uid, double pan, double gain);

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

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

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

Parameters

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

Returns

  • 0: Success.
  • < 0: Failure.

setSubscribeAudioBlacklist

Set the blocklist of subscriptions for audio streams.

public abstract int setSubscribeAudioBlacklist(int[] uidList);

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

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

Parameters

uidList

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

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

Returns

  • 0: Success.
  • < 0: Failure.

setSubscribeAudioWhitelist

Sets the allowlist of subscriptions for audio streams.

public abstract int setSubscribeAudioWhitelist(int[] uidList);

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

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

Parameters

uidList

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

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

Returns

  • 0: Success.
  • < 0: Failure.

setSubscribeVideoBlacklist

Set the bocklist of subscriptions for video streams.

public abstract int setSubscribeVideoBlacklist(int[] uidList);

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

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

Parameters

uidList

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

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

Returns

  • 0: Success.
  • < 0: Failure.

setSubscribeVideoWhitelist

Set the allowlist of subscriptions for video streams.

public abstract int setSubscribeVideoWhitelist(int[] uidList);

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

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

Parameters

uidList

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

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

Returns

  • 0: Success.
  • < 0: Failure.

setupLocalVideo

Initializes the local video view.

public abstract int setupLocalVideo(VideoCanvas local);

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

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

Attention:
  • You can call this method either before or after joining a channel.
  • To update the rendering or mirror mode of the local video view during a call, use the setLocalRenderMode [2/2] method.

Parameters

local
Local video display properties. See VideoCanvas.

Returns

  • 0: Success.
  • < 0: Failure.

setupRemoteVideo

Initializes the video view of a remote user.

public abstract int setupRemoteVideo(VideoCanvas remote);

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

You need to specify the ID of the remote user in this method. If the remote user ID is unknown to the application, set it after the app receives the onUserJoined callback.

To unbind the remote user from the view, set the view parameter to NULL.

Once the remote user leaves the channel, the SDK unbinds the remote user.

Attention:
  • To update the rendering or mirror mode of the remote video view during a call, use the setRemoteRenderMode [2/2] method.
  • If you use the Agora recording feature, the recording client joins the channel as a dummy client, triggering the onUserJoined callback. Do not bind the dummy client to the app view because the dummy client does not send any video streams. If your app does not recognize the dummy client, bind the remote user to the view when the SDK triggers the onFirstRemoteVideoDecoded callback.

Parameters

remote

The remote video view and settings. See VideoCanvas.

Returns

  • 0: Success.
  • < 0: Failure.

setVideoDenoiserOptions

Sets video noise reduction.

public abstract int setVideoDenoiserOptions(boolean enabled, VideoDenoiserOptions options);

Underlit environments and low-end video capture devices can cause video images to contain significant noise, which affects video quality. In real-time interactive scenarios, video noise also consumes bitstream resources and reduces encoding efficiency during encoding.

You can call this method to enable the video noise reduction feature and set the options of the video noise reduction effect.

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

Parameters

enabled
Whether to enable video noise reduction:
  • true: Enable video noise reduction.
  • false: (Default) Disable video noise reduction.
options
The video noise reduction options. See VideoDenoiserOptions.

Returns

  • 0: Success.
  • < 0: Failure.

setVideoEncoderConfiguration

Sets the video encoder configuration.

public abstract int setVideoEncoderConfiguration(VideoEncoderConfiguration config);

Sets the encoder configuration for the local video.

Attention: You can call this method either before or after joining a channel. If you don't need to set the video encoder configuration after joining a channel, Agora recommends you calling this method before the enableVideo method to reduce the rendering time of the first video frame.

Parameters

config
Video profile. See VideoEncoderConfiguration.

Returns

  • 0: Success.
  • < 0: Failure.

setVideoProfile

Sets the video encoder configuration.

public abstract int setVideoProfile(int profile, boolean swapWidthAndHeight);
Deprecated:
This method is deprecated. Use setVideoEncoderConfiguration instead.

This method sets the video encoder configuration. You can call this method either before or after joining a channel. If the user does not need to reset the video encoding properties after joining the channel, Agora recommends calling this method before enableVideo to reduce the time to render the first video frame.

Parameters

profile

The video profile.

swapWidthAndHeight

The SDK outputs video with a fixed width and height according to the video profile (profile) you selected. This parameter sets whether to swap width and height of the video:

  • true: Swap the width and height.
  • false: (Default) Do not swap the width and height.

Returns

  • 0: Success.
  • < 0: Failure.

setVideoQualityParameters

Sets the preferences for high-quality video. (LIVE_BROADCASTING only).

public abstract int setVideoQualityParameters(boolean preferFrameRateOverImageQuality);
Deprecated:
This method is deprecated. Agora recommends using the degradationPreference parameter in the VideoEncoderConfiguration class to set the video quality preference.

Parameters

preferFrameRateOverImageQuality
Whether to prioritize smoothness or image quality.
  • true: Prioritizes smoothness.
  • false: (Default) Prioritizes the image quality.

Returns

  • 0: Success.
  • < 0: Failure.

setVoiceBeautifierParameters

Sets parameters for the preset voice beautifier effects.

public abstract int setVoiceBeautifierParameters(int preset, int param1, int param2);

Call this method to set a gender characteristic and a reverberation effect for the singing beautifier effect. This method sets parameters for the local user who sends an audio stream. After setting the audio parameters, all users in the channel can hear the effect.

For better voice effects, Agora recommends that you call setAudioProfile [1/2] and set scenario to AUDIO_SCENARIO_GAME_STREAMING(3) and profile to MUSIC_HIGH_QUALITY(4) or MUSIC_HIGH_QUALITY_STEREO(5) before calling this method.

Attention:

Parameters

preset
The option for the preset audio effect:
  • SINGING_BEAUTIFIER: The singing beautifier effect.
param1
The gender characteristics options for the singing voice:
  • 1: A male-sounding voice.
  • 2: A female-sounding voice.
param2
The reverberation effect options for the singing voice:
  • 1: The reverberation effect sounds like singing in a small room.
  • 2: The reverberation effect sounds like singing in a large room.
  • 3: The reverberation effect sounds like singing in a hall.

Returns

  • 0: Success.
  • < 0: Failure.

setVoiceBeautifierPreset

Sets a preset voice beautifier effect.

public abstract int setVoiceBeautifierPreset(int preset);

Call this method to set a preset voice beautifier effect for the local user who sends an audio stream. After setting a voice beautifier effect, all users in the channel can hear the effect. You can set different voice beautifier effects for different scenarios. For the applicable scenarios of each voice beautifier effect, refer to Set the Voice Effect.

For better voice effects, Agora recommends that you call setAudioProfile [1/2] and set scenario to AUDIO_SCENARIO_GAME_STREAMING (3) and profile to MUSIC_HIGH_QUALITY (4) or MUSIC_HIGH_QUALITY_STEREO(5) before calling this method.

Attention:
  • You can call this method either before or after joining a channel.
  • Do not set the profile parameter in setAudioProfile [1/2] to SPEECH_STANDARD(1), or the method does not take effect.
  • This method works best with the human voice. Agora does not recommend using this method for audio containing music.
  • After calling setVoiceBeautifierPreset, Agora recommends not calling the following methods, because they can override settings in setVoiceBeautifierPreset:
  • This method relies on the voice beautifier dynamic library libagora_audio_beauty_extension.so. If the dynamic library is deleted, the function cannot be enabled normally.

Parameters

preset
The preset voice beautifier effect options.
  • VOICE_BEAUTIFIER_OFF: Turn off voice beautifier effects and use the original voice.
  • CHAT_BEAUTIFIER_MAGNETIC: A more magnetic voice (Male only).
  • CHAT_BEAUTIFIER_FRESH: A fresher voice (Female only).
  • CHAT_BEAUTIFIER_VITALITY: A more vital voice (Female only).
  • SINGING_BEAUTIFIER: The singing beautifier effect.
    • If you call setVoiceBeautifierPreset(SINGING_BEAUTIFIER), you can beautify a male-sounding voice and add a reverberation effect that sounds like singing in a small room. Agora recommends using this enumerator to process a male-sounding voice; otherwise, you might experience vocal distortion.
    • If you call setVoiceBeautifierParameters(SINGING_BEAUTIFIER, param1, param2), you can beautify a male- or female-sounding voice and add a reverberation effect.
  • TIMBRE_TRANSFORMATION_VIGOROUS: A more rigorous vice.
  • TIMBRE_TRANSFORMATION_DEEP: A deep voice.
  • TIMBRE_TRANSFORMATION_MELLOW: A mellower voice.
  • TIMBRE_TRANSFORMATION_FALSETTO: Falsetto.
  • TIMBRE_TRANSFORMATION_FULL: A fuller voice.
  • TIMBRE_TRANSFORMATION_CLEAR: A clearer voice.
  • TIMBRE_TRANSFORMATION_RESOUNDING: A resounding voice.
  • TIMBRE_TRANSFORMATION_RINGING: A more ringing voice.
  • ULTRA_HIGH_QUALITY_VOICE: Ultra-high quality voice, which makes the audio clearer and restores more details.
    • To achieve better audio effect quality, Agora recommends that you call setAudioProfile [2/2] and set the profile to MUSIC_HIGH_QUALITY(4) or MUSIC_HIGH_QUALITY_STEREO(5) and scenario to AUDIO_SCENARIO_GAME_STREAMING(3) before calling this method.
    • If you have an audio capturing device that can already restore audio details to a high degree, Agora recommends that you do not enable ultra-high quality; otherwise, the SDK may over-restore audio details, and you may not hear the anticipated voice effect.

Returns

  • 0: Success.
  • < 0: Failure.

setVoiceConversionPreset

Sets a preset voice beautifier effect.

public abstract int setVoiceConversionPreset(int preset);

Call this method to set a preset voice beautifier effect for the local user who sends an audio stream. After setting an audio effect, all users in the channel can hear the effect. You can set different voice beautifier effects for different scenarios. For the applicable scenarios of each voice beautifier effect, refer to Set the Voice Effect.

To achieve better audio effect quality, Agora recommends that you call setAudioProfile [1/2] and set the profile to MUSIC_HIGH_QUALITY (4) or MUSIC_HIGH_QUALITY_STEREO (5) and scenario to AUDIO_SCENARIO_GAME_STREAMING(3) before calling this method.

Attention:

Parameters

preset
The options for SDK preset voice conversion effects.
  • VOICE_CONVERSION_OFF: Turn off voice conversion effects and use the original voice.
  • VOICE_CHANGER_NEUTRAL: A gender-neutral voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice.
  • VOICE_CHANGER_SWEET: A sweet voice. To avoid audio distortion, ensure that you use this enumerator to process a female-sounding voice.
  • VOICE_CHANGER_SOLID: A steady voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice.
  • VOICE_CHANGER_BASS: A deep voice. To avoid audio distortion, ensure that you use this enumerator to process a male-sounding voice.

Returns

  • 0: Success.
  • < 0: Failure.

startAudioMixing [1/2]

Starts playing the music file.

public abstract int startAudioMixing(
      String filePath, boolean loopback, boolean replace, int cycle);
Deprecated:
Use startAudioMixing [2/2] instead.

This method mixes the specified local or online audio file with the audio from the microphone, or replaces the microphone's audio with the specified local or remote audio file. A successful method call triggers the onAudioMixingStateChanged (AUDIO_MIXING_STATE_PLAYING) callback. When the audio mixing file playback finishes, the SDK triggers the onAudioMixingStateChanged (AUDIO_MIXING_STATE_STOPPED) callback on the local client.

Attention:
  • You can call this method either before or after joining a channel. If you need to call startAudioMixing [1/2] multiple times, ensure that the time interval between calling this method is more than 500 ms.
  • If the local music file does not exist, the SDK does not support the file format, or the the SDK cannot access the music file URL, the SDK reports the warn code 701.
  • On Android, there are following considerations:
    • To use this method, ensure that the Android device is v4.2 or later, and the API version is v16 or later.
    • If you need to play an online music file, Agora does not recommend using the redirected URL address. Some Android devices may fail to open a redirected URL address.
    • If you call this method on an emulator, ensure that the music file is in the /sdcard/ directory and the format is MP3.

Parameters

filePath

The absolute path or URL address (including the suffixes of the filename) of the audio effect file. For example: content://com.android.providers.media.documents/document/audio%203A14441. Supported audio formats include MP3, AAC, M4A, MP4, WAV, and 3GP. See supported audio formats.

loopback
Whether to play music files only on the local client:
  • true: Only play music files on the local client so that only the local user can hear the music.
  • false: Publish music files to remote clients so that both the local user and remote users can hear the music.
cycle
The number of times the music file plays.
  • ≥ 0: The number of playback times. For example, 0 means that the SDK does not play the music file while 1 means that the SDK plays once.
  • -1: Play the audio file in an infinite loop.

Returns

  • 0: Success.
  • < 0: Failure.

startAudioMixing [2/2]

Starts playing the music file.

public abstract int startAudioMixing(String filePath, boolean loopback, int cycle, int startPos);

This method mixes the specified local or online audio file with the audio from the microphone, or replaces the microphone's audio with the specified local or remote audio file. A successful method call triggers the onAudioMixingStateChanged(AUDIO_MIXING_STATE_PLAYING) callback. When the audio mixing file playback finishes, the SDK triggers the onAudioMixingStateChanged(AUDIO_MIXING_STATE_STOPPED) callback on the local client.

Attention:
  • You can call this method either before or after joining a channel. If you need to call startAudioMixing [2/2] multiple times, ensure that the time interval between calling this method is more than 500 ms.
  • If the local music file does not exist, the SDK does not support the file format, or the the SDK cannot access the music file URL, the SDK reports the warn code 701.
  • For the audio file formats supported by this method, see What formats of audio files the Agora RTC SDK support.
  • On Android, there are following considerations:
    • To use this method, ensure that the Android device is v4.2 or later, and the API version is v16 or later.
    • If you need to play an online music file, Agora does not recommend using the redirected URL address. Some Android devices may fail to open a redirected URL address.
    • If you call this method on an emulator, ensure that the music file is in the /sdcard/ directory and the format is MP3.

Parameters

filePath
File path:
  • Android: The file path, which needs to be accurate to the file name and suffix. Agora supports using a URI address, an absolute path, or a path that starts with /assets/. You might encounter permission issues if you use an absolute path to access a local file, so Agora recommends using a URI address instead. For example: content://com.android.providers.media.documents/document/audio%3A14441.
loopback
Whether to only play music files on the local client:
  • true: Only play music files on the local client so that only the local user can hear the music.
  • false: Publish music files to remote clients so that both the local user and remote users can hear the music.
cycle
The number of times the music file plays.
  • ≥ 0: The number of playback times. For example, 0 means that the SDK does not play the music file while 1 means that the SDK plays once.
  • -1: Play the audio file in an infinite loop.
startPos
The playback position (ms) of the music file.

Returns

  • 0: Success.
  • < 0: Failure.

startAudioRecording [1/2]

Starts the audio recording on the client.

public abstract int startAudioRecording(String filePath, int quality);
Deprecated:
This method is deprecated as of v2.9.1. It has a fixed recording sample rate of 32 kHz. Use startAudioRecording [2/2] instead.
The Agora SDK allows recording during a call. This method records the audio of all the users in the channel and generates an audio recording file. Supported formats of the recording file are as follows:
  • .wav: Large file size with high fidelity.
  • .aac: Small file size with low fidelity.

Ensure that the directory for the recording file exists and is writable. This method should be called after the joinChannel [1/2] method. The recording automatically stops when you call the leaveChannel [1/2] method.

Parameters

filePath
The absolute path (including the filename extensions) of the recording file. For example: content://com.android.providers.media.documents/document/audio%203A14441.
Attention:

Ensure that the path for the recording file exists and is writable.

quality
Audio recording quality.
  • 0: Low quality. The sample rate is 32 kHz, and the file size is around 1.2 MB after 10 minutes of recording.
  • 1: Medium quality. The sample rate is 32 kHz, and the file size is around 2 MB after 10 minutes of recording.
  • 2: High quality. The sample rate is 32 kHz, and the file size is around 3.75 MB after 10 minutes of recording.

Returns

  • 0: Success.
  • < 0: Failure.

startAudioRecording [2/2]

Starts the audio recording on the client.

public abstract int startAudioRecording(AudioFileRecordingConfig config);
The Agora SDK allows recording during a call. After successfully calling this method, you can record the audio of all the users in the channel and get an audio recording file. Supported formats of the recording file are as follows:
  • WAV: High-fidelity files with typically larger file sizes. For example, the size of a WAV file with a sample rate of 32,000 Hz and a recording duration of 10 minutes is around 73 MB.
  • AAC: Low-fidelity files with typically smaller file sizes. For example, if the sample rate is 32,000 Hz and the recording quality is AUDIO_RECORDING_QUALITY_MEDIUM, the file size for a 10-minute recording is approximately 2 MB.

Once the user leaves the channel, the recording automatically stops.

Attention: Call this method after joining a channel.

Parameters

config
Recording configuration. See AudioRecordingConfiguration.

Returns

  • 0: Success.
  • < 0: Failure.

startChannelMediaRelay

Starts relaying media streams across channels. This method can be used to implement scenarios such as co-host across channels.

public abstract int startChannelMediaRelay(
      ChannelMediaRelayConfiguration channelMediaRelayConfiguration);
After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged and onChannelMediaRelayEvent callbacks, and these callbacks return the state and events of the media stream relay.
  • If the onChannelMediaRelayStateChanged callback returns RELAY_STATE_RUNNING (2) and RELAY_OK (0), and the onChannelMediaRelayEvent callback returns RELAY_EVENT_PACKET_SENT_TO_DEST_CHANNEL (4); it means that the SDK starts relaying media streams between the source channel and the destination channel.
  • If the onChannelMediaRelayStateChanged callback returns RELAY_STATE_FAILURE (3), an exception occurs during the media stream relay.
Attention:
  • Call this method after joining the channel.
  • This method takes effect only when you are a host in a live streaming channel.
  • After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay method to quit the current relay.
  • You need to contact technical support before implementing this function.
  • We do not support string type of UID in this API.

Parameters

channelMediaRelayConfiguration
The configuration of the media stream relay. See ChannelMediaRelayConfiguration.

Returns

  • 0: Success.
  • < 0: Failure.

startEchoTest [1/2]

Starts an audio call test.

public abstract int startEchoTest();
Deprecated:
This method is deprecated, use startEchoTest [2/2] instead.

This method starts an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly. To conduct the test, the user speaks, and the recording is played back within 10 seconds. If the user can hear the recording within the interval, the audio devices and network connection are working properly.

Attention:
  • Call this method before joining a channel.
  • After calling startEchoTest [1/2], you must call stopEchoTest to end the test. Otherwise, the app cannot perform the next echo test, and you cannot join the channel.
  • In the live streaming channels, only a host can call this method.

Returns

  • 0: Success.
  • < 0: Failure.

startEchoTest [2/2]

Starts an audio call test.

public abstract int startEchoTest(int intervalInSeconds);
Deprecated:
This method is deprecated as of v4.0.1. Use startEchoTest [3/3] instead.

This method starts an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly. To conduct the test, let the user speak for a while, and the recording is played back within the set interval. If the user can hear the recording within the interval, the audio devices and network connection are working properly.

Attention:
  • Call this method before joining a channel.
  • After calling startEchoTest [2/2], you must call stopEchoTest to end the test. Otherwise, the app cannot perform the next echo test, and you cannot join the channel.
  • In the live streaming channels, only a host can call this method.

Parameters

intervalInSeconds
The time interval (s) between when you speak and when the recording plays back. The value range is [2, 10], and the default value is 10.

Returns

  • 0: Success.
  • < 0: Failure.

startEchoTest [3/3]

Starts an audio and video call loop test.

public abstract int startEchoTest(EchoTestConfiguration config);

Before joining a channel, to test whether the user's local sending and receiving streams are normal, you can call this method to perform an audio and video call loop test, which tests whether the audio and video devices and the user's upstream and downstream networks are working properly.

After starting the test, the user needs to make a sound or face the camera. The audio or video is output after about two seconds. If the audio playback is normal, the audio device and the user's upstream and downstream networks are working properly; if the video playback is normal, the video device and the user's upstream and downstream networks are working properly.
Note:
  • Call this method before joining a channel.
  • After calling this method, call stopEchoTest to end the test; otherwise, the user cannot perform the next audio and video call loop test and cannot join the channel.
  • In live streaming scenarios, this method only applies to hosts.

Parameters

config
The configuration of the audio and video call loop test. See EchoTestConfiguration.

Returns

  • 0: Success.
  • < 0: Failure.

startLastmileProbeTest

Starts the last mile network probe test.

public abstract int startLastmileProbeTest(LastmileProbeConfig config);

This method starts the last-mile network probe test before joining a channel to get the uplink and downlink last mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).

Once this method is enabled, the SDK returns the following callbacks:
  • onLastmileQuality: The SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions and is more closely linked to the user experience.
  • onLastmileProbeResult: The SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
This method applies to the following scenarios:
  • Before a user joins a channel, call this method to check the uplink network quality.
  • In a live streaming channel, call this method to check the uplink network quality before an audience member switches to a host.
Attention:
  • Do not call other methods before receiving the onLastmileQuality and onLastmileProbeResult callbacks. Otherwise, the callbacks may be interrupted.
  • A host should not call this method after joining a channel (when in a call).

Parameters

config
The configurations of the last-mile network probe test. See LastmileProbeConfig.

Returns

  • 0: Success.
  • < 0: Failure.

startPreview [1/2]

Enables the local video preview.

public abstract int startPreview();
This method starts the local video preview before joining the channel. Before calling this method, ensure that you do the following:
Attention:
  • The local preview enables the mirror mode by default.
  • After the local video preview is enabled, if you call leaveChannel [1/2] to exit the channel, the local preview remains until you call stopPreview [1/2] to disable it.

Returns

  • 0: Success.
  • < 0: Failure.

startPreview [2/2]

Enables the local video preview and specifies the video source for the preview.

public abstract int startPreview(Constants.VideoSourceType sourceType);
This method starts the local video preview before joining the channel. Before calling this method, ensure that you do the following:
Attention:
  • The local preview enables the mirror mode by default.
  • After the local video preview is enabled, if you call leaveChannel [1/2] to exit the channel, the local preview remains until you call stopPreview [2/2] to disable it.
  • The video source type set in this method needs to be consistent with the video source type of VideoCanvas you set in setupLocalVideo.

Parameters

sourceType
The type of the video source, see VideoSourceType.

Returns

  • 0: Success.
  • < 0: Failure.

startRhythmPlayer

Enables the virtual metronome.

public abstract int startRhythmPlayer(
    String sound1, String sound2, AgoraRhythmPlayerConfig config);

In music education, physical education, and other scenarios, teachers might need to use a metronome so that students can practice with the correct beat. The meter is composed of a downbeat and upbeats. The first beat of each measure is called a downbeat, and the rest are called upbeats.

In this method, you need to set the paths of the upbeat and downbeat files, the number of beats per measure, the tempo, and whether to send the sound of the metronome to remote users.

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

Parameters

sound1
The absolute path or URL address (including the filename extensions) of the file for the downbeat. For example: content://com.android.providers.media.documents/document/audio%203A14441. For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK v4.0.0 support.
sound2
The absolute path or URL address (including the filename extensions) of the file for the upbeats. For example: content://com.android.providers.media.documents/document/audio%203A14441. For the audio file formats supported by this method, see What formats of audio files does the Agora RTC SDK v4.0.0 support.
config
The metronome configuration. See AgoraRhythmPlayerConfig.

Returns

  • 0: Success.
  • < 0: Failure.
    • -22: Cannot find audio effect files. You need to set the correct paths for sound1 and sound2.

startRtmpStreamWithoutTranscoding

Starts Media Push without transcoding.

public abstract int startRtmpStreamWithoutTranscoding(String url);

You can call this method to push an audio or video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.

After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the Media Push.

Attention:
  • Ensure that you enable the media push service before using this function.
  • Call this method after joining a channel.
  • Only hosts in the LIVE_BROADCASTING profile can call this method.
  • If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.

Parameters

url
The address of media push. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: url is null or the string length is 0.
    • -7: The SDK is not initialized before calling this method.

startRtmpStreamWithTranscoding

Starts Media Push and sets the transcoding configuration.

public abstract int startRtmpStreamWithTranscoding(String url, LiveTranscoding transcoding);

You can call this method to push an audio or video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times.

After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the Media Push.

Attention:
  • Ensure that you enable the media push service before using this function.
  • Call this method after joining a channel.
  • Only hosts in the LIVE_BROADCASTING profile can call this method.
  • If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.

Parameters

url
The address of media push. The format is RTMP or RTMPS. The character length cannot exceed 1024 bytes. Special characters such as Chinese characters are not supported.
transcoding

The transcoding configuration for media push. See LiveTranscoding.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: url is null or the string length is 0.
    • -7: The SDK is not initialized before calling this method.

startScreenCapture

Starts screen sharing.

public abstract int startScreenCapture(ScreenCaptureParameters screenCaptureParameters);
There are two ways to start screen sharing, you can choose one according to the actual needs:
  • Call this method before joining a channel, then call joinChannel [2/2] to join channel and set publishScreenCaptureVideo to true to start screen sharing.
  • Call this method after joining a channel, then call updateChannelMediaOptions and set publishScreenCaptureVideo to true to start screen sharing.
Attention:

Parameters

ScreenCaptureParameters
The screen sharing encoding parameters. The default video dimension is 1920 x 1080, that is, 2,073,600 pixels. Agora uses the value of this parameter to calculate the charges. See ScreenCaptureParameters.

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is null.

startRecordingDeviceTest

Starts the audio capture device test.

public abstract int startRecordingDeviceTest(int indicationInterval);

This method tests whether the audio capture device works properly. After calling this method, the SDK triggers the onAudioVolumeIndication callback at the time interval set in this method, which reports uid = 0 and the volume information of the capturing device.

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

Parameters

indicationInterval
The time interval (ms) at which the SDK triggers the onAudioVolumeIndication callback. Agora recommends a setting greater than 200 ms. This value must not be less than 10 ms; otherwise, you can not receive the onAudioVolumeIndication callback.

Returns

  • 0: Success.
  • < 0: Failure.

stopAudioMixing

Stops playing and mixing the music file.

public abstract int stopAudioMixing();

This method stops the audio mixing. Call this method when you are in a channel.

Returns

  • 0: Success.
  • < 0: Failure.

stopAudioRecording

Stops the audio recording on the client.

public abstract int stopAudioRecording();

Returns

  • 0: Success.
  • < 0: Failure.

stopChannelMediaRelay

Stops the media stream relay. Once the relay stops, the host quits all the destination channels.

public abstract int stopChannelMediaRelay();

After a successful method call, the SDK triggers the onChannelMediaRelayStateChanged callback. If the callback reports RELAY_STATE_IDLE (0) and RELAY_OK (0), the host successfully stops the relay.

Attention: If the method call fails, the SDK triggers the onChannelMediaRelayStateChanged callback with the RELAY_ERROR_SERVER_NO_RESPONSE (2) or RELAY_ERROR_SERVER_CONNECTION_LOST (8) status code. You can call the leaveChannel [1/2] method to leave the channel, and the media stream relay automatically stops.

Returns

  • 0: Success.
  • < 0: Failure.

stopEchoTest

Stops the audio call test.

public abstract int stopEchoTest();

Returns

  • 0: Success.
  • < 0: Failure.
    • -5(ERR_REFUSED): Failed to stop the echo test. The echo test may not be running.

stopLastmileProbeTest

Stops the last mile network probe test.

public abstract int stopLastmileProbeTest();

Returns

  • 0: Success.
  • < 0: Failure.

stopRecordingDeviceTest

Stops the audio capture device test.


                

This method stops the audio capture device test. You must call this method to stop the test after calling the startRecordingDeviceTest method.

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

Returns

  • 0: Success.
  • < 0: Failure.

stopPreview [1/2]

Stops the local video preview.

public abstract int stopPreview();

After calling startPreview [1/2] to start the preview, if you want to close the local video preview, please call this method.

Note: Please call this method before joining a channel or after leaving a channel.

Returns

  • 0: Success.
  • < 0: Failure.

stopPreview [2/2]

Stops the local video preview.

public abstract int stopPreview(Constants.VideoSourceType sourceType);

After calling startPreview [2/2] to start the preview, if you want to close the local video preview, please call this method.

Note: Please call this method before joining a channel or after leaving a channel.

Parameters

sourceType
The type of the video source, see VideoSourceType.

Returns

  • 0: Success.
  • < 0: Failure.

stopRhythmPlayer

Disables the virtual metronome.

public abstract int stopRhythmPlayer();

After calling