All Products
Search
Document Center

ApsaraVideo Live:AliRtcEngine interface

Last Updated:Dec 23, 2025

This topic describes the interfaces of the ApsaraVideo Real-time Communication Mac SDK.

Table of contents

Basic interfaces

API

Function Description

sharedInstance

Gets an AliRtcEngine instance.

destroy[1/2]

Destroys the engine.

destroy[2/2]

Destroys the engine with a callback.

setH5CompatibleMode

Sets the H5 compatibility mode.

getH5CompatibleMode

Checks whether H5 compatibility mode is enabled.

getSdkVersion

Gets the SDK version number.

Channel-related interfaces

API

Function Description

setChannelProfile

Sets the channel profile.

setAudioProfile

Sets the audio profile.

isAudioOnly

Checks whether the current mode is audio-only.

setAudioOnlyMode

Sets the mode to audio-only or audio and video.

joinChannel[1/4]

Joins a channel.

joinChannel[2/4]

Joins a channel.

joinChannel[3/4]

Joins a channel.

joinChannel[4/4]

Joins a channel.

leaveChannel

Leaves the channel.

isInCall

Checks whether the user is in the channel.

setClientRole

Sets the user role.

getClientRole

Gets the user role.

refreshAuthInfo

Refreshes the authentication information.

refreshAuthInfoWithToken

Refreshes the authentication information.

Publishing and subscription interfaces

API

Function Description

publishLocalAudioStream

Sets whether to publish the local audio stream. The audio stream is published by default.

isLocalAudioStreamPublished

Checks whether the local audio stream is being published.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to subscribe to remote audio streams by default. By default, all remote audio streams are subscribed. Call this interface before you join a channel.

subscribeAllRemoteAudioStreams

Stops or resumes receiving all remote audio streams.

subscribeRemoteAudioStream

Stops or resumes receiving the audio stream of a specific remote user.

publishLocalVideoStream

Sets whether to publish the video stream.

isLocalVideoStreamPublished

Checks whether the local video stream is being published.

setDefaultSubscribeAllRemoteVideoStreams

Sets whether to subscribe to remote video streams by default. By default, all remote video streams are subscribed. Call this interface before you join a channel.

subscribeAllRemoteVideoStreams

Stops or resumes receiving all remote video streams.

subscribeRemoteMediaStream [1/2]

Stops or resumes receiving the media stream of a specific remote user. Use this interface when you need to control both audio and video streams.

subscribeRemoteMediaStream [2/2]

Stops or resumes subscribing to the audio and video streams of a remote user.

subscribeRemoteDestChannelStream

Stops or resumes receiving the media stream of a specific remote user in another channel.

subscribeRemoteDestChannelAllStream

Subscribes to the streams of all users in a destination channel.

subscribeRemoteVideoStream

Stops or resumes subscribing to the video stream of a remote user.

setRemoteAudioVolume

Sets the volume of a remote audio stream.

Audio device management interfaces

API

Function Description

muteLocalMic

Stops or resumes publishing the local audio stream.

muteRemoteAudioPlaying

Stops or resumes playing a remote audio stream.

muteAllRemoteAudioPlaying

Stops or resumes playing all remote audio streams.

startAudioCapture [1/2]

Starts audio capture.

startAudioCapture [2/2]

Starts audio capture.

stopAudioCapture

Stops audio capture.

enableAudioVolumeIndication

Enables the volume detection feature.

enableEarBack

Enables in-ear monitoring.

startAudioPlayer

Starts audio playback.

stopAudioPlayer

Stops audio playback.

setPlayoutVolume

Sets the playback volume.

setRecordingVolume

Sets the capture volume.

playAudioFileTest

Starts testing the audio playback device.

stopAudioFileTest

Stops testing the audio playback device.

startAudioCaptureTest

Starts testing the audio capture device.

stopAudioCaptureTest

Stops testing the audio capture device.

Voice changer and reverberation

API

Function Description

setAudioEffectVoiceChangerMode

Sets the voice changer effect mode.

setAudioEffectPitchValue

Sets the pitch shifting parameter.

setAudioEffectReverbMode

Sets the reverberation effect mode.

setAudioEffectReverbParamType

Sets the reverberation effect type and specific parameters.

Custom audio input

API

Function Description

addExternalAudioStream

Adds an external audio stream.

pushExternalAudioStream

Inputs external audio stream data.

setExternalAudioStream:publishVolume

Sets the publishing volume.

getExternalAudioStreamPublishVolume

Gets the publishing volume.

setExternalAudioStream:playoutVolume

Sets the playback volume for the external audio stream.

getExternalAudioStreamPlayoutVolume

Gets the playback volume of the external audio stream.

removeExternalAudioStream

Deletes the external stream.

Audio accompaniment

API

Function Description

getAudioFileInfo

Gets information about the audio accompaniment file.

startAudioAccompanyWithFile

Starts playing the accompaniment file.

stopAudioAccompany

Stops playing the accompaniment file.

setAudioAccompanyVolume

Sets the accompaniment volume.

setAudioAccompanyPublishVolume

Sets the publishing volume of the accompaniment file.

getAudioAccompanyPublishVolume

Gets the publishing volume of the accompaniment file.

setAudioAccompanyPlayoutVolume

Sets the playback volume of the accompaniment file.

getAudioAccompanyPlayoutVolume

Gets the playback volume of the accompaniment file.

pauseAudioAccompany

Pauses accompaniment playback.

resumeAudioAccompany

Resumes accompaniment playback.

getAudioAccompanyDuration

Gets the duration of the accompaniment file.

getAudioAccompanyCurrentPosition

Gets the current playback position of the accompaniment.

setAudioAccompanyPosition

Sets the accompaniment playback position.

Sound effect files

API

Function Description

preloadAudioEffectWithSoundId

Preloads a sound effect file.

unloadAudioEffectWithSoundId

Deletes a preloaded sound effect file.

playAudioEffectWithSoundId

Starts playing a sound effect.

stopAudioEffectWithSoundId

Stops playing a sound effect.

stopAllAudioEffects

Stops playing all sound effects.

pauseAudioEffectWithSoundId

Pauses a sound effect.

pauseAllAudioEffects

Pauses all sound effects.

resumeAudioEffectWithSoundId

Resumes a specified sound effect file.

resumeAllAudioEffects

Resumes all sound effect files.

setAudioEffectPublishVolumeWithSoundId

Sets the mixing volume for publishing a sound effect.

getAudioEffectPublishVolumeWithSoundId

Gets the mixing volume for publishing a sound effect.

setAllAudioEffectsPublishVolume

Sets the mixing volume for publishing all sound effects.

setAudioEffectPlayoutVolumeWithSoundId

Sets the local playback volume of a sound effect.

getAudioEffectPlayoutVolumeWithSoundId

Gets the local playback volume of a sound effect.

setAllAudioEffectsPlayoutVolume

Sets the local playback volume for all sound effects.

Record audio and video files

API

Function Description

startRecord

Records audio and video files (AAC, WAV, MP4).

stopRecord

Stops recording audio and video files.

Video device management interfaces

API

Function Description

setLocalViewConfig

Sets the rendering window and drawing parameters for the local preview.

setCameraCapturerConfiguration

Sets camera capture preferences.

enableLocalVideo

Disables or re-enables local video capture.

muteLocalCamera

Sets whether to stop publishing the local video stream.

setRemoteViewConfig

Sets the rendering window and drawing parameters for a remote video.

isCameraOn

Checks whether the camera is on.

setVideoEncoderConfiguration

Sets video encoding properties.

setVideoDecoderConfiguration

Sets video decoding properties.

startPreview

Starts the local preview.

stopPreview

Stops the local preview.

setVideoMirrorMode

Sets the mirroring capabilities for preview and publishing.

setCapturePipelineScaleMode

Sets the capture scaling timing, which determines whether video data is scaled immediately upon capture or during encoding.

Configure video data callbacks

API

Function Description

registerVideoFrameWithObserver

Registers a video data callback.

unregisterVideoSampleWithObserver

Unregisters a video data callback.

snapshotVideo

Takes a snapshot of the camera video.

registerVideoSampleObserver

Registers a video data output callback.

unRegisterVideoSampleObserver

Unregisters the video data output callback.

Configure audio data callbacks

API

Function Description

enableAudioFrameObserver

Sets audio callback parameters.

registerAudioFrameObserver

Registers an audio data callback.

Custom video input

API

Function Description

setExternalVideoSource

Enables an external video input source.

pushExternalVideoFrame

Inputs video data.

Screen sharing interfaces

API

Function Description

startScreenShareWithDesktopId

Starts publishing the screen sharing stream.

startScreenShareWithWindowId

Starts publishing the screen sharing stream.

StopScreenShare

Stops publishing the screen sharing stream.

updateScreenShareConfig

Sets the volume of the shared audio stream.

isScreenSharePublished

Checks whether screen sharing is being published.

setScreenShareEncoderConfiguration

Configures the screen sharing encoding parameters.

Bypass live streaming interfaces

API

Function Description

startPublishLiveStreamWithURL

Starts bypass live streaming.

updatePublishLiveStreamWithURL

Updates bypass live streaming parameters.

stopPublishLiveStreamWithURL

Stops bypass live streaming.

GetPublishLiveStreamStateWithURL

Gets the bypass live streaming status.

Network quality detection interfaces

API

Function Description

startLastmileDetect

Starts network quality detection.

stopLastmileDetect

Stops network quality detection.

SEI

API

Function Description

sendMediaExtensionMsg

Pushes an SEI stream.

sendMediaExtensionMsgEx

Pushes an SEI stream (extended).

Other interfaces

API

Function Description

setParameter

Sets custom parameters.

getParameter

Gets custom parameters.

setLogDirPath

Sets the path to save the SDK log file.

setLogLevel

Sets the log level.

setDeviceOrientationMode

Sets the device orientation.

getNetworkTime

Gets the network timestamp.

sendDataChannelMessage

Sends a data channel message.

Callback events

API

Function Description

onConnectionStatusChange

Callback for network connection status. The customer needs to handle this callback.

onLocalDeviceException

Callback for local device exceptions. The customer needs to handle this callback.

onAuthInfoWillExpire

Notification that the user authentication information is about to expire. The authentication expires 30 seconds after this notification is received. The customer needs to handle this callback.

onAuthInfoExpired

The server returns an information expiration message when the user calls an interface that requires authentication.

onJoinChannelResult[1/2]

Callback for the result of joining a channel.

onJoinChannelResult[2/2]

Callback for the result of joining a channel.

onLeaveChannelResult

Callback for the result of leaving a channel.

onRemoteUserOffLineNotify

Notification that a remote user has gone offline.

onRemoteUserOnLineNotify

Notification that a remote user has come online.

onRemoteTrackAvailableNotify

Notification about remote stream publishing information.

onBye

Message indicating that the user was kicked out by the server or the session has ended.

onAudioPublishStateChanged

Notification of a change in the audio publishing state.

onAudioSubscribeStateChanged

Notification of a change in the audio subscription state.

onUserAudioMuted

Notification that a remote user is muted.

onUserAudioInterruptedBegin

Notification that an audio device interruption has started.

onUserAudioInterruptedEnded

Notification that an audio device interruption has ended.

onVideoPublishStateChanged

Callback for a change in the video publishing state.

onVideoSubscribeStateChanged

Callback for a change in the camera stream subscription state.

onUserVideoMuted

Notification that a remote user is sending black video frames.

onUserVideoEnabled

Notification that a remote user has disabled camera stream capture.

onUserWillResignActive

A remote user's application has moved to the background.

onUserWillBecomeActive

A remote user's application has returned to the foreground.

