Agora Java API Reference for Android
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
io.agora.rtc2.RtcEngine Class Referenceabstract
Inheritance diagram for io.agora.rtc2.RtcEngine:
io.agora.rtc2.RtcEngineEx io.agora.rtc2.RtcEngineInternal

Public Member Functions

abstract int setChannelProfile (int profile)
 
abstract int setClientRole (int role)
 
abstract int setClientRole (int role, ClientRoleOptions options)
 
abstract int sendCustomReportMessage (String id, String category, String event, String label, int value)
 
abstract int joinChannel (String token, String channelName, String optionalInfo, int optionalUid)
 
abstract int joinChannel (String token, String channelId, int uid, ChannelMediaOptions options)
 
abstract int leaveChannel ()
 
abstract int leaveChannel (LeaveChannelOptions options)
 
abstract int renewToken (String token)
 
abstract int registerLocalUserAccount (String appId, String userAccount)
 
abstract int joinChannelWithUserAccount (String token, String channelName, String userAccount)
 
abstract int joinChannelWithUserAccount (String token, String channelName, String userAccount, ChannelMediaOptions options)
 
abstract UserInfo getUserInfoByUserAccount (String userAccount)
 
abstract UserInfo getUserInfoByUid (int uid)
 
abstract int enableWebSdkInteroperability (boolean enabled)
 
abstract RtcConnection.CONNECTION_STATE_TYPE getConnectionState ()
 
abstract int enableAudio ()
 
abstract int disableAudio ()
 
abstract int pauseAudio ()
 
abstract int resumeAudio ()
 
abstract int setAudioProfile (int profile)
 
abstract int setAudioProfile (int profile, int scenario)
 
abstract int setHighQualityAudioParameters (boolean fullband, boolean stereo, boolean fullBitrate)
 
abstract int adjustRecordingSignalVolume (int volume)
 
abstract int adjustPlaybackSignalVolume (int volume)
 
abstract int enableAudioVolumeIndication (int interval, int smooth)
 
abstract int enableAudioQualityIndication (boolean enabled)
 
abstract int enableLocalAudio (boolean enabled)
 
abstract int muteLocalAudioStream (boolean muted)
 
abstract int muteRemoteAudioStream (int uid, boolean muted)
 
abstract int adjustUserPlaybackSignalVolume (int uid, int volume)
 
abstract int muteAllRemoteAudioStreams (boolean muted)
 
abstract int setDefaultMuteAllRemoteAudioStreams (boolean muted)
 
abstract int enableVideo ()
 
abstract int disableVideo ()
 
abstract int setVideoProfile (int profile, boolean swapWidthAndHeight)
 
abstract int setVideoEncoderConfiguration (VideoEncoderConfiguration config)
 
abstract int setCameraCapturerConfiguration (CameraCapturerConfiguration config)
 
abstract int setupLocalVideo (VideoCanvas local)
 
abstract int setupRemoteVideo (VideoCanvas remote)
 
abstract int setLocalRenderMode (int renderMode)
 
abstract int setLocalRenderMode (int renderMode, int mirrorMode)
 
abstract int setRemoteRenderMode (int userId, int renderMode)
 
abstract int setRemoteRenderMode (int userId, int renderMode, int mirrorMode)
 
abstract int startPreview ()
 
abstract int startPreview (Constants.VideoSourceType sourceType)
 
abstract int stopPreview ()
 
abstract int stopPreview (Constants.VideoSourceType sourceType)
 
abstract int enableLocalVideo (boolean enabled)
 
abstract int startSecondaryCameraCapture (CameraCapturerConfiguration config)
 
abstract int stopSecondaryCameraCapture ()
 
abstract int muteLocalVideoStream (boolean muted)
 
abstract int muteRemoteVideoStream (int userId, boolean muted)
 
abstract int muteAllRemoteVideoStreams (boolean muted)
 
abstract int setDefaultMuteAllRemoteVideoStreams (boolean muted)
 
abstract int setBeautyEffectOptions (boolean enabled, BeautyOptions options)
 
abstract int setDefaultAudioRoutetoSpeakerphone (boolean defaultToSpeaker)
 
abstract int setEnableSpeakerphone (boolean enabled)
 
abstract boolean isSpeakerphoneEnabled ()
 
abstract int enableInEarMonitoring (boolean enabled)
 
abstract int enableInEarMonitoring (boolean enabled, int includeAudioFilters)
 
abstract int setInEarMonitoringVolume (int volume)
 
abstract int useExternalAudioDevice ()
 
abstract int setLocalVoicePitch (double pitch)
 
abstract int setLocalVoiceEqualization (Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY bandFrequency, int bandGain)
 
abstract int setLocalVoiceReverb (Constants.AUDIO_REVERB_TYPE reverbKey, int value)
 
abstract int setLocalVoiceChanger (int voiceChanger)
 
abstract int setLocalVoiceReverbPreset (int reverbPreset)
 
abstract int setAudioEffectPreset (int preset)
 
abstract int setVoiceBeautifierPreset (int preset)
 
abstract int setVoiceConversionPreset (int preset)
 
abstract int setAudioEffectParameters (int preset, int param1, int param2)
 
abstract int setVoiceBeautifierParameters (int preset, int param1, int param2)
 
abstract int setVoiceConversionParameters (int preset, int param1, int param2)
 
abstract int enableSoundPositionIndication (boolean enabled)
 
abstract int setRemoteVoicePosition (int uid, double pan, double gain)
 
abstract int setRemoteVoice3DPosition (int uid, double azimuth, double elevation, double distance)
 
abstract int startAudioMixing (String filePath, boolean loopback, boolean replace, int cycle)
 
abstract int stopAudioMixing ()
 
abstract int pauseAudioMixing ()
 
abstract int resumeAudioMixing ()
 
abstract int adjustAudioMixingVolume (int volume)
 
abstract int adjustAudioMixingPlayoutVolume (int volume)
 
abstract int adjustAudioMixingPublishVolume (int volume)
 
abstract int getAudioMixingPlayoutVolume ()
 
abstract int getAudioMixingPublishVolume ()
 
abstract int getAudioMixingDuration ()
 
abstract int getAudioMixingCurrentPosition ()
 
abstract int setAudioMixingPosition (int pos)
 
abstract IAudioEffectManager getAudioEffectManager ()
 
abstract int startAudioRecording (String filePath, int quality)
 
abstract int startAudioRecording (AudioFileRecordingConfig config)
 
abstract int stopAudioRecording ()
 
abstract int startEchoTest ()
 
abstract int startEchoTest (int intervalInSeconds)
 
abstract int stopEchoTest ()
 
abstract int startLastmileProbeTest (LastmileProbeConfig config)
 
abstract int stopLastmileProbeTest ()
 
abstract int setExternalAudioSink (int sampleRate, int channels)
 
abstract int pullPlaybackAudioFrame (byte[] data, int lengthInByte)
 
abstract int pullPlaybackAudioFrame (ByteBuffer data, int lengthInByte)
 
abstract int setExternalAudioSource (boolean enabled, int sampleRate, int channels)
 
abstract int setExternalAudioSource (boolean enabled, int sampleRate, int channels, int sourceNumber, boolean localPlayback, boolean publish)
 
abstract int pushExternalAudioFrame (byte[] data, long timestamp)
 
abstract int pushExternalAudioFrame (ByteBuffer data, long timestamp, int sourceId)
 
abstract int setExternalVideoSource (boolean enable, boolean useTexture, boolean encodedFrame)
 
abstract boolean pushExternalVideoFrame (AgoraVideoFrame frame)
 
abstract boolean pushExternalVideoFrame (VideoFrame frame)
 
abstract int pushExternalEncodedVideoFrame (ByteBuffer data, EncodedVideoFrameInfo frameInfo)
 
abstract boolean isTextureEncodeSupported ()
 
abstract int registerAudioFrameObserver (IAudioFrameObserver observer)
 
abstract int registerAudioEncodedFrameObserver (AudioEncodedFrameObserverConfig config, IAudioEncodedFrameObserver observer)
 
abstract int setRecordingAudioFrameParameters (int sampleRate, int channel, int mode, int samplesPerCall)
 
abstract int setPlaybackAudioFrameParameters (int sampleRate, int channel, int mode, int samplesPerCall)
 
abstract int setMixedAudioFrameParameters (int sampleRate, int channel, int samplesPerCall)
 
abstract int addVideoWatermark (AgoraImage watermark)
 
abstract int addVideoWatermark (String watermarkUrl, WatermarkOptions options)
 
abstract int clearVideoWatermarks ()
 
abstract int setRemoteUserPriority (int uid, int userPriority)
 
abstract int setLocalPublishFallbackOption (int option)
 
abstract int setRemoteSubscribeFallbackOption (int option)
 
abstract int enableDualStreamMode (boolean enabled)
 
abstract int enableDualStreamMode (Constants.VideoSourceType sourceType, boolean enabled)
 
abstract int enableDualStreamMode (Constants.VideoSourceType sourceType, boolean enabled, SimulcastStreamConfig streamConfig)
 
abstract int setRemoteVideoStreamType (int uid, int streamType)
 
abstract int setRemoteDefaultVideoStreamType (int streamType)
 
abstract int setEncryptionSecret (String secret)
 
abstract int setEncryptionMode (String encryptionMode)
 
abstract int enableEncryption (boolean enabled, EncryptionConfig config)
 
abstract int addInjectStreamUrl (String url, LiveInjectStreamConfig config)
 
abstract int removeInjectStreamUrl (String url)
 
abstract int addPublishStreamUrl (String url, boolean transcodingEnabled)
 
abstract int removePublishStreamUrl (String url)
 
abstract int setLiveTranscoding (LiveTranscoding transcoding)
 
abstract int createDataStream (boolean reliable, boolean ordered)
 
abstract int createDataStream (DataStreamConfig config)
 
abstract int sendStreamMessage (int streamId, byte[] message)
 
abstract int setVideoQualityParameters (boolean preferFrameRateOverImageQuality)
 
abstract int setLocalVideoMirrorMode (int mode)
 
abstract int switchCamera ()
 
abstract boolean isCameraZoomSupported ()
 
abstract boolean isCameraTorchSupported ()
 
abstract boolean isCameraFocusSupported ()
 
abstract boolean isCameraExposurePositionSupported ()
 
abstract boolean isCameraAutoFocusFaceModeSupported ()
 
abstract boolean isCameraFaceDetectSupported ()
 
abstract int setCameraZoomFactor (float factor)
 
abstract float getCameraMaxZoomFactor ()
 
abstract int setCameraFocusPositionInPreview (float positionX, float positionY)
 
abstract int setCameraExposurePosition (float positionXinView, float positionYinView)
 
abstract int enableFaceDetection (boolean enabled)
 
abstract int setCameraTorchOn (boolean isOn)
 
abstract int setCameraAutoFocusFaceModeEnabled (boolean enabled)
 
abstract String getCallId ()
 
abstract int rate (String callId, int rating, String description)
 
abstract int complain (String callId, String description)
 
abstract int setLogFile (String filePath)
 
abstract int setLogFilter (int filter)
 
abstract int setLogLevel (int level)
 
abstract int setLogFileSize (long fileSizeInKBytes)
 
abstract long getNativeHandle ()
 
abstract long getNativeMediaPlayer (int sourceId)
 
void addHandler (IRtcEngineEventHandler handler)
 
void removeHandler (IRtcEngineEventHandler handler)
 
abstract boolean enableHighPerfWifiMode (boolean enable)
 
abstract void monitorHeadsetEvent (boolean monitor)
 
abstract void monitorBluetoothHeadsetEvent (boolean monitor)
 
abstract void setPreferHeadset (boolean enabled)
 
abstract int setParameters (String parameters)
 
abstract String getParameter (String parameter, String args)
 
abstract int registerMediaMetadataObserver (IMetadataObserver observer, int type)
 
abstract int unregisterMediaMetadataObserver (IMetadataObserver observer, int type)
 
abstract int startChannelMediaRelay (ChannelMediaRelayConfiguration channelMediaRelayConfiguration)
 
abstract int stopChannelMediaRelay ()
 
abstract int updateChannelMediaRelay (ChannelMediaRelayConfiguration channelMediaRelayConfiguration)
 
abstract int updateChannelMediaOptions (ChannelMediaOptions options)
 
abstract int startRecordingService (String recordingKey)
 
abstract int stopRecordingService (String recordingKey)
 
abstract int refreshRecordingServiceStatus ()
 
abstract int muteRecordingSignal (boolean muted)
 
abstract int startPlayingStream (String url)
 
abstract int stopPlayingStream ()
 
abstract int setPlaybackAudioFrameBeforeMixingParameters (int sampleRate, int channel)
 
abstract int enableAudioSpectrumMonitor (int intervalInMS)
 
abstract int disableAudioSpectrumMonitor ()
 
abstract int registerAudioSpectrumObserver (IAudioSpectrumObserver observer)
 
abstract int unRegisterAudioSpectrumObserver (IAudioSpectrumObserver observer)
 
abstract double getEffectsVolume ()
 
abstract int setEffectsVolume (double volume)
 
abstract int preloadEffect (int soundId, String filePath)
 
abstract int playEffect (int soundId, String filePath, int loopCount, double pitch, double pan, double gain, boolean publish)
 
abstract int playAllEffects (int loopCount, double pitch, double pan, double gain, boolean publish)
 
abstract int getVolumeOfEffect (int soundId)
 
abstract int setVolumeOfEffect (int soundId, double volume)
 
abstract int pauseEffect (int soundId)
 
abstract int pauseAllEffects ()
 
abstract int resumeEffect (int soundId)
 
abstract int resumeAllEffects ()
 
abstract int stopEffect (int soundId)
 
abstract int stopAllEffects ()
 
abstract int unloadEffect (int soundId)
 
abstract int unloadAllEffects ()
 
abstract int configPublisher (PublisherConfiguration config)
 
abstract int setVideoCompositingLayout (VideoCompositingLayout layout)
 
abstract int clearVideoCompositingLayout ()
 
abstract int registerVideoEncodedImageReceiver (IVideoEncodedImageReceiver receiver)
 
abstract int takeSnapshot (int uid, String filePath)
 
abstract int enableContentInspect (boolean enabled, ContentInspectConfig config)
 
abstract int setAudioOptionParams (String params)
 
abstract String getAudioOptionParams ()
 
abstract int setAudioSessionParams (String params)
 
abstract String getAudioSessionParams ()
 
abstract int enableExtension (String vendor, String extension, boolean enable)
 
abstract int enableExtension (String vendor, String extension, boolean enable, Constants.MediaSourceType sourceType)
 
abstract int setExtensionProperty (String vendor, String extension, String key, String value)
 
abstract int setExtensionProperty (String vendor, String extension, String key, String value, Constants.MediaSourceType sourceType)
 
abstract int setExtensionProviderProperty (String vendor, String key, String value)
 
abstract int startScreenCapture (Intent mediaProjectionPermissionResultData, ScreenCaptureParameters parameters)
 
abstract int stopScreenCapture ()
 
abstract int registerVideoFrameObserver (IVideoFrameObserver observer)
 
abstract IMediaPlayer createMediaPlayer ()
 
abstract int enableExternalAudioSourceLocalPlayback (boolean enabled)
 

Static Public Member Functions

static synchronized RtcEngine create (Context context, String appId, IRtcEngineEventHandler handler) throws Exception
 
static synchronized RtcEngine create (RtcEngineConfig config) throws Exception
 
static synchronized boolean loadExtension (String name)
 
static synchronized void destroy ()
 
static SurfaceView CreateRendererView (Context context)
 
static TextureView CreateTextureView (Context context)
 
static int getRecommendedEncoderType ()
 
static String getSdkVersion ()
 
static String getMediaEngineVersion ()
 
static String getErrorDescription (int error)
 

Static Protected Attributes

static RtcEngineImpl mInstance = null
 

Detailed Description

Main interface class of the Agora Native SDK.

Call the methods of this class to use all the functionalities of the SDK. Agora recommends calling the RtcEngine API methods in the same thread instead of in multiple threads. In previous versions, this class was named AgoraAudio, and was renamed to RtcEngine from version 1.0.

Member Function Documentation

◆ create() [1/2]

static synchronized RtcEngine io.agora.rtc2.RtcEngine.create ( Context  context,
String  appId,
IRtcEngineEventHandler  handler 
) throws Exception
static

Creates an RtcEngine instance.

Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.

Note
  • You must create an RtcEngine instance before calling any other method.
  • You can create an RtcEngine instance either by calling this method or by calling create2. The difference between create2 and this method is that create2 enables you to specify the connection area.
  • The Agora RTC Native SDK supports creating only one RtcEngine instance for an app for now.
Parameters
contextThe context of Android Activity.
appIdThe App ID issued to you by Agora. See How to get the App ID. Only users in apps with the same App ID can join the same channel and communicate with each other. Use an App ID to create only one RtcEngine instance. To change your App ID, call destroy to destroy the current RtcEngine instance and then call create to create an RtcEngine instance with the new App ID.
handlerIRtcEngineEventHandler is an abstract class providing default implementation. The SDK uses this class to report to the app on SDK runtime events.
Returns
  • The RtcEngine instance, if the method call succeeds.
  • < 0, if the method call fails.
