Migrate from Video SDK 3.x
Updated
Upgrade to the latest version of Video Calling.
-
Migration steps to upgrade your app to Video Calling v4.x.
-
What's changed between Video Calling v2.x and v4.x.
Migration steps
This section introduces the main steps to upgrade the SDK from v2.x or 3.7.x to v4.x.
-
Integrate the SDK
See Get started for more information about integrating the v4.x SDK into your project.
-
Update the Agora code in your app
The v4.x SDK has optimized or modified the implementation of some functions, resulting in incompatibility with the v3.7.x SDK. In order to retain Agora functionality in your app, update the code in your app according to the What has changed section below.
What has changed
This section introduces the main changes of v4.x compared to v3.7.x in the following categories. You need to update the code of your app according to your business use-case.
If the version before upgrading is a version before v3.7.0, please check the v3.x release notes to obtain the changes between this version and v3.7.0.
-
Breaking changes: Introduces API compatibility changes that have a big impact. You need to spend significant time modifying the related implementation.
-
Behavior changes: Introduces changes caused by reasonable optimization of the SDK default behavior and API behavior. Less time is required to modify the related implementation, if any.
-
Function gaps: Introduces functions that were supported in v3.7.x but are not supported in 4.x. However, these functions are intended to be added in a future release.
-
Removed APIs: Introduces APIs that were supported in v3.7.x but removed in 4.x. Most of these APIs have alternatives in 4.x. Modifying the related implementation should require less time.
-
Naming and data type changes: Introduces the naming changes of the main APIs. You can update the relevant implementation according to the error message in the IDE, which is expected to take less time.
Breaking changes
After upgrading from v3.7.x to v4.x, 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.
Multiple channels
In v3.7.x, the SDK provides the AgoraRtcChannel and AgoraRtcChannelDelegate classes to implement multi-channel control. The v3.7.x 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.x introduces the following changes:
-
The SDK supports capturing or publishing multiple groups of audio and video streams at the same time. For example, simultaneously publishing video streams captured by multiple cameras or multiple screens.
-
The SDK retains the following behavior of
AgoraRtcEngineKit: you can calljoinChannelExByToken(replacingjoinChannelByTokenof theAgoraRtcChannelclass in v3.7.x) multiple times, and publish the specified stream to different channels through different user IDs (localUid) andAgoraRtcChannelMediaOptionssettings. -
Added a binary group
AgoraRtcConnectionto represent the connection established byjoinChannelExByToken. A connection is determined by the channel name (channelId) andlocalUid. You can control the publishing and subscribing state of different connections throughAgoraRtcConnection. The SDK adds Ex in the name of all APIs with aconnectionparameter (corresponding to theAgoraRtcConnectionclass) to distinguish them, and gathers these APIs in theAgoraRtcEngineKit(Ex)class to implement more multi-stream functions.
By setting AgoraRtcChannelMediaOptions, v4.x supports using one AgoraRtcEngineKit instance to capture audio and video streams from multiple sources at the same time and publish them to the remote user, adapting to various business use-cases. For example:
-
Simultaneously publish a media player stream, a screen-sharing stream, and a video stream captured by the camera.
-
Simultaneously publish one audio stream captured by the microphone and one by the custom audio source, and one media player steam.
Combined with the multi-channel capability, you can also experience the following functions:
-
Publish multiple groups of audio and video streams to the remote user through different
localUids. -
Mix multiple audio streams and publish them to the remote user through one
localUid. -
Mix multiple video streams and publish them to the remote user through one
localUid.
AgoraRtcChannel and AgoraRtcEngineKit of v3.7.x are partially duplicated and overlap in their functionality, so v4.x hides the AgoraRtcChannel and AgoraRtcChannelDelegate classes. See the JoinMultiChannel sample project for more details on how to replace AgoraRtcChannel with joinChannelExByToken and AgoraRtcChannelMediaOptions. The expected migration cost is one day or less.
If you need to continue to use the AgoraRtcChannel and AgoraRtcChannelDelegate classes, contact support@agora.io. The decision whether to maintain compatibility in a future release is based on your feedback.
Media stream publishing control
In v3.7.x, the SDK uses the publishLocalAudio and publishLocalVideo members in AgoraRtcChannelMediaOptions to control the audio and video publishing state in the channel.
In v4.x, the SDK gathers more channel-related settings into AgoraRtcChannelMediaOptions, 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 joinChannelByToken or joinChannelExByToken when joining a channel, or you can flexibly update the media options by calling updateChannelWithMediaOptions after joining achannel, such as switching video sources.
See the JoinChannelVideo sample project to update the code in your app.
Custom video source and renderer
In v3.7.x, the SDK provides the following ways to implement the custom video source and renderer:
-
Push mode for custom video source
-
Raw video data mode for custom video renderer
-
MediaIO mode (
AgoraVideoSourceProtocol) for custom video source -
MediaIO mode (
AgoraVideoSinkProtocol) for custom video renderer
v4.x 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:
-
AgoraVideoSourceProtocal -
AgoraVideoSinkProtocal -
AgoraVideoFrameConsumer -
setVideoSource -
setLocalVideoRenderer -
setRemoteVideoRenderer -
videoSource -
localVideoRenderer -
remoteVideoRendererOfUserId
If you use the MediaIO mode in v3.7.x 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:
-
Custom video source: CustomVideoSourcePush
-
Custom video renderer: CustomVideoRender
-
Switching video source: ScreenShare
Error codes and warning codes
In v3.7.x, the SDK returns error codes and warning codes through the didOccurError and didOccurWarning callbacks.
To facilitate locating and troubleshooting issues, v4.x reports problems and causes through the return values of APIs or different callbacks for listening to states. For example:
-
connectionChangedToState: Reports the network connection state. -
localAudioStateChanged: Reports the local audio state. -
localVideoStateChangedOfState: Reports the local video state. -
remoteAudioStateChangedOfUid: Reports the remote audio state. -
remoteVideoStateChangedOfUid: Reports the remote video state.
As a consequence, v4.x removes the didOccurError and didOccurWarning callbacks.
In addition to the previously mentioned breaking changes relative to v3.7.0, v4.0.0 Beta introduces a few additional breaking changes for the final release of v4.0.0. Notable changes include:
- Replacing
publishAudioTrackwithpublishMicrophoneTrackinAgoraRtcChannelMediaOptions. - Replacing
publishScreenTrackwithpublishScreenCaptureVideoinAgoraRtcChannelMediaOptions. If you used this feature in v4.0.0 and wish to upgrade to v4.0.0, modify the implementation code of the feature after upgrading the SDK.
Behavior changes
This section introduces changes caused by reasonable optimization of the SDK default behavior and API behavior.
Channel profile
In v3.7.x, the default channel profile is AgoraChannelProfileCommunication (the communication profile).
Because the interactive 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 streaming profile. In v4.x, Agora also changed the default channel profile to AgoraChannelProfileLiveBroadcasting (the interactive streaming profile).
Default log file
In v3.7.x, when the SDK creates multiple log files, the earlier files are named in a agorasdk_x.log format, such as agorasdk_1.log. v4.x modified the naming format to agorasdk.x.log, such as agorasdk.1.log. Additionally, v4.x adds the agoraapi.log file to record API logs.
Fast channel switching
In v3.7.x, you need to call switchChannelByToken to quickly switch a channel.
In v4.x, you can achieve the same switching speed as switchChannelByToken in v3.7.x by switching a channel through leaveChannel and joinChannelByToken. Therefore, v4.x removes switchChannelByToken. If you call switchChannelByToken to quickly switch a channel in v3.7.x, see the QuickSwitchChannel sample project to update the code in your app.
Agora self-developed extensions
v4.0.0 adds the feature of automatically loading self-developed dynamic libraries based on v4.0.0. 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 AgoraRtcEngineKit. You can directly call the corresponding method of the extension to enable this feature.
| API | Extension type |
|---|---|
enableVirtualBackground | Virtual background extension |
| Video enhancement extension |
enableRemoteSuperResolution | Super resolution extension |
| Voice beautifier extension |
enableSpatialAudio | Spatial audio extension |
enableContentInspect | Content moderation extension |
Virtual metronome
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:
In v3.7.0, call the configRhythmPlayer, and set publish to false.
In v4.0.0, set publishRhythmPlayerTrack in AgoraRtcChannelMediaOptions to false.
Volume indication
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:
In v3.7.0, Agora recommends that you set the interval to be greater than 200 ms. The minimum is 10 ms; otherwise, the reportAudioVolumeIndicationOfSpeakers callback is not received.
In v4.0.0, you must set the interval to an integer that is a multiple of 200 ms. If the value of interval is lower than 200, the SDK automatically adjusts it to 200.
When the user's volume indication is enabled, the SDK triggers the reportAudioVolumeIndicationOfSpeakers 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:
In v3.7.0, the SDK immediately stops reporting the local user's volume indication callback.
In v4.0.0, the SDK continues to report the local user's volume indication callback.
Device permissions
In v3.7.0, AgoraAudioLocalErrorDeviceNoPermission in localAudioStateChange reports that there is no permission to start the capture device, and AgoraLocalVideoStreamErrorDeviceNoPermission in localVideoStateChange 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 permissionError callback.
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 disableLastmileTest.
In v4.0.0, you can call startLastmileProbeTest to enable network quality testing. If you want to stop network testing, you need to call stopLastmileProbeTest.
Remote media event triggering mechanism
In the following use-cases, the mechanism of triggering remote media events is changed:
- Use-case 1: When the host calls
muteLocalAudioStreamormuteLocalVideoStreamoutside the channel to change the publishing status of the local audio or video stream and then joins the channel. - Use-case 2: When the host calls
muteLocalAudioStreamormuteLocalVideoStreamwithin the channel to change the publishing status of the local audio or video stream, and then other users join the channel.
The behavior differences of Agora SDK between v3.7.0 and v4.0.0 are listed as follow:
- In v3.7.0, the local user receives the
remoteAudioStateChangedOfUidorremoteVideoStateChangedOfUidcallback, which reports the status changes of the remote host's audio or video streams. - In v4.0.0, instead of the
remoteAudioStateChangedOfUidorremoteVideoStateChangedOfUidcallback, the local user receives thedidAudioMutedordidVideoMutedcallback, which reports the changes in the remote host's publishing status.
Media options
There are differences in the behavior of the SDK when setting channel media options while joining a channel between v3.7.0 and v4.0.0:
- In v3.7.0, if you set
publishLocalAudioinAgoraRtcChannelMediaOptionstoNO, it will stop publishing the local audio stream within the channel. - In v4.0.0, if you set
publishMicrophoneTrackinAgoraRtcChannelMediaOptionstoNO, it will not only stop publishing the local audio stream within the channel but also stop local microphone capture.
Video information change event
If the video capture device is put into the landscape or portrait mode during video capture, in v3.7.0 and v4.0.0, the following differences exist in the video information change events reported by the SDK:
- In v3.7.0, the
rotationparameter in thevideoSizeChangedOfUidcallback displays the current device rotation information. - In v4.0.0, the
rotationparameter in thevideoSizeChangedOfSourceTypecallback is always0.
Function gaps
This section introduces functions that were supported in v3.7.x but are no longer supported or behave inconsistently in v4.x. Plans exist to support them or make them consistent in a future release, however.
Audio application scenarios
v4.x reconstructs the audio application scenarios, which can replace most of the audio application scenarios of v3.7.x. The following table shows the correspondence of audio application scenarios in the two releases:
| v3.7.x | v4.x |
|---|---|
AgoraAudioScenarioDefault | AgoraAudioScenarioDefault |
AgoraAudioScenarioChatRoomEntertainment | AgoraAudioScenarioChatRoom |
AgoraAudioScenarioEducation | AgoraAudioScenarioDefault |
AgoraAudioScenarioGameStreaming | AgoraAudioScenarioGameStreaming or AgoraAudioScenarioHighDefinition |
AgoraAudioScenarioShowRoom | AgoraAudioScenarioDefault |
AgoraAudioScenarioChatRoomGaming | AgoraAudioScenarioChatRoom |
AgoraAudioScenarioIot | AgoraAudioScenarioDefault |
AgoraAudioScenarioMeeting | AgoraAudioScenarioMeeting |
Audio route
The following table shows the differences in the behavior of APIs related to the audio route between v3.7.x and v4.x:
| API | v3.x | v4.x |
|---|---|---|
setDefaultAudioRouteToSpeakerphone |
|
|
setEnableSpeakerphone | After connecting external playback devices such as Bluetooth and wired headphones, calling setEnableSpeakerphone cannot switch the audio route to the speakerphone or earpiece. | Not recommended. |
Also, when an external playback device is removed, for example, by disconnecting the Bluetooth headset, the audio route change is different between v3.5.0 and v4.x:
-
In v3.7.x, the audio route changes as follows (in terms of priority): The external device connected next to last (if any) > … > The external device connected first >
setEnableSpeakerphone>setDefaultAudioRoutetoSpeakerphone> The default audio route. -
In v4.x, the audio route changes as follows (in terms of priority): The external device connected next to last (if any) > … > The external device connected first >
setDefaultAudioRoutetoSpeakerphone> The default audio route.
Default video bitrate
In v3.7.x, if you set the video bitrate in AgoraVideoEncoderConfiguration as AgoraVideoBitrateStandard, the default video bitrate in the AgoraChannelProfileLiveBroadcasting profile is twice that of the AgoraChannelProfileCommunication profile.
In v4.x, the video bitrate in the AgoraChannelProfileCommunication profile is the same as that in the AgoraChannelProfileLiveBroadcasting profile, which means the video bitrate in the AgoraChannelProfileCommunication profile is doubled.
Virtual background
See Virtual Background to update the code in your app.
Image enhancement
v4.x modifies the calling logic of setBeautyEffectOptions. Before calling setBeautyEffectOptions, you need to do the following:
-
Integrate the
AgoraVideoProcessExtension.xcframeworkdynamic library in the project. -
Call
enableExtension ("agora", "beauty", "YES")before joining a channel to enable the image enhancement extension. -
Call
enableVideoto enable the video module.
See the VideoProcess sample project to update the code in your app.
Unsupported functions
Compared to v3.7.x, some features are not supported or only partially supported in v4.x. This section shows the APIs currently unsupported but for which support is planned for a future release.
Remote video stream fallback:
-
setRemoteUserPriority -
setRemoteSubscribeFallbackOption -
didRemoteSubscribeFallbackToAudioOnly
Raw audio data:
-
getObservedAudioFramePosition -
getRecordAudioParams -
getMixedAudioParams -
getPlaybackAudioParams
Raw video data:
getVideoFormatPreference
Audio and video statistics:
-
qualityChangedReasonmember inRemoteAudioStats -
captureBrightnessLevelmembers inLocalVideoStats
Network type:
AgoraNetworkTypeMobile5GinAgoraNetworkType
Audio and video errors:
-
AgoraAudioLocalErrorInterrupted(8) -
AgoraLocalVideoStreamErrorCaptureNoDeviceFound(8)
Selecting the playback track of the audio file:
selectAudioTrack
Pre-call network test: Before supporting the following APIs, you can use startLastmileProbeTest and stopLastmileProbeTest instead.
-
enableLastmileTest -
disableLastmileTest
Call loop test:
startEchoTestWithInterval(with theconfigparameter)
Audio recording on the client:
-
recordingChannelinAgoraAudioRecordingConfiguration -
AgoraMediaRecorder -
sharedMediaRecorderWithRtcEngine -
startRecording -
stopRecording -
destroy -
stateDidChanged -
informationDidUpdated
Wi-Fi acceleration:
-
enableWirelessAccelerate -
wlAccMessage -
wlAccStats
Video content inspection:
-
enableContentInspect -
contentInspectResult
Cloud proxy connection state:
didProxyConnected
External audio data:
-
pushExternalAudioFrameRawData(with thesourcePosparameter) -
pushExternalAudioFrameSampleBuffer(with thesourcePosparameter)
Removed APIs
The v4.x removes deprecated or unrecommended APIs. Alternatives to the removed API or reasons for their removal are shown as follows:
-
setVideoDenoiserOptions,setLowlightEnhanceOptions, andsetColorEnhanceOptions: UsesetExtensionPropertyWithVendorinstead. -
virtualBackgroundSourceEnabled: Use the return value ofenableVirtualBackgroundinstead. -
superResolutionEnabledOfUid: Use thesuperResolutionTypemember of theAgoraRtcRemoteVideoStatsclass instead. -
setAudioMixingPlaybackSpeed: UsesetPlaybackSpeedinstead. -
setExternalAudioSourceVolume: UseadjustCustomAudioPublishVolumeinstead. -
setAudioMixingDualMonoMode: UsesetAudioDualMonoModeinstead. -
getEffectCurrentPosition: UsegetPositioninstead. -
setEffectPosition: UseseekToPositioninstead. -
getEffectDuration: UsegetDurationinstead. -
getAudioFileInfoanddidRequestAudioFileInfo: UsegetDurationinstead. -
reportAudioDeviceTestVolume: UsereportAudioVolumeIndicationOfSpeakersinstead. -
firstLocalAudioFrame: UsefirstLocalAudioFramePublishedinstead. -
getRecordAudioParams: UsesetRecordingAudioFrameParametersWithSampleRateinstead. -
getMixedAudioParams: UsesetMixedAudioFrameParametersWithSampleRateinstead. -
getPlaybackAudioParams: UsesetPlaybackAudioFrameParametersWithSampleRateinstead. -
The
pushModeparameter insetExternalVideoSource: The default value of this parameter isYES, and this parameter only takes effect when it is set toYES. After deletion, it does not affect the function. -
setLocalPublishFallbackOptionanddidLocalPublishFallbackToAudioOnly: Rarely used in v3.7.x. -
AgoraVideoRenderModeFill(4)inAgoraVideoRenderMode: This mode might cause image overstretch and is not recommended. -
The following enumerations in
AgoraAudioMixingReasonCode: Rarely used in v3.7.x. -
AgoraAudioMixingReasonStartedByUser -
AgoraAudioMixingReasonOneLoopCompleted -
AgoraAudioMixingReasonStartNewLoop -
AgoraAudioMixingReasonAllLoopsCompleted -
AgoraAudioMixingReasonStoppedByUser -
AgoraAudioMixingReasonPausedByUser -
AgoraAudioMixingReasonResumedByUser -
rtcEngineLocalAudioMixingDidFinish: UseaudioMixingStateChangedinstead. -
The
infoparameter injoinChannelByToken[2/2]: This parameter is optional and rarely used in v3.7.x. -
enableDeepLearningDenoise: The SDK will add deep-learning noise reduction as one of its capability in a future release instead of implementing through an API. -
The
channelparameter intakeSnapshotandsnapshotTakenhas been removed: This change was made as thechannelparameter was found to be redundant and was not essential for the functionality of these APIs. -
setDefaultMuteAllRemoteVideoStreams: UseautoSubscribeVideoinAgoraRtcChannelMediaOptions. -
setDefaultMuteAllRemoteAudioStreams: UseautoSubscribeAudioinAgoraRtcChannelMediaOptions. -
The
replaceparameter instartAudioMixing: UsepublishMicrophoneTrackin theAgoraRtcChannelMediaOptionsinstead.
Naming changes
The naming changes in v4.x 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:
-
localVideoStateChangeis changed tolocalVideoStateChangedOfState. -
localVideoStatsis changed tolocalVideoStatssourceType. -
sourceTypeis added indidVideoPublishStateChange. -
firstLocalVideoFramePublishedis changed tofirstLocalVideoFramePublishedWithElapsed. -
videoSizeChangedOfUidis changed tovideoSizeChangedOfSourceType. -
adjustLoopbackRecordingSignalVolumeis changed toadjustLoopbackSignalVolume. -
sourceTypeis added infirstLocalVideoFrameWithSize. -
firstLocalAudioFrameis changed tofirstLocalAudioFramePublished. -
The
fileSizemember inAgoraLogConfigis renamed tofileSizeInKB. -
The
optionsparameter injoinChannelByToken[2/2] is changed tomediaOptions. -
localVideoStateChangeis changed tolocalVideoStateChangedOfState, andAgoraLocalVideoStreamStateis changed toAgoraVideoLocalState. -
The
report_vadparameter inenableAudioVolumeIndicationis changed toreportVad. -
The
errorCodeparameter inrtmpStreamingChangedToStateis changed toerrCode. -
localAudioMixingStateDidChangedis changed toaudioMixingStateChanged.
