Agora SDK v4.0.0 is a new version of the SDK that you can use to embed real-time video and audio into your app. It supports large-scale real-time interactive activities and provides better real-time interactive effects. For details, see Benefits and features.
This page introduces the main steps to upgrade the SDK from v3.x (v3.7.0 and earlier) to v4.0.0, as well as the related changes.
This section introduces the main steps to upgrade the SDK from v3.x to v4.0.0.
See Project setup for more information about integrating the v4.0.0 SDK into your project.
The v4.0.0 SDK has optimized or modified the implementation of some functions, resulting in incompatibility with the v3.7.0 SDK. In order to retain Agora functionality in your app, update the code in your app according to What has changed.
This section is based on v3.7.0 and introduces the main changes of v4.0.0 compared to v3.7.0 in the following categories. You need to update the code of your app according to your business scenario.
After upgrading from v3.7.0 to v4.0.0, the way the APIs implement some functions is different. This section introduces compatibility changes for these APIs and the logic for updating the code of your app.
In v3.7.0, the SDK provides the
IRtcChannelEventHandler classes to implement multi-channel control. The v3.7.0 SDK supports subscribing to the audio and video streams of multiple channels, but only supports publishing one group of audio and video streams in one channel.
v4.0.0 introduces the following changes:
RtcEngineinstance to collect multiple audio and video sources at the same time and publish them to the remote users by setting
joinChannelto join the first channel, call
joinChannelExmultiple times to join multiple channels, and publish the specified stream to different channels through different user ID (
RtcConnectionto represent the connection established by
joinChannel. A connection is determined by the channel name (
localUid. You can control the publishing and subscribing state of different connections through
RtcConnection. The SDK adds Ex in the name of all APIs with a
connectionparameter (corresponding to the
RtcConnectionclass) to distinguish them, and gathers these APIs in the
RtcEngineExclass to implement more multi-stream functions.
Combined with the multi-channel capability, you can also experience the following functions:
RtcEngine of v3.7.0 are partially duplicated and overlap in their functionality, so v4.0.0 hides the
IRtcChannelEventHandler classes. See the JoinMultiChannel sample project for more details on how to replace
ChannelMediaOptions. The expected migration cost is one day or less.
If you need to continue to use the
IRtcChannelEventHandler classes, contact email@example.com. The decision whether to maintain compatibility in a future release is based on your feedback.
In v4.0.0, the SDK gathers more channel-related settings into
ChannelMediaOptions, including publishing of audio and video streams from different sources, automatic subscribing of audio and video streams, user role switching, token updating, and default dual stream options. You can determine the media stream publishing and subscribing behavior by calling
joinChannelEx when joining a channel, or you can flexibly update the media options by calling
updateChannelMediaOptions after joining a channel, such as switching video sources.
See the LiveBroadcasting sample project to update the code in your app.
In v3.7.0, the SDK provides the following ways to implement the custom video source and renderer:
IVideoSource) for custom video source
IVideoSink) for custom video renderer
v4.0.0 unifies the audio and video processing pipeline internally. Push mode and raw video data mode are simpler for integration, so Agora recommends using them for custom video source and renderer and removes the following related APIs of the MediaIO mode:
If you use the MediaIO mode in v3.7.0 to implement custom video source, custom video renderer, switching video source, and other functions, Agora recommends updating the code of your app by referring to the following sample projects:
In v3.7.0, the SDK returns warning codes through the
To facilitate locating and troubleshooting issues, v4.0.0 reports problems and causes through the return values of APIs or different callbacks for listening to states. For example:
getConnectionState: Reports the network connection state.
onLocalAudioStateChanged: Reports the local audio state.
onLocalVideoStateChanged: Reports the local video state.
onRemoteAudioStateChanged: Reports the remote audio state.
onRemoteVideoStateChanged: Reports the remote video state.
As a consequence, v4.0.0 removes the
In addition to the breaking changes listed here relative to v3.7.0, v4.0.0 has a small number of breaking changes relative to the v4.0.0 Beta release. For example:
If you used this feature in v4.0.0 Beta and wish to upgrade to v4.0.0, modify the implementation code of the feature after upgrading the SDK.
This section introduces changes caused by reasonable optimization of the SDK default behavior and API behavior.
In v3.7.0, the default channel profile is
CHANNEL_PROFILE_COMMUNICATION (the communication profile).
Because the interactive live streaming profile supports seamless switching from one-to-one calls to multi-user interaction, since v3.0.0, Agora has changed the internal transmission protocol and the ability to resist poor network conditions in the communication profile to be consistent with the interactive live streaming profile. In v4.0.0, Agora also changed the default channel profile to
CHANNEL_PROFILE_LIVE_BROADCASTING (the interactive live streaming profile).
In v3.7.0, if the
uid parameter returned in
0, the callback reports the network quality of the local user. In v4.0.0, the
uid of the local user returned in this callback is the same as the local user's actual
uid in the channel.
In v3.7.0, when the SDK creates multiple log files, the earlier files are named in a
agorasdk_x.log format, such as
agorasdk_1.log. v4.0.0 modified the naming format to
agorasdk.x.log, such as
agorasdk.1.log. Additionally, v4.0.0 adds the
agoraapi.log file to record API logs.
In v3.7.0, you need to call
switchChannel to quickly switch a channel.
In v4.0.0, you can achieve the same switching speed as
switchChannel in v3.7.0 by switching a channel through
joinChannel. Therefore, v4.0.0 removes
switchChannel. If you call
switchChannel to quickly switch a channel in v3.7.0, you need to call
leaveChannel to leave the current channel in v4.0.0 and
joinChannel to join the second channel instead.
Agora self-developed extensions
v4.0.0 adds the feature of automatically loading self-developed dynamic libraries based on v4.0.0 Beta. As of this release, when using an Agora self-developed extension, you do not need to manually integrate the dynamic library in the project. The SDK automatically loads the dynamic library during the initialization phase of
RtcEngine. You can directly call the corresponding method of the extension to enable this feature.
||Virtual background extension|
||Video enhancement extension|
||Super resolution extension|
||Voice beautifier extension|
||Spatial audio extension|
||Content moderation extension|
When you call
startRhythmPlayer, the SDK publishes the sound of the virtual metronome to the remote by default. If you do not want the remote users to hear the virtual metronome, refer to the following operations:
You can call the
enableAudioVolumeIndication method to enable the user's volume indication function. There is a difference in the definition of the
interval parameter in the
enableAudioVolumeIndication method between v3.7.0 and v4.0.0, as follows:
intervalto be greater than 200 ms. The minimum is 10 ms; otherwise, the
onAudioVolumeIndicationcallback is not received.
intervalto an integer that is a multiple of 200 ms. If the value of
intervalis lower than 200, the SDK automatically adjusts it to 200.
When the user's volume indication is enabled, the SDK triggers the onAudioVolumeIndication callback at the time interval set in this method. If the local user calls muteLocalAudioStream to mute themselves, the SDK behaves inconsistently between v3.7.0 and v4.0.0:
onLocalAudioStateChanged reports that there is no permission to start the capture device, and
onLocalVideoStateChanged reports that there is no permission to start the video capture device.
In v4.0.0, the permission statuses of the audio and video capture devices are both reported in the
Pre-call network test
If you need to start or stop the network connection quality test, note the following:
In v3.7.0, you can call
enableLastmileTest to start the network quality test. If you want to stop the network test, you need to call
In v4.0.0, you can call
startLastmileProbeTest to enable network quality testing. If you want to stop network testing, you need to call
This section introduces functions that were supported in v3.7.0 but are no longer supported or behave inconsistently in v4.0.0. Plans exist to support them or make them consistent in a future release, however.
v4.0.0 reconstructs the audio application scenarios, which can replace most of the audio application scenarios of v3.7.0. The following table shows the correspondence of audio application scenarios in the two releases:
Compared to v3.7.0, some features are not supported or only partially supported in v4.0.0. This section shows the APIs currently unsupported but for which support is planned in a future release.
Remote video stream fallback:
The v4.0.0 removes deprecated or unrecommended APIs. Alternatives to the removed API or reasons for their removal are shown as follows:
virtualBackgroundSourceEnabled: Use the return value of
onUserSuperResolutionEnabled: Use the
remoteVideoStatsmember of the
setAudioMixingPlaybackSpeed: Use the relevant API under the IMediaPlayer (
AgoraRtcMediaPlayerProtocol) class instead.
onLocalPublishFallbackToAudioOnly: Rarely used in v3.7.0.
RENDER_MODE_TYPE: This mode can cause image overstretch and is not recommended.
AUDIO_MIXING_REASON_TYPE: Rarely used in v3.7.0.
enableDeepLearningDenoise: The SDK adds deep-learning noise reduction as one of its capability in a future release instead of implementing through an API.
onSnapshotTaken: The parameter is redundant.
in theChannelMediaOptions` instead.
The naming changes in v4.0.0 cause error messages in the IDE when you compile your project, and you need to update the code of your app according to each error message.
The main API and parameter name changes are as follows:
onFirstLocalAudioFrameis changed to
LogConfigis renamed to
joinChannel[2/2] is changed to
enableAudioVolumeIndicationis changed to