Exceptions
ExceptionFails to create an RtcEngine instance.

◆ create() [2/2]

static synchronized RtcEngine io.agora.rtc2.RtcEngine.create ( RtcEngineConfig  config) throws Exception
static

Creates an RtcEngine instance.

The Agora Native SDK only supports one RtcEngine instance at a time, therefore the app should create one RtcEngine object only. Unless otherwise specified:

  • All called methods provided by the RtcEngine class are executed asynchronously. We recommends calling these methods in the same thread.
  • The following rule applies to all APIs whose return values are integer types:
    • 0: The method call succeeds.
    • < 0: The method call fails.
Note
  • Ensure that you call this method before calling any other API.
  • Only users with the same App ID can join the same channel and call each other.
  • An App ID can create only one RtcEngine object. For multiple App IDs in an app, you need to create multiple RtcEngine objects. Call destroy first to destroy the current RtcEngine instance before calling this method.
Parameters
configConfigurations for the RtcEngine instance. For details, see {}. An RtcEngine object. Exception Fails to create an RtcEngine instance.

◆ destroy()

static synchronized void io.agora.rtc2.RtcEngine.destroy ( )
static

Releases all the resources used by the Agora SDK.

This method is useful for apps that occasionally make voice or video calls, to free up resources for other operations when not making calls.

Note
  • Do not immediately uninstall the SDK's dynamic library after the call, or it may crash because the SDK clean-up thread has not quit.
  • Call this method in the sub-thread.
  • Once the app destroys the created RtcEngine instance, you cannot use any method or callback in the SDK.

◆ setChannelProfile()

abstract int io.agora.rtc2.RtcEngine.setChannelProfile ( int  profile)
abstract

Sets the channel profile.

The RtcEngine differentiates channel profiles and applies different optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for a video broadcast.

Note
  • To ensure the quality of real-time communication, we recommend that all users in a channel use the same channel profile.
  • Call this method before calling joinChannel. You cannot set the channel profile once you have joined the channel.
Parameters
profileThe channel profile:
  • CHANNEL_PROFILE_COMMUNICATION(0): (Default) Communication. Use this profile when there are two users in the channel.
  • CHANNEL_PROFILE_LIVE_BROADCASTING(1): Live Broadcast. Use this profile when there are more than two users in the channel.
  • CHANNEL_PROFILE_GAME(2): Gaming. This profile is deprecated.
  • CHANNEL_PROFILE_CLOUD_GAMING(3): Cloud gaming. This profile is for interactive streaming scenario which is highly sensitive to end-to-end latency, and any delay in render impacts the end-user experience. These use cases prioritize reducing delay over any smoothing done at the receiver. We recommend using this profile in scenarios there users need to interact with each other.
  • CHANNEL_PROFILE_COMMUNICATION_1v1(4): Communication 1v1. Use this profile when needs communication 1v1.
  • CHANNEL_PROFILE_LIVE_BROADCASTING_2(5): Live Broadcast 2. Use this profile for technical preview.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setClientRole() [1/2]

abstract int io.agora.rtc2.RtcEngine.setClientRole ( int  role)
abstract

Sets the role of a user.

This method sets the user role as either BROADCASTER or AUDIENCE (default).

  • The broadcaster sends and receives streams.
  • The audience receives streams only.

By default, all users are audience regardless of the channel profile. Call this method to change the user role to BROADCASTER so that the user can send a stream.

Note
After calling the setClientRole() method to CLIENT_ROLE_AUDIENCE, the SDK stops audio recording. However, CLIENT_ROLE_AUDIENCE will keep audio recording with AUDIO_SCENARIO_CHATROOM(5). Normally, app developer can also use mute api to achieve the same result, and we implement this 'non-orthogonal' behavior only to make API backward compatible.
Parameters
roleThe role of the client:
  • CLIENT_ROLE_BROADCASTER(1): The broadcaster.
  • CLIENT_ROLE_AUDIENCE(2): The audience.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setClientRole() [2/2]

abstract int io.agora.rtc2.RtcEngine.setClientRole ( int  role,
ClientRoleOptions  options 
)
abstract

Sets the role of a user (LIVE_BROADCASTING profile only).

This method sets the role of a user, such as a host or an audience (default), before joining a channel.

This method can be used to switch the user role after a user joins a channel. In the LIVE_BROADCASTING profile, when a user switches user roles after joining a channel, a successful setClientRole method call triggers the following callbacks:

◆ sendCustomReportMessage()

abstract int io.agora.rtc2.RtcEngine.sendCustomReportMessage ( String  id,
String  category,
String  event,
String  label,
int  value 
)
abstract

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.

To try out this function, contact support@agora.io and discuss the format of customized messages with us.

◆ joinChannel() [1/2]

abstract int io.agora.rtc2.RtcEngine.joinChannel ( String  token,
String  channelName,
String  optionalInfo,
int  optionalUid 
)
abstract

Joins a channel.

Users in the same channel can talk to each other; and multiple users in the same channel can start a group chat. Note that users using different App IDs cannot call each other.

Once in a call, the user must call the leaveChannel method to exit the current call before entering another channel.

Note
  • This method allows you to join only one channel at a time.
  • A channel does not accept duplicate uids, that is, two users with the same uid. If you set uid as 0, the system automatically assigns a user ID.
  • Ensure that the app ID you use to generate the token is the same app ID that you pass in the create method.
Parameters
tokenThe token for authentication.
  • In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token.
  • In situations requiring high security: Set it as the token generated at you server. For details, see Generate a token.
channelNameThe unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
optionalInfo(Optional) Additional information about the channel that you want to add. It can be set as a NULL string or channel related information. Other users in the channel will not receive this message.
optionalUid(Optional) User ID: A 32-bit unsigned integer ranging from 1 to (2^32-1). It must be unique. If not assigned (or set to 0), the SDK assigns one and reports it in the onJoinChannelSuccess callback. Your app must record and maintain the returned value as the SDK does not maintain it.
Returns
  • 0: Success.
  • < 0: Failure.

◆ joinChannel() [2/2]

abstract int io.agora.rtc2.RtcEngine.joinChannel ( String  token,
String  channelId,
int  uid,
ChannelMediaOptions  options 
)
abstract

Joins a channel with media options.

Users in the same channel can talk to each other; and multiple users in the same channel can start a group chat. Note that users using different App IDs cannot call each other.

Once in a call, the user must call the leaveChannel method to exit the current call before entering another channel.

Note
  • This method allows you to join only one channel at a time.
  • A channel does not accept duplicate uids, that is, two users with the same uid. If you set uid as 0, the system automatically assigns a user ID.
  • Ensure that the app ID you use to generate the token is the same app ID that you pass in the create method.
Parameters
tokenThe token for authentication.
  • In situations not requiring high security: You can use the temporary token generated at Console. For details, see Get a temporary token.
  • In situations requiring high security: Set it as the token generated at you server. For details, see Generate a token.
channelIdThe unique channel name for the AgoraRTC session in the string format. The string length must be less than 64 bytes. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
uid(Optional) User ID: A 32-bit unsigned integer ranging from 1 to (2^32-1). It must be unique. If not assigned (or set to 0), the SDK assigns one and reports it in the onJoinChannelSuccess callback. Your app must record and maintain the returned value as the SDK does not maintain it.
optionsThe channel media options: ChannelMediaOptions.
Returns
  • 0: Success.
  • < 0: Failure.

◆ leaveChannel() [1/2]

abstract int io.agora.rtc2.RtcEngine.leaveChannel ( )
abstract

Leaves the channel.

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

After joining a channel, the user must call this method to end the current call before joining another one. This method also releases all resources related to the call.

This method is an asynchronous call, which means that the result of this method returns even before the user has not actually left the channel. Once the user successfully leaves the channel, the SDK triggers the onLeaveChannel callback.

Note
If you call destroy immediately after this method, the leaveChannel process will be interrupted, and the SDK will not trigger the onLeaveChannel callback.
Returns
  • 0: Success.
  • < 0: Failure.

◆ leaveChannel() [2/2]

abstract int io.agora.rtc2.RtcEngine.leaveChannel ( LeaveChannelOptions  options)
abstract

Leaves the channel.

Parameters
optionsThe leave channel options.

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

This method is an asynchronous call, which means that the result of this method returns even before the user has not actually left the channel. Once the user successfully leaves the channel, the SDK triggers the onLeaveChannel callback.

Note
If you call release immediately after this method, the leaveChannel process will be interrupted, and the SDK will not trigger the onLeaveChannel callback.
Returns
  • 0: Success.
  • < 0: Failure.

◆ renewToken()

abstract int io.agora.rtc2.RtcEngine.renewToken ( String  token)
abstract

Renews the token.

Once a token is enabled and used, it expires after a certain period of time.

Under the following circumstances, generate a new token on your server, and then call this method to renew it. Failure to do so results in the SDK disconnecting from the server.

Parameters
tokenThe new token.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerLocalUserAccount()

abstract int io.agora.rtc2.RtcEngine.registerLocalUserAccount ( String  appId,
String  userAccount 
)
abstract

Registers a user account.

Once registered, the user account can be used to identify the local user when the user joins 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.

To join a channel with a user account, you can choose either of the following:

  • Call the registerLocalUserAccount method to create a user account, and then the joinChannelWithUserAccount method to join the channel.
  • Call the joinChannelWithUserAccount method to join the channel.

The difference between the two is that for the former, the time elapsed between calling the joinChannelWithUserAccount method and joining the channel is shorter than the latter.

Note
  • Ensure that you set the userAccount parameter. Otherwise, this method does not take effect.
  • Ensure that the value of the userAccount parameter 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 uid of the user is set to the same parameter type.
Parameters
appIdThe App ID of your project.
userAccountThe user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
Returns
  • 0: Success.
  • < 0: Failure.

◆ joinChannelWithUserAccount() [1/2]

abstract int io.agora.rtc2.RtcEngine.joinChannelWithUserAccount ( String  token,
String  channelName,
String  userAccount 
)
abstract

Joins the channel with a user account.

After the user successfully joins the channel, the SDK triggers the following callbacks:

  • The local client: onLocalUserRegistered and onJoinChannelSuccess . The remote client: onUserJoined and onUserInfoUpdated , if the user joining the channel is in the COMMUNICATION profile, or is a host in the LIVE_BROADCASTING profile.
Note
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 uid of the user is set to the same parameter type.
Parameters
tokenThe token generated at your server:
  • For low-security requirements: You can use the temporary token generated at Console. For details, see Get a temporary toke.
  • For high-security requirements: Set it as the token generated at your server. For details, see Get a token.
channelNameThe channel name. The maximum length of this parameter is 64 bytes. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
userAccountThe user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
  • All lowercase English letters: a to z.
  • All uppercase English letters: A to Z.
  • All numeric characters: 0 to 9.
  • The space character.
  • Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ",".
optionsThe channel media options: ChannelMediaOptions
Returns
  • 0: Success.
  • < 0: Failure.
    • #ERR_INVALID_ARGUMENT (-2)
    • #ERR_NOT_READY (-3)
    • #ERR_REFUSED (-5)

◆ joinChannelWithUserAccount() [2/2]

abstract int io.agora.rtc2.RtcEngine.joinChannelWithUserAccount ( String  token,
String  channelName,
String  userAccount,
ChannelMediaOptions  options 
)
abstract

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

Since
v3.3.0.

After the user successfully joins the channel, the SDK triggers the following callbacks:

◆ getUserInfoByUserAccount()

abstract UserInfo io.agora.rtc2.RtcEngine.getUserInfoByUserAccount ( String  userAccount)
abstract

Gets the user information by passing in the user account.

After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (userInfo), and triggers the onUserInfoUpdated callback on the local client.

After receiving the oonUserInfoUpdated callback, you can call this method to get the user ID of the remote user from the userInfo object by passing in the user account.

Parameters
userAccountThe user account of the user. Ensure that you set this parameter.
Returns
userInfo A userInfo object that identifies the user
  • not null: Success.
  • null: Failure.

◆ getUserInfoByUid()

abstract UserInfo io.agora.rtc2.RtcEngine.getUserInfoByUid ( int  uid)
abstract

Gets the user information by passing in the user ID.

After a remote user joins the channel, the SDK gets the user ID and user account of the remote user, caches them in a mapping table object (userInfo), and triggers the onUserInfoUpdated callback on the local client.

After receiving the onUserInfoUpdated 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
uidThe user ID of the remote user. Ensure that you set this parameter.
Returns
userInfo A userInfo object that identifies the user
  • not null: Success.
  • null: Failure.

◆ enableWebSdkInteroperability()

abstract int io.agora.rtc2.RtcEngine.enableWebSdkInteroperability ( boolean  enabled)
abstract

Enables interoperability with the Agora Web SDK (Live Broadcast only).

Use this method when the channel profile is Live Broadcast. Interoperability with the Agora Web SDK is enabled by default when the channel profile is Communication.

Parameters
enabledDetermines whether to enable interoperability with the Agora Web SDK.
  • true: Enable interoperability with the Agora Native SDK.
  • false: Disable interoperability with the Agora Native SDK。
Returns
  • 0: Success.
  • < 0: Failure.

◆ getConnectionState()

abstract RtcConnection.CONNECTION_STATE_TYPE io.agora.rtc2.RtcEngine.getConnectionState ( )
abstract

Gets the connection state of the SDK.

Returns
The connection state:

◆ enableAudio()

abstract int io.agora.rtc2.RtcEngine.enableAudio ( )
abstract

Enables the audio.

The audio is enabled by default.

Note
This method controls the underlying states of the Engine. It is still valid after one leaves channel.
Returns
  • 0: Success.
  • < 0: Failure.

◆ disableAudio()

abstract int io.agora.rtc2.RtcEngine.disableAudio ( )
abstract

Disables the audio.

Note
This method controls the underlying states of the Engine. It is still valid after one leaves channel.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pauseAudio()

abstract int io.agora.rtc2.RtcEngine.pauseAudio ( )
abstract

Disables the audio function in the channel.

Note: This method controls the underlying states of the Engine. It is still valid after one leaves channel.

Returns
  • 0: Success.
  • <0: Failure.

◆ resumeAudio()

abstract int io.agora.rtc2.RtcEngine.resumeAudio ( )
abstract

Enables the audio function in the channel.

Returns
  • 0: Success.
  • <0: Failure.

◆ setAudioProfile() [1/2]

abstract int io.agora.rtc2.RtcEngine.setAudioProfile ( int  profile)
abstract

Sets the audio profile.

Note
  • Call this method before calling joinChannel method.
  • In scenarios requiring high-quality audio, Agora recommends setting profile as MUSIC_HIGH_QUALITY(4).
  • To set the audio scenario, call create2 and pass value in the mAudioScenario member.
Parameters
profileSets the sample rate, bitrate, encoding mode, and the number of channels. See AudioProfile.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setAudioProfile() [2/2]

abstract int io.agora.rtc2.RtcEngine.setAudioProfile ( int  profile,
int  scenario 
)
abstract

Sets the audio parameters and application scenarios.

Note
  • Call this method before calling joinChannel.
  • In scenarios requiring high-quality audio, we recommend setting profile as MUSIC_HIGH_QUALITY(4) and scenario as AUDIO_SCENARIO_GAME_STREAMING(3).
Parameters
profileSets the sample rate, bitrate, encoding mode, and the number of channels. See AudioProfile.
scenarioSets the audio application scenarios. See AudioScenario.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setHighQualityAudioParameters()

abstract int io.agora.rtc2.RtcEngine.setHighQualityAudioParameters ( boolean  fullband,
boolean  stereo,
boolean  fullBitrate 
)
abstract

Sets high-quality audio preferences.

Call this method and set all the modes before joining a channel. Do NOT call this method again after joining a channel.

Note: Agora does not recommend using this method. If you want to set the audio profile, see setAudioProfile.

Parameters
fullbandFull-band codec (48 kHz sampling rate), not compatible with versions before v1.7.4.
  • True: Enable full-band codec.
  • False: Disable full-band codec.
stereoStereo codec, not compatible with versions before v1.7.4.
  • True: Enable stereo codec.
  • False: Disable stereo codec.
fullBitrateHigh bitrate. Recommended in voice-only mode.
  • True: Enable high bitrate mode.
  • False: Disable high bitrate mode.
Returns
  • 0: Success.
  • <0: Failure.

◆ adjustRecordingSignalVolume()

abstract int io.agora.rtc2.RtcEngine.adjustRecordingSignalVolume ( int  volume)
abstract

Adjusts the recording volume.

Parameters
volumeRecording volume, ranges from 0 to 400:
  • 0: Mute
  • 100: Original volume
  • 400: (Maximum) Four times the original volume with signal clipping protection
Returns
  • 0: Success.
  • <0: Failure.

