AgoraRtcEngineKit(Ex)
This interface class contains multi-channel methods.
Inherited from AgoraRtcEngineKit.
addVideoWatermarkEx
Adds a watermark image to the local video.
- (int)addVideoWatermarkEx:(NSURL* _Nonnull)url options:(WatermarkOptions* _Nonnull)options connection:(AgoraRtcConnection * _Nonnull)connection;
This method adds a PNG watermark image to the local video in the live streaming. Once the watermark image is added, all the audience in the channel (CDN audience included), and the capturing 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.
- If the orientation mode of the encoding video (AgoraVideoOutputOrientationMode) is fixed landscape mode or the adaptive landscape mode, the watermark uses the landscape orientation.
- If the orientation mode of the encoding video (AgoraVideoOutputOrientationMode) is fixed portrait mode or the adaptive portrait mode, the watermark uses the portrait orientation.
- When setting the watermark position, the region must be less than the setVideoEncoderConfigurationEx dimensions set in the method; otherwise, the watermark image will be cropped.
- Ensure that you have called enableVideo before calling this 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 of 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 startPreview method, you can use the
visibleInPreview
member to set whether or not the watermark is visible in the 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.
Parameters
- url
- The local file path of the watermark image to be added. This method supports adding a watermark image from the local absolute or relative file path.
- options
- The options of the watermark image to be added. For details, see WatermarkOptions.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
clearVideoWatermarkEx
Removes the watermark image from the video stream.
- (int)clearVideoWatermarkEx:(AgoraRtcConnection * _Nonnull)connection;
Parameters
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
enableDualStreamModeEx
Enables or disables dual-stream mode on the sender side.
- (int)enableDualStreamModeEx:(BOOL)enabled streamConfig:(AgoraSimulcastStreamConfig*)streamConfig connection:(AgoraRtcConnection* _Nonnull)connection;
- Since
- v4.0.1
- High-quality video stream: High bitrate, high resolution.
- Low-quality video stream: Low bitrate, low resolution.
After you enable dual-stream mode, you can call setRemoteVideoStream to choose to receive either the high-quality video stream or the low-quality video stream on the subscriber side.
- This method is applicable to all types of streams from the sender, including but not limited to video streams collected from cameras, screen sharing streams, and custom-collected video streams.
- If you need to enable dual video streams in a multi-channel scenario, you can call the enableDualStreamModeEx method.
- You can call this method either before or after joining a channel.
Parameters
- enabled
-
Whether to enable dual-stream mode:
YES
: Enable dual-stream mode.NO
: (Default) Disable dual-stream mode.
- streamConfig
-
The configuration of the low-quality video stream. See AgoraSimulcastStreamConfig.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
getConnectionStateEx
Gets the current connection state of the SDK.
- (AgoraConnectionState)getConnectionStateEx:(AgoraRtcConnection * _Nonnull)connection;
You can call this method either before or after joining a channel.
Parameters
- connection
- The connection information. See AgoraRtcConnection.
Returns
The current connection state. For details, see AgoraConnectionState.
getUserInfoWithUserId
Gets the user information by passing in the user ID.
- (int)getUserInfoWithUserId:(NSUInteger)uid userInfo:(AgoraUserInfo *_Nullable* _Nullable)userInfo channelId:(NSString* _Nonnull)channelId localUserAccount:(NSString* _Nonnull)localUserAccount;
After a remote user joins the channel, the SDK gets the UID and User Account of the remote user, caches them in a mapping table object, and triggers the didUserInfoUpdatedWithUserId callback on the local client. After receiving the callback, you can call this method to get the user account of the remote user from the AgoraUserInfo object by passing in the user ID.
Parameters
- uid
- The user ID.
- userInfo
- The AgoraUserInfo object that identifies the user information.
- Input value: A AgoraUserInfo object.
- Output: A AgoraUserInfo object that contains the user account and user ID of the user.
- channelId
-
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
- All lowercase English letters: a to z.
- All uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- Space
- "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "= ", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
- localUserAccount
- The user account of the local user.
Returns
- 0: Success.
- < 0: Failure.
getUserInfoWithUserAccount
Gets the user information by passing in the user account.
- (int)getUserInfoWithUserAccount:(NSString * _Nonnull)userAccount userInfo:(AgoraUserInfo *_Nullable* _Nullable)userInfo channelId:(NSString* _Nonnull)channelId localUserAccount:(NSString* _Nonnull)localUserAccount;
After a remote user joins the channel, the SDK gets the UID and User Account of the remote user, caches them in a mapping table object, and triggers the didUserInfoUpdatedWithUserId callback on the local client. After receiving the callback, you can call this method to get the user account of the remote user from the AgoraUserInfo object by passing in the user ID.
Parameters
- userAccount
- The user account.
- userInfo
- The AgoraUserInfo object that identifies the user information.
- Input value: A AgoraUserInfo object.
- Output: A AgoraUserInfo object that contains the user account and user ID of the user.
- channelId
-
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
- All lowercase English letters: a to z.
- All uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- Space
- "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "= ", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
- localUserAccount
- The user account of the local user.
Returns
- 0: Success.
- < 0: Failure.
joinChannelExByToken
Joins a channel with the connection ID.
- (int)joinChannelExByToken:(NSString* _Nullable)token connection:(AgoraRtcConnection * _Nonnull)connection delegate:(id<AgoraRtcEngineDelegate> _Nullable)delegate mediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions joinSuccess:(void(^ _Nullable)(NSString* _Nonnull channel, NSUInteger uid, NSInteger elapsed))joinSuccessBlock;
You can call this method multiple times to join more than one channels.
- If you are already in a channel, you cannot rejoin it with the same user ID.
- If you want to join the same channel from different devices, ensure that the user IDs in all devices are different.
- Ensure that the app ID you use to generate the token is the same with the app ID used when creating the AgoraRtcEngineKit instance.
Parameters
- token
- The token generated on your server for authentication. See .
- connection
- The connection information. See AgoraRtcConnection.
- mediaOptions
- The channel media options. See AgoraRtcChannelMediaOptions.
- delegate
- The callback class of AgoraRtcEngineKit(Ex). For details, see AgoraRtcEngineDelegate.
- joinSuccessBlock
- Occurs when a user joins a channel. If you implement both
joinSuccessBlock
and didJoinChannel, joinSuccessBlock takes higher priority than didJoinChannel. Agora recommends settingjoinSuccessBlock
asnil
to use didJoinChannel.
Returns
- 0: Success.
- < 0: Failure.
- -2: The parameter is invalid. For example, the token is invalid, the uid parameter is not set to an integer, or the value of a member in the AgoraRtcChannelMediaOptions structure is invalid. You need to pass in a valid parameter and join the channel again.
- -3: Failes to initialize the AgoraRtcEngineKit object. You need to reinitialize the AgoraRtcEngineKit object.
- -7: The AgoraRtcEngineKit object has not been initialized. You need to initialize the AgoraRtcEngineKit object before calling this method.
- -8: AgoraRtcEngineKitThe internal state of the object is wrong. The typical cause is that you call this method to join the channel without calling stopEchoTest to stop the test after calling startEchoTestWithInterval to start a call loop test. You need to call stopEchoTest before calling this method.
- -17: The request to join the channel is rejected. The typical cause is that the user is in the channel. Agora recommends using the connectionChangedToState callback to get whether the user is in the channel. Do not call this method to join the channel unless you receive the AgoraConnectionStateDisconnected(1) state.
- -102: The channel name is invalid. You need to pass in a valid channel name inchannelId to rejoin the channel.
- -121: The user ID is invalid. You need to pass in a valid user ID in uid to rejoin the channel.
joinChannelExByToken
Joins the channel with a user account, and configures whether to automatically subscribe to audio or video streams after joining the channel.
- (int)joinChannelExByToken:(NSString* _Nullable)token channelId:(NSString* _Nonnull)channelId userAccount:(NSString* _Nonnull)userAccount delegate:(id<AgoraRtcEngineDelegate> _Nullable)delegate mediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions joinSuccess:(void(^ _Nullable)(NSString* _Nonnull channel, NSUInteger uid, NSInteger elapsed))joinSuccessBlock;
- The local client: didLocalUserRegisteredWithUserId, didJoinChannel and connectionChangedToState callbacks.
- The remote client: The didJoinedOfUid callback if the user is in the COMMUNICATION profile, and the didUserInfoUpdatedWithUserId callback if the user is a host in the LIVE_BROADCASTING profile.
Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods.
Parameters
- token
- The token generated on your server for authentication. See .
- channelId
-
The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
- All lowercase English letters: a to z.
- All uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- Space
- "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "= ", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
- userAccount
-
The user account. This parameter is used to identify the user in the channel for real-time audio and video engagement. You need to set and manage user accounts yourself and ensure that each user account in the same channel is unique. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as nil. Supported characters are (89 in total):
- The 26 lowercase English letters: a to z.
- The 26 uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- Space
- "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "= ", ".", ">", "?", "@", "[", "]", "^", "_", "{", "}", "|", "~", ","
- mediaOptions
- The channel media options. See AgoraRtcChannelMediaOptions.
- joinSuccessBlock
- Occurs when a user joins a channel. If you implement both
joinSuccessBlock
and didJoinChannel, joinSuccessBlock takes higher priority than didJoinChannel. Agora recommends settingjoinSuccessBlock
asnil
to use didJoinChannel.
Returns
- 0: Success.
- < 0: Failure.
leaveChannelEx
Leaves a channel.
- (int)leaveChannelEx:(AgoraRtcConnection * _Nonnull)connection leaveChannelBlock:(void(^ _Nullable)(AgoraChannelStats* _Nonnull stat))leaveChannelBlock;
Parameters
- connection
- The connection information. See AgoraRtcConnection.
- leaveChannelBlock
-
This callback indicates that a user leaves a channel, and provides the statistics of the call in AgoraChannelStats.
Returns
- 0: Success.
- < 0: Failure.
muteRemoteAudioStreamEx
Stops or resumes receiving the audio stream of a specified user.
- (int)muteRemoteAudioStreamEx:(NSUInteger)uid mute:(BOOL)mute connection:(AgoraRtcConnection * _Nonnull)connection;
Parameters
- uid
- The ID of the specified user.
- mute
-
Whether to stop receiving the audio stream of the specified user:
YES
: Stop receiving the audio stream of the specified user.NO
: (Default) Resume receiving the audio stream of the specified user.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
muteRemoteVideoStreamEx
Stops or resumes receiving the video stream of a specified user.
- (int)muteRemoteVideoStreamEx:(NSUInteger)uid mute:(BOOL)mute connection:(AgoraRtcConnection * _Nonnull)connection;
This method is used to 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
- uid
-
The user ID of the remote user.
- mute
-
Whether to stop receiving the video stream of the specified user:
YES
: Stop receiving the video stream of the specified user.NO
: (Default) Resume receiving the video stream of the specified user.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
pushExternalVideoFrame
Pushes the external raw video frame to the SDK.
- (BOOL)pushExternalVideoFrame:(AgoraVideoFrame * _Nonnull)frame videoTrackId:(NSUInteger)videoTrackId;
To push the unencoded external raw video frame to the SDK, call setExternalVideoSource, set enabled as YES
, and set encodedFrame as NO
.
Parameters
- frame
-
The external raw video frame to be pushed. See AgoraVideoFrame.
- videoTrackId
- The video track ID returned by calling the createCustomVideoTrack method. The default value is 0.
Returns
YES
: Pushes the external raw video frame to the SDK successfully.NO
: Fails to push external raw video frame to the SDK.
sendCustomReportMessageEx
Agora supports reporting and analyzing customized messages.
- (int)sendCustomReportMessageEx:(NSString * _Nullable)messageId category:(NSString * _Nullable)category event:(NSString * _Nullable)event label:(NSString * _Nullable)label value:(NSInteger)value connection:(AgoraRtcConnection * _Nonnull)connection;
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 and each string not exceeding 100 bytes. To try out this function, contact support@agora.io and discuss the format of customized messages with us.
setDualStreamModeEx
Sets dual-stream mode on the sender side.
- (int)setDualStreamModeEx:(AgoraSimulcastStreamMode)mode streamConfig:(AgoraSimulcastStreamConfig*)streamConfig connection:(AgoraRtcConnection* _Nonnull)connection;
- Since
- v4.0.1
The SDK enables the low-quality video stream auto mode on the sender by default, which is equivalent to calling this method and setting the mode to AgoraAutoSimulcastStream. If you want to modify this behavior, you can call this method and modify the mode to AgoraDisableSimulcastStream(always never send low-quality video streams) or AgoraEnableSimulcastStream (always send low-quality video streams).
- When calling this method and setting mode to AgoraDisableSimulcastStream, it has the same effect as
enableDualStreamModeEx(NO)
. - When calling this method and setting mode to AgoraEnableSimulcastStream, it has the same effect as
enableDualStreamModeEx(YES)
. - Both methods can be called before and after joining a channel. If they are used at the same time, the settings in the method called later shall prevail.
Parameters
- mode
- The mode in which the video stream is sent. See AgoraSimulcastStreamMode.
- streamConfig
-
The configuration of the low-quality video stream. See AgoraSimulcastStreamConfig.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setRemoteRenderModeEx
Sets the video display mode of a specified remote user.
- (int)setRemoteRenderModeEx:(NSUInteger)uid mode:(AgoraVideoRenderMode)mode mirror:(AgoraVideoMirrorMode)mirror connection:(AgoraRtcConnection * _Nonnull)connection;
- Call this method after initializing the remote view by calling the setupRemoteVideo 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
- uid
- The user ID of the remote user.
- renderMode
-
The video display mode of the remote user. For details, see AgoraVideoRenderMode.
- mirrorMode
-
The mirror mode of the remote user view. For details, see AgoraVideoMirrorMode.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setRemoteVoicePositionEx
Sets the 2D position (the position on the horizontal plane) of the remote user's voice.
- (int)setRemoteVoicePosition:(NSUInteger)uid pan:(double)pan gain:(double)gain connection:(AgoraRtcConnection * _Nonnull)connection;
This method sets the voice position and volume of a remote user.
When the local user calls this method to set the voice position of a remote user, the voice difference between the left and right channels allows the local user to track the real-time position of the remote user, creating a sense of space. This method applies to massive multiplayer online games, such as Battle Royale games.
- For the best voice positioning, Agora recommends using a wired headset.
- Call this method after joining a channel.
Parameters
- uid
- The user ID of the remote user.
- pan
- The voice position of the remote user. The value ranges from -1.0 to 1.0:
- -1.0: The remote voice comes from the left.
- 0.0: (Default) The remote voice comes from the front.
- 1.0: The remote voice comes from the right.
- gain
- The volume of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original volume of the remote user). The smaller the value, the lower the volume.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setSubscribeAudioBlacklistEx
Set the blocklist of subscriptions for audio streams.
- (int)setSubscribeAudioBlacklistEx:(NSArray <NSNumber *> *_Nonnull)blacklist connection:(AgoraRtcConnection * _Nonnull)connection;
You can call this method to specify the audio streams of a user that you do not want to subscribe to.
- You can call this method either before or after joining a channel.
- The blocklist is not affected by the setting in muteRemoteAudioStream, muteAllRemoteAudioStreams and autoSubscribeAudio in AgoraRtcChannelMediaOptions.
- Once the blocklist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
- If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.
Parameters
- blacklist
-
The user ID list of users that you do not want to subscribe to.
If you want to specify the audio streams of a user that you do not want to subscribe to, add the user ID in this list. If you want to remove a user from the blocklist, you need to call the setSubscribeAudioBlacklist method to update the user ID list; this means you only add the uid of users that you do not want to subscribe to in the new user ID list.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setSubscribeAudioWhitelistEx
Sets the allowlist of subscriptions for audio streams.
- (int)setSubscribeAudioWhitelistEx:(NSArray <NSNumber *> *_Nonnull)whitelist connection:(AgoraRtcConnection * _Nonnull)connection;
You can call this method to specify the audio streams of a user that you want to subscribe to.
- You can call this method either before or after joining a channel.
- The allowlist is not affected by the setting in muteRemoteAudioStream, muteAllRemoteAudioStreams and autoSubscribeAudio in AgoraRtcChannelMediaOptions.
- Once the allowlist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
- If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.
Parameters
- whitelist
-
The user ID list of users that you want to subscribe to.
If you want to specify the audio streams of a user for subscription, add the user ID in this list. If you want to remove a user from the allowlist, you need to call the setSubscribeAudioWhitelist method to update the user ID list; this means you only add the uid of users that you want to subscribe to in the new user ID list.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setSubscribeVideoBlacklistEx
Set the bocklist of subscriptions for video streams.
- (int)setSubscribeVideoBlacklistEx:(NSArray <NSNumber *> *_Nonnull)blacklist connection:(AgoraRtcConnection * _Nonnull)connection;
You can call this method to specify the video streams of a user that you do not want to subscribe to.
- You can call this method either before or after joining a channel.
- The blocklist is not affected by the setting in muteRemoteVideoStream, muteAllRemoteVideoStreams and autoSubscribeAudio in AgoraRtcChannelMediaOptions.
- Once the blocklist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
- If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.
Parameters
- blacklist
-
The user ID list of users that you do not want to subscribe to.
If you want to specify the video streams of a user that you do not want to subscribe to, add the user ID of that user in this list. If you want to remove a user from the blocklist, you need to call the setSubscribeVideoBlacklist method to update the user ID list; this means you only add the uid of users that you do not want to subscribe to in the new user ID list.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setSubscribeVideoWhitelistEx
Set the allowlist of subscriptions for video streams.
- (int)setSubscribeVideoWhitelistEx:(NSArray <NSNumber *> *_Nonnull)whitelist connection:(AgoraRtcConnection * _Nonnull)connection;
You can call this method to specify the video streams of a user that you want to subscribe to.
- You can call this method either before or after joining a channel.
- The allowlist is not affected by the setting in muteRemoteVideoStream, muteAllRemoteVideoStreams and autoSubscribeAudio in AgoraRtcChannelMediaOptions.
- Once the allowlist of subscriptions is set, it is effective even if you leave the current channel and rejoin the channel.
- If a user is added in the allowlist and blocklist at the same time, only the blocklist takes effect.
Parameters
-
The user ID list of users that you want to subscribe to.
If you want to specify the video streams of a user for subscription, add the user ID of that user in this list. If you want to remove a user from the allowlist, you need to call the setSubscribeVideoWhitelist method to update the user ID list; this means you only add the uid of users that you want to subscribe to in the new user ID list.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setupRemoteVideoEx
Initializes the video view of a remote user.
- (int)setupRemoteVideoEx:(AgoraRtcVideoCanvas* _Nonnull)remote connection:(AgoraRtcConnection * _Nonnull)connection;
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. Call this method to bind the remote video stream to a video view and to set the rendering and mirror modes of the video view.
The application specifies the uid of the remote video in the AgoraRtcVideoCanvas method before the remote user joins the channel.
If the remote uid is unknown to the application, set it after the application receives the didJoinedOfUid callback. If the Video Recording function is enabled, the Video Recording Service joins the channel as a dummy client, causing other clients to also receive the onUserJoined
callback. Do not bind the dummy client to the application view because the dummy client does not send any video streams.
To unbind the remote user from the view, set the view parameter to NULL.
Once the remote user leaves the channel, the SDK unbinds the remote user.
To update the rendering or mirror mode of the remote video view during a call, use the setRemoteRenderModeEx method.
Parameters
- remote
-
The remote video view settings. See AgoraRtcVideoCanvas.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
setVideoEncoderConfigurationEx
Sets the encoder configuration for the local video.
- (int)setVideoEncoderConfigurationEx:(AgoraVideoEncoderConfiguration* _Nonnull)config connection:(AgoraRtcConnection * _Nonnull)connection;
Each configuration profile corresponds to a set of video parameters, including the resolution, frame rate, and bitrate.
The config specified in this method is the maximum values under ideal network conditions. If the network condition is not good, the video engine cannot use the config renders local video, which automatically reduces to an appropriate video parameter setting.
Parameters
- config
- Video profile. See AgoraVideoEncoderConfiguration.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
takeSnapshotEx
Takes a snapshot of a video stream.
- (NSInteger)takeSnapshotEx:(AgoraRtcConnection * _Nonnull)connection uid:(NSInteger)uid filePath:(NSString* _Nonnull)filePath;
This method takes a snapshot of a video stream from the specified user, generates a JPG image, and saves it to the specified path.
The method is asynchronous, and the SDK has not taken the snapshot when the method call returns. After a successful method call, the SDK triggers the snapshotTaken callback to report whether the snapshot is successfully taken, as well as the details for that snapshot.
- Call this method after the joinChannelExByToken method.
- This method takes a snapshot of the published video stream specified in AgoraRtcChannelMediaOptions.
- If the user's video has been preprocessed, for example, watermarked or beautified, the resulting snapshot includes the pre-processing effect.
Parameters
- connection
- The connection information. See AgoraRtcConnection.
- uid
- The user ID. Set uid as 0 if you want to take a snapshot of the local user's video.
- filePath
-
The local path (including filename extensions) of the snapshot. For example:
- iOS:
/App Sandbox/Library/Caches/example.jpg
- iOS:
Returns
- 0: Success.
- < 0: Failure.
updateChannelExWithMediaOptions
Updates the channel media options after joining the channel.
- (int)updateChannelExWithMediaOptions:(AgoraRtcChannelMediaOptions* _Nonnull)mediaOptions connection:(AgoraRtcConnection * _Nonnull)connection;
Parameters
- options
- The channel media options. See AgoraRtcChannelMediaOptions.
- connection
- The connection information. See AgoraRtcConnection.
Returns
- 0: Success.
- < 0: Failure.
- -2: The value of a member in the AgoraRtcChannelMediaOptions structure is invalid. For example, the token or the user ID is invalid. You need to fill in a valid parameter.
- -7: The AgoraRtcEngineKit object has not been initialized. You need to initialize the AgoraRtcEngineKit object before calling this method.
- -8: The internal state of the AgoraRtcEngineKit object is wrong. The possible reason is that the user is not in the channel. Agora recommends using the connectionChangedToState callback to get whether the user is in the channel. If you receive the AgoraConnectionStateDisconnected (1) or AgoraConnectionStateFailed (5) state, the user is not in the channel. You need to call joinChannelByToken [2/4] to join a channel before calling this method.