onAudioEffectFinished

Callback for when local sound effect playback finishes.

onAudioVolumeCallback

The audio volume, speech status, and UID of the subscribed audio.

onActiveSpeaker

Callback for active speaker detection.

onPublishLiveStreamStateChanged

Callback for a change in the bypass stream publishing state.

onPublishTaskStateChanged

Callback for a change in the bypass task state.

onNetworkQualityChanged

Callback for a change in network quality.

onLastmileDetectResultWithQuality

Callback for network quality detection.

onLastmileDetectResultWithBandWidth

Callback for the result of network quality detection.

onOccurError

This callback notifies the application of an engine error.

onFirstAudioPacketSentWithTimecost

Callback for the first audio packet sent.

onFirstVideoFrameReceivedWithUid

Callback for the first video frame received.

onFirstVideoPacketSentWithVideoTrack

Callback for the first video packet sent.

onFirstAudioPacketReceivedWithUid

Callback for the first audio packet received.

onFirstRemoteAudioDecodedWithUid

Callback for the first decoded remote audio frame.

onFirstRemoteVideoFrameDrawn

This message is triggered when the first video frame of a remote user is displayed.

onFirstLocalVideoFrameDrawn

This message is triggered when the first video frame is displayed in the preview.

onTestAudioVolumeCallback

Callback for the volume from the pre-call audio capture test.

onAudioAccompanyStateChanged

Callback for the local accompaniment playback state.

onRemoteAudioAccompanyStarted

Callback for when a remote user starts accompaniment playback.

onRemoteAudioAccompanyFinished

Callback for when a remote user finishes accompaniment playback.

onRtcStats

Real-time data callback (triggered every 2 seconds).

onRtcLocalVideoStats

Local video statistics (triggered every 2 seconds).

onRtcRemoteVideoStats

Remote video statistics (triggered every 2 seconds).

onRtcLocalAudioStats

Local audio statistics (triggered every 2 seconds).

onRtcRemoteAudioStats

Remote audio statistics (triggered every 2 seconds).

onMediaExtensionMsgReceived

Callback for receiving a media extension message.

onSnapshotComplete

Snapshot callback.

onLocalAudioStateChanged

Callback for the local audio capture device state.

onLocalVideoStateChanged

Callback for the local video capture device state.

onRemoteUserSubscribedDataChannel

Callback indicating that you can start sending data channel messages.

onDataChannelMessage

Callback for data channel messages.

onScreenSharePublishStateChanged

Callback for a change in the screen sharing publishing state.

AliRtcAudioFrameDelegate

API

Function Description

onCapturedAudioFrame

Callback for captured raw data.

onProcessCapturedAudioFrame

Callback for data after 3A processing.

onPublishAudioFrame

Callback for published stream data.

onPlaybackAudioFrame

Callback for playback data.

onRemoteUserAudioFrame

Callback for remote stream data.

AliRtcEngineDestroyDelegate

API

Function Description

onDestroyCompletion

Callback for when the engine is destroyed. The engine is considered destroyed only after this callback is executed.

AliRtcVideoFrameDelegate

API

Function Description

onCaptureVideoSample

Callback for captured video frames.

onPreEncodeVideoSample

Callback for subscribed local video data before encoding.

onRemoteVideoSample

Callback for subscribed remote video data.

onGetVideoFormatPreference

Video data output format.

onGetVideoObservedFramePosition

Video data output position.

API details

sharedInstance

Creates an `AliRtcEngine` instance.

+ (instancetype _Nonnull )sharedInstance:(id<AliRtcEngineDelegate>_Nullable)delegate extras:(NSString *_Nullable)extras;

Parameters

Name

Type

Description

delegate

id<AliRtcEngineDelegate>_Nullable

The delegate for listening to callbacks.

extras

NSString *_Nullable

Configures special features of the SDK using JSON Configurations. If no special features are required, enter an empty string: "".

Important

Only one primary instance can exist at a time.

destroy[1/2]

Destroys the SDK instance.

+ (void)destroy;
Important

Call this method after you complete all operations.

destroy[2/2]

Destroys the engine with a callback.

+ (void)destroy:(id<AliRtcEngineDestroyDelegate>_Nullable)delegate;

Parameters

Name

Type

Description

delegate

id<AliRtcEngineDestroyDelegate> _Nullable

The object for the post-release callback.

Important

This is an asynchronous method. Wait for the `onDestroyCompletion` callback to complete before you call other methods. To avoid blocking the main thread, call this method in a subthread. If you want to create another `{@link AliRtcEngine}` instance after destruction, ensure that the `destroy` method has finished executing before you create the new instance.

setH5CompatibleMode

Sets whether to enable H5 compatibility mode.

+ (void)setH5CompatibleMode:(BOOL)comp;

Parameters

Name

Type

Description

comp

BOOL

YES indicates that H5 compatibility is enabled. NO indicates that H5 compatibility is disabled. The default value is NO.

Important

In the current version, you cannot change the H5 compatibility mode after an `AliRtcEngine` instance is created. You must call this method before you create the instance.

getH5CompatibleMode

Checks whether H5 compatibility mode is enabled.

+ (BOOL)getH5CompatibleMode;

Return value

Returns `YES` if H5 compatibility is enabled or `NO` if H5 compatibility is disabled.

setChannelProfile

Sets the channel profile.

- (int)setChannelProfile:(AliRtcChannelProfile)profile;

Parameters

Name

Type

Description

profile

AliRtcChannelProfile

The channel profile. The default value is AliRtcCommunication. For RTC scenarios, set this to the interactive mode (AliRtcInteractivelive).

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

You can call this method only before you join a channel. You cannot change the channel profile during a session, but you can change it after you leave the channel.

setAudioProfile

Sets the audio profile.

- (int)setAudioProfile:(AliRtcAudioProfile)audio_profile audio_scene:(AliRtcAudioScenario)audio_scene;

Parameters

Name

Type

Description

audio_profile

AliRtcAudioProfile

The audio capture or encoding mode. We recommend that you use the high-quality mode (AliRtcEngineHighQualityMode).

Note

To interoperate with a web client, set the sample rate to 48 kHz.

  • AliRtcEngineLowQualityMode: Low-quality audio mode. Default sample rate: 8,000 Hz. Mono channel. Maximum encoding bitrate: 12 kbps.

  • AliRtcEngineBasicQualityMode: Standard-quality audio mode. Default sample rate: 16,000 Hz. Mono channel. Maximum encoding bitrate: 24 kbps.

  • AliRtcEngineHighQualityMode: High-quality audio mode. Default sample rate: 48,000 Hz. Mono channel. Maximum encoding bitrate: 64 kbps.

  • AliRtcEngineStereoHighQualityMode: High-quality stereo audio mode. Default sample rate: 48,000 Hz. Stereo channel. Maximum encoding bitrate: 80 kbps.

  • AliRtcEngineSuperHighQualityMode: Ultra-high-quality audio mode. Default sample rate: 48,000 Hz. Mono channel. Maximum encoding bitrate: 96 kbps.

  • AliRtcEngineStereoSuperHighQualityMode: Ultra-high-quality stereo audio mode. Default sample rate: 48,000 Hz. Stereo channel. Maximum encoding bitrate: 128 kbps.

audio_scene

AliRtcAudioScenario

The audio scenario. It includes the following modes:

  • AliRtcSceneMusicMode (Recommended): The music scenario. This mode uses software-based 3A algorithms and captures audio from the device for higher audio quality.

  • AliRtcSceneDefaultMode: The default scenario. This mode uses hardware-based 3A algorithms and can capture audio from Bluetooth devices.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

isAudioOnly

Checks whether the current mode is audio-only.

- (BOOL)isAudioOnly;

Return value

Returns `YES` for audio-only mode or `NO` for audio and video mode.

setAudioOnlyMode

Sets the mode to audio-only or audio and video.

- (int)setAudioOnlyMode:(BOOL)audioOnly;

Parameters

Name

Type

Description

audioOnly

BOOL

YES indicates that only audio is published and subscribed. NO indicates that both audio and video are supported. The default value is NO.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

joinChannel[1/4]

Joins a channel.

- (int)joinChannel:(NSString _Nonnull)token channelId:(NSString _Nullable)channelId userId:(NSString _Nullable)userId name:(NSString _Nullable)userName onResultWithUserId:(void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSString _Nonnull userId, NSInteger elapsed))onResult;

After you successfully join a channel, you must call `leaveChannel` to leave the current channel before you can join another one. If you fail to join a channel, you can try to join again without calling `leaveChannel`.

Parameters

Parameter

Type

Description

token

String

The authentication information for joining a channel with a single parameter.

channelId

String

The channel to join. This must be the same as the channel ID used to generate the token.

userId

String

The user ID for joining the channel. This must be the same as the user ID used to generate the token.

userName

String

The display name of the user, not the user ID.

onResultWithUserId

void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSString _Nonnull userId, NSInteger elapsed)

The callback that is invoked when this interface call is complete.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This is an asynchronous method. The result of joining the channel is returned in the `onJoinChannelResult` callback.

joinChannel[2/4]

Joins a channel.

- (int)joinChannel:(AliRtcAuthInfo _Nonnull)authInfo name:(NSString _Nullable)userName onResultWithUserId:(void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSString _Nonnull userId, NSInteger elapsed))onResult;

After you successfully join a channel, you must call `leaveChannel` to leave the current channel before you can join another one. If you fail to join a channel, you can try to join again without calling `leaveChannel`.

Parameters

Name

Type

Description

authInfo

AliRtcAuthInfo

The authentication information.

userName

String

The display name of the user, not the user ID.

onResultWithUserId

void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSString _Nonnull userId, NSInteger elapsed)

The callback that is invoked when this interface call is complete.

joinChannel[3/4]

Joins a channel.

- (int)joinChannel:(AliRtcAuthInfo _Nonnull)authInfo name:(NSString _Nullable)userName onResult:(void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSInteger elapsed))onResult;

After you successfully join a channel, you must call `leaveChannel` to leave the current channel before you can join another one. If you fail to join a channel, you can try to join again without calling `leaveChannel`.

Parameters

Name

Type

Description

authInfo

AliRtcAuthInfo

The authentication information.

userName

String

The display name of the user, not the user ID.

onResult

void(^_Nullable)(NSInteger errCode,NSString _Nonnull channel,NSInteger elapsed)

The callback that is invoked when this interface call is complete.

joinChannel[4/4]

Joins a channel.

- (int)joinChannel:(NSString _Nonnull)token channelParam:(AliRtcChannelParam _Nonnull)channelParam onResultWithUserId:(void(^_Nullable)(NSInteger errCode, NSString _Nonnull channel, NSString _Nonnull userId, NSInteger elapsed))onResult;

After you successfully join a channel, you must call `leaveChannel` to leave the current channel before you can join another one. If you fail to join a channel, you can try to join again without calling `leaveChannel`.

Parameters

Name

Type

Description

token

NSString

The authentication information obtained from your App Server.

channelParam

AliRtcChannelParam

The parameters for joining the channel.

onResult

void(^_Nullable)(NSInteger errCode,NSString _Nonnull channel,NSInteger elapsed)

The callback that is invoked when this interface call is complete.

leaveChannel

Leaves the current channel.

- (int)leaveChannel;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

isInCall

Checks whether the user is in the channel.

- (BOOL)isInCall;

Return value

Returns `YES` if the user is in the channel or `NO` if the user is not in the channel.

setClientRole

Sets the user role.

- (int)setClientRole:(AliRtcClientRole)role;

Parameters

Name

Type

Description

role

AliRtcClientRole