◆ adjustPlaybackSignalVolume()

abstract int io.agora.rtc2.RtcEngine.adjustPlaybackSignalVolume ( int  volume)
abstract

Adjusts the playback volume.

Parameters
volumePlayback volume, ranges from 0 to 400:
  • 0: Mute
  • 100: Original volume
  • 400: (Maximum) Four times the original volume with signal clipping protection
Returns
  • 0: Success.
  • <0: Failure.

◆ enableAudioVolumeIndication()

abstract int io.agora.rtc2.RtcEngine.enableAudioVolumeIndication ( int  interval,
int  smooth 
)
abstract

Enables the onAudioVolumeIndication callback to report on which users are speaking and the speakers' volume.

Once the onAudioVolumeIndication callback is enabled, the SDK returns the volume indication in the at the time interval set in enableAudioVolumeIndication, regardless of whether any user is speaking in the channel.

Parameters
intervalSets the time interval between two consecutive volume indications:
  • ≤ 0: Disables the volume indication.
  • > 0: Time interval (ms) between two consecutive volume indications, and should be integral multiple of 200 (less than 200 will be set to 200).
smoothThe smoothing factor that sets the sensitivity of the audio volume indicator. The value ranges is [0, 10]. The greater the value, the more sensitive the indicator. The recommended value is 3.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableAudioQualityIndication()

abstract int io.agora.rtc2.RtcEngine.enableAudioQualityIndication ( boolean  enabled)
abstract

Enables the audio quality notification callbacks.

Deprecated:
From v2.4.1.

The onAudioQuality callback triggers periodically after this callback is enabled.

Parameters
enabledWhether to enable the audio quality notification callbacks. True/False.
Returns
  • 0: Success.
  • <0: Failure.

◆ enableLocalAudio()

abstract int io.agora.rtc2.RtcEngine.enableLocalAudio ( boolean  enabled)
abstract

Enables or disables the local audio capture.

The audio function is enabled by default. This method disables or re-enables the local audio function, that is, to stop or restart local audio capture and processing.

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.

Parameters
enabledDetermines whether to disable or re-enable the local audio function:
  • true: (Default) Re-enable the local audio function, that is, to start local audio capture and processing.
  • false: Disable the local audio function, that is, to stop local audio capture and processing.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteLocalAudioStream()

abstract int io.agora.rtc2.RtcEngine.muteLocalAudioStream ( boolean  muted)
abstract

Stops or resumes sending the local audio stream.

Parameters
muteDetermines whether to send or stop sending the local audio stream:
  • true: Stop sending the local audio stream.
  • false: (Default) Send the local audio stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteRemoteAudioStream()

abstract int io.agora.rtc2.RtcEngine.muteRemoteAudioStream ( int  uid,
boolean  muted 
)
abstract

Stops or resumes receiving the audio stream of a specified user.

You can call this method before or after joining a channel. If a user leaves a channel, the settings in this method become invalid.

Parameters
uidThe ID of the specified user.
muteWhether to stop receiving the audio stream of the specified user:
  • true: Stop receiving the specified audio stream.
  • false: (Default) Receive the specified audio stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustUserPlaybackSignalVolume()

abstract int io.agora.rtc2.RtcEngine.adjustUserPlaybackSignalVolume ( int  uid,
int  volume 
)
abstract

Adjust the playback volume of the user specified by uid.

You can call this method to adjust the playback volume of the user specified by uid in call. If you want to adjust playback volume of the multi user, you can call this this method multi times.

Note
Please call this method after join channel. This method adjust the playback volume of specified user.
Parameters
uidRemote user ID。
volumeThe playback volume, range is [0,100]: 0: mute, 100: The original volume
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteAllRemoteAudioStreams()

abstract int io.agora.rtc2.RtcEngine.muteAllRemoteAudioStreams ( boolean  muted)
abstract

Stops or resumes receiving all remote audio streams.

This method works for all remote users that join or will join a channel using the joinChannel method. It is equivalent to the autoSubscribeAudio member in the ChannelMediaOptions class. You can call this method before, during, or after a call.

  • If you call muteAllRemoteAudioStreams(true) before joining a channel, the local user does not receive any audio stream after joining the channel.
  • If you call muteAllRemoteAudioStreams(true) after joining a channel, the local use stops receiving any audio stream from any user in the channel, including any user who joins the channel after you call this method.
  • If you call muteAllRemoteAudioStreams(true) after leaving a channel, the local user does not receive any audio stream the next time the user joins a channel.

After you successfully call muteAllRemoteAudioStreams(true), you can take the following actions:

  • To resume receiving all remote audio streams, call muteAllRemoteAudioStreams(false).
  • To resume receiving the audio stream of a specified user, call muteRemoteAudioStream(uid, false), where uid is the ID of the user whose audio stream you want to resume receiving.
Note
  • The result of calling this method is affected by calling enableAudio and disableAudio. Settings in muteAllRemoteAudioStreams stop taking effect if either of the following occurs:
    • Calling enableAudio after muteAllRemoteAudioStreams(true).
    • Calling disableAudio after muteAllRemoteAudioStreams(false).
  • This method only works for the channel created by calling joinChannel. To set whether to receive remote audio streams for a specific channel, Agora recommends using autoSubscribeAudio in the ChannelMediaOptions class.
Parameters
mutedWhether to stop receiving remote audio streams:
  • true: Stop receiving any remote audio stream.
  • false: (Default) Resume receiving all remote audio streams.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setDefaultMuteAllRemoteAudioStreams()

abstract int io.agora.rtc2.RtcEngine.setDefaultMuteAllRemoteAudioStreams ( boolean  muted)
abstract

Determines whether to receive all remote audio streams by default.

Deprecated:
This method is deprecated. To set whether to receive remote audio streams by default, call muteAllRemoteAudioStreams before calling joinChannel.

Use setDefaultMuteAllRemoteAudioStreams to set whether to receive audio streams of subsequent peer users. Agora recommends calling it before joining a channel.

A successful call of setDefaultMuteAllRemoteAudioStreams(true) results in that the local user not receiving any audio stream after joining a channel.

Parameters
mutedWhether to receive remote audio streams by default:
  • true: Do not receive any remote audio stream by default.
  • false: (Default)) Receive remote audio streams by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableVideo()

abstract int io.agora.rtc2.RtcEngine.enableVideo ( )
abstract

Enables the video.

You can call this method either before joining a channel or during a call. If you call this method before entering a channel, the service starts the video; if you call it during a call, the audio call switches to a video call.

Note
This method controls the underlying states of the Engine. It is still valid after one leaves the channel.
Returns
  • 0: Success.
  • < 0: Failure.

◆ disableVideo()

abstract int io.agora.rtc2.RtcEngine.disableVideo ( )
abstract

Disables the video.

This method stops capturing the local video and receiving any remote video. To enable the local preview function, call enableLocalVideo (true).

Returns
  • 0: Success.
  • < 0: Failure.

◆ setVideoProfile()

abstract int io.agora.rtc2.RtcEngine.setVideoProfile ( int  profile,
boolean  swapWidthAndHeight 
)
abstract

Sets the video encoding profile.

Each profile includes a set of parameters, such as the resolution, frame rate, and bitrate. When the camera does not support the specified resolution, the SDK chooses a suitable camera resolution, while the encoder resolution is the one specified by setVideoProfile.

Note:

Parameters
profileVideoProfile.
swapWidthAndHeightThe width and height of the output video is consistent with that of the video profile you set. This parameter sets whether to swap the width and height of the stream:
  • True: Swap the width and height. After that the video will be in the portrait mode, that is, width < height.
  • False: (Default) Do not swap the width and height, and the video remains in the landscape mode, that is, width > height.
Returns
  • 0: Success.
  • <0: Failure.

◆ setVideoEncoderConfiguration()

abstract int io.agora.rtc2.RtcEngine.setVideoEncoderConfiguration ( VideoEncoderConfiguration  config)
abstract

Sets the video encoder configuration.

Each configuration profile corresponds to a set of video parameters, including the resolution, frame rate, and bitrate.

The parameters specified in this method are the maximum values under ideal network conditions. If the video engine cannot render the video using the specified parameters due to poor network conditions, the parameters further down the list are considered until a successful configuration is found.

Parameters
configThe local video encoder configuration: VideoEncoderConfiguration.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setCameraCapturerConfiguration()

abstract int io.agora.rtc2.RtcEngine.setCameraCapturerConfiguration ( CameraCapturerConfiguration  config)
abstract

◆ setupLocalVideo()

abstract int io.agora.rtc2.RtcEngine.setupLocalVideo ( VideoCanvas  local)
abstract

Initializes the local video view.

This method initializes the video view of the local stream on the local device. It affects only the video view that the local user sees, not the published local video stream.

To unbind the local video from the view, set view in VideoCanvas as null.

Note
Call this method before joining a channel.
Parameters
localThe local video view setting: VideoCanvas.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setupRemoteVideo()

abstract int io.agora.rtc2.RtcEngine.setupRemoteVideo ( VideoCanvas  remote)
abstract

Initializes the video view of a remote user.

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.

Usually the app should specify the uid of the remote video in the method call before the remote user joins the channel. If the remote uid is unknown to the app, set it later when the app receives the onUserJoined callback.

To unbind the remote user from the view, set view in VideoCanvas as null.

Note
Ensure that you call this method in the UI thread.
Parameters
remoteThe remote video view settings: VideoCanvas.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLocalRenderMode() [1/2]

abstract int io.agora.rtc2.RtcEngine.setLocalRenderMode ( int  renderMode)
abstract

Updates the display mode of the local video view.

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

Note
  • Ensure that you have called setupLocalVideo to initialize the local video view before this method.
  • During a call, you can call this method as many times as necessary to update the local video view.
Parameters
renderModeSets the local display mode:
  • RENDER_MODE_HIDDEN(1): Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): 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 will be filled with black.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLocalRenderMode() [2/2]

abstract int io.agora.rtc2.RtcEngine.setLocalRenderMode ( int  renderMode,
int  mirrorMode 
)
abstract

Updates the display mode of the local video view.

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

Note
  • Ensure that you have called setupLocalVideo to initialize the local video view before this method.
  • During a call, you can call this method as many times as necessary to update the local video view.
Parameters
renderModeSets the local display mode:
  • RENDER_MODE_HIDDEN(1): Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): 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 will be filled with black.
mirrorModeSets the local video mirror mode:
  • VIDEO_MIRROR_MODE_AUTO(0): (Default) The mirror mode determined by the SDK. If you use the front camera, the SDK enables the mirror mode; if you use the rear camera, the SDK disables the mirror mode.
  • VIDEO_MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • VIDEO_MIRROR_MODE_DISABLED(2): Disable the mirror mode.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteRenderMode() [1/2]

abstract int io.agora.rtc2.RtcEngine.setRemoteRenderMode ( int  userId,
int  renderMode 
)
abstract

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

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.

Note
  • Ensure that you have called setupRemoteVideo to initialize the remote 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 video view of a remote user.
Parameters
uidID of the remote user.
renderModeSets the remote display mode:
  • RENDER_MODE_HIDDEN(1): Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): 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 will be filled with black.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteRenderMode() [2/2]

abstract int io.agora.rtc2.RtcEngine.setRemoteRenderMode ( int  userId,
int  renderMode,
int  mirrorMode 
)
abstract

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

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.

Note
  • Ensure that you have called setupRemoteVideo to initialize the remote 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 video view of a remote user.
Parameters
uidID of the remote user.
renderModeSets the remote display mode:
  • RENDER_MODE_HIDDEN(1): Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.
  • RENDER_MODE_FIT(2): 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 will be filled with black.
mirrorModeSets the remote video mirror mode:
  • VIDEO_MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • VIDEO_MIRROR_MODE_DISABLED(2): Disable the mirror mode.
Returns
  • 0: Success.
  • < 0: Failure.

◆ CreateRendererView()

static SurfaceView io.agora.rtc2.RtcEngine.CreateRendererView ( Context  context)
static

Creates a video renderer view.

Deprecated:
This method is deprecated. You can use SurfaceView or TextureView created by Android system.

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

Returns
SurfaceView

◆ CreateTextureView()

static TextureView io.agora.rtc2.RtcEngine.CreateTextureView ( Context  context)
static

Creates a TextureView.

Deprecated:
This method is deprecated. You can use SurfaceView or TextureView created by Android system.

It returns the TextureView type. The operation and layout of the view are managed by the application, and the Agora SDK renders the view provided by the application. The view to display videos must be created using this method instead of directly calling TextureView.

Returns
TextureView

◆ startPreview() [1/2]

abstract int io.agora.rtc2.RtcEngine.startPreview ( )
abstract

Starts the local video preview before joining a channel.

Once you call this method to start the local video preview, if you leave the channel by calling leaveChannel, the local video preview remains until you call stopPreview to disable it.

Returns

◆ startPreview() [2/2]

abstract int io.agora.rtc2.RtcEngine.startPreview ( Constants.VideoSourceType  sourceType)
abstract

Starts the local video preview before joining a channel.

Parameters
sourceType- The video source type.

◆ stopPreview() [1/2]

abstract int io.agora.rtc2.RtcEngine.stopPreview ( )
abstract

Stops the local video preview and the video.

Returns
  • 0: Success.
  • < 0: Failure.

◆ stopPreview() [2/2]

abstract int io.agora.rtc2.RtcEngine.stopPreview ( Constants.VideoSourceType  sourceType)
abstract

Stops the local video preview and the video.

Parameters
sourceType- The video source type.

◆ enableLocalVideo()

abstract int io.agora.rtc2.RtcEngine.enableLocalVideo ( boolean  enabled)
abstract

Disables or re-enables the local video capture.

Once you enable the video using enableVideo, the local video is enabled by default. This method disables or re-enables the local video capture.

enableLocalVideo(false) applies to scenarios when the user wants to watch the remote video without sending any video stream to the other user.

Note
Call this method after enableVideo. Otherwise, this method may not work properly.
Parameters
enabledDetermines whether to disable or re-enable the local video, including the capturer, renderer, and sender:
  • true: (Default) Re-enable the local video.
  • false: Disable the local video. 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 other remote users. When you set enabled as false, this method does not require a local camera.
Returns
  • 0: Success.
  • < 0: Failure.

◆ startSecondaryCameraCapture()

abstract int io.agora.rtc2.RtcEngine.startSecondaryCameraCapture ( CameraCapturerConfiguration  config)
abstract

Start the secondary camera capture.

Parameters
config- The config for secondary camera capture

◆ stopSecondaryCameraCapture()

abstract int io.agora.rtc2.RtcEngine.stopSecondaryCameraCapture ( )
abstract

Stop the secondary camera capture.

◆ muteLocalVideoStream()

abstract int io.agora.rtc2.RtcEngine.muteLocalVideoStream ( boolean  muted)
abstract

Stops or resumes sending the local video stream.

Parameters
muteDetermines whether to send or stop sending the local video stream:
  • true: Stop sending the local video stream.
  • false: (Default) Send the local video stream.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteRemoteVideoStream()

abstract int io.agora.rtc2.RtcEngine.muteRemoteVideoStream ( int  userId,
boolean  muted 
)
abstract

Stops or resumes receiving the video stream of a specified user.

You can call this method before or after joining a channel. If a user leaves a channel, the settings in this method become invalid.

Parameters
userIdThe ID of the specified user.
muteWhether to stop receiving the video stream of the specified user:
  • true: Stop receiving the video stream of the specified user.
  • false: (Default) Resume receiving the video stream of the specified user.
Returns
  • 0: Success.
  • < 0: Failure.

◆ muteAllRemoteVideoStreams()

abstract int io.agora.rtc2.RtcEngine.muteAllRemoteVideoStreams ( boolean  muted)
abstract

Stops or resumes receiving all remote video streams.

This method works for all remote users that join or will join a channel using the joinChannel method. It is equivalent to the autoSubscribeVideo member in the ChannelMediaOptions class. You can call this method before, during, or after a call.

  • If you call muteAllRemoteVideoStreams(true) before joining a channel, the local user does not receive any video stream after joining the channel.
  • If you call muteAllRemoteVideoStreams(true) after joining a channel, the local use stops receiving any video stream from any user in the channel, including any user who joins the channel after you call this method.
  • If you call muteAllRemoteVideoStreams(true) after leaving a channel, the local user does not receive any video stream the next time the user joins a channel.

After you successfully call muteAllRemoteVideoStreams(true), you can take the following actions:

  • To resume receiving all remote video streams, call muteAllRemoteVideoStreams(false).
  • To resume receiving the video stream of a specified user, call muteRemoteVideoStream(uid, false), where uid is the ID of the user whose video stream you want to resume receiving.
Note
  • The result of calling this method is affected by calling enableVideo and disableVideo. Settings in muteAllRemoteVideoStreams stop taking effect if either of the following occurs:
    • Calling enableVideo after muteAllRemoteVideoStreams(true).
    • Calling disableVideo after muteAllRemoteVideoStreams(false).
  • This method only works for the channel created by calling joinChannel. To set whether to receive remote audio streams for a specific channel, Agora recommends using autoSubscribeVideo in the ChannelMediaOptions class.
