API Overview
Agora provides ensured quality of experience (QoE) for worldwide Internet-based voice and video communications through a virtual global network optimized for real-time web and mobile-to-mobile applications.
Note:
- During API calls, the SDK may returns error codes and warning codes. See Error Codes and Warning Codes.
- RtcEngine provides the main methods that can be invoked by your application.
- RtcEngineEventHandler reports runtime events to the application.
- RtcChannel provides methods that enable real-time communications in a specified channel. By creating multiple RtcChannel objects, users can join multiple channels at the same time.
- RtcChannelEventHandler provides callbacks that report events and statistics of a specified channel.
- RtcDeviceManager allows for video device interface testing.
Core methods
Method | Description |
---|---|
create | Creates the RtcEngine object. |
createWithContext | Creates and initializes RtcEngine . |
destroy | Releases the RtcEngine instance. |
setChannelProfile | Sets the channel profile. |
setClientRole | Sets the user role and level in an interactive live streaming channel. |
joinChannel | Joins a channel with the user ID, and configures whether to automatically subscribe to the audio or video streams. |
switchChannel | Switches to a different channel, and configures whether to automatically subscribe to audio or video streams in the target channel. |
leaveChannel | Leaves a channel. |
renewToken | Gets a new token when the current token expires after a period of time. |
getConnectionState | Gets the current connection state of the SDK. |
Core events
Event | Description |
---|---|
connectionStateChanged | Occurs when the network connection state changes. |
joinChannelSuccess | Occurs when a user joins a channel. |
rejoinChannelSuccess | Occurs when a user rejoins the channel. |
leaveChannel | Occurs when a user leaves a channel. |
clientRoleChanged | Occurs when the user role switches in the interactive live streaming. |
userJoined | Occurs when a remote user (COMMUNICATION)/ host (LIVE_BROADCASTING) joins the channel. |
userOffline | Occurs when a remote user (COMMUNICATION)/ host (LIVE_BROADCASTING) leaves the channel. |
networkTypeChanged | Occurs when the local network type changes. |
connectionLost | Occurs when the SDK cannot reconnect to Agora's edge server 10 seconds after its connection to the server is interrupted. |
tokenPrivilegeWillExpire | Occurs when the token expires in 30 seconds. |
requestToken | Occurs when the token expires. |
Audio management
Method | Description |
---|---|
enableAudio | Enables the audio module. |
disableAudio | Disables the audio module. |
setAudioProfile | Sets the audio profile and audio scenario. |
adjustRecordingSignalVolume | Adjusts the capturing signal volume. |
adjustUserPlaybackSignalVolume | Adjusts the playback signal volume of a specified remote user. |
adjustPlaybackSignalVolume | Adjusts the playback signal volume of all remote users. |
enableLocalAudio | Enables/Disables the local audio capture. |
muteLocalAudioStream | Stops or resumes publishing the local audio stream. |
muteRemoteAudioStream | Stops or resumes subscribing to the audio stream of a specified user. |
muteAllRemoteAudioStreams | Stops or resumes subscribing to the audio streams of all remote users. |
Video management
Method | Description |
---|---|
enableVideo | Enables the video module. |
disableVideo | Disables the video module. |
setVideoEncoderConfiguration | Sets the video encoder configuration. |
startPreview | Enables the local video preview. |
stopPreview | Stops the local video preview. |
enableLocalVideo | Enables/Disables the local video capture. |
muteLocalVideoStream | Stops or resumes publishing the local video stream. |
muteRemoteVideoStream | Stops or resumes subscribing to the video stream of a specified user. |
muteAllRemoteVideoStreams | Stops or resumes subscribing to the video streams of all remote users. |
Local media events
Event | Description |
---|---|
localAudioStateChanged | Occurs when the local audio stream state changes. |
localVideoStateChanged | Occurs when the local video stream state changes. |
firstLocalAudioFramePublished | Occurs when the first audio frame is published. |
firstLocalVideoFramePublished | Occurs when the first video frame is published. |
firstLocalVideoFrame | Occurs when the first local video frame is rendered. |
audioPublishStateChanged | Occurs when the audio publishing state changes. |
videoPublishStateChanged | Occurs when the video publishing state changes. |
Remote media events
Event | Description |
---|---|
remoteAudioStateChanged | Occurs when the remote audio state changes. |
remoteVideoStateChanged | Occurs when the remote video state changes. |
firstRemoteVideoFrame | Occurs when the first remote video frame is rendered. |
audioSubscribeStateChanged | Occurs when the audio subscribing state changes. |
videoSubscribeStateChanged | Occurs when the video subscribing state changes. |
userMuteAudio | Occurs when a remote user (in the communication profile)/ host (in the live streaming profile) joins the channel. |
userMuteVideo | Occurs when a remote user's video stream playback pauses/resumes. |
userEnableVideo | Occurs when a remote user enables/disables the video module. |
userEnableLocalVideo | Occurs when a specific remote user enables/disables the local video capturing function. |
Statistics events
After joining a channel, SDK triggers this group of callbacks once every two seconds.
Event | Description |
---|---|
rtcStats | Reports the statistics of the current call. |
networkQuality | Reports the last mile network quality of each user in the channel. |
localAudioStats | Reports the statistics of the local audio stream. |
localVideoStats | Reports the statistics of the local video stream. |
remoteAudioStats | Reports the transport-layer statistics of each remote audio stream. |
remoteVideoStats | Reports the transport-layer statistics of each remote video stream. |
Video pre-processing and post-processing
Method | Description |
---|---|
setBeautyEffectOptions | Sets the image enhancement options. |
enableVirtualBackground | Enables/Disables the virtual background. (beta feature) |
enableRemoteSuperResolution | Enables/Disables the super resolution algorithm for a remote user's video stream. |
setVideoDenoiserOptions | Sets video noise reduction. |
setLowlightEnhanceOptions | Sets low-light enhancement. |
setColorEnhanceOptions | Sets color enhancement. |
Event | Description |
---|---|
virtualBackgroundSourceEnabled | Reports whether virtual background is successfully enabled. (beta feature) |
userSuperResolutionEnabled | Reports whether the super resolution feature is successfully enabled. |
Multiple channels management
API | Description |
---|---|
create | Creates and gets an RtcChannel object. |
RtcChannel | Provides methods that enable real-time communications in an |
RtcChannelEventHandler | The SDK uses RtcChannelEventHandler to send RtcChannel event notifications to your app. |
Screen share API
Method | Description |
---|---|
getAssetAbsolutePath | Gets the actual absolute path of the asset through the relative path of the asset. |
enumerateDisplays | Enumerates the information of all the screens in the system. |
enumerateWindows | Enumerates the information of all the cpp in the system. |
startScreenCaptureByDisplayId | Shares the screen by specifying the display ID. |
startScreenCaptureByWindowId | Shares the whole or part of a window by specifying the window ID. |
setScreenCaptureContentHint | Sets the content hint for screen sharing. |
setScreenCaptureScenario | Sets the screen sharing scenario. |
updateScreenCaptureParameters | Updates the screen sharing parameters. |
updateScreenCaptureParametersMobile | Updates the screen sharing configuration. This method is only available on Android and iOS. |
updateScreenCaptureRegion | Updates the screen sharing region. |
startScreenCaptureMobile | Starts screen sharing. This method is only available on Android and iOS. |
stopScreenCapture | Stops screen sharing. |
Event | Description |
---|---|
screenCaptureInfoUpdated | Occurs when the screen sharing information is updated. |
Music file playback and mixing
Method | Description |
---|---|
startAudioMixing | Starts playing the music file. |
stopAudioMixing | Stops playing and mixing the music file. |
pauseAudioMixing | Pauses playing and mixing the music file. |
resumeAudioMixing | Resumes playing and mixing the music file. |
adjustAudioMixingVolume | Adjusts the volume during audio mixing. |
adjustAudioMixingPlayoutVolume | Adjusts the volume of audio mixing for local playback. |
adjustAudioMixingPublishVolume | Adjusts the volume of audio mixing for publishing. |
setAudioMixingPitch | Sets the pitch of the local music file. |
getAudioMixingPlayoutVolume | Retrieves the audio mixing volume for local playback. |
getAudioMixingPublishVolume | Retrieves the audio mixing volume for publishing. |
getAudioMixingDuration | Retrieves the duration (ms) of the music file. |
getAudioMixingCurrentPosition | Retrieves the playback position (ms) of the music file. |
setAudioMixingPosition | Sets the audio mixing position. |
getAudioTrackCount | Gets the audio track index of the current music file. |
selectAudioTrack | Specified the playback track of the current music file. |
setAudioMixingPlaybackSpeed | Sets the channel mode of the current music file. |
setAudioMixingDualMonoMode | Sets the channel mode of the current music file. |
Event | Description |
---|---|
audioMixingStateChanged | Occurs when the playback state of the music file changes. |
remoteAudioMixingBegin | Occurs when a remote user starts audio mixing. |
remoteAudioMixingEnd | Occurs when a remote user finishes audio mixing. |
Audio effect file playback
Method | Description |
---|---|
getEffectsVolume | Retrieves the volume of the audio effects. |
setEffectsVolume | Sets the volume of the audio effects. |
setVolumeOfEffect | Sets the volume of a specified audio effect. |
playEffect | Plays the specified local or online audio effect file. |
stopEffect | Stops playing a specified audio effect. |
stopAllEffects | Stops playing all audio effects. |
preloadEffect | Preloads a specified audio effect file into the memory. |
unloadEffect | Releases a specified preloaded audio effect from the memory. |
pauseEffect | Pauses a specified audio effect. |
pauseAllEffects | Pauses all audio effects. |
resumeEffect | Resumes playing a specified audio effect. |
resumeAllEffects | Resumes playing all audio effects. |
getEffectDuration | Retrieves the duration of the audio effect file. |
setEffectPosition | Sets the playback position of an audio effect file. |
getEffectCurrentPosition | Retrieves the playback position of the audio effect file. |
Event | Description |
---|---|
audioEffectFinished | Occurs when the playback of the local audio effect file finishes. |
Audio file info
Method | Description |
---|---|
getAudioFileInfo | Gets the information of a specified audio file. |
Event | Description |
---|---|
requestAudioFileInfo | Reports the information of an audio file. |
Virtual metronome
Method | Description |
---|---|
startRhythmPlayer | Enables the virtual metronome. |
stopRhythmPlayer | Disables the virtual metronome. |
configRhythmPlayer | Configures the virtual metronome. |
Voice effect
Method | Description |
---|---|
setLocalVoicePitch | Changes the voice pitch of the local speaker. |
enableLocalVoicePitchCallback | Enables reporting the voice pitch of the local user. |
setLocalVoiceEqualization | Sets the local voice equalization effect. |
setLocalVoiceReverb | Sets the local voice reverberation. |
setVoiceBeautifierPreset | Sets a preset voice beautifier effect. |
setVoiceBeautifierParameters | Sets parameters for the preset voice beautifier effects. |
setAudioEffectPreset | Sets an SDK preset audio effect. |
setAudioEffectParameters | Sets parameters for SDK preset audio effects. |
setVoiceConversionPreset | Sets a preset voice beautifier effect. |
Event | Description |
---|---|
localVoicePitchInHz | Reports the voice pitch of the local user. |
Sound localization
Method | Description |
---|---|
enableSoundPositionIndication | Enables/Disables stereo panning for remote users. |
setRemoteVoicePosition | Sets the 2D position (the position on the horizontal plane) of the remote user's voice. |
CDN publisher
This method applies only to interactive live streaming.
Method | Description |
---|---|
startRtmpStreamWithoutTranscoding | Starts pushing media streams to a CDN without transcoding. |
startRtmpStreamWithTranscoding | Starts Media Push and sets the transcoding configuration. |
updateRtmpTranscoding | Updates the transcoding configuration. |
stopRtmpStream | Stops pushing media streams to a CDN. |
Event | Description |
---|---|
rtmpStreamingStateChanged | Occurs when the media push state changes. |
rtmpStreamingEvent | Reports events during the media push. |
transcodingUpdated | Occurs when the publisher's transcoding is updated. |
Channel media stream relay
Method | Description |
---|---|
startChannelMediaRelay | Starts relaying media streams across channels. This method can be used to implement scenarios such as co-host across channels. |
updateChannelMediaRelay | Updates the channels for media stream relay. |
pauseAllChannelMediaRelay | Pauses the media stream relay to all destination channels. |
resumeAllChannelMediaRelay | Resumes the media stream relay to all destination channels. |
stopChannelMediaRelay | Stops the media stream relay. Once the relay stops, the host quits all the destination channels. |
Event | Description |
---|---|
channelMediaRelayStateChanged | Occurs when the state of the media stream relay changes. |
channelMediaRelayEvent | Reports events during the media stream relay. |
Volume indication
Method | Description |
---|---|
enableAudioVolumeIndication | Enables the reporting of users' volume indication. |
Event | Description |
---|---|
audioVolumeIndication | Reports the volume information of users. |
activeSpeaker | Occurs when the most active speaker is detected. |
Face detection
Method | Description |
---|---|
enableFaceDetection | Enables/Disables face detection for the local user. |
Event | Description |
---|---|
facePositionChanged | Reports the face detection result of the local user. |
Audio routing control
This method is for Android and iOS only.
Method | Description |
---|---|
setDefaultAudioRouteToSpeakerphone | Sets the default audio playback route. |
setEnableSpeakerphone | Enables/Disables the audio playback route to the speakerphone. |
isSpeakerphoneEnabled | Checks whether the speakerphone is enabled. |
Event | Description |
---|---|
audioRouteChanged | Occurs when the local audio route changes. |
In-ear monitoring
This method is for Android and iOS only.
Method | Description |
---|---|
enableInEarMonitoring | Enables in-ear monitoring. |
setInEarMonitoringVolume | Sets the volume of the in-ear monitor. |
Dual video stream mode
Method | Description |
---|---|
enableDualStreamMode | Enables/Disables dual-stream mode. |
setRemoteVideoStreamType | Sets the stream type of the remote video. |
setRemoteDefaultVideoStreamType | Sets the default stream type of remote video streams. |
Video stream fallback
Method | Description |
---|---|
setLocalPublishFallbackOption | Sets the fallback option for the published video stream based on the network conditions. |
setRemoteSubscribeFallbackOption | Sets the fallback option for the remotely subscribed video stream based on the network conditions. |
setRemoteUserPriority | Prioritizes a remote user's stream. |
Event | Description |
---|---|
localPublishFallbackToAudioOnly | Occurs when the published media stream falls back to an audio-only stream. |
remoteSubscribeFallbackToAudioOnly | Occurs when the remote media stream falls back to the audio-only stream due to poor network conditions or switches back to the video stream after the network conditions improve. |
Pre-call network test
Method | Description |
---|---|
startEchoTest | Starts an audio call test. |
stopEchoTest | Stops the audio call test. |
enableLastmileTest | Enables the network connection quality test. |
disableLastmileTest | Disables the network connection quality test. |
startLastmileProbeTest | Starts the last mile network probe test. |
stopLastmileProbeTest | Stops the last mile network probe test. |
Event | Description |
---|---|
lastmileQuality | Reports the last-mile network quality of the local user once every two seconds. |
lastmileProbeResult | Reports the last mile network probe result. |
Media metadata
This method applies only to interactive live streaming.
Method | Description |
---|---|
registerMediaMetadataObserver | Registers the metadata observer. |
unregisterMediaMetadataObserver | Unregisters the specified metadata observer. |
setMaxMetadataSize | Sets the maximum size of the media metadata. |
sendMetadata | Sends media metadata. |
Event | Description |
---|---|
metadataReceived | Occurs when the local user receives the metadata. |
Watermark
This method applies only to interactive live streaming.
Method | Description |
---|---|
addVideoWatermark | Adds a watermark image to the local video. |
clearVideoWatermarks | Removes the watermark image from the video stream. |
Video snapshot
Method | Description |
---|---|
takeSnapshot | Takes a snapshot of a video stream. |
Event | Description |
---|---|
snapshotTaken | Reports the result of taking a video snapshot. |
Encryption
Method | Description |
---|---|
enableEncryption | Enables/Disables the built-in encryption. |
Audio recorder
Method | Description |
---|---|
startAudioRecordingWithConfig | Starts audio recording on the client. |
stopAudioRecording | Stops the audio recording on the client. |
Audio and video recording
Method | Description |
---|---|
startRecording | Starts recording the local audio and video. |
stopRecording | Stops recording the local audio and video |
Event | Description |
---|---|
onRecorderStateChanged | Occurs when the local audio and video recording state changes. |
onRecorderInfoUpdated | Occurs when the recording information is updated. |
Camera control
Method | Description |
---|---|
switchCamera | Switches between front and rear cameras. |
isCameraZoomSupported | Checks whether the device supports camera zoom. |
isCameraTorchSupported | Checks whether the device supports camera flash. |
isCameraFocusSupported | Check whether the device supports the manual focus function. |
isCameraExposurePositionSupported | Checks whether the device supports manual exposure. |
isCameraAutoFocusFaceModeSupported | Checks whether the device supports the face auto-focus function. |
setCameraTorchOn | Enables the camera flash. |
setCameraAutoFocusFaceModeEnabled | Enables the camera auto-face focus function. |
setCameraZoomFactor | Sets the camera zoom ratio. |
getCameraMaxZoomFactor | Gets the maximum zoom ratio supported by the camera. |
setCameraFocusPositionInPreview | Sets the camera manual focus position. |
setCameraExposurePosition | Sets the camera exposure position. |
Event | Description |
---|---|
cameraFocusAreaChanged | Occurs when the camera focus area changes. |
cameraExposureAreaChanged | Occurs when the camera exposure area changes. |
Device management
Method | Description |
---|---|
enumerateAudioPlaybackDevices | Enumerates the audio playback devices. |
enumerateAudioRecordingDevices | Enumerates the audio capture devices. |
setAudioPlaybackDevice | Sets the audio playback device. |
setAudioRecordingDevice | Sets the audio capture device. |
startAudioPlaybackDeviceTest | Starts the audio playback device test. |
stopAudioPlaybackDeviceTest | Stops the audio playback device test. |
startAudioRecordingDeviceTest | Starts the audio capture device test. |
stopAudioRecordingDeviceTest | Stops the audio capture device test. |
startAudioDeviceLoopbackTest | Starts an audio device loopback test. |
stopAudioDeviceLoopbackTest | Stops the audio device loopback test. |
setAudioPlaybackDeviceVolume | Sets the volume of the audio playback device. |
getAudioPlaybackDeviceVolume | Retrieves the volume of the audio playback device. |
setAudioRecordingDeviceVolume | Sets the volume of the audio capture device. |
getAudioRecordingDeviceVolume | Retrieves the volume of the audio recording device. |
setAudioPlaybackDeviceMute | Mutes the audio playback device. |
getAudioPlaybackDeviceMute | Retrieves whether the audio playback device is muted. |
setAudioRecordingDeviceMute | Sets the mute status of the audio capture device. |
getAudioRecordingDeviceMute | Gets the microphone's mute status. |
followSystemPlaybackDevice | Sets the audio playback device used by the SDK to follow the system default audio playback device. |
followSystemRecordingDevice | Sets the audio recording device used by the SDK to follow the system default audio recording device. |
enumerateVideoDevices | Enumerates the video devices. |
getVideoDevice | Retrieves the current video capture device. |
setVideoDevice | Specifies the video capture device with the device ID. |
Event | Description |
---|---|
audioDeviceStateChanged | Occurs when the audio device state changes. |
audioDeviceVolumeChanged | Occurs when the volume on the playback or audio capture device, or the volume in the application changes. |
audioDeviceTestVolumeIndication | Reports the result of an audio device test. |
videoDeviceStateChanged | Occurs when the video device state changes. |
Stream message
Method | Description |
---|---|
createDataStreamWithConfig | Creates a data stream. |
sendStreamMessage | Sends data stream messages. |
Event | Description |
---|---|
streamMessage | Occurs when the local user receives the data stream from the remote user. |
streamMessageError | Occurs when the local user does not receive the data stream from the remote user. |
Subthread
Method | Description |
---|---|
getScreenShareHelper | Gets a child process object. |
Miscellaneous audio control
Method | Description |
---|---|
enableLoopbackRecording | Enables loopback audio capturing. |
setAudioSessionOperationRestriction | Sets the operational permission of the SDK on the audio session. |
Miscellaneous video control
Method | Description |
---|---|
setCameraCapturerConfiguration | Sets the camera capture configuration. |
Miscellaneous methods
Method | Description |
---|---|
setCloudProxy | Sets the Agora cloud proxy service. |
enableDeepLearningDenoise | Enables/Disables deep-learning noise reduction. |
sendCustomReportMessage | Reports customized messages. |
getCallId | Retrieves the call ID. |
rate | Allows a user to rate a call after the call ends. |
complain | Allows a user to complain about the call quality after a call ends. |
getSdkVersion | Gets the SDK version. |
getErrorDescription | Gets the warning or error description. |
Miscellaneous events
Event | Description |
---|---|
warning | Reports a warning during SDK runtime. |
error | Reports an error during SDK runtime. |
apiCallExecuted | Occurs when a method is executed by the SDK. |
proxyConnected | Reports the proxy connection state. |