The user role. The default value is AliRtcClientRoleLive (viewer). The role type is valid only in non-communication modes.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getClientRole

Retrieves the user role.

- (AliRtcClientRole)getClientRole;

Return value

Returns the current user role.

refreshAuthInfo

Refreshes the authentication information.

- (int)refreshAuthInfo:(AliRtcAuthInfo _Nonnull)authInfo;

Parameters

Name

Type

Description

authInfo

AliRtcAuthInfo _Nonnull

The authentication information.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

refreshAuthInfoWithToken

Refreshes the authentication information.

- (int)refreshAuthInfoWithToken:(NSString _Nonnull)token;

Parameters

Name

Type

Description

token

NSString _Nonnull

The authentication information for joining a channel with a single parameter.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

publishLocalAudioStream

Enables or disables publishing of the local audio stream.

- (int)publishLocalAudioStream:(BOOL)enabled;

Parameters

Name

Type

Description

enable

BOOL

YES indicates that the local audio stream is sent. NO indicates that publishing is stopped. The default value is YES.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

isLocalAudioStreamPublished

Checks whether the local audio stream is being published.

- (BOOL)isLocalAudioStreamPublished;

Return value

Returns `YES` if publishing is allowed or `NO` if publishing is not allowed.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to subscribe to remote audio streams by default.

- (int)setDefaultSubscribeAllRemoteAudioStreams:(BOOL)sub;

Parameters

Name

Type

Description

sub

BOOL

YES indicates that the audio streams of users are received. NO indicates that receiving the audio streams of users is stopped. The default value is YES.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important
  • You can call this method before or after you join a channel. If you call setDefaultSubscribeAllRemoteAudioStreams:NO after you join a channel, you will not receive the audio streams of users who join after the setting is applied.

  • After you stop receiving audio streams, if you want to resume receiving the audio stream of a specific user, call `subscribeRemoteAudioStream:uid sub:YES` to subscribe to that user's stream.

  • To resume receiving audio streams from multiple users, you must call the AliRtcEngine interface multiple times. setDefaultSubscribeAllRemoteAudioStreams:YES only resumes receiving audio streams from users who subsequently join the channel.

subscribeAllRemoteAudioStreams

Stops or resumes receiving all remote audio streams.

- (int)subscribeAllRemoteAudioStreams:(BOOL)sub;

Parameters

Name

Type

Description

sub

BOOL

YES indicates that the audio streams of all users are received. NO indicates that receiving the audio streams of all users is stopped. The default value is YES.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This interface acts as a master switch for subscribing to remote audio streams. If this parameter is set to NO, you will be unsubscribed from all current remote audio streams and will not be subscribed to the audio streams of new users who join the session, even if the AliRtcEngine interface is set to YES.

subscribeRemoteAudioStream

Stops or resumes receiving the audio stream of a specific remote user.

- (int)subscribeRemoteAudioStream:(NSString _Nonnull)uid sub:(BOOL)sub;

Parameters

Name

Type

Description

uid

NSString _Nonnull

The remote user ID.

sub

BOOL

YES indicates that the audio stream of the specified user is received. NO indicates that receiving the audio stream of the specified user is stopped. The default value is YES.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

If you have muted all remote audio by calling the AliRtcEngine interface with NO, you must call the AliRtcEngine interface with YES before you call this API. The AliRtcEngine interface provides global control, while the AliRtcEngine interface provides fine-grained control.

publishLocalVideoStream

Enables or disables publishing of the local camera stream.

- (int)publishLocalVideoStream:(BOOL)enabled;

Parameters

Name

Type

Description

enable

BOOL

YES indicates that the video is sent. NO indicates that sending is stopped. The default value is YES.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

isLocalVideoStreamPublished

Checks whether the local camera stream is being published.

- (BOOL)isLocalVideoStreamPublished;

Return value

Returns `YES` if the camera stream is published or `NO` if the camera stream is not published.

setDefaultSubscribeAllRemoteVideoStreams

Sets whether to subscribe to remote video streams by default.

- (int)setDefaultSubscribeAllRemoteVideoStreams:(BOOL)sub;

Parameters

Name

Type

Description

sub

BOOL

YES indicates that the video streams of users are received. NO indicates that receiving the video streams of users is stopped. The default value is YES.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important
  • You can call this method before or after you join a channel. If you call setDefaultSubscribeAllRemoteVideoStreams:NO after you join a channel, you will not receive the video streams of users who join after the setting is applied.

  • If you stop receiving video streams and want to resume, call the AliRtcEngine interface: uid track:track sub:YES, and specify the UID of the remote user whose stream you want to receive.

  • To resume receiving video streams from multiple users, you must make multiple calls through the AliRtcEngine interface. Calling setDefaultSubscribeAllRemoteVideoStreams:YES only resumes video streams from users who join the channel afterward.

subscribeAllRemoteVideoStreams

Stops or resumes receiving all remote video streams.

- (int)subscribeAllRemoteVideoStreams:(BOOL)sub;

Parameters

Name

Type

Description

sub

BOOL

YES indicates that the video streams of all users are received. NO indicates that receiving the video streams of all users is stopped. The default value is YES.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This interface is the master switch for subscribing to remote video streams. If this parameter is set to NO, all current remote video streams are unsubscribed, and new users joining the session will not be subscribed. This occurs even if the AliRtcEngine interface is set to YES.

subscribeRemoteMediaStream [1/2]

Stops or resumes receiving the media stream of a specific remote user.