Parameters
mutedWhether to stop receiving remote video streams:
  • true: Stop receiving any remote video stream.
  • false: (Default) RResume receiving all remote video streams.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setDefaultMuteAllRemoteVideoStreams()

abstract int io.agora.rtc2.RtcEngine.setDefaultMuteAllRemoteVideoStreams ( boolean  muted)
abstract

Determines whether to receive all remote video streams by default.

Deprecated:
This method is deprecated. To set whether to receive remote video streams by default, call muteAllRemoteVideoStreams before calling joinChannel.

Use setDefaultMuteAllRemoteVideoStreams to set whether to receive video streams of subsequent peer users. Agora recommends calling it before joining a channel.

A successful call of setDefaultMuteAllRemoteVideoStreams(true) results in that the local user not receiving any video stream after joining a channel.

Parameters
mutedWhether to receive remote video streams by default:
  • true: Do not receive any remote video stream by default.
  • false: (Default) Receive remote video streams by default.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setBeautyEffectOptions()

abstract int io.agora.rtc2.RtcEngine.setBeautyEffectOptions ( boolean  enabled,
BeautyOptions  options 
)
abstract

Enables/Disables image enhancement and sets the options.

Since
v2.4.0.
Note
  • Call this method after calling enableVideo.
  • This method applies to Android 4.4 or later.
Parameters
enabledWhether to enable image enhancement:
  • true: Enables image enhancement.
  • false: Disables image enhancement.
optionsThe image enhancement options. See BeautyOptions.
Returns
  • 0: Success.
  • < 0: Failure.
    • ERR_NOT_SUPPORTED(4): The system version is earlier than Android 4.4, which does not support this function.

◆ setDefaultAudioRoutetoSpeakerphone()

abstract int io.agora.rtc2.RtcEngine.setDefaultAudioRoutetoSpeakerphone ( boolean  defaultToSpeaker)
abstract

Sets the default audio route.

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:

  • Voice call: Earpiece.
  • Video call: Speakerphone.
  • Audio broadcast: Speakerphone.
  • Video broadcast: Speakerphone.

Call this method before, during, or after a call, to change the default audio route. When the audio route changes, 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
defaultToSpeakerWhether to set the speakerphone as the default audio route:
  • true: Set the speakerphone as the default audio route.
  • false: Do not set the speakerphone as the default audio route.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setEnableSpeakerphone()

abstract int io.agora.rtc2.RtcEngine.setEnableSpeakerphone ( boolean  enabled)
abstract

◆ isSpeakerphoneEnabled()

abstract boolean io.agora.rtc2.RtcEngine.isSpeakerphoneEnabled ( )
abstract

Checks whether the speakerphone is enabled.

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.

◆ enableInEarMonitoring() [1/2]

abstract int io.agora.rtc2.RtcEngine.enableInEarMonitoring ( boolean  enabled)
abstract

Enables in-ear monitoring.

Parameters
enabledDetermines whether to enable in-ear monitoring.
  • true: Enable in-ear monitoring.
  • false: Disable in-ear monitoring.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableInEarMonitoring() [2/2]

abstract int io.agora.rtc2.RtcEngine.enableInEarMonitoring ( boolean  enabled,
int  includeAudioFilters 
)
abstract

Enables in-ear monitoring.

Parameters
enabledDetermines whether to enable in-ear monitoring.
  • true: Enable in ear monitoring.
  • false: Disable in ear monitoring.
includeAudioFiltersThe type of the ear monitoring
Returns
  • 0: Success.
  • < 0: Failure.

◆ setInEarMonitoringVolume()

abstract int io.agora.rtc2.RtcEngine.setInEarMonitoringVolume ( int  volume)
abstract

Sets the volume of the in-ear monitoring.

Parameters
volumeThe volume of the in-ear monitor, ranging from 0 to 100. The default value is 100.
Returns
  • 0: Success.
  • < 0: Failure.

◆ useExternalAudioDevice()

abstract int io.agora.rtc2.RtcEngine.useExternalAudioDevice ( )
abstract

Use the external audio device.

Returns
  • 0: Success.
  • <0: Failure.

◆ setLocalVoicePitch()

abstract int io.agora.rtc2.RtcEngine.setLocalVoicePitch ( double  pitch)
abstract

Sets the voice pitch of the local speaker.

Parameters
pitchVoice frequency, in the range of 0.5 to 2.0. The default value is 1.0.
Returns
  • 0: Success.
  • <0: Failure.

◆ setLocalVoiceEqualization()

abstract int io.agora.rtc2.RtcEngine.setLocalVoiceEqualization ( Constants.AUDIO_EQUALIZATION_BAND_FREQUENCY  bandFrequency,
int  bandGain 
)
abstract

Sets the local voice equalization effect.

Parameters
bandFrequencyThe band frequency ranging from 0 to 9; representing the respective 10-band center frequencies of voice effects, including 31, 62, 125, 500, 1k, 2k, 4k, 8k, and 16k Hz. Constants#AUDIO_EQUALIZATION_BAND_FREQUENCY
bandGainGain of each band in dB; ranging from -15 to 15.

◆ setLocalVoiceReverb()

abstract int io.agora.rtc2.RtcEngine.setLocalVoiceReverb ( Constants.AUDIO_REVERB_TYPE  reverbKey,
int  value 
)
abstract

Sets the local voice reverberation.

Parameters
reverbKeyThe reverberation key. This method contains five reverberation keys. For details, see the description of each value.
valueLocal voice reverberation value:

◆ setLocalVoiceChanger()

abstract int io.agora.rtc2.RtcEngine.setLocalVoiceChanger ( int  voiceChanger)
abstract

Sets the local voice changer option.

This method can be used to set the local voice effect for users in a communication channel or broadcasters in a live broadcast channel. Voice changer options include the following voice effects:

  • VOICE_CHANGER_XXX: Changes the local voice to an old man, a little boy, or the Hulk. Applies to the voice talk scenario.
  • VOICE_BEAUTY_XXX: Beautifies the local voice by making it sound more vigorous, resounding, or adding spacial resonance. Applies to the voice talk and singing scenario.
  • GENERAL_VOICE_BEAUTY_XXX: Adds gender-based beautification effect to the local voice. Applies to the voice talk scenario.
    • For a male voice: Adds magnetism to the voice.
    • For a female voice: Adds freshness or vitality to the voice.
Note
  • To achieve better voice effect quality, Agora recommends setting the profile parameter in setAudioProfile as AUDIO_PROFILE_MUSIC_HIGH_QUALITY or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO.
  • This method works best with the human voice, and Agora does not recommend using it for audio containing music and a human voice.
  • Do not use this method with setLocalVoiceReverbPreset, because the method called later overrides the one called earlier.
Parameters
voiceChangerThe local voice changer option:
Returns
  • 0: Success.
  • -1: Failure. Check if the enumeration is properly set.

◆ setLocalVoiceReverbPreset()

abstract int io.agora.rtc2.RtcEngine.setLocalVoiceReverbPreset ( int  reverbPreset)
abstract

Sets the local voice reverberation option.

This method sets the local voice reverberation for users in a communication channel or broadcasters in a live-broadcast channel. After successfully calling this method, all users in the channel can hear the voice with reverberation.

Note
  • When calling this method with enumerations that begin with AUDIO_REVERB_FX, ensure that you set profile in setAudioProfile as AUDIO_PROFILE_MUSIC_HIGH_QUALITY or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO. Otherwise, this method call does not take effect.
  • This method works best with the human voice, and Agora does not recommend using it for audio containing music and a human voice.
  • Do not use this method with setLocalVoiceChanger, because the method called later overrides the one called earlier.
Parameters
reverbPresetThe local voice reverberation option. To achieve better voice effects, Agora recommends the enumeration whose name begins with AUDIO_REVERB_FX.
Returns
  • 0: Success.
  • -1: Failure. Check if the enumeration is properly set.

◆ setAudioEffectPreset()

abstract int io.agora.rtc2.RtcEngine.setAudioEffectPreset ( int  preset)
abstract

Sets an SDK preset audio effect.

Since
v3.2.0

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.

You can set different audio effects for different scenarios. See Set the Voice Effect.

To achieve better audio effect quality, Agora recommends calling {setAudioProfile} and setting the scenario parameter to AUDIO_SCENARIO_GAME_STREAMING(3) before calling this method. You can call this method either before or after joining a channel.Do not set the profile parameter of setAudioProfile to AUDIO_PROFILE_SPEECH_STANDARD(1); otherwise, this method call 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 this method and set the preset parameter to enumerators except ROOM_ACOUSTICS_3D_VOICE or PITCH_CORRECTION, do not call setAudioEffectParameters setAudioEffectParameters}; otherwise, setAudioEffectParameters overrides this method.After calling this method, Agora recommends not calling the following methods, because they can override setAudioEffectPreset: RtcEngine#setVoiceBeautifierPreset setVoiceBeautifierPreset} RtcEngine#setLocalVoiceReverbPreset setLocalVoiceReverbPreset} RtcEngine#setLocalVoiceChanger setLocalVoiceChanger} RtcEngine#setLocalVoicePitch setLocalVoicePitch} RtcEngine#setLocalVoiceEqualization setLocalVoiceEqualization} RtcEngine#setLocalVoiceReverb setLocalVoiceReverb} RtcEngine#setVoiceBeautifierParameters setVoiceBeautifierParameters} preset The options for SDK preset audio effects Constants#AUDIO_EFFECT_OFF AUDIO_EFFECT_OFF} Constants#ROOM_ACOUSTICS_KTV ROOM_ACOUSTICS_KTV} Constants#ROOM_ACOUSTICS_VOCAL_CONCERT ROOM_ACOUSTICS_VOCAL_CONCERT} Constants#ROOM_ACOUSTICS_STUDIO ROOM_ACOUSTICS_STUDIO} Constants#ROOM_ACOUSTICS_PHONOGRAPH ROOM_ACOUSTICS_PHONOGRAPH} Constants#ROOM_ACOUSTICS_VIRTUAL_STEREO ROOM_ACOUSTICS_VIRTUAL_STEREO} Constants#ROOM_ACOUSTICS_SPACIAL ROOM_ACOUSTICS_SPACIAL} Constants#ROOM_ACOUSTICS_ETHEREAL ROOM_ACOUSTICS_ETHEREAL} Constants#ROOM_ACOUSTICS_3D_VOICE ROOM_ACOUSTICS_3D_VOICE} Constants#VOICE_CHANGER_EFFECT_UNCLE VOICE_CHANGER_EFFECT_UNCLE} Constants#VOICE_CHANGER_EFFECT_OLDMAN VOICE_CHANGER_EFFECT_OLDMAN} Constants#VOICE_CHANGER_EFFECT_BOY VOICE_CHANGER_EFFECT_BOY} Constants#VOICE_CHANGER_EFFECT_SISTER VOICE_CHANGER_EFFECT_SISTER} Constants#VOICE_CHANGER_EFFECT_GIRL VOICE_CHANGER_EFFECT_GIRL} Constants#VOICE_CHANGER_EFFECT_PIGKING VOICE_CHANGER_EFFECT_PIGKING} Constants#VOICE_CHANGER_EFFECT_HULK VOICE_CHANGER_EFFECT_HULK} Constants#STYLE_TRANSFORMATION_RNB STYLE_TRANSFORMATION_RNB} Constants#STYLE_TRANSFORMATION_POPULAR STYLE_TRANSFORMATION_POPULAR} Constants#PITCH_CORRECTION PITCH_CORRECTION} 0: Success.< 0: Failure.

◆ setVoiceBeautifierPreset()

abstract int io.agora.rtc2.RtcEngine.setVoiceBeautifierPreset ( int  preset)
abstract

Sets an SDK preset voice beautifier effect.

Since
v3.2.0

Call this method to set an SDK 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. See Set the Voice Effect.

To achieve better audio effect quality, Agora recommends calling {setAudioProfile} and setting the scenario parameter to AUDIO_SCENARIO_GAME_STREAMING(3) and the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before calling this method. You can call this method either before or after joining a channel.Do not set the profile parameter of setAudioProfile to AUDIO_PROFILE_SPEECH_STANDARD(1); otherwise, this method call 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 this method, Agora recommends not calling the following methods, because they can override RtcEngine#setVoiceBeautifierPreset setVoiceBeautifierPreset}: RtcEngine#setAudioEffectPreset setAudioEffectPreset} RtcEngine#setAudioEffectParameters setAudioEffectParameters} RtcEngine#setLocalVoiceReverbPreset setLocalVoiceReverbPreset} RtcEngine#setLocalVoiceChanger setLocalVoiceChanger} RtcEngine#setLocalVoicePitch setLocalVoicePitch} RtcEngine#setLocalVoiceEqualization setLocalVoiceEqualization} RtcEngine#setLocalVoiceReverb setLocalVoiceReverb} RtcEngine#setVoiceBeautifierParameters setVoiceBeautifierParameters} RtcEngine#setVoiceConversionPreset setVoiceConversionPreset} preset The options for SDK preset voice beautifier effects: Constants#VOICE_BEAUTIFIER_OFF VOICE_BEAUTIFIER_OFF} Constants#CHAT_BEAUTIFIER_MAGNETIC CHAT_BEAUTIFIER_MAGNETIC} Constants#CHAT_BEAUTIFIER_FRESH CHAT_BEAUTIFIER_FRESH} Constants#CHAT_BEAUTIFIER_VITALITY CHAT_BEAUTIFIER_VITALITY} Constants#TIMBRE_TRANSFORMATION_VIGOROUS TIMBRE_TRANSFORMATION_VIGOROUS} Constants#TIMBRE_TRANSFORMATION_DEEP TIMBRE_TRANSFORMATION_DEEP} Constants#TIMBRE_TRANSFORMATION_MELLOW TIMBRE_TRANSFORMATION_MELLOW} Constants#TIMBRE_TRANSFORMATION_FALSETTO TIMBRE_TRANSFORMATION_FALSETTO} Constants#TIMBRE_TRANSFORMATION_FULL TIMBRE_TRANSFORMATION_FULL} Constants#TIMBRE_TRANSFORMATION_CLEAR TIMBRE_TRANSFORMATION_CLEAR} Constants#TIMBRE_TRANSFORMATION_RESOUNDING TIMBRE_TRANSFORMATION_RESOUNDING} Constants#TIMBRE_TRANSFORMATION_RINGING TIMBRE_TRANSFORMATION_RINGING} 0: Success.< 0: Failure.

◆ setVoiceConversionPreset()

abstract int io.agora.rtc2.RtcEngine.setVoiceConversionPreset ( int  preset)
abstract

Sets an SDK preset voice conversion effect.

Since
v3.3.1

Call this method to set an SDK preset voice conversion effect for the local user who sends an audio stream. After setting a voice conversion effect, all users in the channel can hear the effect.

You can set different voice conversion effects for different scenarios. See Set the Voice Effect.

To achieve better audio effect quality, Agora recommends calling {setAudioProfile} and setting the scenario parameter to AUDIO_SCENARIO_GAME_STREAMING(3) and the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before calling this method. You can call this method either before or after joining a channel.Do not set the profile parameter of setAudioProfile to AUDIO_PROFILE_SPEECH_STANDARD(1); otherwise, this method call 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 this method, Agora recommends not calling the following methods, because they can override RtcEngine#setVoiceConversionPreset setVoiceConversionPreset}: RtcEngine#setAudioEffectPreset setAudioEffectPreset} RtcEngine#setAudioEffectParameters setAudioEffectParameters} RtcEngine#setVoiceBeautifierPreset setVoiceBeautifierPreset} RtcEngine#setVoiceBeautifierParameters setVoiceBeautifierParameters} RtcEngine#setLocalVoiceReverbPreset setLocalVoiceReverbPreset} RtcEngine#setLocalVoiceChanger setLocalVoiceChanger} RtcEngine#setLocalVoicePitch setLocalVoicePitch} RtcEngine#setLocalVoiceEqualization setLocalVoiceEqualization} RtcEngine#setLocalVoiceReverb setLocalVoiceReverb} preset The options for SDK preset voice conversion effects: Constants#VOICE_CONVERSION_OFF VOICE_CONVERSION_OFF} Constants#VOICE_CHANGER_NEUTRAL VOICE_CHANGER_NEUTRAL} Constants#VOICE_CHANGER_SWEET VOICE_CHANGER_SWEET} Constants#VOICE_CHANGER_SOLID VOICE_CHANGER_SOLID} Constants#VOICE_CHANGER_BASS VOICE_CHANGER_BASS} 0: Success.< 0: Failure.

◆ setAudioEffectParameters()

abstract int io.agora.rtc2.RtcEngine.setAudioEffectParameters ( int  preset,
int  param1,
int  param2 
)
abstract

Sets parameters for SDK preset audio effects.

