Agora SDK v4.0.0 Beta is a new 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.6.2 to v4.0.0 Beta, as well as the related changes.
This section introduces the main steps to upgrade the SDK from v3.6.2 to v4.0.0 Beta.
See Project setup for more information about integrating the v4.0.0 Beta SDK into your project.
The v4.0.0 Beta SDK has optimized or modified the implementation of some functions, resulting in incompatibility with the v3.6.2 SDK. In order to retain Agora functionality in your app, update the code in your app according to What has changed.
This section introduces the main changes of v4.0.0 Beta compared to v3.6.2 in the following categories. You need to update the code of your app according to your business scenario.
After upgrading from v3.6.2 to v4.0.0 Beta, 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.6.2, the SDK provides the AgoraRtcChannel
and AgoraRtcChannelDelegate
classes to implement multi-channel control. The v3.6.2 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 Beta introduces the following changes:
AgoraRtcEngineKit
: you can call joinChannelExByToken
(replacing joinChannelByToken
of the AgoraRtcChannel
class in v3.6.2) multiple times, and publish the specified stream to different channels through different user IDs (localUid
) and AgoraRtcChannelMediaOptions
settings.AgoraRtcConnection
to represent the connection established by joinChannelExByToken
. A connection is determined by the channel name (channelId
) and localUid
. You can control the publishing and subscribing state of different connections through AgoraRtcConnection
. The SDK adds Ex in the name of all APIs with a connection
parameter (corresponding to the AgoraRtcConnection
class) to distinguish them, and gathers these APIs in the AgoraRtcEngineKit(Ex)
class to implement more multi-stream functions.By setting AgoraRtcChannelMediaOptions
, v4.0.0 Beta 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 scenarios. For example:
Combined with the multi-channel capability, you can also experience the following functions:
localUids
.localUid
.localUid
.AgoraRtcChannel
and AgoraRtcEngineKit
of v3.6.2 are partially duplicated and overlap in their functionality, so v4.0.0 Beta 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.
In v3.6.2, the SDK uses the publishLocalAudio
and publishLocalVideo
members in AgoraRtcChannelMediaOptions
to control the audio and video publishing state in the channel.
In v4.0.0 Beta, 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.
In v3.6.2, the SDK provides the following ways to implement the custom video source and renderer:
AgoraVideoSourceProtocol
) for custom video sourceAgoraVideoSinkProtocol
) for custom video rendererv4.0.0 Beta 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.6.2 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.6.2, the SDK returns error codes and warning codes through the didOccurError
and didOccurWarning
callbacks.
To facilitate locating and troubleshooting issues, v4.0.0 Beta 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.0.0 Beta removes the didOccurError
and didOccurWarning
callbacks.
This section introduces changes caused by reasonable optimization of the SDK default behavior and API behavior.
In v3.6.2, the default channel profile is AgoraChannelProfileCommunication
(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 Beta, Agora also changed the default channel profile to AgoraChannelProfileLiveBroadcasting
(the interactive live streaming profile).
In v3.6.2, if the uid
parameter returned in networkQuality
is 0, the callback reports the network quality of the local user. In v4.0.0 Beta, 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.6.2, 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 Beta modified the naming format to agorasdk.x.log
, such as agorasdk.1.log
. Additionally, v4.0.0 Beta adds the agoraapi.log
file to record API logs.
In v3.6.2, you need to call switchChannel
to quickly switch a channel.
In v4.0.0 Beta, you can achieve the same switching speed as switchChannel
in v3.6.2 by switching a channel through leaveChannel
and joinChannelByToken
. Therefore, v4.0.0 Beta removes switchChannel
. If you call switchChannel
to quickly switch a channel in v3.6.2, see the QuickSwitchChannel sample project to update the code in your app.
This section introduces functions that were supported in v3.6.2 but are no longer supported or behave inconsistently in v4.0.0 Beta. Plans exist to support them or make them consistent in a future release, however.
v4.0.0 Beta reconstructs the audio application scenarios, which can replace most of the audio application scenarios of v3.6.2. The following table shows the correspondence of audio application scenarios in the two releases:
v3.6.2 | v4.0.0 Beta |
---|---|
AgoraAudioScenarioDefault |
AgoraAudioScenarioDefault |
AgoraAudioScenarioChatRoomEntertainment |
AgoraAudioScenarioChatRoom |
AgoraAudioScenarioEducation |
AgoraAudioScenarioDefault |
AgoraAudioScenarioGameStreaming |
AgoraAudioScenarioGameStreaming or AgoraAudioScenarioHighDefinition |
AgoraAudioScenarioShowRoom |
AgoraAudioScenarioDefault |
AgoraAudioScenarioChatRoomGaming |
AgoraAudioScenarioChatRoom |
AgoraAudioScenarioIot |
AgoraAudioScenarioDefault |
AgoraAudioScenarioMeeting |
None |
The following table shows the differences in the behavior of APIs related to the audio route between v3.6.2 and v4.0.0 Beta:
API | v3.6.2 | v4.0.0 Beta |
---|---|---|
setDefaultAudioRouteToSpeakerphone |
setDefaultAudioRouteToSpeakerphone to YES or NO , calling setEnableSpeakerphone(NO) changes the audio route to the earpiece. |
setDefaultAudioRouteToSpeakerphone(YES) to set the initial audio route to the speakerphone, calling setEnableSpeakerphone(NO) cannot change the audio route to the earpiece. |
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.6.2 and v4.0.0 Beta:
setEnableSpeakerphone
> setDefaultAudioRoutetoSpeakerphone
> The default audio route.setDefaultAudioRoutetoSpeakerphone
> The default audio route.In v3.6.2, 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.0.0 Beta, 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.
v4.0.0 Beta modifies the calling logic of enableVirtualBackground
. Before calling enableVirtualBackground
, you need to do the following:
AgoraVideoSegmentationExtension.xcframework
dynamic library in the project.enableExtension("agora_segmentation", "PortraitSegmentation", "YES")
before joining a channel to enable the virtual background extension.
enableVideo
to enable the video module.See the VideoProcess sample project to update the code in your app.
v4.0.0 Beta modifies the calling logic of setBeautyEffectOptions
. Before calling setBeautyEffectOptions
, you need to do the following:
AgoraVideoProcessExtension.xcframework
dynamic library in the project.enableExtension ("agora", "beauty", "YES")
before joining a channel to enable the image enhancement extension.enableVideo
to enable the video module.See the VideoProcess sample project to update the code in your app.
Compared to v3.6.2, some features are not supported or only partially supported in v4.0.0 Beta. 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
getVideoFormatPreference
is added in 4.0.0.beta-2.Audio and video statistics:
qualityChangedReason
member in AgoraRtcRemoteAudioStats
qualityChangedReason
is added in 4.0.0.beta-2.captureBrightnessLevel
members in LocalVideoStats
Network type:
AgoraNetworkTypeMobile5G
in AgoraNetworkType
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 the config
parameter)Audio recording on the client:
recordingChannel
in AgoraAudioRecordingConfiguration
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 the sourcePos
parameter)pushExternalAudioFrameSampleBuffer
(with the sourcePos
parameter)setExternalAudioSourceVolume
The v4.0.0 Beta removes deprecated or unrecommended APIs. Alternatives to the removed API or reasons for their removal are shown as follows:
setVideoDenoiserOptions
, setLowlightEnhanceOptions
, and setColorEnhanceOptions
: Use setExtensionPropertyWithVendor
instead. See How to enable the video enhancement extensions.virtualBackgroundSourceEnabled
: Use the return value of enableVirtualBackground
instead.superResolutionEnabledOfUid
: Use the superResolutionType
member of the AgoraRtcRemoteVideoStats
class instead.setAudioMixingPlaybackSpeed
: Use setPlaybackSpeed
instead.setAudioMixingDualMonoMode
: Use setAudioDualMonoMode
instead.getEffectCurrentPosition
: Use getPosition
instead.setEffectPosition
: Use seekToPosition
instead.getEffectDuration
: Use getDuration
instead.getAudioFileInfo
and didRequestAudioFileInfo
: Use getDuration
instead.firstLocalAudioFrame
: Use firstLocalAudioFramePublished
instead.getRecordAudioParams
: Use setRecordingAudioFrameParametersWithSampleRate
instead.getMixedAudioParams
: Use setMixedAudioFrameParametersWithSampleRate
instead.getPlaybackAudioParams
: Use setPlaybackAudioFrameParametersWithSampleRate
instead.pushMode
parameter in setExternalVideoSource
: The default value of this parameter is YES
, and this parameter only takes effect when it is set to YES
. After deletion, it does not affect the function.setLocalPublishFallbackOption
and didLocalPublishFallbackToAudioOnly
: Rarely used in v3.6.2.AgoraVideoRenderModeFill(4)
in AgoraVideoRenderMode
: This mode might cause image overstretch and is not recommended.AgoraAudioMixingReasonCode
: Rarely used in v3.6.2.AgoraAudioMixingReasonStartedByUser
AgoraAudioMixingReasonOneLoopCompleted
AgoraAudioMixingReasonStartNewLoop
AgoraAudioMixingReasonAllLoopsCompleted
AgoraAudioMixingReasonStoppedByUser
AgoraAudioMixingReasonPausedByUser
AgoraAudioMixingReasonResumedByUser
rtcEngineLocalAudioMixingDidFinish
: Rarely used in v3.6.2.info
parameter in joinChannelByToken
[2/2]: This parameter is optional and rarely used in v3.6.2.enableDeepLearningDenoise
: The SDK will add deep-learning noise reduction as one of its capability in a future release instead of implementing through an API.channel
parameter in takeSnapshot
and snapshotTaken
: The parameter is redundant.The naming changes in v4.0.0 Beta 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:
fileSize
member in AgoraLogConfig
is renamed to fileSizeInKB
.options
parameter in joinChannelByToken
[2/2] is changed to mediaOptions
.localVideoStateChange
is changed to localVideoStateChangedOfState
, and AgoraLocalVideoStreamState
is changed to AgoraVideoLocalState
.report_vad
parameter in enableAudioVolumeIndication
is changed to reportVad
.localAudioMixingStateDidChanged
is changed to audioMixingStateChanged
.