- (int)subscribeRemoteMediaStream:(NSString _Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack subVideo:(BOOL)subVideo subAudio:(BOOL)subAudio;

Parameters

Parameter

Type

Description

uid

NSString

The remote user ID.

videoTrack

AliRtcVideoTrack

The video stream type.

subVideo

BOOL

Stops or resumes receiving the video stream of a specific remote user. Valid values:
true (default): Resumes.
false: Stops.




subAudio

BOOL

Stops or resumes receiving the audio stream of a specific remote user. Valid values:
true (default): Resumes.
false: Stops.




Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

subscribeRemoteMediaStream [2/2]

Stops or resumes receiving the media stream of a specific remote user.

- (int)subscribeRemoteMediaStream:(NSString _Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack audioTrack:(AliRtcAudioTrack)audioTrack;

Parameters

Parameter

Type

Description

uid

NSString

The remote user ID.

videoTrack

AliRtcVideoTrack

The video stream type.

audioTrack

AliRtcAudioTrack

The audio stream type.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

This method informs the SDK of the desired state using the videoTrack and audioTrack parameters.

subscribeRemoteDestChannelStream

Subscribes to the stream of a specified user in another channel.

- (int)subscribeRemoteDestChannelStream:(NSString _Nonnull)channelId uid:(NSString _Nonnull)uid track:(AliRtcVideoTrack)track subAudio:(BOOL)subAudio sub:(BOOL)sub;

Parameters

Parameter

Type

Description

channelId

NSString

The remote channel ID.

uid

NSString

The remote user ID.

track

AliRtcVideoTrack

The video stream to subscribe to.

subAudio

BOOL

Stops or resumes receiving the audio stream of a specific remote user. Valid values:
true (default): Resumes.
false: Stops.




sub

BOOL

Stops or resumes subscribing to the stream of a specified user in another channel.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

muteLocalMic

Mutes or unmutes the local microphone.

- (int)muteLocalMic:(BOOL)mute mode:(AliRtcMuteLocalAudioMode)mode;

Parameters

Name

Type

Description

mute

BOOL

YES indicates that silent audio frames are sent. NO indicates that normal sending is resumed. The default value is NO.

mode

AliRtcMuteLocalAudioMode

The mute mode. The default is microphone mute mode.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

Muting sends silent audio frames, but the capture and encoding modules continue to operate.

muteRemoteAudioPlaying

Stops or resumes playing a remote audio stream.

- (int)muteRemoteAudioPlaying:(NSString _Nonnull)uid mute:(BOOL)mute;

Parameters

Name

Type

Description

uid

NSString _Nonnull

The user ID.

mute

BOOL

YES indicates that playback is stopped. NO indicates that playback is resumed. The default value is NO.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

muteAllRemoteAudioPlaying

Stops or resumes playing all remote audio streams.

- (int)muteAllRemoteAudioPlaying:(BOOL)mute;

Parameters

Name

Type

Description

mute

BOOL

YES indicates that playback is stopped. NO indicates that playback is resumed. The default value is NO.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

You can configure this setting before or after calling the AliRtcEngine interface without affecting stream pulling and decoding.

startAudioCapture [1/2]

Starts audio capture.

- (void)startAudioCapture;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

You can use this method to start audio capture in advance. If you do not call this method, the SDK starts audio capture at the appropriate time.

startAudioCapture [2/2]

Starts audio capture.

- (void)startAudioCapture:(BOOL)keepAlive;

Parameters

Parameter

Type

Description

keepAlive

BOOL

The state of the capture device after leaving the channel. Valid values:
true: The capture device remains on after leaving the channel.
false (default): The capture device is turned off after leaving the channel.




Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

stopAudioCapture

Stops audio capture. This method corresponds to `startAudioCapture`.

- (void)stopAudioCapture;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

startRecord

Starts local audio and video recording.

- (BOOL)startRecord:(AliRtcRecordType)recordType recordFormat:(AliRtcRecordFormat)recordFormat filePath:(NSString)filePath audioConfig:(AliRtcRecordAudioConfig)audioConfig videoConfig:(AliRtcRecordVideoConfig)videoConfig;

Parameters

Name

Type

Description

recordType

AliRtcRecordType

The recording type.

recordFormat

AliRtcRecordFormat

The recording format.

filePath

NSString

The recording file name and path.

audioConfig

AliRtcRecordAudioConfig

The audio configuration.

videoConfig

AliRtcRecordVideoConfig

The video configuration.

Return value

Returns `TRUE` on success or another value on failure.

Important

If you are recording a video file, call this interface after the stream is successfully published (onVideoPublishStateChanged). This records the locally encoded video stream to a local file. If you are recording an audio stream, the recorded file is a mix of local and remote audio.

stopRecord

Stops the current recording operation.

- (void)stopRecord;

Return value

None

playAudioFileTest

Tests the playback of an audio file from a specified path.

- (int)playAudioFileTest:(NSString _Nonnull)filePath;

Parameters

Name

Type

Description

filePath

NSString _Nonnull

The path of the file to play.

Return value

Returns 0 on success or another value on failure.

Important

You must call this method before you call `JoinChannel`.

stopAudioFileTest

Stops playing the current audio file.

- (int)stopAudioFileTest;

Return value

Returns 0 on success or another value on failure.

Important

You must call this method before you call `JoinChannel`.

enableAudioVolumeIndication

Enables or disables the volume and speaker detection callback.

- (int)enableAudioVolumeIndication:(NSInteger)interval smooth:(NSInteger)smooth reportVad:(NSInteger)reportVad;

Parameters

Name

Type

Description

interval

NSInteger

The time interval in milliseconds. The minimum value is 10 ms. We recommend setting this to 300-500 ms. A value less than or equal to 0 disables the volume and speaker detection features.

smooth

NSInteger

The smoothing coefficient. The range is [0, 9]. A larger value provides more smoothing but less real-time accuracy. We recommend setting this to 3.

reportVad

NSInteger

The speaker detection switch. Valid values: 1: On. The status of each speaker is reported through the callback. 0: Off.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

enableEarBack

Enables or disables the in-ear monitoring feature.

- (int)enableEarBack:(BOOL)enable;

Parameters

Name

Type

Description

enable

BOOL

YES indicates that in-ear monitoring is enabled. NO indicates that in-ear monitoring is disabled. The default value is NO.

Response description

Returns 0 if the method call is successful or a non-zero value if it fails.

setEarBackVolume

You can set the output volume for in-ear monitoring.

- (int)setEarBackVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The range is [0, 100]. The default value is 100.

Return value

A return value of 0 indicates success. A non-zero value indicates failure.

setAudioEffectVoiceChangerMode

Sets the voice changer effect mode.

- (int)setAudioEffectVoiceChangerMode:(AliRtcAudioEffectVoiceChangerMode)mode;

Parameters

Name

Type

Description

mode

AliRtcAudioEffectVoiceChangerMode

The mode value. The default value is AliRtcSdk_AudioEffect_Voice_Changer_OFF.

Return value

Returns 0 on success or a non-zero value on failure.

setAudioEffectPitchValue

- (int)setAudioEffectPitchValue:(double)value;

Parameters

Name

Type

Description

value

double

The value range is [0.5, 2.0]. The default value is 1.0, which indicates that the pitch is unchanged.

Return value

Returns 0 if the method was called successfully or another value if the call failed.

setAudioEffectReverbMode

Sets the audio reverberation effect mode.

- (int)setAudioEffectReverbMode:(AliRtcAudioEffectReverbMode)mode;

Parameters

Name

Type

Description

mode

AliRtcAudioEffectReverbMode

The sound effect mode. The default value is AliRtcAudioEffectReverb_Off.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setAudioEffectReverbParamType

Sets the audio reverberation effect mode.

- (int)setAudioEffectReverbParamType:(AliRtcAudioEffectReverbParamType)type value:(float)value;

Parameters

Name

Type

Description

type

AliRtcAudioEffectReverbParamType

The sound effect reverb pattern.

value

float

The specific parameter value.

Response description

Returns 0 if the method call is successful or a non-zero value if it fails.

addExternalAudioStream

Registers an external audio input stream.

- (int)addExternalAudioStream:(AliRtcExternalAudioStreamConfig _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcExternalAudioStreamConfig

The external audio stream configuration.

Response Description

If successful, this method returns a value greater than 0, which is the external audio stream ID. Otherwise, it returns a failure code.

pushExternalAudioStream

- (int)pushExternalAudioStream:(int)streamId rawData:(AliRtcAudioFrame _Nonnull)audioFrame;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

audioFrame

AliRtcAudioFrame

The audio data.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setExternalAudioStream:publishVolume

Sets the publishing volume of a specified external audio stream.

- (int)setExternalAudioStream:(int)streamId publishVolume:(int)publishVolume;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

publishVolume

int

The publishing volume.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getExternalAudioStreamPublishVolume

Retrieves the publishing volume of a specified external audio stream.

- (int)getExternalAudioStreamPublishVolume:(int)streamId;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

Return value

Returns the publishing volume in the range of [0, 100]. A value less than 0 indicates failure.

setExternalAudioStream:playoutVolume

Sets the local playback volume of a specified external audio stream.

- (int)setExternalAudioStream:(int)streamId playoutVolume:(int)playoutVolume;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

playoutVolume

int

The playback volume.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getExternalAudioStreamPlayoutVolume

Retrieves the local playback volume of a specified external audio stream.

- (int)getExternalAudioStreamPlayoutVolume:(int)streamId;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

Return value

Returns the playback volume in the range of [0, 100]. A value less than 0 indicates failure.

preloadAudioEffectWithSoundId

Preloads a specified sound effect file into memory.

- (int)preloadAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString _Nonnull)filePath;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

filePath

NSString _Nonnull

The path of the sound effect file.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

unloadAudioEffectWithSoundId

Unloads the sound effect file with the specified ID from memory.

- (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

playAudioEffectWithSoundId

Plays the sound effect file with the specified ID.

- (int)playAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString _Nonnull)filePath cycles:(NSInteger)cycles publish:(BOOL)publish;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

filePath

NSString _Nonnull

The path of the sound effect file.

cycles

NSInteger

The number of loops. You can set this to -1 or a positive integer.

publish

BOOL

Whether to publish.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

stopAudioEffectWithSoundId

Stops playing the sound effect with the specified ID.

- (int)stopAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

stopAllAudioEffects

Stops all currently playing sound effects.

- (int)stopAllAudioEffects;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

pauseAudioEffectWithSoundId

Pauses the playback of the sound effect with the specified ID.

- (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

pauseAllAudioEffects

Pauses all currently playing sound effects.

- (int)pauseAllAudioEffects;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

resumeAudioEffectWithSoundId

Resumes the playback of the sound effect with the specified ID.

- (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

resumeAllAudioEffects

Resumes playback of all paused sound effects.

- (int)resumeAllAudioEffects;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setAudioEffectPublishVolumeWithSoundId

Sets the mixing volume of a specified sound effect in the published stream.

- (int)setAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

volume

NSInteger

The mixing volume. The range is [0, 100]. The default value is 50.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getAudioEffectPublishVolumeWithSoundId

Retrieves the mixing volume of a specified sound effect in the published stream.

- (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

setAllAudioEffectsPublishVolume

Sets the mixing volume for publishing all sound effects.

- (int)setAllAudioEffectsPublishVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The mixing volume. The range is [0, 100]. The default value is 50.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setAudioEffectPlayoutVolumeWithSoundId

Sets the local playback volume of a sound effect.

- (int)setAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

volume

NSInteger

The mixing volume. The range is [0, 100]. The default value is 50.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

getAudioEffectPlayoutVolumeWithSoundId

Retrieves the local playback volume of a sound effect.

- (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

The ID assigned to the sound effect file by the user.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setAllAudioEffectsPlayoutVolume

Sets the local playback volume for all sound effects.

- (int)setAllAudioEffectsPlayoutVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The mixing volume. The range is [0, 100]. The default value is 50.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setLocalViewConfig

Sets the rendering window and drawing parameters for the local preview.

- (int)setLocalViewConfig:(AliVideoCanvas _Nullable)viewConfig forTrack:(AliRtcVideoTrack)track;

Parameters

Name

Type

Description

viewConfig

AliVideoCanvas _Nullable

The rendering parameters, including the rendering window and rendering method.

track

AliRtcVideoTrack

The video track type.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

Note

You can switch windows before or after you call the `joinChannel` method. If `canvas` or `AliVideoCanvas::view` is `nil`, rendering stops. To reset the render mode during playback, keep the other member variables in the canvas unchanged and modify only `renderMode`. To reset the mirror mode during playback, keep the other member variables in the canvas unchanged and modify only `mirrorMode`.

setCameraCapturerConfiguration

Sets camera capture preferences.

- (int)setCameraCapturerConfiguration:(AliRtcCameraCapturerConfiguration _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcCameraCapturerConfiguration _Nonnull

The camera capture preferences. Default values:
preference: 0
cameraDirection: 0
fps: 0
cameraCaptureProfile: 0
disableVideoCaptureReverse: -1
enableCameraMacroFocus: -1
captureObserverOriginal: -1
nativeBufferObserver: -1
captureCallbackCvpixelbufferToRaw: -1
A value of -1 indicates that the SDK's internal default settings are used.




























Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

enableLocalVideo

Disables or re-enables local video capture.

- (int)enableLocalVideo:(BOOL)enable;

Parameters

Name

Type

Description

enable

BOOL

YES indicates that normal operation is resumed. NO indicates that video capture is stopped. The default value is YES.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

muteLocalCamera

Mutes or unmutes the local camera.

- (int)muteLocalCamera:(BOOL)mute forTrack:(AliRtcVideoTrack)track;

This method only controls whether to send black frames on the specified video stream. The local preview remains on the last frame, and capture and data sending do not stop. To stop capture, use `enableLocalVideo`. To stop sending video data, use `publishLocalVideoStream`.

Parameters

Name

Type

Description

mute

BOOL

YES indicates that black frames are sent. NO indicates that normal sending is resumed. The default value is NO.

track

AliRtcVideoTrack

The video track type whose publishing state needs to be changed.

Response description

Returns 0 if the method call is successful or a non-zero value if it fails.

setRemoteViewConfig

Sets the rendering window and drawing parameters for a remote video.

- (int)setRemoteViewConfig:(AliVideoCanvas _Nullable)canvas uid:(NSString _Nonnull)uid forTrack:(AliRtcVideoTrack)track;

You can switch windows before or after you call the `joinChannel` method. If `canvas` or `view` is `nil`, rendering of the corresponding stream stops. To reset the render mode during playback, keep the other member variables in the canvas unchanged and modify only `renderMode`. To reset the mirror mode during playback, keep the other member variables in the canvas unchanged and modify only `mirrorMode`.

Parameters

Name

Type

Description

canvas

AliVideoCanvas _Nullable

The rendering parameters, including the rendering window and rendering method.

uid

NSString _Nonnull

The user ID.

track

AliRtcVideoTrack

The video track type to set.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

isCameraOn

Checks whether the camera is on.

- (BOOL)isCameraOn;

Response description

Returns `YES` if the camera is on or `NO` if the camera is not on.

setVideoEncoderConfiguration

Sets video encoding properties.

- (void)setVideoEncoderConfiguration:(AliRtcVideoEncoderConfiguration _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcVideoEncoderConfiguration _Nonnull

The predefined encoding properties. Default values:
dimensions: [640, 480]
frameRate: 15
bitrate: 0
mirrorMode: 0
orientationMode: 0
rotation: 0
codecType: AliRtcVideoCodecTypeDefault
encoderType: AliRtcVideoEncodeCodecTypeDefault
seiForceFrontIFrame: -1
enableDynamicEncode: -1
disableDipenseResolutionChange: -1
enableDowngrade: -1
enableH264BFrame: -1
enableHevcBFrame: -1
backgroundHardwareToSoftware: -1
A value of -1 indicates that the SDK's internal default settings are used.














































setVideoDecoderConfiguration

Sets video decoding properties.

- (void)setVideoDecoderConfiguration:(AliRtcVideoDecoderConfiguration _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcVideoDecoderConfiguration _Nonnull

The predefined decoding properties. Default values:
codecType: AliRtcVideoCodecTypeDefault
enableDecoderBframe: -1
backgroundHardwareToSoftware: -1
A value of -1 indicates that the SDK's internal default settings are used.










startPreview

Starts the local preview, which automatically turns on the camera.

- (int)startPreview;

If no view is set, the preview is not available. You can start the preview before you call the `joinChannel` method.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

stopPreview

Stops the local preview.

- (int)stopPreview;

`leaveChannel` automatically stops the local preview and turns off the camera. However, if a camera stream is being published, the camera is not turned off.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setExternalVideoSource

Enables an external video input source.

- (int)setExternalVideoSource:(BOOL)enable sourceType:(AliRtcVideoSource)type renderMode:(AliRtcRenderMode)renderMode;

Parameters

Name

Type

Description

enable

BOOL

YES indicates enabled. NO indicates disabled.

type

AliRtcVideoSource

The stream type.

renderMode

AliRtcRenderMode

The rendering mode.

pushExternalVideoFrame

Enter the video data.

- (int)pushExternalVideoFrame:(AliRtcVideoDataSample _Nonnull)frame sourceType:(AliRtcVideoSource)type;

Parameters

Name

Type

Description

frame

AliRtcVideoDataSample _Nonnull

The frame data.

type

AliRtcVideoSource

The stream type.

Response description

Returns 0 if the method call is successful or a non-zero value if it fails.

startScreenShareWithDesktopId

Starts sharing the screen stream that corresponds to the specified desktop ID.

- (int)startScreenShareWithDesktopId:(int)desktopId config:(AliRtcScreenShareConfig * _Nonnull)config;

Parameters

Name

Type

Description

desktopId

int

The desktop ID.

config

AliRtcScreenShareConfig

The desktop sharing configuration.

Return value

  • 0: Success

  • Other: Failure

startScreenShareWithWindowId

Uses the specified window ID as a video source to share and publish a video stream.

- (int)startScreenShareWithWindowId:(int)windowId config:(AliRtcScreenShareConfig * _Nonnull)config;

Parameters

Name

Type

Description

windowId

int

The window ID.

config

AliRtcScreenShareConfig

The screen sharing configuration.

Return value

  • 0: Success

  • Other: Failure

StopScreenShare

Stops screen sharing.

- (int)stopScreenShare;

Parameters

None

Return value

  • 0: Success

  • Other: Failure

updateScreenShareConfig

Updates the screen sharing configuration.

- (int)updateScreenShareConfig:(AliRtcScreenShareConfig * _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcScreenShareConfig

The screen sharing configuration.

Return value

  • 0: Success

  • Other: Failure

isScreenSharePublished

Checks whether the screen sharing stream is being published.

- (BOOL)isScreenSharePublished;

Parameters

None

Return value

  • `TRUE`: Screen sharing is in progress.

  • `FALSE`: Screen sharing is not in progress.

startPublishLiveStreamWithURL

Starts bypass live streaming.

- (int)startPublishLiveStreamWithURL:(NSString _Nonnull)streamURL liveTranscoding:(AliRtcLiveTranscodingParam _Nonnull)trancoding;

Parameters

Name

Type

Description

streamURL

NSString _Nonnull

The ingest URL.

trancoding

AliRtcLiveTranscodingParam _Nonnull

The parameters required for stream ingest.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

updatePublishLiveStreamWithURL

Updates bypass live streaming parameters.

- (int)updatePublishLiveStreamWithURL:(NSString _Nonnull)streamURL liveTranscoding:(AliRtcLiveTranscodingParam _Nonnull)trancoding;

Parameters

Name

Type

Description

streamURL

NSString _Nonnull

The ingest URL.

trancoding

AliRtcLiveTranscodingParam _Nonnull

The parameters required for stream ingest.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

stopPublishLiveStreamWithURL

Stops bypass live streaming.

- (int)subscribeRemoteDestChannelAllStream:(NSString _Nonnull)channelId track:(AliRtcVideoTrack)track subAudio:(BOOL)subAudio sub:(BOOL)sub;

Parameters

Name

Type

Description

streamURL

NSString _Nonnull

The ingest URL.

Response description

Returns 0 if the method call is successful or a non-zero value if it fails.

GetPublishLiveStreamStateWithURL

Retrieves the bypass live streaming status.

- (AliRtcLiveTranscodingState)GetPublishLiveStreamStateWithURL:(NSString _Nonnull)streamURL;

Parameters

Name

Type

Description

streamURL

NSString _Nonnull

The ingest URL.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

startLastmileDetect

Starts network quality detection.

- (int)startLastmileDetect:(AliRtcNetworkQualityProbeConfig _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcNetworkQualityProbeConfig _Nonnull

The detection configuration parameters.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

stopLastmileDetect

Stops network quality detection.

- (int)stopLastmileDetect;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setParameter

Sets custom parameters.

- (int)setParameter:(NSString _Nonnull)param;

Parameters

Name

Type

Description

param

NSString _Nonnull

The custom parameter.

getParameter

Retrieves custom parameters.

- (NSString _Nonnull)getParameter:(NSString _Nonnull)param;

Parameters

Name

Type

Description

param

NSString _Nonnull

The custom parameter.

enableAudioFrameObserver

Sets audio callback parameters.

- (int)enableAudioFrameObserver:(bool)enable audioSource: (AliRtcAudioSource)audioSource config:(AliRtcAudioFrameObserverConfig_Nullable)config;

Parameters

Name

Type

Description

enable

bool

Whether to allow data callbacks.

audioSource

AliRtcAudioSource

The callback data source type.

config

AliRtcAudioFrameObserverConfig _Nullable

The callback parameter settings.

registerAudioFrameObserver

Registers an audio data output.

- (int)registerAudioFrameObserver:(id<AliRtcAudioFrameDelegate> _Nullable)observer;

Parameters

Name

Type

Description

observer

id<AliRtcAudioFrameDelegate> _Nullable

The audio data callback.

registerVideoSampleObserver

Registers a video data output.

- (void)registerVideoSampleObserver;

unRegisterVideoSampleObserver

Unregisters a video data output.

- (void)unregisterVideoSampleObserver;

setLogDirPath

Sets the path to save the SDK log file.

+ (int)setLogDirPath:(NSString _Nullable)logDirPath;

Parameters

Name

Type

Description

logDirPath

NSString _Nullable

The absolute path to save the log file. The default log storage path for iOS is Library/Caches/Ali_RTC_Log. The default log storage path for Mac is /Users/xxx/Documents/Ali_RTC_Log.

Important

Call this method before any other SDK methods to avoid log loss. Ensure that the specified directory exists and is writable.

setLogLevel

Sets the log level.

- (void)setLogLevel:(AliRtcLogLevel)logLevel;

Parameters

Name

Type

Description

logLevel

AliRtcLogLevel

The log level. The default value is AliRtcLogLevelInfo.

setVideoMirrorMode

Sets the video mirror mode.

- (int)setVideoMirrorMode:(AliRtcVideoPipelineMirrorMode)mirrorMode;

Parameters

Name

Type

Description

mirrorMode

AliRtcVideoPipelineMirrorMode

The mirror type.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

You can dynamically set this method before and after you join a channel. The SDK records the state and applies it to the video when the preview and encoding can be operated. This method has a higher priority than `setLocalViewConfig` and `setVideoEncoderConfig`. This method overlaps with the `mirror` parameter in `setLocalViewConfig` and `setVideoEncoderConfig`. Use only one of them.

setCapturePipelineScaleMode

Sets the video pipeline scaling mode.

- (void)setCapturePipelineScaleMode:(AliRtcCapturePipelineScaleMode)mode;

Parameters

Name

Type

Description

mode

AliRtcCapturePipelineScaleMode

The scaling type.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This controls the timing of capture scaling. The default is to scale immediately upon capture. You must call this method before the camera is turned on, which is before `startPreview` or `joinChannel`.

getSdkVersion

Retrieves the SDK version number.

+ (NSString _Nonnull)getSdkVersion;

Return value

The current SDK version number as a string, for example, "2.5.0.x". This is a static method and can be called at any time to retrieve the version number.

setScreenShareEncoderConfiguration

Sets the screen sharing encoder settings.

- (void)setScreenShareEncoderConfiguration:(AliRtcScreenShareEncoderConfiguration _Nonnull)config;

Parameters

Name

Type

Description

config

AliRtcScreenShareEncoderConfiguration _Nonnull

The screen sharing video encoding parameters, such as resolution, frame rate, bitrate, and video orientation. All set parameters have corresponding range limits. If a parameter is set outside its valid range, the SDK will adjust it automatically.

Important

This method sets the video parameters for screen stream video encoding, such as resolution, frame rate, bitrate, and video orientation. All set parameters have corresponding range limits. If a parameter is set outside its valid range, the SDK adjusts it automatically. You can call this method before or after you join a channel. If you only need to set the screen stream video encoding properties once per session, we recommend that you call it before you join.

setRemoteAudioVolume

Sets the volume of a remote audio stream.

- (int)setRemoteAudioVolume:(NSString _Nonnull)uid volume:(NSInteger)volume;

Parameters

Name

Type

Description

uid

NSString _Nonnull

The user ID, a unique identifier assigned by the App server.

volume

NSInteger

The playback volume. The range is [0, 100]. 0: Mute. 100: Original volume.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

The `uid` must be set after the user has joined the channel. If the user has not joined, the setting will fail.

subscribeRemoteVideoStream

Stops or resumes subscribing to the video stream of a remote user.

- (int)subscribeRemoteVideoStream:(NSString _Nonnull)uid track:(AliRtcVideoTrack)track sub:(BOOL)sub;

Parameters

Name

Type

Description

uid

NSString _Nonnull

The user ID, a unique identifier assigned by the App server.

track

AliRtcVideoTrack

The video stream type.

sub

BOOL

Whether to subscribe.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

If you have previously called `subscribeAllRemoteVideoStreams` to stop subscribing to all remote videos, this method call will be invalid. `subscribeAllRemoteVideoStreams` provides global control, while `subscribeRemoteVideoStream` provides individual control.

subscribeRemoteDestChannelStream

Subscribes to a specified user's stream in a destination channel.

- (int)subscribeRemoteDestChannelStream:(NSString _Nonnull)channelId uid:(NSString _Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack audioTrack:(AliRtcAudioTrack)audioTrack sub:(BOOL)sub;

Parameters

Name

Type

Description

channelId

NSString _Nonnull

The destination channel.

uid

NSString _Nonnull

The user ID, a unique identifier assigned by the App server.

videoTrack

AliRtcVideoTrack

The video stream type.

audioTrack

AliRtcAudioTrack

The audio stream type.

sub

BOOL

Whether to subscribe to the stream of the remote channel user.

Return value

A return value of 0 indicates success. A non-zero value indicates failure.

subscribeRemoteDestChannelAllStream

Subscribes to the streams of all users in a destination channel.

- (int)subscribeRemoteDestChannelAllStream:(NSString _Nonnull)channelId track:(AliRtcVideoTrack)track subAudio:(BOOL)subAudio sub:(BOOL)sub;

Parameters

Name

Type

Description

channelId

NSString _Nonnull

The destination channel.

track

AliRtcVideoTrack

The video stream type.

subAudio

BOOL

Whether to subscribe to the audio stream.

sub

BOOL

Whether to subscribe to the video stream of the remote channel user.

Response Description

Returns 0 if the method call is successful or a non-zero value if it fails.

setRecordingVolume

Sets the recording volume.

- (int)resumeAudioAccompany;

Parameters

Name

Type

Description

volume

NSInteger

The range is [0, 400]. [0, 100] is the original volume. [100, 400] is volume amplification.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setPlayoutVolume

Sets the playback volume.

- (int)getAudioAccompanyDuration;

Parameters

Name

Type

Description

volume

NSInteger

The range is [0, 400]. [0, 100] is the original volume range. [100, 400] is volume amplification.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

startAudioCaptureTest

Starts the audio capture device test before a call.

- (int)getAudioAccompanyCurrentPosition;
Important

You can call this method only before you call `joinChannel`. Calling it after `joinChannel` will fail.

stopAudioCaptureTest

Stops the pre-call audio capture device test.

- (int)setAudioAccompanyPosition:(int)pos;
Important

You can call this method only before you call `joinChannel`. Calling it afterward will fail.

getAudioFileInfo

Retrieves information about the audio file.

- (int)getAudioFileInfo:(NSString *_Nonnull)filePath;

Parameters

Name

Type

Description

filePath

NSString *

The file path.

Important

This is an asynchronous method. You can obtain the audio file information through `{@link onAudioFileInfo:errorCode:}`.

startAudioAccompanyWithFile

Starts accompaniment mixing.

- (int)startAudioAccompanyWithFile:(NSString *_Nonnull)filePath config:(AliRtcAudioAccompanyConfig *_Nonnull)config;

Parameters

Name

Type

Description

filePath

NSString *

The file path.

config

AliRtcAudioAccompanyConfig *

The accompaniment configuration.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This is an asynchronous method. You can listen for the player state through `{@link onAudioAccompanyStateChanged:errorCode:}`.

stopAudioAccompany

Stops accompaniment mixing.

- (int)stopAudioAccompany;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setAudioAccompanyVolume

Sets the accompaniment volume.

- (int)setAudioAccompanyVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The accompaniment volume. The range is [0, 100].

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This sets both the local playback volume and the publishing volume of the accompaniment.

setAudioAccompanyPublishVolume

Sets the publishing volume of the accompaniment.

- (int)setAudioAccompanyPublishVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The accompaniment volume. The range is [0, 100].

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

Important

This method sets the volume of the published stream.

getAudioAccompanyPublishVolume

Retrieves the publishing volume of the accompaniment.

- (int)getAudioAccompanyPublishVolume;

Return value

Returns a value in the range of [0, 100] on success or another value on failure.

setAudioAccompanyPlayoutVolume

Sets the local playback volume of the accompaniment.

- (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The accompaniment volume. The range is [0, 100].

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getAudioAccompanyPlayoutVolume

Retrieves the local playback volume of the accompaniment.

- (int)getAudioAccompanyPlayoutVolume;

Return value

Returns a value in the range of [0, 100] on success or another value on failure.

pauseAudioAccompany

Pauses accompaniment mixing.

- (int)pauseAudioAccompany;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

resumeAudioAccompany

Resumes accompaniment mixing.

- (int)resumeAudioAccompany;

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

getAudioAccompanyDuration

Retrieves the duration of the accompaniment file in milliseconds.

- (int)getAudioAccompanyDuration;

Return value

Returns a value greater than or equal to 0, which is the duration of the accompaniment file in milliseconds. A value less than 0 indicates failure.

getAudioAccompanyCurrentPosition

Retrieves the accompaniment playback progress in milliseconds.

- (int)getAudioAccompanyCurrentPosition;

Return value

Returns a value greater than or equal to 0, which is the accompaniment playback progress. A value less than 0 indicates failure.

setAudioAccompanyPosition

Sets the playback position of the accompaniment file.

- (int)setAudioAccompanyPosition:(int)pos;

Parameters

Name

Type

Description

pos

int

The progress bar position in milliseconds.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

setEarBackVolume

Sets the in-ear monitoring volume.

- (int)setEarBackVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

The volume. The range is [0, 100]. The default value is 100.

Return value

Returns 0 if the method call is successful or a non-zero value if it fails.

snapshotVideo

Takes a snapshot of the video.

- (int)snapshotVideo:(NSString*_Nullable)userId type:(AliRtcVideoTrack)type;

Parameters

Name

Type

Description

userId

NSString *

The user ID. A nil or empty userId represents the local user.

type

AliRtcVideoTrack

The video stream type. Only `{@link AliRtcVideoTrack::AliRtcVideoTrackCamera}` and `{@link AliRtcVideoTrack::AliRtcVideoTrackScreen}` are supported.

Returns

Returns 0 if the method call is successful or a non-zero value if it fails.

sendMediaExtensionMsg

Sends Supplemental Enhancement Information (SEI).

- (int)sendMediaExtensionMsg:(NSData *_Nonnull)data repeatCount:(int)repeatCount delay:(int)delay isKeyFrame:(bool)isKeyFrame;

Parameters

Name

Type

Description

data

NSData *

The content of the extension message. The maximum length is 4 KB.

repeatCount

int

The number of repetitions, which represents message redundancy to prevent message loss due to packet loss. A value of -1 means infinite repetitions until sendMediaExtensionMsg is called again.

delay

int

The delay in milliseconds before sending the SEI. Because SEI is attached to the encoded H.264/H.265 stream, the actual delay will be slightly longer than the set delay.

isKeyFrame

bool

Whether to add SEI only to keyframes. If set to true, SEI information is added only to keyframes.

Return value

Returns 0 on success or another value on failure.

Important

Because media extension messages reuse the audio and video data channel, you must control the sending frequency and message data length. The limits are as follows:

  1. You can send a maximum of `fps` messages per second, where `fps` is set in the profile.

  2. To avoid affecting media data transmission quality, the custom message body is limited to 4 KB. You can use this to transmit small amounts of data.

  3. The `repeatCount` parameter in the `sendMediaExtensionMsg` function provides custom message redundancy. If `repeatCount` is greater than 1, the message is sent multiple times to prevent loss from packet loss. Other users in the channel receive the same message multiple times and must remove duplicates.

  4. Custom messages sent during bypass live streaming are also received by subscribers in the channel. If you set `repeatCount` to -1, the data is sent permanently until `sendMediaExtensionMsg` is called again.

  5. SEI is currently supported on H5 clients as follows:

    Browsers: Chrome/Edge 86+
    Safari 15.4+
    Firefox 117+
    ApsaraVideo Real-time Communication (ARTC) SDK Version: 6.12.0+







  6. You can send only one `sendMediaExtensionMsg` at a time. A new call to `sendMediaExtensionMsg` overwrites the previous call if the previous message has not been sent or has not finished sending.

sendMediaExtensionMsgEx

Sends media extension information, which is implemented using SEI at the underlying layer.

- (int)sendMediaExtensionMsgEx:(NSData *_Nonnull)data repeatCount:(int)repeatCount delay:(int)delay isKeyFrame:(bool)isKeyFrame payloadType:(int)payloadType;

Parameters

Name

Type

Description

data

NSData *

The content of the extension message. The maximum length is 4 KB.

repeatCount

int

The number of repetitions, which represents message redundancy to prevent message loss due to packet loss. A value of -1 means infinite repetitions until sendMediaExtensionMsg is called again.

delay

int

The delay in milliseconds before sending the SEI. Because SEI is attached to the encoded H.264/H.265 stream, the actual delay will be slightly longer than the set delay.

isKeyFrame

bool

Whether to add SEI only to keyframes. If set to true, SEI information is added only to keyframes.

payloadType

int

The type. Use 5 for types with a UUID. The range is [5, 100..254].

Returns

Returns 0 on success or another value on failure.

Important

Because media extension messages reuse the audio and video data channel, you must control the sending frequency and message data length. The limits are as follows:

  1. You can send a maximum of `fps` messages per second, where `fps` is set in the profile.

  2. To avoid affecting media data transmission quality, the custom message body is limited to 4 KB. You can use this to transmit small amounts of data.

  3. The `repeatCount` parameter in the `sendMediaExtensionMsg` function provides custom message redundancy. If `repeatCount` is greater than 1, the message is sent multiple times to prevent loss from packet loss. Other users in the channel receive the same message multiple times and must remove duplicates.

  4. Custom messages sent during bypass live streaming are also received by subscribers in the channel. If you set `repeatCount` to -1, the data is sent permanently until `sendMediaExtensionMsg` is called again.

  5. SEI is currently supported on H5 clients as follows:

    Browsers: Chrome/Edge 86+
    Safari 15.4+
    Firefox 117+
    ARTC SDK Version: 6.12.0+







  6. You can send only one `sendMediaExtensionMsg` at a time. A new call to `sendMediaExtensionMsg` overwrites the previous call if the previous message has not been sent or has not finished sending.

startAudioPlayer

Starts audio playback.

- (void)startAudioPlayer;

Important

You can use this method to start audio playback in advance. If you do not call this method, the SDK automatically starts audio playback after subscribing to an audio stream.

stopAudioPlayer

Stops audio playback.

- (void)stopAudioPlayer;
Important

You can use this method to stop audio playback.

removeExternalAudioStream

Deletes an external audio stream.

- (int)removeExternalAudioStream:(int)streamId;

Parameters

Name

Type

Description

streamId

int

The external audio stream ID.

Returns

Returns 0 on success or another value on failure.

getNetworkTime

Retrieves the timeline time.

-(long long)getNetworkTime;

Parameters

Name

Type

Description

Return value

The timestamp.

sendDataChannelMessage

Sends a data channel message.

-(int) sendDataChannelMessage:(AliRtcDataChannelMsg* _Nonnull)controlMsg;

The ARTC SDK lets you send and receive custom messages. This feature lets you send custom real-time messages while you transmit audio and video data. For example, you can call this interface to transmit real-time control instructions, status synchronization data, or other business messages along with the audio and video. For more information, see Send and receive custom messages.

Note
  • The custom message channel is disabled by default. To use this feature, call the setParameter method with `("{\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}")` to enable it. You can do this before or after you join a channel.

  • The message can be any data, such as text.

Related callbacks

  • After the sender successfully enables the custom message channel, they can call this method to send custom messages. The receiver listens for the onDataChannelMessage callback to receive them.

Limits

  • Users with the streamer role can send and receive messages. Users with the viewer role can only receive messages.

  • You must call `setParameter` to enable the custom message channel.

  • Data sending is limited as follows:

    • The bitrate is capped at 30 KB/s.

    • The data channel can send a maximum of 60 data packets per second, with each packet up to 1 KB in size.

Parameters

Name

Type

Description

controlMsg

AliRtcDataChannelMsg *

The accompaniment control message.

Return value

Returns 0 on success or another value on failure.

setDeviceOrientationMode

Sets the device orientation.

- (int)setDeviceOrientationMode:(AliRtcOrientationMode)mode;

Parameters

Name

Type

Description

mode

AliRtcOrientationMode

The device orientation.

Return value

Returns 0 on success or another value on failure.

registerVideoFrameWithObserver

Registers a video data output object.

- (void)registerVideoFrameWithObserver:(id<AliRtcVideoFrameDelegate> _Nullable)observer;

Parameters

Name

Type

Description

observer

AliRtcVideoFrameDelegate

The video data output object.

unregisterVideoSampleWithObserver

Unregisters a video data output object.

- (void)unregisterVideoSampleWithObserver:(id<AliRtcVideoFrameDelegate> _Nullable)observer;

Parameters

Name

Type

Description

observer

AliRtcVideoFrameDelegate

The video data output object.

Callback details

onConnectionStatusChange

This callback is triggered when the network connection status changes.

- (void)onConnectionStatusChange:(AliRtcConnectionStatus)status reason:(AliRtcConnectionStatusChangeReason)reason;

Parameters

Name

Type

Description

status

AliRtcConnectionStatus

The current status value.

reason

AliRtcConnectionStatusChangeReason

The specific reason for the status change.

onLocalDeviceException

This callback is triggered when a local device exception occurs. Your application must handle this callback.

- (void)onLocalDeviceException:(AliRtcLocalDeviceType)deviceType exceptionType:(AliRtcLocalDeviceExceptionType)exceptionType message:(NSString *_Nullable)msg;

Parameters

Name

Type

Description

deviceType

AliRtcLocalDeviceType

The device type.

exceptionType

AliRtcLocalDeviceExceptionType

The device exception type.

msg

NSString *

The information carried with the exception.

onAuthInfoWillExpire

This callback notifies you that the user authentication information is about to expire. The authentication expires 30 seconds after this notification is received. Your application must handle this callback.

- (void)onAuthInfoWillExpire;

onAuthInfoExpired

This callback is triggered when the server returns an information expiration message because the user called an interface that requires authentication.

- (void)onAuthInfoExpired;

onJoinChannelResult[1/2]

This callback returns the result of joining a channel. This callback is equivalent to the block operation of the `joinChannel` method. You can use either one to handle events after you join a channel.

- (void)onJoinChannelResult:(int)result channel:(NSString *_Nonnull)channel userId:(NSString *_Nonnull)userId elapsed:(int) elapsed;

Parameters

Name

Type

Description

result

int

The result of joining the channel. 0 indicates success. A non-zero value indicates an error code.

channel

NSString *

The ID of the channel joined.

userId

NSString *

The ID of the user who joined.

elapsed

int

The time taken to join the channel.

onJoinChannelResult[2/2]

This callback returns the result of joining a channel. This callback is equivalent to the block operation of the `joinChannel` method. You can use either one to handle events after you join a channel.

- (void)onJoinChannelResult:(int)result channel:(NSString *_Nonnull)channel elapsed:(int) elapsed;

Parameters

Name

Type

Description

result

int

The result of joining the channel. 0 indicates success. A non-zero value indicates an error code.

channel

NSString *

The ID of the channel joined.

elapsed

int

The time taken to join the channel.

onLeaveChannelResult

This callback returns the result of leaving a channel. It is returned after you call the `leaveChannel` method. If you call `destroy` immediately after `leaveChannel`, you will not receive this callback.

- (void)onLeaveChannelResult:(int)result stats:(AliRtcStats)stats;

Parameters

Name

Type

Description

result

int

The result of leaving the channel. 0 indicates success. A non-zero value indicates an error code.

stats

AliRtcStats

A summary of data statistics for this channel session.

onRemoteUserOffLineNotify

This callback is triggered when a remote user goes offline.

- (void)onRemoteUserOffLineNotify:(NSString *_Nonnull)uid offlineReason:(AliRtcUserOfflineReason)reason;

Parameters

Name

Type

Description

uid

NSString *

The user ID, a unique identifier assigned by the App server.

reason

AliRtcUserOfflineReason

The reason the user went offline.

onRemoteUserOnLineNotify

This callback is triggered when a remote user comes online.

- (void)onRemoteUserOnLineNotify:(NSString *_Nonnull)uid elapsed:(int)elapsed;

Parameters

Name

Type

Description

uid

NSString *

The user ID, a unique identifier assigned by the App server.

elapsed

int

The time taken for the user to join the channel.

onRemoteTrackAvailableNotify

This callback is triggered when a remote user's stream changes.

- (void)onRemoteTrackAvailableNotify:(NSString *_Nonnull)uid audioTrack:(AliRtcAudioTrack)audioTrack videoTrack:(AliRtcVideoTrack)videoTrack;

Parameters

Name

Type

Description

uid

NSString *

The user ID, a unique identifier assigned by the App server.

audioTrack

AliRtcAudioTrack

The audio stream of the remote user after the change.

videoTrack

AliRtcVideoTrack

The video stream of the remote user after the change.

onBye

This callback is triggered when the user is kicked out by the server or the channel is closed.

- (void)onBye:(int)code;

Parameters

Name

Type

Description

code

int

The message type. Valid values:
1: Kicked out by the server.
2: The channel is closed.
3: Kicked out by the server because the same user ID logged on from another device.







onAudioPublishStateChanged

This callback is triggered when the audio publishing state changes.

- (void)onAudioPublishStateChanged:(AliRtcPublishState)oldState newState:(AliRtcPublishState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

oldState

AliRtcPublishState

The previous publishing state.

newState

AliRtcPublishState

The current publishing state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onAudioSubscribeStateChanged

This callback is triggered when the audio subscription state changes.

- (void)onAudioSubscribeStateChanged:(NSString *_Nonnull)uid oldState:(AliRtcSubscribeState)oldState newState:(AliRtcSubscribeState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

uid

NSString *

The user ID whose subscription state has changed.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onUserAudioMuted

This callback notifies you that a user has muted their audio.

- (void)onUserAudioMuted:(NSString *_Nonnull)uid audioMuted:(BOOL)isMute;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user who muted their audio.

isMute

BOOL

YES indicates muted. NO indicates unmuted.

onUserAudioInterruptedBegin

This callback notifies you that a user's audio has been interrupted. This typically occurs when the audio is preempted by a phone call.

- (void)onUserAudioInterruptedBegin:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user whose audio was interrupted.

onUserAudioInterruptedEnded

This callback notifies you that a user's audio interruption has ended.

- (void)onUserAudioInterruptedEnded:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user whose audio interruption has ended.

onVideoPublishStateChanged

This callback is triggered when the video publishing state changes.

- (void)onVideoPublishStateChanged:(AliRtcPublishState)oldState newState:(AliRtcPublishState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

oldState

AliRtcPublishState

The previous publishing state.

newState

AliRtcPublishState

The current publishing state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onVideoSubscribeStateChanged

This callback is triggered when the camera stream subscription state changes.

- (void)onVideoSubscribeStateChanged:(NSString *_Nonnull)uid oldState:(AliRtcSubscribeState)oldState newState:(AliRtcSubscribeState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

uid

NSString *

The user ID whose subscription state has changed.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onUserVideoMuted

This callback notifies you that a user has muted their video.

- (void)onUserVideoMuted:(NSString *_Nonnull)uid videoMuted:(BOOL)isMute;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user who muted their video.

isMute

BOOL

YES indicates that black frames are being published. NO indicates normal publishing.

onUserVideoEnabled

This callback notifies you that local video capture has been disabled or re-enabled.

- (void)onUserVideoEnabled:(NSString *_Nullable)uid videoEnabled:(BOOL)isEnable;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user who called EnableLocalVideo.

isMute

BOOL

YES indicates that camera stream capture is enabled. NO indicates that camera stream capture is disabled.

onUserWillResignActive

This callback is triggered when a remote user's application moves to the background.

- (void)onUserWillResignActive:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user whose application moved to the background.

onUserWillBecomeActive

This callback is triggered when a remote user's application returns to the foreground.

- (void)onUserWillBecomeActive:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID of the user whose application returned to the foreground.

onRtcStats

This callback provides real-time data and is triggered every 2 seconds.

- (void)onRtcStats:(AliRtcStats)stats;

Parameters

Name

Type

Description

stats

AliRtcStats

The data callback.

onAudioEffectFinished

This callback is triggered when local sound effect playback finishes.

- (void)onAudioEffectFinished:(int)soundId;

Parameters

Name

Type

Description

soundId

int

The ID of the sound effect that has finished playing.

onAudioVolumeCallback

This callback provides the audio volume, speech status, and UID of the subscribed audio.

- (void)onAudioVolumeCallback:(NSArray <AliRtcUserVolumeInfo *> *_Nullable)array totalVolume:(int)totalVolume;

Parameters

Name

Type

Description

array

NSArray <AliRtcUserVolumeInfo *> *

An array of user volume information, including user UID, speech status, and volume. A UID of 0 indicates the local speaker.

totalVolume

int

The total volume after mixing. The range is [0, 255]. In the local user's callback, totalVolume is the volume after local user mixing. In the remote user's callback, totalVolume is the total volume of all speakers after mixing.

onActiveSpeaker

This callback provides the current speaker.

- (void)onActiveSpeaker:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The ID of the current speaker.

onPublishLiveStreamStateChanged

This callback is triggered when the bypass stream publishing state changes.

- (void)onPublishLiveStreamStateChanged:(NSString *_Nonnull)streamURL state:(AliRtcLiveTranscodingState)state errCode:(AliRtcTrascodingLiveStreamErrorCode)errCode;

Parameters

Name

Type

Description

streamURL

NSString *

The stream URL.

state

AliRtcLiveTranscodingState

The state.

errCode

AliRtcTrascodingLiveStreamErrorCode

The error code.

onPublishTaskStateChanged

This callback is triggered when the bypass task state changes.

- (void)onPublishTaskStateChanged:(NSString *_Nonnull)streamURL state:(AliRtcTrascodingLiveTaskStatus)state;

Parameters

Name

Type

Description

streamURL

NSString *

The stream URL.

state

AliRtcTrascodingLiveTaskStatus

The state.

onNetworkQualityChanged

This callback is triggered when the network quality changes.

- (void)onNetworkQualityChanged:(NSString *_Nonnull)uid upNetworkQuality:(AliRtcNetworkQuality)upQuality downNetworkQuality:(AliRtcNetworkQuality)downQuality;

Parameters

Name

Type

Description

uid

NSString *

The user ID. An empty value indicates the uplink and downlink network status of the local user.

upQuality

AliRtcNetworkQuality

The uplink network status.

downQuality

AliRtcNetworkQuality

The downlink network status.

onLastmileDetectResultWithQuality

This callback provides the result of network quality detection.

- (void)onLastmileDetectResultWithQuality:(AliRtcNetworkQuality)networkQuality;

Parameters

Name

Type

Description

networkQuality

AliRtcNetworkQuality

The network quality.

onLastmileDetectResultWithBandWidth

This callback provides the result of network quality detection.

- (void)onLastmileDetectResultWithBandWidth:(int)code result:(AliRtcNetworkQualityProbeResult* _Nonnull)result;

Parameters

Name

Type

Description

code

int

The detection result.0 indicates success. -1 indicates failure due to poor network conditions.

result

AliRtcNetworkQualityProbeResult *

The network quality.

onAudioPublishStateChanged

This callback is triggered when the audio publishing state changes.

- (void)onAudioPublishStateChanged:(AliRtcAudioTrack)track oldState:(AliRtcPublishState)oldState newState:(AliRtcPublishState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

track

AliRtcAudioTrack

The track that has changed.

oldState

AliRtcPublishState

The previous publishing state.

newState

AliRtcPublishState

The new publishing state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onScreenSharePublishStateChanged

This callback is triggered when the screen sharing publishing state changes.

- (void)onScreenSharePublishStateChanged:(AliRtcPublishState)oldState newState:(AliRtcPublishState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

oldState

AliRtcPublishState

The previous publishing state.

newState

AliRtcPublishState

The new publishing state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onAudioSubscribeStateChanged

This callback is triggered when the audio stream subscription state changes.

- (void)onAudioSubscribeStateChanged:(NSString *_Nonnull)uid track:(AliRtcAudioTrack)track oldState:(AliRtcSubscribeState)oldState newState:(AliRtcSubscribeState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

track

AliRtcAudioTrack

Dynamic Track

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The new subscription state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onScreenShareSubscribeStateChanged

This callback is triggered when the screen sharing stream subscription state changes.

- (void)onScreenShareSubscribeStateChanged:(NSString *_Nonnull)uid oldState:(AliRtcSubscribeState)oldState newState:(AliRtcSubscribeState)newState elapseSinceLastState:(NSInteger)elapseSinceLastState channel:(NSString *_Nonnull)channel;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The new subscription state.

elapseSinceLastState

NSInteger

The time interval since the last state change, in milliseconds.

channel

NSString *

The current channel ID.

onUpdateRoleNotifyWithOldRole

This callback is triggered when the user role changes.

- (void)onUpdateRoleNotifyWithOldRole:(AliRtcClientRole)oldRole newRole:(AliRtcClientRole)newRole;

Parameters

Name

Type

Description

oldRole

AliRtcClientRole

The role type before the change.

newRole

AliRtcClientRole

The role type after the change.

onOccurError

This callback notifies the application if an engine error occurs.

- (void)onOccurError:(int)error message:(NSString *_Nonnull)message;

Parameters

Name

Type

Description

error

int

The error type. See {@link AliRtcErrorCode}.

message

NSString *

The error description.

onFirstAudioPacketSentWithTimecost

This callback is triggered when the first audio packet is sent.

- (void)onFirstAudioPacketSentWithTimecost:(AliRtcAudioTrack)track timeCost:(int)timeCost;

Parameters

Name

Type

Description

track

AliRtcAudioTrack

The track.

timeCost

int

The time taken to send.

onFirstVideoFrameReceivedWithUid

This callback is triggered when the first video frame is received.

- (void)onFirstVideoFrameReceivedWithUid:(NSString *_Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack timeCost:(int)timeCost;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

videoTrack

AliRtcVideoTrack

The video stream tag.

timeCost

int

The time taken, in milliseconds.

onFirstVideoPacketSentWithVideoTrack

This callback is triggered when the first video packet is sent.

- (void)onFirstVideoPacketSentWithVideoTrack:(AliRtcVideoTrack)videoTrack timeCost:(int)timeCost;

Parameters

Name

Type

Description

videoTrack

AliRtcVideoTrack

The video stream tag.

timeCost

int

The time taken, in milliseconds.

onFirstAudioPacketReceivedWithUid

This callback is triggered when the first audio packet is received.

- (void)onFirstAudioPacketReceivedWithUid:(NSString *_Nonnull)uid track:(AliRtcAudioTrack)track timeCost:(int)timeCost;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

track

AliRtcAudioTrack

The audio stream tag.

timeCost

int

The time taken, in milliseconds.

onFirstRemoteAudioDecodedWithUid

This callback is triggered when the first remote audio frame is decoded.

- (void)onFirstRemoteAudioDecodedWithUid:(NSString *_Nonnull)uid track:(AliRtcAudioTrack)track elapsed:(int)elapsed;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

track

AliRtcAudioTrack

The audio stream tag.

elapsed

int

The time taken, in milliseconds.

onFirstRemoteVideoFrameDrawn

This callback is triggered when the first video frame of a remote user is displayed.

- (void)onFirstRemoteVideoFrameDrawn:(NSString *_Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack width:(int)width height:(int)height elapsed:(int)elapsed;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

videoTrack

AliRtcVideoTrack

The video stream tag.

width

int

The width.

height

int

The height.

elapsed

int

The total delay from when the local user joins the channel until this callback is triggered, in milliseconds.

onFirstLocalVideoFrameDrawn

This callback is triggered when the first video frame is displayed in the preview.

- (void)onFirstLocalVideoFrameDrawn:(int)width height:(int)height elapsed:(int)elapsed;

Parameters

Name

Type

Description

width

int

The width of the local preview video.

height

int

The height of the local preview video.

elapsed

int

The total delay from when the local user joins the channel until this callback is triggered, in milliseconds.


onTestAudioVolumeCallback

This callback provides the volume from the pre-call audio capture test.

- (void)onTestAudioVolumeCallback:(int)volume;

Parameters

Name

Type

Description

volume

int

The volume [0-100].

onAudioAccompanyStateChanged

This callback provides the local accompaniment playback state.

- (void)onAudioAccompanyStateChanged:(AliRtcAudioAccompanyStateCode)playState errorCode:(AliRtcAudioAccompanyErrorCode)errorCode;

Parameters

Name

Type

Description

playState

AliRtcAudioAccompanyStateCode

The accompaniment state.

errorCode

AliRtcAudioAccompanyErrorCode

The error code.

onRemoteAudioAccompanyStarted

Occurs when a remote user starts accompaniment playback.

- (void)onRemoteAudioAccompanyStarted:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

onRemoteAudioAccompanyFinished

This callback is triggered when a remote user finishes accompaniment playback.

- (void)onRemoteAudioAccompanyFinished:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

onVideoResolutionChanged

The video resolution changed.

- (void)onVideoResolutionChanged:(NSString *_Nonnull)uid videoTrack:(AliRtcVideoTrack)videoTrack width:(int)width height:(int)height;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

videoTrack

AliRtcVideoTrack

The video track.

width

int

The width.

height

int

The height.

onRtcLocalVideoStats

This callback provides local video statistics and is triggered every 2 seconds.

- (void)onRtcLocalVideoStats:(AliRtcLocalVideoStats *_Nonnull)localVideoStats;

Parameters

Name

Type

Description

localVideoStats

AliRtcLocalVideoStats *

The local video statistics.

onRtcRemoteVideoStats

This callback provides remote video statistics and is triggered every 2 seconds.

- (void)onRtcRemoteVideoStats:(AliRtcRemoteVideoStats *_Nonnull)remoteVideoStats;

Parameters

Name

Type

Description

remoteVideoStats

AliRtcRemoteVideoStats *

The remote video statistics.

onRtcLocalAudioStats

This callback provides local audio statistics and is triggered every 2 seconds.

- (void)onRtcLocalAudioStats:(AliRtcLocalAudioStats *_Nonnull)localAudioStats;

Parameters

Name

Type

Description

localAudioStats

AliRtcLocalAudioStats *

The local audio statistics.

onRtcRemoteAudioStats

This callback provides remote audio statistics and is triggered every 2 seconds.

- (void)onRtcRemoteAudioStats:(AliRtcRemoteAudioStats *_Nonnull)remoteAudioStats;

Parameters

Name

Type

Description

remoteAudioStats

AliRtcRemoteAudioStats *

The remote audio statistics.

onMediaExtensionMsgReceived

This callback is triggered when a media extension message is received.

- (void)onMediaExtensionMsgReceived:(NSString *_Nonnull)uid payloadType:(int)payloadType message:(NSData *_Nonnull)data;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

payloadType

int

The payload type.

message

NSData *

The media extension message.

onSnapshotComplete

This is the snapshot callback.

- (void)onSnapshotComplete:(NSString*_Nullable)uid videoTrack:(AliRtcVideoTrack)videoTrack image:(UIImage* _Nullable)image success:(BOOL)success;

Parameters

Name

Type

Description

image

UIImage *

The image type.

success

BOOL

Whether the operation was successful.

onLocalAudioStateChanged

This callback provides the local audio capture device state.

- (void)onLocalAudioStateChanged:(AliRtcLocalAudioStateType)state message:(NSString *_Nullable)msg;

Parameters

Name

Type

Description

state

AliRtcLocalAudioStateType

The device state, of type AliRtcLocalAudioStateType.

msg

NSString *

A description of the device state change.

Important

This callback provides the results of `startAudioCapture` and `stopAudioCapture`.

onLocalVideoStateChanged

Callback for the state of the local video capture device.

- (void)onLocalVideoStateChanged:(AliRtcLocalVideoStateType)state message:(NSString *_Nullable)msg;

Parameters

Name

Type

Description

state

AliRtcLocalVideoStateType

The device state, of type AliRtcLocalVideoStateType.

msg

NSString *

A description of the device state change.

onRemoteUserSubscribedDataChannel

This callback indicates that you can start sending data channel messages.

- (void)onRemoteUserSubscribedDataChannel:(NSString *_Nonnull)uid;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

onDataChannelMessage

Callback for messages from the data channel.

- (void)onDataChannelMessage:(NSString *_Nonnull)uid controlMsg:(AliRtcDataChannelMsg*_Nonnull)controlMsg;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

controlMsg

AliRtcDataChannelMsg

The data channel message.

AliRtcVideoFrameDelegate

onCaptureVideoSample

This callback provides captured raw video data.

- (BOOL)onCaptureVideoSample:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *_Nonnull)videoSample;

Parameters

Name

Type

Description

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return value

`YES`: The data must be written back to the SDK. This is valid only for I420 and CVPixelBuffer on iOS and macOS.
`NO`: The data does not need to be written back to the SDK.

onPreEncodeVideoSample

This callback provides subscribed local video data before encoding.

- (BOOL)onPreEncodeVideoSample:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *_Nonnull)videoSample;

Parameters

Name

Type

Description

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return value

`YES`: The data must be written back to the SDK. This is valid only for I420 and CVPixelBuffer on iOS and macOS.
`NO`: The data does not need to be written back to the SDK.

onRemoteVideoSample

This callback provides subscribed remote video data.

- (BOOL)onRemoteVideoSample:(NSString *_Nonnull)uid videoSource:(AliRtcVideoSource)videoSource videoSample:(AliRtcVideoDataSample *_Nonnull)videoSample;

Parameters

Name

Type

Description

uid

NSString *

The user ID.

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return value

`YES`: The data must be written back to the SDK. This is valid only for I420 and CVPixelBuffer on iOS and macOS.
`NO`: The data does not need to be written back to the SDK.

onGetVideoFormatPreference

Video data output format.

- (AliRtcVideoFormat)onGetVideoFormatPreference;

Return value

The desired video output format.

Important

The application can return the desired video output format. The default is `AliRtcYUV420`.

onGetVideoObservedFramePosition

Output location for video data.

- (NSInteger)onGetVideoObservedFramePosition;

Return Value

The desired position for the video output. For more information, see {@link AliRtcVideoObserPosition}.

AliRtcAudioFrameDelegate

onCapturedAudioFrame

A callback that provides the captured raw data.

- (BOOL)onCapturedAudioFrame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame.

Return value

true: The operation was successful.

Important
  1. Do not perform any time-consuming operations in this callback function because it may cause audio issues.

  2. You can use this interface to set the sample rate and number of channels.

  3. You can use this interface in read/write mode.

onProcessCapturedAudioFrame

This callback provides data after 3A processing.

- (BOOL)onProcessCapturedAudioFrame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame

Return value

`true`: Success.

Important
  1. Do not perform time-consuming operations in this callback function because this may cause audio abnormalities.

  2. This interface supports setting the sample rate and number of channels.

  3. This interface supports read and write mode.

onPublishAudioFrame

A callback that is invoked when stream data is published.

- (BOOL)onPublishAudioFrame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame

Return value

true: The operation is successful.

Important
  1. Do not perform time-consuming operations in this callback function because they may cause audio abnormalities.

  2. You can use this interface to set the sample rate and the number of channels.

  3. You can use this interface in read/write mode.

onPlaybackAudioFrame

A callback to receive playback data.

- (BOOL)onPlaybackAudioFrame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame

Return value

true: The operation was successful.

Important
  1. Do not perform time-consuming operations in this callback function because they may cause audio abnormalities.

  2. You can use this interface to set the sample rate and the number of channels.

  3. You can use this interface in read/write mode.

onMixedAllAudioFrame

This callback provides mixed data from published and playback streams.

- (BOOL)onMixedAllAudioFrame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame

Return value

true: The operation was successful.

Important

Currently not supported.

  1. Do not perform any time-consuming operations in this callback function, because it may cause audio issues.

  2. You can use this interface to set the sample rate and number of channels.

  3. This interface supports read/write mode.

onRemoteUserAudioFrame

Callback for handling data from a remote stream.

- (BOOL)onRemoteUserAudioFrame:(NSString *_Nullable)uid frame:(AliRtcAudioFrame* _Nonnull)frame;

Parameters

Name

Type

Description

frame

AliRtcAudioFrame *

Video frame

Return value

true: The operation was successful.

Important
  1. Do not perform any time-consuming operations in this callback function because they may cause audio abnormalities.

  2. You can use this interface to set the sample rate and number of channels.

  3. This interface supports read and write modes.

AliRtcEngineDestroyDelegate

onDestroyCompletion

This callback is triggered when the engine is destroyed. The engine is considered destroyed only after this callback is executed.

- (void)onDestroyCompletion;
Important

Wait for the `onDestroyCompletion` callback to complete before you call other methods to avoid blocking the main thread.

onTextureUpdate

This is the OpenGL texture update callback.

- (int)onTextureUpdate:(int)textureId width:(int)width height:(int)height videoSample:(AliRtcVideoDataSample *_Nonnull)videoSample;

Parameters

Name

Type

Description

textureId

int

OpenGL context

width

int

The video width.

height

int

The video height.

videoSample

AliRtcVideoDataSample *

The video frame data.

Return value

Returns the new or old texture ID. If a value less than 0 is returned, the texture ID is not updated.

Important

This callback is triggered after each video frame is uploaded to an OpenGL texture. If an external OpenGL texture data observer is registered, you can process the texture in this callback and return the processed texture ID.
Note: This callback must return a valid texture ID. If you do not perform any processing, you must return the original `textureId` parameter.

onTextureDestory

This is the OpenGL context destruction callback.

- (void)onTextureDestory;
Important

This callback is triggered when the SDK's internal OpenGL context is destroyed.