Since
v3.2.0

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 parameters, all users in the channel can hear the relevant effect.

Note
Parameters
presetThe options for SDK preset audio effects:
  • 3D voice effect: ROOM_ACOUSTICS_3D_VOICE
    • Call setAudioProfile and set the profile parameter to AUDIO_PROFILE_MUSIC_STANDARD_STEREO(3) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before setting this enumerator; otherwise, the enumerator setting does not take effect.
    • If the 3D voice effect is enabled, users need to use stereo audio playback devices to hear the anticipated voice effect.
  • Pitch correction effect: PITCH_CORRECTION. To achieve better audio effect quality, Agora recommends calling setAudioProfile and setting the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5) before setting this enumerator.
param1
  • If you set preset to ROOM_ACOUSTICS_3D_VOICE, the param1 sets the cycle period of the 3D voice effect. The value range is [1, 60] and the unit is a second. The default value is 10 seconds, indicating that the voice moves around you every 10 seconds.
  • If you set preset to PITCH_CORRECTION, param1 sets the basic mode of the pitch correction effect:
    • 1: (Default) Natural major scale.
    • 2: Natural minor scale.
    • 3: Japanese pentatonic scale.
param2
  • You need to set param2 to 0.
  • If you set preset to PITCH_CORRECTION, param2 sets 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.

◆ setVoiceBeautifierParameters()

abstract int io.agora.rtc2.RtcEngine.setVoiceBeautifierParameters ( int  preset,
int  param1,
int  param2 
)
abstract

Sets parameters for SDK preset voice beautifier effects.

Since
3.3.0.

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 you call this method successfully, all users in the channel can hear the relevant effect.

To achieve better audio effect quality, before you call this method, Agora recommends calling setAudioProfile, and setting the scenario parameter to AUDIO_SCENARIO_GAME_STREAMING(3) and the profile parameter to AUDIO_PROFILE_MUSIC_HIGH_QUALITY(4) or AUDIO_PROFILE_MUSIC_HIGH_QUALITY_STEREO(5).

Note
Parameters
presetThe options for SDK preset voice beautifier effects:
  • SINGING_BEAUTIFIER: Singing beautifier effect.
param1The gender characteristics options for the singing voice:
  • 1: A male-sounding voice.
  • 2: A female-sounding voice.
param2The reverberation effects options:
  • 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.

◆ setVoiceConversionParameters()

abstract int io.agora.rtc2.RtcEngine.setVoiceConversionParameters ( int  preset,
int  param1,
int  param2 
)
abstract

Set parameters for SDK preset voice conversion.

Note
  • reserved interface
Parameters
presetThe options for SDK preset audio effects. See #VOICE_CONVERSION_PRESET.
param1reserved.
param2reserved.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableSoundPositionIndication()

abstract int io.agora.rtc2.RtcEngine.enableSoundPositionIndication ( boolean  enabled)
abstract

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

Parameters
enabledSets whether or not to enable stereo panning for remote users:
  • true: enables stereo panning.
  • false: disables stereo panning.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteVoicePosition()

abstract int io.agora.rtc2.RtcEngine.setRemoteVoicePosition ( int  uid,
double  pan,
double  gain 
)
abstract

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

Note
  • For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel.
  • This method requires hardware support. For the best sound positioning, we recommend using a wired headset.
  • Ensure that you call this method after joining a channel.
Parameters
uidThe ID of the remote user.
panThe sound position of the remote user. The value ranges from -1.0 to 1.0:
  • 0.0: the remote sound comes from the front.
  • -1.0: the remote sound comes from the left.
  • 1.0: the remote sound comes from the right.
gainGain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteVoice3DPosition()

abstract int io.agora.rtc2.RtcEngine.setRemoteVoice3DPosition ( int  uid,
double  azimuth,
double  elevation,
double  distance 
)
abstract

Sets the 3D sound position of a remote user.

Note
  • For this method to work, enable stereo panning for remote users by calling the enableSoundPositionIndication method before joining a channel.
  • This method requires hardware support. For the best sound positioning, we recommend using a wired headset.
  • Ensure that you call this method after joining a channel.
Parameters
uidThe ID of the remote user.
azimuth
elevation
distance
Returns
  • 0: Success.
  • < 0: Failure.

◆ startAudioMixing()

abstract int io.agora.rtc2.RtcEngine.startAudioMixing ( String  filePath,
boolean  loopback,
boolean  replace,
int  cycle 
)
abstract

Starts playing and mixing the music file.

This method mixes the specified local or online audio file with the audio stream from the microphone, or replaces the microphone’s audio stream with the specified local or remote audio file.

You can choose whether the other user can hear the local audio playback and specify the number of playback loops.

A successful startAudioMixing method call triggers the {onAudioMixingStateChanged}(AUDIO_MIXING_STATE_PLAYING) callback on the local client. When the audio mixing file playback finishes, the SDK triggers the { IRtcEngineEventHandler#onAudioMixingStateChanged onAudioMixingStateChanged}(AUDIO_MIXING_STATE_STOPPED) callback on the local client. filePath Specifies the absolute path (including the suffixes of the filename) of the local or online audio file to be mixed. For example, /sdcard/emulated/0/audio.mp4. Supported audio formats: mp3, mp4, m4a, aac, 3gp, mkv, and wav.If the path begins with /assets/, the audio file is in the /assets/ directory.Otherwise, the audio file is in the absolute path. loopback Sets which user can hear the audio mixing:true: Only the local user can hear the audio mixing.false: Both users can hear the audio mixing. replace Sets the audio mixing content:true: Only publish the specified audio file; the audio stream from the microphone is not published.false: The local audio file is mixed with the audio stream from the microphone. cycle Sets the number of playback loops:Positive integer: Number of playback loops.-1: Infinite playback loops. To use this method, ensure that the Android device is v4.2 or later, and the API version is v16 or later.Call this method when you are in the channel, otherwise it may cause issues.If you want to play an online music file, ensure that the time interval between calling this method is more than 100 ms, or the AUDIO_FILE_OPEN_TOO_FREQUENT(702) warning occurs.If you want 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, only the MP3 file format is supported. 0: Success.< 0: Failure. Constants#WARN_AUDIO_MIXING_OPEN_ERROR WARN_AUDIO_MIXING_OPEN_ERROR (701)}: If the local audio file does not exist, or the online audio packet is not received within five seconds after it is opened, the SDK assumes that the media file cannot be used and returns this warning.

◆ stopAudioMixing()

abstract int io.agora.rtc2.RtcEngine.stopAudioMixing ( )
abstract

Stops playing or mixing the music file.

Call this method when you are in a channel.

Returns
  • 0: Success.
  • < 0: Failure.

◆ pauseAudioMixing()

abstract int io.agora.rtc2.RtcEngine.pauseAudioMixing ( )
abstract

Pauses playing and mixing the music file.

Call this method when you are in a channel.

Returns
  • 0: Success.
  • < 0: Failure.

◆ resumeAudioMixing()

abstract int io.agora.rtc2.RtcEngine.resumeAudioMixing ( )
abstract

Resumes playing and mixing the music file.

Call this method when you are in a channel.

Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustAudioMixingVolume()

abstract int io.agora.rtc2.RtcEngine.adjustAudioMixingVolume ( int  volume)
abstract

Adjusts the volume of audio mixing.

Call this method when you are in a channel.

Note
Calling this method does not affect the volume of the audio effect file playback invoked by the  playEffect method.
Parameters
volumeAudio mixing volume. The value ranges between 0 and 100 (default).
Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustAudioMixingPlayoutVolume()

abstract int io.agora.rtc2.RtcEngine.adjustAudioMixingPlayoutVolume ( int  volume)
abstract

Adjusts the audio mixing volume for local playback.

Note
Call this method when you are in a channel.
Parameters
volumeAudio mixing volume for local playback. The value ranges between 0 and 100 (default).
Returns
  • 0: Success.
  • < 0: Failure.

◆ adjustAudioMixingPublishVolume()

abstract int io.agora.rtc2.RtcEngine.adjustAudioMixingPublishVolume ( int  volume)
abstract

Adjusts the audio mixing volume for publishing (for remote users).

Note
Call this method when you are in a channel.
Parameters
volumeAudio mixing volume for publishing. The value ranges between 0 and 100 (default).
Returns
  • 0: Success.
  • < 0: Failure.

◆ getAudioMixingPlayoutVolume()

abstract int io.agora.rtc2.RtcEngine.getAudioMixingPlayoutVolume ( )
abstract

Retrieves the audio mixing volume for local playback. This method helps troubleshoot audio volume related issues.

Note
Call this method when you are in a channel.
Returns
  • ≥ 0: The audio mixing volume, if this method call succeeds. The value range is [0,100].
  • < 0: Failure.

◆ getAudioMixingPublishVolume()

abstract int io.agora.rtc2.RtcEngine.getAudioMixingPublishVolume ( )
abstract

Retrieves the audio mixing volume for publishing. This method helps troubleshoot audio volume related issues.

Note
Call this method when you are in a channel.
Returns
  • ≥ 0: The audio mixing volume for publishing, if this method call succeeds. The value range is [0,100].
  • < 0: Failure.

◆ getAudioMixingDuration()

abstract int io.agora.rtc2.RtcEngine.getAudioMixingDuration ( )
abstract

Gets the duration (ms) of the music file.

Call this method when you are in a channel.

Returns
  • Returns the audio mixing duration, if the method call is successful.
  • < 0: Failure.

◆ getAudioMixingCurrentPosition()

abstract int io.agora.rtc2.RtcEngine.getAudioMixingCurrentPosition ( )
abstract

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

Call this method when you are in a channel.

Returns
  • Returns the current playback position of the audio mixing, if the method call is successful.
  • < 0: Failure.

◆ setAudioMixingPosition()

abstract int io.agora.rtc2.RtcEngine.setAudioMixingPosition ( int  pos)
abstract

Sets the playback position (ms) of the music file to a different starting position (the default plays from the beginning).

Parameters
posThe playback starting position (ms) of the audio mixing file.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getAudioEffectManager()

abstract IAudioEffectManager io.agora.rtc2.RtcEngine.getAudioEffectManager ( )
abstract

Gets the IAudioEffectManager object associated with the current RTC engine.

Returns
IAudioEffectManager

◆ startAudioRecording() [1/2]

abstract int io.agora.rtc2.RtcEngine.startAudioRecording ( String  filePath,
int  quality 
)
abstract

Starts an audio recording.

The SDK allows recording during a call, which supports either one of the following formats:

  • .wav: Large file size with high sound fidelity
  • .aac: Small file size with low sound fidelity

Ensure that the directory to save the recording file exists and is writable. This method is usually called after the token, java.lang.String channelName, java.lang.String optionalInfo, int optionalUid) joinChannel method. The recording automatically stops when the leaveChannel method is called.

Parameters
filePathFull file path of the recording file. The string of the file name is in UTF-8 code.
qualityAudio recording quality:
Returns
  • 0: Success.
  • <0: Failure.

◆ startAudioRecording() [2/2]

abstract int io.agora.rtc2.RtcEngine.startAudioRecording ( AudioFileRecordingConfig  config)
abstract

Starts an audio recording.

The SDK allows recording during a call, which supports either one of the following formats:

  • .wav: Large file size with high sound fidelity
  • .aac: Small file size with low sound fidelity

Ensure that the directory to save the recording file exists and is writable. This method is usually called after the token, java.lang.String channelName, java.lang.String optionalInfo, int optionalUid) joinChannel method. The recording automatically stops when the leaveChannel method is called.

Parameters
configaudio file recording config
Returns
  • 0: Success.
  • <0: Failure.

◆ stopAudioRecording()

abstract int io.agora.rtc2.RtcEngine.stopAudioRecording ( )
abstract

Stops the audio recording on the client.

Note: Call this method before calling leaveChannel, otherwise the recording automatically stops when the leaveChannel method is called.

Returns
  • 0: Success.
  • <0: Failure.

◆ startEchoTest() [1/2]

abstract int io.agora.rtc2.RtcEngine.startEchoTest ( )
abstract
Deprecated:
Now use startEchoTest(int)

Starts an audio call test to determine whether the audio devices (for example, headset and speaker) and the network connection are working properly.

In the test, the user first speaks, and the recording is played back in 10 seconds. If the user can hear the recording in 10 seconds, it indicates that the audio devices and network connection work properly.

Note: After calling the startEchoTest method, call stopEchoTest to end the test; otherwise the application cannot run the next echo test, nor can it call the token, java.lang.String channelName, java.lang.String optionalInfo, int optionalUid) joinChannel method to start a new call.

Returns
  • 0: Success.
  • <0: Failure.

◆ startEchoTest() [2/2]

abstract int io.agora.rtc2.RtcEngine.startEchoTest ( int  intervalInSeconds)
abstract

Starts an audio call test.

Since
v2.4.0.

In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly.

Note

◆ stopEchoTest()

abstract int io.agora.rtc2.RtcEngine.stopEchoTest ( )
abstract

Stops an audio call test.

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

◆ startLastmileProbeTest()

abstract int io.agora.rtc2.RtcEngine.startLastmileProbeTest ( LastmileProbeConfig  config)
abstract

◆ stopLastmileProbeTest()

abstract int io.agora.rtc2.RtcEngine.stopLastmileProbeTest ( )
abstract

Stops the last-mile network probe test.

Returns
  • 0: Success.
  • < 0: Failure.

◆ setExternalAudioSink()

abstract int io.agora.rtc2.RtcEngine.setExternalAudioSink ( int  sampleRate,
int  channels 
)
abstract

Sets the external audio sink.

This method applies to scenarios where you want to use external audio data for playback. After calling the RtcEngine#create(RtcEngineConfig) method and pass value of false in the enableAudioDevice member in the RtcEngineConfig#mEnableAudioDevice, you can call the pullPlaybackAudioFrame method to pull the remote audio data, process it, and play it with the audio effects that you want.

Ensure that you call this method before joining a channel.

Note
Once you call the RtcEngine#create(RtcEngineConfig) method and pass value of false in the enableAudioDevice member in the RtcEngineConfig#mEnableAudioDevice, the app will not retrieve any audio data from the {int, int, int, int, ByteBuffer, long, int)} onPlaybackFrame} callback. sampleRate The sample rate (Hz) of the external audio sink. You can set this parameter as 16000, 32000, 44100, or 48000. channels The number of audio channels of the external audio sink:1: Mono.2: Stereo. 0: Success.< 0: Failure.

◆ pullPlaybackAudioFrame() [1/2]

abstract int io.agora.rtc2.RtcEngine.pullPlaybackAudioFrame ( byte[]  data,
int  lengthInByte 
)
abstract

Pulls the remote audio frame.

Before calling this method, call the RtcEngine#create(RtcEngineConfig) method and pass value of false in the enableAudioDevice member in the {}, and call the RtcEngine#setExternalAudioSink(int, int)} method to enable and set the external audio sink. Ensure that you call this method after joining a channel. After a successful method call, the app pulls the decoded and mixed audio data for playback. Once you call the pullPlaybackAudioFrame method successfully, the app will not retrieve any audio data from the io.agora.rtc2.IAudioFrameObserver#onPlaybackAudioFrame(int, int, int, int, int, ByteBuffer, long, int)} onPlaybackFrame} callback.The difference between the onPlaybackFrame callback and the pullPlaybackAudioFrame method is as follows:onPlaybackFrame: 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: 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. data The audio data that you want to pull. The data format is in byte[]. lengthInByte The data length (byte) of the external 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 RtcEngine#setExternalAudioSink setExternalAudioSink}. Agora recommends setting the audio duration no shorter than 10 ms. The formula for lengthInByte is: lengthInByte = sampleRate/1000 × 2 × channels × audio duration (ms).

Returns
  • 0: Success.
  • < 0: Failure.

◆ pullPlaybackAudioFrame() [2/2]

abstract int io.agora.rtc2.RtcEngine.pullPlaybackAudioFrame ( ByteBuffer  data,
int  lengthInByte 
)
abstract

Pulls the remote audio frame.

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

Ensure that you call this method after joining a channel.

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

Note
  • Once you call the pullPlaybackAudioFrame method successfully, the app will not retrieve any audio data from the int, int, int, int, ByteBuffer, long, int) onPlaybackFrame} callback.
  • The difference between the onPlaybackFrame callback and the pullPlaybackAudioFrame method is as follows:
    • onPlaybackFrame: 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: 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
dataThe audio data that you want to pull. The data format is in ByteBuffer.
lengthInByteThe data length (byte) of the external 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. Agora recommends setting the audio duration no shorter than 10 ms. The formula for lengthInByte is:
lengthInByte = sampleRate/1000 × 2 × channels × audio duration (ms).
Returns
  • 0: Success.
  • < 0: Failure.

◆ setExternalAudioSource() [1/2]

abstract int io.agora.rtc2.RtcEngine.setExternalAudioSource ( boolean  enabled,
int  sampleRate,
int  channels 
)
abstract

Sets the external audio source.

Note
Ensure that you call this method before calling joinChannel.
Parameters
enabledDetermines whether to enable the external audio source:
  • true: Enable the external audio source.
  • false: (default) Disable the external audio source.
sampleRateThe Sample rate (Hz) of the external audio source, which can set be as 8000, 16000, 32000, 44100, or 48000.
channelsThe number of channels of the external audio source, which can be set as 1 or 2:
  • 1: Mono.
  • 2: Stereo.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setExternalAudioSource() [2/2]

abstract int io.agora.rtc2.RtcEngine.setExternalAudioSource ( boolean  enabled,
int  sampleRate,
int  channels,
int  sourceNumber,
boolean  localPlayback,
boolean  publish 
)
abstract

Sets the external audio source.

Note
Ensure that you call this method before joinChannel.
Parameters
enabledDetermines whether to enable the external audio source:
  • true: Enable the external audio source.
  • false: (default) Disable the external audio source.
sampleRateThe Sample rate (Hz) of the external audio source, which can set be as 8000, 16000, 32000, 44100, or 48000.
channelsThe number of channels of the external audio source, which can be set as 1 or 2:
  • 1: Mono.
  • 2: Stereo.
sourceNumberThe number of audio source per channel.
  • 1: Mono.
  • 2: Stereo.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pushExternalAudioFrame() [1/2]

abstract int io.agora.rtc2.RtcEngine.pushExternalAudioFrame ( byte[]  data,
long  timestamp 
)
abstract

Pushes the external audio data to the app.

Parameters
dataThe audio buffer data.
timestampThe timestamp of the audio data.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pushExternalAudioFrame() [2/2]

abstract int io.agora.rtc2.RtcEngine.pushExternalAudioFrame ( ByteBuffer  data,
long  timestamp,
int  sourceId 
)
abstract

Pushes the external audio data to the app.

Parameters
dataThe audio buffer data.
timestampThe timestamp of the audio data.
sourceIdThe audio track ID.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setExternalVideoSource()

abstract int io.agora.rtc2.RtcEngine.setExternalVideoSource ( boolean  enable,
boolean  useTexture,
boolean  encodedFrame 
)
abstract

Sets the external video source.

Once the external video source is enabled, the SDK prepares to accept the external video frame.

Parameters
enableDetermines whether to enable the external video source.
  • true: Enable the external video source. Once set, the SDK creates the external source and prepares video data from pushExternalVideoFrame or pushExternalEncodedVideoImage.
  • false: Disable the external video source.
useTextureDetermines whether to use textured video data.
  • true: Use texture, which is not supported now.
  • False: Do not use texture.
encodedFrameDetermines whether the external video source is encoded.
  • true: The external video source is encoded.
  • false: The external video source is not encoded.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pushExternalVideoFrame() [1/2]

abstract boolean io.agora.rtc2.RtcEngine.pushExternalVideoFrame ( AgoraVideoFrame  frame)
abstract

◆ pushExternalVideoFrame() [2/2]

abstract boolean io.agora.rtc2.RtcEngine.pushExternalVideoFrame ( VideoFrame  frame)
abstract

◆ pushExternalEncodedVideoFrame()

abstract int io.agora.rtc2.RtcEngine.pushExternalEncodedVideoFrame ( ByteBuffer  data,
EncodedVideoFrameInfo  frameInfo 
)
abstract

Pushes the encoded external video frame to Agora SDK.

Note
Ensure that you call setExternalVideoSource before calling this method.
Parameters
dataThe encoded external video data, which must be the direct buffer.
frameInfoThe encoded external video frame info: {EncodedVideoFrameInfo}. 0: Success, which means that the encoded external video frame is pushed successfully.< 0: Failure, which means that the encoded external video frame fails to be pushed.

◆ isTextureEncodeSupported()

abstract boolean io.agora.rtc2.RtcEngine.isTextureEncodeSupported ( )
abstract

Checks whether texture encoding is supported.

Returns
True/False.

◆ registerAudioFrameObserver()

abstract int io.agora.rtc2.RtcEngine.registerAudioFrameObserver ( IAudioFrameObserver  observer)
abstract

Registers an audio frame observer object.

Note
Call this method before calling joinChannel.
Parameters
observerThe IAudioFrameObserver interface, null means unregistering observer instead.
Returns
  • 0: Success.
  • < 0: Failure.

◆ registerAudioEncodedFrameObserver()

abstract int io.agora.rtc2.RtcEngine.registerAudioEncodedFrameObserver ( AudioEncodedFrameObserverConfig  config,
IAudioEncodedFrameObserver  observer 
)
abstract

Registers an encoded audio frame observer object.

Note
Ensure that you call this method before joining the channel.
Parameters
observerThe IAudioEncodedFrameObserver interface, null means unregistering observer instead.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRecordingAudioFrameParameters()

abstract int io.agora.rtc2.RtcEngine.setRecordingAudioFrameParameters ( int  sampleRate,
int  channel,
int  mode,
int  samplesPerCall 
)
abstract

Sets the audio recording format for the onRecordAudioFrame callback.

Parameters
sampleRateSets the sample rate (samplesPerSec) returned in the onRecordAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channelSets the number of audio channels (channels) returned in the onRecordAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
modeSets the use mode of the onRecordAudioFrame callback:
  • 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_WRITE_ONLY(1): Write-only mode: Users replace the audio data with their own data and pass the data to the SDK for encoding. For example, when users acquire the data.
  • 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 sound-effect processing module and perform some voice pre-processing, such as a voice change.
samplesPerCallSets the number of samples the onRecordAudioFrame callback returns. In RTMP streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.
Note
The SDK calculates the sample interval according to the value of the sampleRate, channel, and samplesPerCall parameters you set in this method. Sample interval (s) = samplePerCall/(sampleRate × channel). Ensure that the value of sample interval ≥ 0.01. The SDK triggers the onRecordAudioFrame callback according to the sample interval.

◆ setPlaybackAudioFrameParameters()

abstract int io.agora.rtc2.RtcEngine.setPlaybackAudioFrameParameters ( int  sampleRate,
int  channel,
int  mode,
int  samplesPerCall 
)
abstract

Sets the audio recording format for the onPlaybackAudioFrame callback.

Parameters
sampleRateSets the sample rate (samplesPerSec) returned in the onPlaybackAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channelSets the number of audio channels (channels) returned in the onPlaybackAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
modeSets the use mode of the onPlaybackAudioFrame callback:
  • 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_WRITE_ONLY(1): Write-only mode: Users replace the audio data with their own data and pass the data to the SDK for encoding. For example, when users acquire the data.
  • 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 sound-effect processing module and perform some voice pre-processing, such as a voice change.
samplesPerCallSets the number of samples the onPlaybackAudioFrame callback returns. In RTMP streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.
Note
The SDK calculates the sample interval according to the value of the sampleRate, channel, and samplesPerCall parameters you set in this method. Sample interval (s) = samplePerCall/(sampleRate × channel). Ensure that the value of sample interval ≥ 0.01. The SDK triggers the onPlaybackAudioFrame callback according to the sample interval.

◆ setMixedAudioFrameParameters()

abstract int io.agora.rtc2.RtcEngine.setMixedAudioFrameParameters ( int  sampleRate,
int  channel,
int  samplesPerCall 
)
abstract

Sets the mixed audio format for the onMixedAudioFrame callback.

Parameters
sampleRateSets the sample rate (samplesPerSec) returned in the onMixedAudioFrame callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channelSets the number of audio channels (channels) returned in the onPlaybackAudioFrame callback:
  • 1: Mono.
  • 2: Stereo.
samplesPerCallSets the number of samples the onMixedAudioFrame callback returns. In RTMP streaming scenarios, set it as 1024.
Returns
  • 0: Success.
  • < 0: Failure.
Note
The SDK calculates the sample interval according to the value of the sampleRate and samplesPerCall parameters you set in this method. Sample interval (s) = samplePerCall/(sampleRate × channel). Ensure that the value of sample interval ≥ 0.01. The SDK triggers the onMixedAudioFrame callback according to the sample interval.

◆ addVideoWatermark() [1/2]

abstract int io.agora.rtc2.RtcEngine.addVideoWatermark ( AgoraImage  watermark)
abstract

Adds a watermark image to the local video.

Deprecated:
From v2.9.1. We recommend using the WatermarkOptions) addVideoWatermark2 method instead.

This method adds a PNG watermark image to the local video stream for the sampling device, channel audience, or CDN live audience to see and capture. To add the PNG file to a CDN live publishing stream, see the setLiveTranscoding method.

Parameters
watermarkWatermark image to be added to the local video stream. See {Agora Image}. The URL descriptions are different for the local video and CDN live streams:
  • In a local video stream, url in Agora Image refers to the absolute path of the added watermark image file in the local video stream.
  • In a CDN live stream, url in Agora Image refers to the 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 is 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. If you set orientationMode as Adaptive in the {setVideoEncoderConfiguration} method, the watermark image rotates with the video frame around the upper left corner of the watermark image.
Returns
  • 0: Success.
  • < 0: Failure.

◆ addVideoWatermark() [2/2]

abstract int io.agora.rtc2.RtcEngine.addVideoWatermark ( String  watermarkUrl,
WatermarkOptions  options 
)
abstract

Adds a watermark image to the local video.

Since
v2.9.1 to replace addVideoWatermark1.

This method adds a PNG watermark image to the local video stream in a live streaming. Once the watermark image is added, all the audience in the channel (CDN audience included), and the sampling 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 position depends on the settings in the {setVideoEncoderConfiguration} method:If the orientation mode of the encoding video is ORIENTATION_MODE_FIXED_LANDSCAPE, or the landscape mode in ORIENTATION_MODE_ADAPTIVE, the watermark uses the landscape orientation.If the orientation mode of the encoding video is ORIENTATION_MODE_FIXED_PORTRAIT, or the portrait mode in ORIENTATION_MODE_ADAPTIVE, the watermark uses the portrait orientation.When setting the watermark position, the region must be less than the dimensions set in the setVideoEncoderConfiguration method. Otherwise, the watermark image will be cropped. Ensure that you have called the RtcEngine#enableVideo enableVideo} method to enable the video module before calling this method.If you only want to add a watermark image to the local video for the audience in the CDN live streaming channel to see and capture, you can call this method or the { RtcEngine#setLiveTranscoding 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 the PNG image differ from your settings in this method, the image will be cropped or zoomed to conform to your settings.If you have enabled the local video preview by calling the RtcEngine#startPreview startPreview} method, you can use the visibleInPreview member in the WatermarkOptions class to set whether or not the watermark is visible in 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. watermarkUrl The local file path of the watermark image to be added. This method supports adding a watermark image from either the local file path or the assets file path. If you use the assets file path, you need to start with /assets/ when filling in this parameter. options The options of the watermark image to be added. See { io.agora.rtc.video.WatermarkOptions Watermark Options}. 0: Success.< 0: Failure.

◆ clearVideoWatermarks()

abstract int io.agora.rtc2.RtcEngine.clearVideoWatermarks ( )
abstract

Removes the watermark image from the video stream added by {addVideoWatermark}. 0: Success.< 0: Failure.

◆ setRemoteUserPriority()

abstract int io.agora.rtc2.RtcEngine.setRemoteUserPriority ( int  uid,
int  userPriority 
)
abstract

Sets the priority of a remote user's media stream.

Since
v2.4.0.

Use this method with the setRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality.

Note
The SDK supports setting userPriority as high for one user only.
Parameters
uidThe ID of the remote user.
userPriorityThe priority of the remote user:
Returns
  • 0: Success.
  • <0: Failure.

◆ setLocalPublishFallbackOption()

abstract int io.agora.rtc2.RtcEngine.setLocalPublishFallbackOption ( int  option)
abstract

◆ setRemoteSubscribeFallbackOption()

abstract int io.agora.rtc2.RtcEngine.setRemoteSubscribeFallbackOption ( int  option)
abstract

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

If option is set as STREAM_FALLBACK_OPTION_AUDIO_ONLY(2), the SDK automatically switches the video from a high-stream to a low-stream, or disables the video when the downlink network condition 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 remotely subscribed video stream falls back to audio only, or the audio-only stream switches back to the video, the SDK triggers the {onRemoteSubscribeFallbackToAudioOnly} callback. Ensure that you call this method before joining a channel. option The fallback option for the remotely subscribed video stream: io.agora.rtc.Constants#STREAM_FALLBACK_OPTION_DISABLED STREAM_FALLBACK_OPTION_DISABLED(0)}: No fallback behavior for the remotely subscribed video stream when the downlink network condition is poor. The quality of the video stream is not guaranteed. io.agora.rtc.Constants#STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW STREAM_FALLBACK_OPTION_VIDEO_STREAM_LOW(1)}: (Default) The remotely subscribed video stream falls back to the low-stream video when the downlink network condition worsens. This option works only for this method and not for the { io.agora.rtc.RtcEngine#setLocalPublishFallbackOption(int) setLocalPublishFallbackOption} method. io.agora.rtc.Constants#STREAM_FALLBACK_OPTION_AUDIO_ONLY STREAM_FALLBACK_OPTION_AUDIO_ONLY(2)}: Under poor downlink network conditions, the remotely subscribed video stream first falls back to the low-stream video; and then to an audio-only stream if the network condition worsens. 0: Success.< 0: Failure.

◆ enableDualStreamMode() [1/3]

abstract int io.agora.rtc2.RtcEngine.enableDualStreamMode ( boolean  enabled)
abstract

Enables or disables the dual video stream mode.

If dual-stream mode is enabled, the subscriber can choose to receive the high-stream (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) video using setRemoteVideoStreamType.

Parameters
enabled
  • true: Enable the dual-stream mode.
  • false: (default) Disable the dual-stream mode.

◆ enableDualStreamMode() [2/3]

abstract int io.agora.rtc2.RtcEngine.enableDualStreamMode ( Constants.VideoSourceType  sourceType,
boolean  enabled 
)
abstract

Enables or disables the dual video stream mode.

If dual-stream mode is enabled, the subscriber can choose to receive the high-stream (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) video using setRemoteVideoStreamType.

Parameters
sourceType
  • The video source type.
enabled
  • true: Enable the dual-stream mode.
  • false: (default) Disable the dual-stream mode.

◆ enableDualStreamMode() [3/3]

abstract int io.agora.rtc2.RtcEngine.enableDualStreamMode ( Constants.VideoSourceType  sourceType,
boolean  enabled,
SimulcastStreamConfig  streamConfig 
)
abstract

Enables or disables the dual video stream mode.

If dual-stream mode is enabled, the subscriber can choose to receive the high-stream (high-resolution high-bitrate video stream) or low-stream (low-resolution low-bitrate video stream) video using setRemoteVideoStreamType.

Parameters
sourceType
  • The video source type.
enabled
  • true: Enable the dual-stream mode.
  • false: (default) Disable the dual-stream mode.
streamConfig
  • The minor stream config

◆ setRemoteVideoStreamType()

abstract int io.agora.rtc2.RtcEngine.setRemoteVideoStreamType ( int  uid,
int  streamType 
)
abstract

Sets the remote video stream type.

If the remote user has enabled the dual-stream mode, by default the SDK receives the high-stream video by Call this method to switch to the low-stream video.

Note
This method applies to scenarios where the remote user has enabled the dual-stream mode using enableDualStreamMode(true) before joining the channel.
Parameters
uidID of the remote user sending the video stream.
streamTypeSets the video stream type:
  • 0: High-stream video.
  • 1: Low-stream video.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setRemoteDefaultVideoStreamType()

abstract int io.agora.rtc2.RtcEngine.setRemoteDefaultVideoStreamType ( int  streamType)
abstract

Sets the default stream type of the remote video if the remote user has enabled dual-stream.

Parameters
streamTypeSets the default video stream type:
  • 0: High-stream video.
  • 1: Low-stream video.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setEncryptionSecret()

abstract int io.agora.rtc2.RtcEngine.setEncryptionSecret ( String  secret)
abstract

Specifies an encryption password to enable built-in encryption before joining a channel.

Deprecated:
This method is deprecated.

All users in a channel must set the same encryption password. The encryption password is automatically cleared once a user has left the channel. If the encryption password is not specified or set to empty, the encryption function will be disabled.

Note: Do not use this function together with CDN.

Parameters
secretEncryption Password
Returns
  • 0: Success.
  • <0: Failure.

◆ setEncryptionMode()

abstract int io.agora.rtc2.RtcEngine.setEncryptionMode ( String  encryptionMode)
abstract

Sets the built-in encryption mode.

Deprecated:
This method is deprecated.

The Agora Native SDK supports built-in encryption. Call this API to set the encryption mode.

All users in the same channel must use the same encryption mode and password. Refer to information related to the encryption algorithm on the differences between encryption modes.

Call setEncryptionSecret to enable the built-in encryption function before calling this API.

Note: Do not use this function together with CDN.

Parameters
encryptionModeEncryption mode:
  • "sm4-128-ecb": 128-bit SM4 encryption, ECB mode
Returns
  • 0: Success.
  • <0: Failure.

◆ enableEncryption()

abstract int io.agora.rtc2.RtcEngine.enableEncryption ( boolean  enabled,
EncryptionConfig  config 
)
abstract

Enables/Disables the built-in encryption.

In scenarios requiring high security, Agora recommends calling enableEncryption 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. Once all users leave the channel, the encryption key of this channel is automatically cleared.

Note
  • If you enable the built-in encryption, you cannot use the RTMP streaming function.
Parameters
enabledWhether to enable the built-in encryption.
  • true: Enable the built-in encryption.
  • false: Disable the built-in encryption.
configConfigurations of built-in encryption schemas. See {EncryptionConfig}. 0: Success.< 0: Failure.-2(ERR_INVALID_ARGUMENT): An invalid parameter is used. Set the parameter with a valid value.-7(ERR_NOT_INITIALIZED: The SDK is not initialized. Initialize the IRtcEngine instance before calling this method.-4(ERR_NOT_SUPPORTED): The encryption mode is incorrect or the SDK fails to load the external encryption library. Check the enumeration or reload the external encryption library.

◆ addInjectStreamUrl()

abstract int io.agora.rtc2.RtcEngine.addInjectStreamUrl ( String  url,
LiveInjectStreamConfig  config 
)
abstract

Adds a URL address of the added stream into the live broadcast channel.

If successful, you can find the stream in the channels of argus and the uid of the stream is 666.

Parameters
urlURL address to be added into the ongoing live broadcast. You can use the RTMP, HLS, and FLV live streaming protocols.
configLiveInjectStreamConfig
Returns
  • 0: Success.
  • <0: Failure.

◆ removeInjectStreamUrl()

abstract int io.agora.rtc2.RtcEngine.removeInjectStreamUrl ( String  url)
abstract

Removes the URL from the live broadcast.

Parameters
urlURL address of the added stream to be removed.

◆ addPublishStreamUrl()

abstract int io.agora.rtc2.RtcEngine.addPublishStreamUrl ( String  url,
boolean  transcodingEnabled 
)
abstract

Adds the URL to which the host publishes the stream.

Used in CDN live only.

Parameters
urlURL to which the host publishes the stream.
transcodingEnabledWhether transcoding is enabled. True/False.

◆ removePublishStreamUrl()

abstract int io.agora.rtc2.RtcEngine.removePublishStreamUrl ( String  url)
abstract

Removes the URL to which the host publishes the stream.

Used in CDN live only.

Note:

  • This method only removes one URL each time it is called.
  • Do not add special characters such as Chinese to the URL.
Parameters
urlURL to which the host publishes the stream.
Returns
  • 0: Success.
  • <0: Failure.

◆ setLiveTranscoding()

abstract int io.agora.rtc2.RtcEngine.setLiveTranscoding ( LiveTranscoding  transcoding)
abstract

Sets the video layout and audio for CDN Live.

Used in CDN live only.

Parameters
transcodingLiveTranscoding

◆ createDataStream() [1/2]

abstract int io.agora.rtc2.RtcEngine.createDataStream ( boolean  reliable,
boolean  ordered 
)
abstract

Creates a data stream.

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

Note
  • Ensure that you set the same value for reliable and ordered.
  • Each user can only create a maximum of 5 data streams during an RtcEngine lifecycle.
  • The data channel allows a data delay of up to 5 seconds. If the receiver does not receive the data stream within 5 seconds, the data channel reports an error.
Parameters
reliableSets whether the recipients are guaranteed to receive the data stream from the sender within five seconds:
  • true: The recipients receive the data stream from the sender within five seconds. If the recipient does not receive the data stream within five seconds, an error is reported to the application.
  • 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.
orderedSets whether the recipients receive the data stream in the sent order:
  • true: The recipients receive the data stream in the sent order.
  • false: The recipients do not receive the data stream in the sent order.
Returns
  • Returns the stream ID, if the method call is successful.
  • <0: Failure.

◆ createDataStream() [2/2]

abstract int io.agora.rtc2.RtcEngine.createDataStream ( DataStreamConfig  config)
abstract

Creates a data stream.

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

Parameters
configThe config of data stream.
Returns

◆ sendStreamMessage()

abstract int io.agora.rtc2.RtcEngine.sendStreamMessage ( int  streamId,
byte[]  message 
)
abstract

◆ setVideoQualityParameters()

abstract int io.agora.rtc2.RtcEngine.setVideoQualityParameters ( boolean  preferFrameRateOverImageQuality)
abstract

Sets the video quality preferences.

Parameters
preferFrameRateOverImageQualityThe video preference to be set:
  • True: Frame rate over image quality
  • False: Image quality over frame rate (default)
Returns
  • 0: Success.
  • <0: Failure.

◆ setLocalVideoMirrorMode()

abstract int io.agora.rtc2.RtcEngine.setLocalVideoMirrorMode ( int  mode)
abstract

Sets the local video mirror mode.

Use this method before calling the startPreview method, or the mirror mode does not take effect until you call the startPreview method again.

Parameters
mirrorModeSets the local video mirror mode:
  • VIDEO_MIRROR_MODE_AUTO(0): (Default) The mirror mode determined by the SDK. If you use the front camera, the SDK enables the mirror mode; if you use the rear camera, the SDK disables the mirror mode.
  • VIDEO_MIRROR_MODE_ENABLED(1): Enable the mirror mode.
  • VIDEO_MIRROR_MODE_DISABLED(2): Disable the mirror mode.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getRecommendedEncoderType()

static int io.agora.rtc2.RtcEngine.getRecommendedEncoderType ( )
static

Gets the recommended encoder type.

Deprecated:
This method is deprecated.
Returns
The encoder type:

◆ switchCamera()

abstract int io.agora.rtc2.RtcEngine.switchCamera ( )
abstract

Switches between front and rear cameras.

Returns
  • 0: Success.
  • < 0: Failure.

◆ isCameraZoomSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraZoomSupported ( )
abstract

Checks whether the camera zoom function is supported.

Returns
  • true: The camera zoom function is supported.
  • false: The camera zoom function is not supported.

◆ isCameraTorchSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraTorchSupported ( )
abstract

Checks whether the camera flash function is supported.

Returns
  • true: The camera flash function is supported.
  • false: The camera flash function is not supported.

◆ isCameraFocusSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraFocusSupported ( )
abstract

Checks whether the camera manual focus function is supported.

Returns
  • true: The camera manual focus function is supported.
  • false: The camera manual focus function is not supported.

◆ isCameraExposurePositionSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraExposurePositionSupported ( )
abstract

Checks whether the camera exposure function is supported.

Ensure that you call this method after the camera starts, for example, by calling startPreview or joinChannel.

Since
v2.3.2.
Returns
  • true: The device supports the camera exposure function.
  • false: The device does not support the camera exposure function.

◆ isCameraAutoFocusFaceModeSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraAutoFocusFaceModeSupported ( )
abstract

Checks whether the camera auto focus function is supported.

Returns
  • true: The camera auto focus function is supported.
  • false: The camera auto focus function is not supported.

◆ isCameraFaceDetectSupported()

abstract boolean io.agora.rtc2.RtcEngine.isCameraFaceDetectSupported ( )
abstract

Checks whether the camera face detect function is supported.

Returns
  • true: The camera face detect is supported.
  • false: The camera face detect is not supported.

◆ setCameraZoomFactor()

abstract int io.agora.rtc2.RtcEngine.setCameraZoomFactor ( float  factor)
abstract

Sets the camera zoom ratio.

Parameters
factorThe camera zoom factor. It ranges from 1.0 to the maximum zoom supported by the camera.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getCameraMaxZoomFactor()

abstract float io.agora.rtc2.RtcEngine.getCameraMaxZoomFactor ( )
abstract

Gets the maximum zoom ratio supported by the camera.

Returns
The maximum zoom ratio supported by the camera.

◆ setCameraFocusPositionInPreview()

abstract int io.agora.rtc2.RtcEngine.setCameraFocusPositionInPreview ( float  positionX,
float  positionY 
)
abstract

Sets the manual focus position.

Parameters
positionXThe horizontal coordinate of the touch point in the view.
positionYThe vertical coordinate of the touch point in the view.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setCameraExposurePosition()

abstract int io.agora.rtc2.RtcEngine.setCameraExposurePosition ( float  positionXinView,
float  positionYinView 
)
abstract

Sets the camera exposure position.

Ensure that you call this method after the camera starts, for example, by calling startPreview or joinChannel.

A successful setCameraExposurePosition method call triggers the onCameraExposureAreaChanged callback on the local client.

Since
v2.3.2.
Parameters
positionXinViewThe horizontal coordinate of the touch point in the view.
positionYinViewThe vertical coordinate of the touch point in the view.
Returns
  • 0: Success.
  • < 0: Failure.

◆ enableFaceDetection()

abstract int io.agora.rtc2.RtcEngine.enableFaceDetection ( boolean  enabled)
abstract

Enables the camera face detect.

Parameters
enabledDetermines whether to enable the camera face detect.
  • true: Enable the face detect.
  • false: Do not enable the face detect.

◆ setCameraTorchOn()

abstract int io.agora.rtc2.RtcEngine.setCameraTorchOn ( boolean  isOn)
abstract

Enables the camera flash.

Parameters
isOnDetermines whether to enable the camera flash.
  • true: Enable the flash.
  • false: Do not enable the flash.

◆ setCameraAutoFocusFaceModeEnabled()

abstract int io.agora.rtc2.RtcEngine.setCameraAutoFocusFaceModeEnabled ( boolean  enabled)
abstract

Enables the camera auto focus face function.

Parameters
enabledDetermines whether to enable the camera auto focus face mode.
  • true: Enable the auto focus face function.
  • false: Do not enable the auto focus face function.

◆ getCallId()

abstract String io.agora.rtc2.RtcEngine.getCallId ( )
abstract

Gets the current call ID.

When a user joins a channel on a client, a callId is generated to identify the call.

After a call ends, you can call rate or complain to gather feedback from the customer. These methods require a callId parameter. To use these feedback methods, call the this method first to retrieve the callId during the call, and then pass the value as an argument in the rate or complain method after the call ends.

Returns
  • The call ID if the method call is successful.
  • < 0: Failure.

◆ rate()

abstract int io.agora.rtc2.RtcEngine.rate ( String  callId,
int  rating,
String  description 
)
abstract

Allows a user to rate the call.

It is usually called after the call ends.

Parameters
callIdThe call ID retrieved from the getCallId method.
ratingThe rating of the call between 1 (the lowest score) to 5 (the highest score).
description(Optional) The description of the rating. The string length must be less than 800 bytes.
Returns
  • 0: Success.
  • < 0: Failure.

◆ complain()

abstract int io.agora.rtc2.RtcEngine.complain ( String  callId,
String  description 
)
abstract

Allows a user to complain about the call quality.

This method is usually called after the call ends.

Parameters
callIdThe call ID retrieved from the getCallId method.
description(Optional) The description of the complaint. The string length must be less than 800 bytes.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getSdkVersion()

static String io.agora.rtc2.RtcEngine.getSdkVersion ( )
static

Gets the SDK version.

Returns
The version of the current SDK in the string format.

◆ getMediaEngineVersion()

static String io.agora.rtc2.RtcEngine.getMediaEngineVersion ( )
static

Returns the media engine version.

Returns
The string of the version number in char format.

◆ setLogFile()

abstract int io.agora.rtc2.RtcEngine.setLogFile ( String  filePath)
abstract

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 create, or the output log may not be complete.
Parameters
filePathFile path of the log file. The string of the log file is in UTF-8.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLogFilter()

abstract int io.agora.rtc2.RtcEngine.setLogFilter ( int  filter)
abstract

Sets the output log filter level of the SDK.

You can use one or a combination of the filters. The log level follows the sequence of OFF, CRITICAL, ERROR, WARNING, INFO, and DEBUG. Choose a level and you will see logs preceding that level. For example, if you set the log level to WARNING, you see the logs within levels CRITICAL, ERROR, and WARNING.

Parameters
filterSets the log filter level:
  • LOG_FILTER_DEBUG(0x80f): Output all API logs. Set your log filter as DEBUG if you want to get the most complete log file.
  • LOG_FILTER_INFO(0x0f): Output logs of the CRITICAL, ERROR, WARNING, and INFO level. We recommend setting your log filter as this level.
  • LOG_FILTER_WARNING(0x0e): Output logs of the CRITICAL, ERROR, and WARNING level.
  • LOG_FILTER_ERROR(0x0c): Output logs of the CRITICAL and ERROR level.
  • LOG_FILTER_CRITICAL(0x08): Output logs of the CRITICAL level.
  • LOG_FILTER_OFF(0): Do not output any log.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLogLevel()

abstract int io.agora.rtc2.RtcEngine.setLogLevel ( int  level)
abstract

Sets the output log level of the SDK.

You can use one of the level defined in LogLevel.

Parameters
levelSets the log level: LogLevel.
Returns
  • 0: Success.
  • < 0: Failure.

◆ setLogFileSize()

abstract int io.agora.rtc2.RtcEngine.setLogFileSize ( long  fileSizeInKBytes)
abstract

Sets the log file size (KB).

The SDK has two log files, each with a default size of 512 KB. If you set fileSizeInBytes as 1024 KB, the SDK outputs log files with a total maximum size of 2 MB. If the total size of the log files exceed the set value, the new output log files overwrite the old output log files.

Parameters
fileSizeInKBytesThe SDK log file size (KB).
Returns
  • 0: Success.
  • < 0: Failure.

◆ getNativeHandle()

abstract long io.agora.rtc2.RtcEngine.getNativeHandle ( )
abstract

Returns the native handler of the SDK Engine.

This interface is used to get native the C++ handler of the SDK engine that can be used in special scenarios, such as register the audio and video frame observer.

Returns

◆ getNativeMediaPlayer()

abstract long io.agora.rtc2.RtcEngine.getNativeMediaPlayer ( int  sourceId)
abstract

Returns the native handler of the mediaplayer.

◆ addHandler()

void io.agora.rtc2.RtcEngine.addHandler ( IRtcEngineEventHandler  handler)

Adds the IRtcEngineEventHandler.

Parameters
handlerThe IRtcEngineEventHandler instance.

◆ removeHandler()

void io.agora.rtc2.RtcEngine.removeHandler ( IRtcEngineEventHandler  handler)

Removes the specified IRtcEngineEventHandler object.

For callback events that you only want to listen for once, call this method to remove subsequent IRtcEngineEventHandler objects after you have received them. This interface is used to remove the specific IRtcEngineEventHandler interface class instance.

Parameters
handlerThe IRtcEngineEventHandler object.

◆ enableHighPerfWifiMode()

abstract boolean io.agora.rtc2.RtcEngine.enableHighPerfWifiMode ( boolean  enable)
abstract

Enables the Wi-Fi mode.

Deprecated:
This method is deprecated.
Parameters
enableWhether to enable/disable the Wi-Fi mode:
  • true: Enable the Wi-Fi mode.
  • false: Disable the Wi-Fi mode.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getErrorDescription()

static String io.agora.rtc2.RtcEngine.getErrorDescription ( int  error)
static

Gets the warning or error description.

Parameters
errorThe warning or error code.
Returns
The detailed warning or error description.

◆ monitorHeadsetEvent()

abstract void io.agora.rtc2.RtcEngine.monitorHeadsetEvent ( boolean  monitor)
abstract

Monitors external headset device events.

Parameters
monitorWhether to enable monitoring external headset device events. True/False.
Returns
  • 0: Success.
  • <0: Failure.

◆ monitorBluetoothHeadsetEvent()

abstract void io.agora.rtc2.RtcEngine.monitorBluetoothHeadsetEvent ( boolean  monitor)
abstract

Monitors Bluetooth headset device events.

Parameters
monitorWhether to enable monitoring Bluetooth headset device events. True/False.
Returns
  • 0: Success.
  • <0: Failure.

◆ setPreferHeadset()

abstract void io.agora.rtc2.RtcEngine.setPreferHeadset ( boolean  enabled)
abstract

Sets the default audio route to the headset.

Deprecated:
This method is deprecated.
Parameters
enabledSets whether or not the default audio route is to the headset:
  • true: Set the default audio route to the headset.
  • false: Do not set the default audio route to the headset.

◆ setParameters()

abstract int io.agora.rtc2.RtcEngine.setParameters ( String  parameters)
abstract

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

The JSON options are not public by default. Agora is working on making commonly used JSON options public in a standard way.

Parameters
parametersParameter to be set as a JSON string in the specified format.
Returns
  • 0: Success.
  • <0: Failure.

◆ getParameter()

abstract String io.agora.rtc2.RtcEngine.getParameter ( String  parameter,
String  args 
)
abstract

Gets the Agora SDK’s parameters for customization purposes. This method is not disclosed yet. Contact support@agora.io for more information.

◆ registerMediaMetadataObserver()

abstract int io.agora.rtc2.RtcEngine.registerMediaMetadataObserver ( IMetadataObserver  observer,
int  type 
)
abstract

◆ unregisterMediaMetadataObserver()

abstract int io.agora.rtc2.RtcEngine.unregisterMediaMetadataObserver ( IMetadataObserver  observer,
int  type 
)
abstract

Unregisters the metadata observer.

Parameters
observerThe IMetadataObserver class.
typeThe metadata type. Currently, the SDK supports {VIDEO_METADATA(0)} only. 0: Success.< 0: Failure.

◆ startChannelMediaRelay()

abstract int io.agora.rtc2.RtcEngine.startChannelMediaRelay ( ChannelMediaRelayConfiguration  channelMediaRelayConfiguration)
abstract

Starts to relay media streams across channels.

After a successful method call, the SDK triggers the {onChannelMediaRelayStateChanged} and IRtcEngineEventHandler#onChannelMediaRelayEvent 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), the SDK starts relaying media streams between the original and the destination channel.If the onChannelMediaRelayStateChanged callback returns RELAY_STATE_FAILURE(3), an exception occurs during the media stream relay. Contact sales.nosp@m.-us@.nosp@m.agora.nosp@m..io before implementing this function.We do not support string user accounts in this API.Call this method after the joinChannel method.This method takes effect only when you are a broadcaster in a Live-broadcast channel.After a successful method call, if you want to call this method again, ensure that you call the stopChannelMediaRelay stopChannelMediaRelay} method to quit the current relay. channelMediaRelayConfiguration The configuration of the media stream relay. See { io.agora.rtc2.video.ChannelMediaRelayConfiguration ChannelMediaRelayConfiguration}. 0: Success.< 0: Failure.

◆ stopChannelMediaRelay()

abstract int io.agora.rtc2.RtcEngine.stopChannelMediaRelay ( )
abstract

◆ updateChannelMediaRelay()

abstract int io.agora.rtc2.RtcEngine.updateChannelMediaRelay ( ChannelMediaRelayConfiguration  channelMediaRelayConfiguration)
abstract

Updates the channels for media relay.

After the channel media relay starts, if you want to relay the media stream to more channels, or leave the current relay channel, you can call the updateChannelMediaRelay method.

After a successful method call, the SDK triggers the {onChannelMediaRelayEvent} callback with the RELAY_EVENT_PACKET_UPDATE_DEST_CHANNEL(7) state code. channelMediaRelayConfiguration The media stream relay configuration: { io.agora.rtc.video.ChannelMediaRelayConfiguration ChannelMediaRelayConfiguration}. 0: Success.< 0: Failure.

◆ updateChannelMediaOptions()

abstract int io.agora.rtc2.RtcEngine.updateChannelMediaOptions ( ChannelMediaOptions  options)
abstract

Updates the channel media options after joining the channel.

Parameters
optionsThe channel media options: ChannelMediaOptions.
Returns
  • 0: Success.
  • < 0: Failure.

◆ startRecordingService()

abstract int io.agora.rtc2.RtcEngine.startRecordingService ( String  recordingKey)
abstract

Starts the recording service.

◆ stopRecordingService()

abstract int io.agora.rtc2.RtcEngine.stopRecordingService ( String  recordingKey)
abstract

Stops the recording service.

◆ refreshRecordingServiceStatus()

abstract int io.agora.rtc2.RtcEngine.refreshRecordingServiceStatus ( )
abstract

Refreshes the server recording service status.

Returns
  • 0: Success.
  • <0: Failure.

◆ muteRecordingSignal()

abstract int io.agora.rtc2.RtcEngine.muteRecordingSignal ( boolean  muted)
abstract

Mute or resume recording signal volume.

Parameters
mutedDetermines whether to mute or resume the recording signal volume.
  • true: Mute the recording signal volume.
  • false: (Default) Resume the recording signal volume.
Returns
  • 0: Success.
  • < 0: Failure.

◆ startPlayingStream()

abstract int io.agora.rtc2.RtcEngine.startPlayingStream ( String  url)
abstract

Starts playing the imported stream from the URL.

Parameters
urlURL of the imported stream to play.
Returns
  • 0: Success.
  • <0: Failure.

◆ stopPlayingStream()

abstract int io.agora.rtc2.RtcEngine.stopPlayingStream ( )
abstract

Stops playing the imported stream.

Returns
  • 0: Success.
  • <0: Failure.

◆ setPlaybackAudioFrameBeforeMixingParameters()

abstract int io.agora.rtc2.RtcEngine.setPlaybackAudioFrameBeforeMixingParameters ( int  sampleRate,
int  channel 
)
abstract

Sets the audio playback format before mixing for the onPlaybackAudioFrameBeforeMixing callback.

Parameters
sampleRateSets the sample rate (samplesPerSec) returned in the onPlaybackAudioFrameBeforeMixing callback, which can be set as 8000, 16000, 32000, 44100, or 48000 Hz.
channelNumber of channels of the audio data returned in onPlaybackAudioFrameBeforeMixing, which can be set as 1 or 2:
  • 1: Mono
  • 2: Stereo
Returns
  • 0: Success.
  • < 0: Failure.
Note
The SDK calculates the sample interval according to the value of the sampleRate and channel parameters you set in this method. Ensure that the value of sample interval ≥ 0.01. The SDK triggers the onPlaybackAudioFrameBeforeMixing callback according to the sample interval.

◆ enableAudioSpectrumMonitor()

abstract int io.agora.rtc2.RtcEngine.enableAudioSpectrumMonitor ( int  intervalInMS)
abstract

Enable the audio spectrum monitor.

Parameters
intervalInMSSets the time interval(ms) between two consecutive audio spectrum callback. The default value is 100. This param should be larger than 10.
Returns
  • 0: Success.
  • < 0: Failure.

◆ disableAudioSpectrumMonitor()

abstract int io.agora.rtc2.RtcEngine.disableAudioSpectrumMonitor ( )
abstract

Disalbe the audio spectrum monitor.

Returns
  • 0: Success.
  • < 0: Failure.

◆ registerAudioSpectrumObserver()

abstract int io.agora.rtc2.RtcEngine.registerAudioSpectrumObserver ( IAudioSpectrumObserver  observer)
abstract

Registers an audio spectrum observer.

You need to implement the IAudioSpectrumObserver class in this method, and register the following callbacks according to your scenario:

  • onAudioSpectrumComputed: Occurs when the SDK receives the audio data and at set intervals.
Parameters
observerA pointer to the audio spectrum observer: IAudioSpectrumObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unRegisterAudioSpectrumObserver()

abstract int io.agora.rtc2.RtcEngine.unRegisterAudioSpectrumObserver ( IAudioSpectrumObserver  observer)
abstract

Releases the audio spectrum observer.

Parameters
observerThe pointer to the audio spectrum observer: IAudioSpectrumObserver.
Returns
  • 0: Success.
  • < 0: Failure.

◆ getEffectsVolume()

abstract double io.agora.rtc2.RtcEngine.getEffectsVolume ( )
abstract

Gets the volume of the audio effects.

Returns
  • Returns the volume of audio effects, if the method call is successful. The value ranges between 0.0 and 100.0 (original volume).
  • < 0: Failure.

◆ setEffectsVolume()

abstract int io.agora.rtc2.RtcEngine.setEffectsVolume ( double  volume)
abstract

Sets the volume of audio effects.

Parameters
volumeThe volume of audio effects. The value ranges between 0.0 and 100.0 (default).
Returns
  • 0: Success.
  • < 0: Failure.

◆ preloadEffect()

abstract int io.agora.rtc2.RtcEngine.preloadEffect ( int  soundId,
String  filePath 
)
abstract

Preloads a specified audio effect.

This method preloads only one specified audio effect into the memory each time it is called. To preload multiple audio effects, call this method multiple times.

After preloading, you can call  playEffect to play the preloaded audio effect or call  playAllEffects to play all the preloaded audio effects.

Note
  • To ensure smooth communication, limit the size of the audio effect file.
  • Agora recommends calling this method before joining the channel.
Parameters
soundIdThe ID of the audio effect.
filePathThe absolute path of the local audio effect file or the URL of the online audio effect file. Supported audio formats: mp3, mp4, m4a, aac, 3gp, mkv and wav.
Returns
  • 0: Success.
  • < 0: Failure.

◆ playEffect()

abstract int io.agora.rtc2.RtcEngine.playEffect ( int  soundId,
String  filePath,
int  loopCount,
double  pitch,
double  pan,
double  gain,
boolean  publish 
)
abstract

Plays a specified audio effect.

After calling preloadEffect, you can call this method to play the specified audio effect for all users in the channel.

This method plays only one specified audio effect each time it is called. To play multiple audio effects, call this method multiple times.

Note
  • Agora recommends playing no more than three audio effects at the same time.
  • The ID and file path of the audio effect in this method must be the same as that in the preloadEffect method.
Parameters
soundIdThe ID of the audio effect.
filePathThe absolute path of the local audio effect file or the URL of the online audio effect file. Supported audio formats: mp3, mp4, m4a, aac, 3gp, mkv and wav.
loopCountThe number of times the audio effect loops:

◆ playAllEffects()

abstract int io.agora.rtc2.RtcEngine.playAllEffects ( int  loopCount,
double  pitch,
double  pan,
double  gain,
boolean  publish 
)
abstract

◆ getVolumeOfEffect()

abstract int io.agora.rtc2.RtcEngine.getVolumeOfEffect ( int  soundId)
abstract

Get the volume of a specified sound effect.

Parameters
soundIdThe ID of the audio effect.
Returns
  • Returns the volume of the specified audio effect, if the method call is successful. The value ranges between 0.0 and 100.0 (original volume).
  • < 0: Failure.

◆ setVolumeOfEffect()

abstract int io.agora.rtc2.RtcEngine.setVolumeOfEffect ( int  soundId,
double  volume 
)
abstract

Sets the volume of the specified audio effect.

Parameters
soundIdThe ID of the audio effect.
volumeThe volume of the specified audio effect. The value ranges between 0.0 and 100.0 (default).
Returns
  • 0: Success.
  • < 0: Failure.

◆ pauseEffect()

abstract int io.agora.rtc2.RtcEngine.pauseEffect ( int  soundId)
abstract

Pauses playing the specified audio effect.

Parameters
soundIdThe ID of the audio effect.
Returns
  • 0: Success.
  • < 0: Failure.

◆ pauseAllEffects()

abstract int io.agora.rtc2.RtcEngine.pauseAllEffects ( )
abstract

Pauses playing all audio effects.

Returns
  • 0: Success.
  • < 0: Failure.

◆ resumeEffect()

abstract int io.agora.rtc2.RtcEngine.resumeEffect ( int  soundId)
abstract

Resumes playing the specified audio effect.

Parameters
soundIdThe ID of the audio effect.
Returns
  • 0: Success.
  • < 0: Failure.

◆ resumeAllEffects()

abstract int io.agora.rtc2.RtcEngine.resumeAllEffects ( )
abstract

Resumes playing all audio effects.

Returns
  • 0: Success.
  • < 0: Failure.

◆ stopEffect()

abstract int io.agora.rtc2.RtcEngine.stopEffect ( int  soundId)
abstract

Stops playing the specified audio effect.

Parameters
soundIdThe ID of the audio effect.
Returns
  • 0: Success.
  • < 0: Failure.

◆ stopAllEffects()

abstract int io.agora.rtc2.RtcEngine.stopAllEffects ( )
abstract

Stops playing all audio effects.

Returns
  • 0: Success.
  • < 0: Failure.

◆ unloadEffect()

abstract int io.agora.rtc2.RtcEngine.unloadEffect ( int  soundId)
abstract

Releases the specific preloaded audio effect from the memory.

Parameters
soundIdThe ID of the audio effect.
Returns
  • 0: Success.
  • < 0: Failure.

◆ unloadAllEffects()

abstract int io.agora.rtc2.RtcEngine.unloadAllEffects ( )
abstract

Releases all preloaded audio effects from the memory.

Returns
  • 0: Success.
  • < 0: Failure.

◆ configPublisher()

abstract int io.agora.rtc2.RtcEngine.configPublisher ( PublisherConfiguration  config)
abstract

Configures the push-stream settings for the engine before joining a channel for CDN Live.

Agora provides a Builder class to configure the push-stream for CDN Live.

Note:

  • Check the Builder Class on how to call each method included for the push-stream settings configuration.
  • Set the resolution, frame rate, and bitrate the same as those of the uplink host to avoid video quality degradation.
  • This method is in beta. Contact sales@agora.io to use this method.
Parameters
configPublisherConfiguration
Returns
  • 0: Success.
  • <0: Failure.

◆ setVideoCompositingLayout()

abstract int io.agora.rtc2.RtcEngine.setVideoCompositingLayout ( VideoCompositingLayout  layout)
abstract

Sets the picture-in-picture layouts for live broadcast.

This method is only applicable when you want to push streams at the Agora server. When you push stream at the server:

  1. Define a canvas, its width and height (video resolution), the background color, and the number of videos you want to display in total.
  2. Define the position and size of each video on the canvas, and whether it is cropped or zoomed to fit.

The push stream application will format the information of the customized layouts as JSON and package it to the Supplemental Enhancement Information (SEI) of each keyframe when generating the H.264 video stream and pushing it to the CDN vendors through the RTMP protocol.

Note:

  • Call this method after joining a channel.
  • The application should only allow one user to call this method in the same channel, if more than one user calls this method, the other users must call clearVideoCompositingLayout to remove the settings.
Parameters
layoutVideoCompositingLayout

◆ clearVideoCompositingLayout()

abstract int io.agora.rtc2.RtcEngine.clearVideoCompositingLayout ( )
abstract

Removes the settings made after calling setVideoCompositingLayout.

◆ registerVideoEncodedImageReceiver()

abstract int io.agora.rtc2.RtcEngine.registerVideoEncodedImageReceiver ( IVideoEncodedImageReceiver  receiver)
abstract

Registers a receiver object for the encoded video image.

Note
  • Ensure that you call this method before joining the channel.
  • If you register a receiver for encoded video data, you cannot register an IVideoFrameObserver object.
Parameters
receiverThe IVideoEncodedImageReceiver object: {IVideoEncodedImageReceiver}. 0: Success.< 0: Failure.

◆ setExtensionProperty()

abstract int io.agora.rtc2.RtcEngine.setExtensionProperty ( String  vendor,
String  extension,
String  key,
String  value 
)
abstract

Get local video filter property

Parameters
vendorfilter's vendor
extensionfilter's extension
keyproperty's key
valueproperty's value
Returns
true, if get property success, otherwise false

◆ setExtensionProviderProperty()

abstract int io.agora.rtc2.RtcEngine.setExtensionProviderProperty ( String  vendor,
String  key,
String  value 
)
abstract

Set extension provider specific property.

Parameters
vendorfilter's vendor
keyproperty's key
valueproperty's value
Returns
  • 0: Success.
  • < 0: Failure.

◆ startScreenCapture()

abstract int io.agora.rtc2.RtcEngine.startScreenCapture ( Intent  mediaProjectionPermissionResultData,
ScreenCaptureParameters  parameters 
)
abstract

Screen sharing by specifying a result data which obtained from a successful screen capture request.

Note
From Android 10 and later, a Service must be running and call startForeground to post a Notification before we can obtain the MediaProjection instance; failing to do so will cause a SecurityException. https://developer.android.google.cn/about/versions/10/privacy/changes#screen-contents
Parameters
mediaProjectionPermissionResultDataThe resulting data from android.app.Activity#onActivityResult.
parametersSets the screen sharing encoding parameters. See ScreenCaptureParameters.
Returns
  • 0: Success.
  • < 0: Failure.
    • ERR_INVALID_ARGUMENT if mediaProjectionPermissionResultData is null.

◆ stopScreenCapture()

abstract int io.agora.rtc2.RtcEngine.stopScreenCapture ( )
abstract

Stops the screen sharing.

Returns
  • 0: Success.
  • < 0: Failure.

◆ registerVideoFrameObserver()

abstract int io.agora.rtc2.RtcEngine.registerVideoFrameObserver ( IVideoFrameObserver  observer)
abstract

Registers a video frame observer object.

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.

Note
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.
Parameters
observerVideo frame observer object instance. See {IVideoFrameObserver}. 0: Success.< 0: Failure.

◆ createMediaPlayer()

abstract IMediaPlayer io.agora.rtc2.RtcEngine.createMediaPlayer ( )
abstract

Create a media player

You can use this function to create a ffmpeg or simple media player

Returns
IMediaPlayer

◆ enableExternalAudioSourceLocalPlayback()

abstract int io.agora.rtc2.RtcEngine.enableExternalAudioSourceLocalPlayback ( boolean  enabled)
abstract

Enable or disable the external audio source local playback.

  • Parameters
    enabledDetermines whether to enable the external audio source local playback:
  • true: Enable the external audio source local playback.
  • false: (default) Disable the external audio source local playback.
    Returns
  • 0: Success.
  • <0: Failure.