AliRtcEngine API

Updated at:
Copy as MD

AliRtcEngine provides the core APIs of the Real-Time Communication Mac SDK for audio and video calls.

Contents

Basic APIs

API

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 the H5 compatibility mode is enabled.

getSdkVersion

Gets the SDK version number.

Channel APIs

API

Description

setChannelProfile

Sets the channel mode.

setAudioProfile

Sets the audio profile.

isAudioOnly

Checks if the channel is in audio-only mode.

setAudioOnlyMode

Sets the channel to audio-only or audio/video mode.

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 if the user is in a channel.

setClientRole

Sets the user role.

getClientRole

Gets the user role.

refreshAuthInfo

Refreshes the authentication information.

refreshAuthInfoWithToken

Refreshes the authentication information using a token.

Publish and subscribe APIs

API

Description

publishLocalAudioStream

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

isLocalAudioStreamPublished

Checks whether the local audio stream is published.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to subscribe to all remote audio streams by default. Call this method before joining a channel.

subscribeAllRemoteAudioStreams

Stops or resumes subscribing to all remote audio streams.

subscribeRemoteAudioStream

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

publishLocalVideoStream

Sets whether to publish the local video stream.

isLocalVideoStreamPublished

Checks whether the local video stream is published.

setDefaultSubscribeAllRemoteVideoStreams

Sets whether to subscribe to all remote video streams by default. Call this method before joining a channel.

subscribeAllRemoteVideoStreams

Stops or resumes subscribing to all remote video streams.

subscribeRemoteMediaStream [1/2]

Stops or resumes subscribing to the media stream of a specified remote user. Use this interface to control both the audio and video streams.

subscribeRemoteMediaStream [2/2]

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

subscribeRemoteDestChannelStream

Stops or resumes subscribing to the cross-channel media stream of a specified remote user.

subscribeRemoteDestChannelAllStream

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

subscribeRemoteVideoStream

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

setRemoteAudioVolume

Sets the playback volume of a remote audio stream.

Audio device management APIs

API

Description

muteLocalMic

Stops or resumes publishing local audio.

muteRemoteAudioPlaying

Stops or resumes playing the remote audio stream.

muteAllRemoteAudioPlaying

Stops or resumes audio playback for all remote users.

startAudioCapture [1/2]

Starts audio capture.

startAudioCapture [2/2]

Starts audio capture.

stopAudioCapture

Stops audio capture.

enableAudioVolumeIndication

Enables audio volume indication.

enableEarBack

Enables ear back.

startAudioPlayer

Starts audio playback.

stopAudioPlayer

Stops audio playback.

setPlayoutVolume

Sets the playout volume.

setRecordingVolume

Sets the recording volume.

playAudioFileTest

Starts an audio playback device test.

stopAudioFileTest

Stops the audio playback device test.

startAudioCaptureTest

Starts an audio capture device test.

stopAudioCaptureTest

Stops the audio capture device test.

Voice changer and reverb

API

Description

setAudioEffectVoiceChangerMode

Sets the voice changer mode.

setAudioEffectPitchValue

Sets the pitch parameter.

setAudioEffectReverbMode

Sets the reverb mode.

setAudioEffectReverbParamType

Sets the reverb effect type and its parameters.

Custom audio input

API

Description

addExternalAudioStream

Adds an external audio stream.

pushExternalAudioStream

Pushes data to the external audio stream.

setExternalAudioStream:publishVolume

Sets the publish volume.

getExternalAudioStreamPublishVolume

Gets the publish volume.

setExternalAudioStream:playoutVolume

Sets the playout volume.

getExternalAudioStreamPlayoutVolume

Gets the playout volume.

removeExternalAudioStream

Removes an external audio stream.

Audio accompaniment

API

Description

getAudioFileInfo

Gets information about the audio accompaniment file.

startAudioAccompanyWithFile

Starts accompaniment playback.

stopAudioAccompany

Stops accompaniment playback.

setAudioAccompanyVolume

Sets the accompaniment volume.

setAudioAccompanyPublishVolume

Sets the publish volume for the audio accompaniment.

getAudioAccompanyPublishVolume

Gets the publish volume for the audio accompaniment.

setAudioAccompanyPlayoutVolume

Sets the playout volume for the audio accompaniment.

getAudioAccompanyPlayoutVolume

Gets the playout volume for the audio accompaniment.

pauseAudioAccompany

Pauses accompaniment playback.

resumeAudioAccompany

Resumes accompaniment playback.

getAudioAccompanyDuration

Gets the duration of the accompaniment file.

getAudioAccompanyCurrentPosition

Gets the current position of the accompaniment playback.

setAudioAccompanyPosition

Sets the accompaniment playback position.

Audio effect file

API

Description

preloadAudioEffectWithSoundId

Preloads an audio effect file.

unloadAudioEffectWithSoundId

Unloads a preloaded audio effect file.

playAudioEffectWithSoundId

Plays a specified audio effect.

stopAudioEffectWithSoundId

Stops a specified audio effect.

stopAllAudioEffects

Stops all audio effects.

pauseAudioEffectWithSoundId

Pauses a specified audio effect.

pauseAllAudioEffects

Pauses all audio effects.

resumeAudioEffectWithSoundId

Resumes a specified audio effect.

resumeAllAudioEffects

Resumes all audio effects.

setAudioEffectPublishVolumeWithSoundId

Sets the publish volume for a specified audio effect.

getAudioEffectPublishVolumeWithSoundId

Gets the publish volume of a specified audio effect.

setAllAudioEffectsPublishVolume

Sets the publish volume for all audio effects.

setAudioEffectPlayoutVolumeWithSoundId

Sets the playout volume for a specified audio effect.

getAudioEffectPlayoutVolumeWithSoundId

Gets the playout volume of a specified audio effect.

setAllAudioEffectsPlayoutVolume

Sets the playout volume for all audio effects.

Recording audio and video files

API

Description

startRecord

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

stopRecord

Stops recording audio and video files.

Video device management interfaces

API

Description

setLocalViewConfig

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

setCameraCapturerConfiguration

Sets camera capture preferences.

enableLocalVideo

Enables or disables local video capture.

muteLocalCamera

Mutes or unmutes the local video stream.

setRemoteViewConfig

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

isCameraOn

Checks whether the camera is on.

setVideoEncoderConfiguration

Sets the video encoding properties.

setVideoDecoderConfiguration

Sets the video decoding properties.

startPreview

Starts the local preview.

stopPreview

Stops the local preview.

setVideoMirrorMode

Sets the mirroring mode for the local preview and published stream.

setCapturePipelineScaleMode

Sets whether to scale video data immediately after capture or during encoding.

Configure video data callbacks

API

Description

registerVideoFrameWithObserver

Registers a video data callback.

unregisterVideoSampleWithObserver

Unregisters a video data callback.

snapshotVideo

Takes a snapshot of the camera feed.

registerVideoSampleObserver

Registers a video data output callback.

unRegisterVideoSampleObserver

Unregisters a video data output callback.

Audio data callbacks

API

Description

enableAudioFrameObserver

Enables the audio frame observer.

registerAudioFrameObserver

Registers an audio data callback.

Custom video input

API

Description

setExternalVideoSource

Enables an external video input source.

pushExternalVideoFrame

Pushes video data.

Screen sharing API

API

Description

startScreenShareWithDesktopId

Starts screen share publishing.

startScreenShareWithWindowId

Starts screen share publishing.

StopScreenShare

Stops screen share publishing.

updateScreenShareConfig

Sets the volume of the shared audio stream.

isScreenSharePublished

Checks if the screen share is being published.

setScreenShareEncoderConfiguration

Configures the encoder for screen sharing.

CDN streaming APIs

API

Description

startPublishLiveStreamWithURL

Starts CDN streaming.

updatePublishLiveStreamWithURL

Updates CDN streaming parameters.

stopPublishLiveStreamWithURL

Stops CDN streaming.

GetPublishLiveStreamStateWithURL

Gets the CDN streaming status.

Last-mile network probe APIs

API

Description

startLastmileDetect

Starts the last-mile network probe.

stopLastmileDetect

Stops the last-mile network probe.

SEI

API

Description

sendMediaExtensionMsg

Sends an SEI stream.

sendMediaExtensionMsgEx

Sends an extended SEI stream.

Other APIs

API

Description

setParameter

Sets a custom parameter.

getParameter

Gets a custom parameter.

setLogDirPath

Sets the directory path for SDK log files.

setLogLevel

Sets the log level.

setDeviceOrientationMode

Sets the device orientation mode.

getNetworkTime

Gets the network timestamp.

sendDataChannelMessage

Sends a data channel message.

Callback events

API

Description

onConnectionStatusChange

Reports a change in the network connection state.

onLocalDeviceException

Reports an exception with a local device.

onAuthInfoWillExpire

Occurs 30 seconds before the authentication token expires. Your application must handle this callback to refresh the token.

onAuthInfoExpired

Occurs when an API call that requires authentication fails because the token has expired.

onJoinChannelResult[1/2]

Reports the result of joining a channel.

onJoinChannelResult[2/2]

Reports the result of joining a channel.

onLeaveChannelResult

Reports the result of leaving a channel.

onRemoteUserOffLineNotify

Occurs when a remote user leaves the channel.

onRemoteUserOnLineNotify

Occurs when a remote user joins the channel.

onRemoteTrackAvailableNotify

Occurs when a remote user publishes or unpublishes a media track.

onBye

Occurs when the local user is removed from the channel by the server or the session ends.

onAudioPublishStateChanged

Reports a change in the audio publishing state.

onAudioSubscribeStateChanged

Reports a change in the audio subscribing state.

onUserAudioMuted

Occurs when a remote user mutes or unmutes their audio.

onUserAudioInterruptedBegin

Occurs when an audio device interruption starts.

onUserAudioInterruptedEnded

Occurs when an audio device interruption ends.

onVideoPublishStateChanged

Reports a change in the video publishing state.

onVideoSubscribeStateChanged

Reports a change in the video stream subscribing state.

onUserVideoMuted

Occurs when a remote user mutes their video by sending black frames.

onUserVideoEnabled

Occurs when a remote user enables or disables their video stream.

onUserWillResignActive

Occurs when a remote user's application moves to the background.

onUserWillBecomeActive

Occurs when a remote user's application returns to the foreground.

onAudioEffectFinished

Occurs when the playback of a local audio effect finishes.

onAudioVolumeCallback

Reports the user ID, volume, and voice activity status of subscribed audio streams.

onActiveSpeaker

Reports the active speaker in the channel based on active speaker detection.

onPublishLiveStreamStateChanged

Reports a change in the CDN live streaming state.

onPublishTaskStateChanged

Reports a change in the state of a CDN live streaming task.

onNetworkQualityChanged

Reports a change in network quality.

onLastmileDetectResultWithQuality

Reports the result of the last-mile network quality probe.

onLastmileDetectResultWithBandWidth

Reports the result of the last-mile network bandwidth probe.

onOccurError

Reports an error that occurs during engine runtime.

onFirstAudioPacketSentWithTimecost

Occurs when the first local audio packet is sent.

onFirstVideoFrameReceivedWithUid

Occurs when the first video frame from a remote user is received.

onFirstVideoPacketSentWithVideoTrack

Occurs when the first local video packet is sent.

onFirstAudioPacketReceivedWithUid

Occurs when the first audio packet from a remote user is received.

onFirstRemoteAudioDecodedWithUid

Occurs when the first frame of a remote audio stream is decoded.

onFirstRemoteVideoFrameDrawn

Occurs when the first frame of a remote video stream is rendered.

onFirstLocalVideoFrameDrawn

Occurs when the first frame of the local video preview is rendered.

onTestAudioVolumeCallback

Reports the volume during a pre-call audio capture test.

onAudioAccompanyStateChanged

Reports a change in the local audio mixing state.

onRemoteAudioAccompanyStarted

Occurs when a remote user starts audio mixing.

onRemoteAudioAccompanyFinished

Occurs when a remote user finishes audio mixing.

onRtcStats

Reports runtime statistics of the session. Triggered every 2 seconds.

onRtcLocalVideoStats

Reports statistics of the local video stream. Triggered every 2 seconds.

onRtcRemoteVideoStats

Reports statistics of remote video streams. Triggered every 2 seconds.

onRtcLocalAudioStats

Reports statistics of the local audio stream. Triggered every 2 seconds.

onRtcRemoteAudioStats

Reports statistics of remote audio streams. Triggered every 2 seconds.

onMediaExtensionMsgReceived

Occurs when a supplemental enhancement information (SEI) message is received.

onSnapshotComplete

Reports the result of a snapshot request.

onLocalAudioStateChanged

Reports a change in the state of the local audio capture device.

onLocalVideoStateChanged

Reports a change in the state of the local video capture device.

onRemoteUserSubscribedDataChannel

Occurs when the data channel to a remote user is ready to send messages.

onDataChannelMessage

Occurs when a message is received on the data channel.

onScreenSharePublishStateChanged

Reports a change in the screen sharing publishing state.

AliRtcAudioFrameDelegate

API

Description

onCapturedAudioFrame

Provides captured raw audio data.

onProcessCapturedAudioFrame

Provides audio data after 3A processing.

onPublishAudioFrame

Provides the audio data for publishing.

onPlaybackAudioFrame

Provides audio data for playback.

onRemoteUserAudioFrame

Provides audio data received from a remote user.

AliRtcEngineDestroyDelegate

API

Description

onDestroyCompletion

Occurs when the engine has finished de-initializing. All resources are released after this callback.

AliRtcVideoFrameDelegate

API

Description

onCaptureVideoSample

Provides captured video frames.

onPreEncodeVideoSample

Provides local video frames before they are encoded.

onRemoteVideoSample

Provides video frames received from a remote user.

onGetVideoFormatPreference

Lets you specify the preferred format for video data output.

onGetVideoObservedFramePosition

Lets you specify the desired position in the video pipeline for observing video frames.

API

sharedInstance

Creates an AliRtcEngine instance.

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

Parameters

Parameter

Type

Description

delegate

id<AliRtcEngineDelegate>_Nullable

The delegate for receiving callbacks.

extras

NSString *_Nullable

A JSON string for configuring special SDK features. Pass an empty string ("") if no special features are required.

Important

Only one main instance can exist at a time.

Destroy[1/2]

Releases the SDK instance.

+ (void)destroy;
Important

Call this method after all operations are complete.

Destroy[2/2]

Asynchronously destroys the engine.

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

Parameters

Parameter

Type

Description

delegate

id<AliRtcEngineDestroyDelegate> _Nullable

A delegate to receive the callback after the engine is destroyed.

Important

This is an asynchronous method. Wait for the onDestroyCompletion callback before calling any other methods. To avoid blocking the main thread, we recommend that you call this method from a child thread. To create a new {@link AliRtcEngine} instance, wait until you receive the onDestroyCompletion callback.

setH5CompatibleMode

Enables or disables H5 compatibility mode.

+ (void)setH5CompatibleMode:(BOOL)comp;

Parameters

Parameter

Type

Description

comp

BOOL

Set to YES to enable H5 compatibility mode. The default is NO.

Important

You must call this method before creating the AliRtcEngine instance. H5 compatibility mode cannot be changed after the instance is created.

getH5CompatibleMode

Checks whether h5 compatible mode is enabled.

+ (BOOL)getH5CompatibleMode;

Return value

YES if h5 compatible mode is enabled; NO otherwise.

setChannelProfile

Sets the channel profile.

- (int)setChannelProfile:(AliRtcChannelProfile)profile;

Parameters

Parameter

Type

Description

profile

AliRtcChannelProfile

The channel profile. The default value is AliRtcCommunication. For RTC use cases, this parameter is typically set to AliRtcInteractivelive (interactive mode).

Returns

Returns 0 if the method call succeeds, or a non-zero value if it fails.

Call this method before you join a channel. You cannot change the profile while in a channel, but you can set it again after leaving the channel.

setAudioProfile

Sets the audio profile.

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

Parameters

Parameter

Type

Description

audio_profile

AliRtcAudioProfile

The audio profile for capturing or encoding audio. We recommend using the high-quality mode (AliRtcEngineHighQualityMode).

Note

For interoperability with the Web, the sample rate must be set to 48 kHz.

  • AliRtcEngineLowQualityMode: The low-quality mode. Default: 8,000 Hz sample rate, mono, and a maximum encoding bitrate of 12 kbps.

  • AliRtcEngineBasicQualityMode: The standard-quality mode. Default: 16,000 Hz sample rate, mono, and a maximum encoding bitrate of 24 kbps.

  • AliRtcEngineHighQualityMode: The high-quality mode. Default: 48,000 Hz sample rate, mono, and a maximum encoding bitrate of 64 kbps.

  • AliRtcEngineStereoHighQualityMode: The stereo high-quality mode. Default: 48,000 Hz sample rate, stereo, and a maximum encoding bitrate of 80 kbps.

  • AliRtcEngineSuperHighQualityMode: The super-high-quality mode. Default: 48,000 Hz sample rate, mono, and a maximum encoding bitrate of 96 kbps.

  • AliRtcEngineStereoSuperHighQualityMode: The stereo super-high-quality mode. Default: 48,000 Hz sample rate, stereo, and a maximum encoding bitrate of 128 kbps.

audio_scene

AliRtcAudioScenario

The audio scenario. Valid values:

  • AliRtcSceneMusicMode (Recommended): The music scenario, which uses software 3A and captures audio from the mobile phone, providing higher audio quality.

  • AliRtcSceneDefaultMode: The default scenario, which uses hardware 3A and allows capturing audio from a Bluetooth device.

Note

For ARTC SDK v6.21 and later, do not set the scenario to the chatroom scenario (AliRtcSceneChatroomMode).

Returns

A value of 0 indicates success; any other value indicates failure.

isAudioOnly

Checks if the current session is in audio-only mode.

- (BOOL)isAudioOnly;

Returns

YES if the session is in audio-only mode; NO if in audio and video mode.

setAudioOnlyMode

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

- (int)setAudioOnlyMode:(BOOL)audioOnly;

Parameters

Parameter

Type

Description

audioOnly

BOOL

Set to YES to enable audio-only mode for both stream publishing and stream subscribing. Set to NO to enable audio and video mode. The default is NO.

Returns

Returns 0 on success, or a non-zero error code if the call 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 joining a channel, you must call leaveChannel before joining another. If a join attempt fails, you do not need to call leaveChannel before retrying.

Parameters

Parameter

Type

Description

token

String

The authentication token for joining the channel.

channelId

String

The ID of the channel to join. This value must match the channelId used to generate the token.

userId

String

The user ID. This value must match the userId used to generate the token.

userName

String

The user name to display. This is not the user ID.

onResultWithUserId

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

The callback invoked when the operation completes.

Returns

Returns 0 if the method call succeeds, or a non-zero value if it fails.

Important

This is an asynchronous method. The onResultWithUserId callback returns the result of the join operation.

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 joining a channel, you must call leaveChannel to exit before joining another. If a join attempt fails, you can retry without calling leaveChannel.

Parameters

Parameter

Type

Description

authInfo

AliRtcAuthInfo

Authentication information.

userName

String

The user's display name (not the user ID).

onResultWithUserId

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

The callback invoked when the API 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 joining a channel, you must call leaveChannel before joining another. If the join fails, you can retry without calling leaveChannel.

Parameters

Parameter

Type

Description

authInfo

AliRtcAuthInfo

Authentication credentials.

userName

String

The user's display name, not their user ID.

onResult

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

The callback invoked when the API call completes.

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 successfully joining a channel, you must call leaveChannel to leave it before joining another. If a join attempt fails, you do not need to call leaveChannel.

Parameters

Parameter

Type

Description

token

NSString

The authentication token. Obtain this from your app server.

channelParam

AliRtcChannelParam

The channel parameters.

onResult

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

The callback that is invoked when the API call is complete.

leaveChannel

Leaves the channel.

- (int)leaveChannel;

Returns

Returns 0 on success, or a non-zero value if the method call fails.

isInCall

Checks if the current user is in a channel.

- (BOOL)isInCall;

Return value

YES if in a channel; NO otherwise.

setClientRole

Sets the user role.

- (int)setClientRole:(AliRtcClientRole)role;

Parameters

Parameter

Type

Description

role

AliRtcClientRole

Specifies the user role. The default is AliRtcClientRoleLive (audience role). This setting applies only when the channel is not in communication mode.

Returns

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

getClientRole

Returns the client's role.

- (AliRtcClientRole)getClientRole;

Return value

The client's current role.

refreshAuthInfo

Refreshes the authentication information.

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

Parameters

Parameter

Type

Description

authInfo

AliRtcAuthInfo _Nonnull

The new authentication information.

Returns

0 on success; a non-zero value on failure.

refreshAuthInfoWithToken

Refreshes the authentication information.

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

Parameters

Parameter

Type

Description

token

NSString _Nonnull

The new authentication token.

Returns

0 indicates success, and any other value indicates failure.

publishLocalAudioStream

Publishes or unpublishes the local audio stream.

- (int)publishLocalAudioStream:(BOOL)enabled;

Parameters

Parameter

Type

Description

enable

BOOL

Set to YES to publish the local audio stream, or NO to unpublish it. Defaults to YES.

Return value

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

isLocalAudioStreamPublished

Checks if the local audio stream is published.

- (BOOL)isLocalAudioStreamPublished;

Returns

YES if the audio stream is published; NO otherwise.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to subscribe to all remote audio streams by default.

- (int)setDefaultSubscribeAllRemoteAudioStreams:(BOOL)sub;

Parameters

Parameter

Type

Description

sub

BOOL

Specifies whether to subscribe to all remote audio streams by default. Set to YES to subscribe or NO to prevent automatic subscription. The default is YES.

Returns

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

Important
  • You can call this method both before and after joining a channel. If you call setDefaultSubscribeAllRemoteAudioStreams:NO after joining a channel, you will not receive the audio streams from users who join the channel after you make the call.

  • To resume receiving the audio stream from a specific user, call subscribeRemoteAudioStream uid sub:YES.

  • If you want to resume receiving audio streams from multiple users, you need to call an AliRtcEngine API multiple times. setDefaultSubscribeAllRemoteAudioStreams:YES can only resume receiving audio streams from users who subsequently join the channel.

subscribeAllRemoteAudioStreams

Subscribes to or unsubscribes from all remote audio streams.

- (int)subscribeAllRemoteAudioStreams:(BOOL)sub;

Parameters

Parameter

Type

Description

sub

BOOL

Specifies whether to subscribe to all remote audio streams. The default is YES.

Return value

Returns 0 if the method call succeeds, or a non-zero value if it fails.

Important

Setting this parameter to NO unsubscribes from all current and future remote audio streams. This setting overrides the default subscription behavior in AliRtcEngine.

subscribeRemoteAudioStream

Subscribes to or unsubscribes from the audio stream of a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString _Nonnull

The remote user ID.

sub

BOOL

Set to YES to subscribe to the user's audio stream (the default), or NO to unsubscribe.

Return value

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

Note

If you have muted all remote audio streams by calling subscribeAllRemoteAudioStreams:NO, you must call subscribeAllRemoteAudioStreams:YES before using this method. The subscribeAllRemoteAudioStreams method provides global control, while the subscribeRemoteAudioStream method provides fine-grained control.

publishLocalVideoStream

Enables or disables publishing the local video stream.

- (int)publishLocalVideoStream:(BOOL)enabled;

Parameters

Parameter

Type

Description

enable

BOOL

Whether to publish the local video stream. YES to publish; NO to unpublish. Defaults to YES.

Returns

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

isLocalVideoStreamPublished

Checks whether the local video stream is being published.

- (BOOL)isLocalVideoStreamPublished;

Returns

YES if the local video stream from the camera is being published; NO otherwise.

setDefaultSubscribeAllRemoteVideoStreams

Sets whether to subscribe to all remote video streams by default.

- (int)setDefaultSubscribeAllRemoteVideoStreams:(BOOL)sub;

Parameters

Parameter

Type

Description

sub

BOOL

Set to YES to subscribe to remote video streams, or NO to not subscribe. The default value is YES.

Returns

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

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

  • To resume receiving a specific video stream, call the AliRtcEngine method for individual subscriptions, passing parameters like uid track:track sub:YES.

  • To resume receiving video streams from multiple users already in the channel, call an individual subscription method in AliRtcEngine for each user. Calling setDefaultSubscribeAllRemoteVideoStreams:YES applies only to users who subsequently join the channel; it does not affect users already in the channel.

subscribeAllRemoteVideoStreams

Subscribes to or unsubscribes from all remote video streams.

- (int)subscribeAllRemoteVideoStreams:(BOOL)sub;

Parameters

Parameter

Type

Description

sub

BOOL

Specifies whether to subscribe to all remote video streams. Set this to YES to subscribe and NO to unsubscribe. The default is YES.

Returns

0 indicates a successful method call; a non-zero value indicates failure.

Important

This interface acts as the master switch for subscribing to remote video streams. If you set it to NO, you will stop subscribing to all remote video streams in the current conference and will not subscribe to streams from new users who join later, even if the AliRtcEngine interface is set to YES.

subscribeRemoteMediaStream [1/2]

Subscribes to or unsubscribes from the media stream of a specified 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

Whether to subscribe to the remote user's video stream.
true (default): Subscribes to the video stream.
false: Unsubscribes from the video stream.










subAudio

BOOL

Whether to subscribe to the remote user's audio stream.
true (default): Subscribes to the audio stream.
false: Unsubscribes from the audio stream.










Returns

Returns 0 if the method call succeeds, or a non-zero value if it fails.

subscribeRemoteMediaStream [2/2]

Subscribes to or unsubscribes from a specified remote user's media stream.

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

Parameters

Parameter

Type

Description

uid

NSString

The ID of the remote user.

videoTrack

AliRtcVideoTrack

The type of video track.

audioTrack

AliRtcAudioTrack

The type of audio track.

Returns

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

Note

Use the videoTrack and audioTrack parameters to manage video and audio subscriptions in a single method call.

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

Controls the reception of the remote user's audio stream.
true (default): Resumes receiving the audio stream.
false: Stops receiving the audio stream.










sub

BOOL

Specifies whether to subscribe to or unsubscribe from the remote user's stream.

Returns

A return value of 0 indicates success. Any other value indicates failure.

muteLocalMic

Stops or resumes sending local audio data.

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

Parameters

Parameter

Type

Description

mute

BOOL

Set to YES to send null frames, or NO to resume normal sending. The default is NO.

mode

AliRtcMuteLocalAudioMode

Specifies the mute mode. The default is microphone mute mode.

Returns

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

Note

This method only sends mute frames. The audio capture and encoding modules remain active.

muteRemoteAudioPlaying

Mutes or unmutes the audio playback of a specified remote user.

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

Parameters

Parameter

Type

Description

uid

NSString _Nonnull

The user ID of the specified remote user.

mute

BOOL

Specifies whether to mute the audio playback. YES: Mute. NO: (Default) Unmute.

Return value

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

muteAllRemoteAudioPlaying

Stops or resumes audio from all remote users.

- (int)muteAllRemoteAudioPlaying:(BOOL)mute;

Parameters

Parameter

Type

Description

mute

BOOL

YES stops playback; NO resumes playback. The default value is NO.

Returns

0 indicates success; any other value indicates failure.

Note

This method does not affect stream pulling and decoding. You can call this method before or after initializing AliRtcEngine.

startAudioCapture [1/2]

Starts audio capture.

- (void)startAudioCapture;

Return value

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

Note

This API lets you start audio capture in advance; otherwise, the SDK automatically starts it at an appropriate time.

startAudioCapture [2/2]

Starts audio capture.

- (void)startAudioCapture:(BOOL)keepAlive;

Parameters

Parameter

Type

Description

keepAlive

BOOL

Specifies whether the capture device remains active after you leave the channel.
true: The capture device remains active.
false (default): The capture device is deactivated.










Returns

0: The method call was successful.
< 0: The method call failed.

stopAudioCapture

Stops audio capture. This method is the counterpart to startAudioCapture.

- (void)stopAudioCapture;

Returns

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

startRecord

Starts local audio and video recording.

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

Parameters

Parameter

Type

Description

recordType

AliRtcRecordType

The type of recording.

recordFormat

AliRtcRecordFormat

The format of the recording file.

filePath

NSString

The storage path for the recording file, including the file name.

audioConfig

AliRtcRecordAudioConfig

The audio configuration.

videoConfig

AliRtcRecordVideoConfig

The video configuration.

Return value

Returns TRUE if successful, or FALSE otherwise.

Important

If you record a video file, call this API after the stream is successfully published (onVideoPublishStateChanged). The API records the locally encoded video stream to a local file. If you record an audio stream, the recorded file is an audio file that contains the mix of local and remote audio.

stopRecord

Stops the current recording.

- (void)stopRecord;

Returns

None.

playAudioFileTest

Tests audio playback by playing an audio file from the specified path.

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

Parameters

Parameter

Type

Description

filePath

NSString _Nonnull

The path to the audio file.

Return Value

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

Important

Call this method before you join a channel.

stopAudioFileTest

Stops playing the current audio file.

- (int)stopAudioFileTest;

Return value

Returns 0 on success, or a non-zero error code on failure.

Important

We recommend calling this method before you join a channel.

enableAudioVolumeIndication

Enables or disables the audio volume indication and voice activity detection callbacks.

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

Parameters

Parameter

Type

Description

interval

NSInteger

The time interval, in milliseconds (ms). The minimum value is 10 ms. A value between 300 ms and 500 ms is recommended. Setting this parameter to 0 or less disables the callbacks.

smooth

NSInteger

The smoothing factor. The value ranges from 0 to 9. A higher value results in smoother but less responsive volume changes. The recommended value is 3.

reportVad

NSInteger

Specifies whether to enable voice activity detection. 1: Enables the feature, which reports the speaking status of each user via a callback. 0: Disables the feature.

Returns

0 indicates success; a non-zero value indicates failure.

enableEarBack

Enables or disables the ear back function.

- (int)enableEarBack:(BOOL)enable;

Parameters

Parameter

Type

Description

enable

BOOL

Set to YES to enable ear back, or NO to disable it. The default is NO.

Returns

0 indicates success, and a non-zero value indicates failure.

setEarBackVolume

Sets the in-ear monitoring volume.

- (int)setEarBackVolume:(NSInteger)volume;

Parameter

Parameter

Type

Description

volume

NSInteger

The value ranges from 0 to 100, with a default of 100.

Returns

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

setAudioEffectVoiceChangerMode

Sets the audio effect voice changer mode.

- (int)setAudioEffectVoiceChangerMode:(AliRtcAudioEffectVoiceChangerMode)mode;

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectVoiceChangerMode

Specifies the audio effect voice changer mode. The default value is AliRtcSdk_AudioEffect_Voice_Changer_OFF.

Returns

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

setAudioEffectPitchValue

- (int)setAudioEffectPitchValue:(double)value;

Parameters

Parameter

Type

Description

value

double

The range is [0.5, 2.0]. The default value is 1.0 (no change in pitch).

Return Value

A return value of 0 indicates success; any other value indicates failure.

setAudioEffectReverbMode

Sets the audio effect reverb mode.

- (int)setAudioEffectReverbMode:(AliRtcAudioEffectReverbMode)mode;

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectReverbMode

The audio effect mode. The default value is AliRtcAudioEffectReverb_Off.

Return value

Returns 0 for success, or a non-zero value for failure.

setAudioEffectReverbParamType

Sets the value of a specific reverb audio effect parameter.

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

Parameters

Parameter

Type

Description

type

AliRtcAudioEffectReverbParamType

The reverb mode.

value

float

The parameter value.

Returns

A value of 0 indicates success, and any other value indicates failure.

addExternalAudioStream

Registers an external audio input stream.

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

Parameters

Parameter

Type

Description

config

AliRtcExternalAudioStreamConfig

The external audio stream configuration.

Returns

Returns the external audio stream ID as a positive integer on success. A return value of 0 or less indicates failure.

pushExternalAudioStream

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

Parameters

Parameter

Type

Description

streamId

int

The external audio stream ID.

audioFrame

AliRtcAudioFrame

The audio data.

Returns

0 indicates success. Any other value indicates failure.

setExternalAudioStream:publishVolume

Sets the publishing volume for a specific external audio stream.

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

Parameters

Parameter

Type

Description

streamId

int

The external audio stream ID.

publishVolume

int

The publishing volume.

Return value

A return value of 0 indicates success. Any other value indicates failure.

getExternalAudioStreamPublishVolume

Retrieves the publishing volume of a specified external audio stream.

- (int)getExternalAudioStreamPublishVolume:(int)streamId;

Parameters

Parameter

Type

Description

streamId

int

The ID of the external audio stream.

Return Value

The publishing volume, ranging from 0 to 100. A value less than 0 indicates that the method call failed.

setExternalAudioStream:playoutVolume

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

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

Parameters

Parameter

Type

Description

streamId

int

The external audio stream ID.

playoutVolume

int

The playout volume.

Return value

0 indicates that the method call succeeded; any other value indicates failure.

getExternalAudioStreamPlayoutVolume

Gets the local playout volume for a specified external audio stream.

- (int)getExternalAudioStreamPlayoutVolume:(int)streamId;

Parameters

Parameter

Type

Description

streamId

int

The ID of the external audio stream.

Returns

The playout volume, an integer from 0 to 100. A negative value indicates failure.

preloadAudioEffectWithSoundId

Preloads an audio effect file into memory.

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

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID you assign to the audio effect file.

filePath

NSString _Nonnull

The path to the audio effect file.

Returns

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

unloadAudioEffectWithSoundId

Unloads a specified audio effect from memory.

- (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID of the audio effect to unload.

Return value

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

playAudioEffectWithSoundId

Plays the audio effect file with the specified ID.

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

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID that you assign to the audio effect file.

filePath

NSString _Nonnull

The path to the audio effect file.

cycles

NSInteger

The number of times to play the audio effect. A value of -1 means the effect loops indefinitely.

publish

BOOL

Specifies whether to publish the audio effect.

Returns

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

stopAudioEffectWithSoundId

Stops playing the audio effect with the specified ID.

- (int)stopAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID of the audio effect to stop.

Returns

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

stopAllAudioEffects

Stops all audio effects.

- (int)stopAllAudioEffects;

Return value

Returns 0 on success. Any other value indicates failure.

pauseAudioEffectWithSoundId

Pauses the audio effect with the specified ID.

- (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID you assign to the audio effect file.

Return value

0 indicates that the method call was successful; any other value indicates that it failed.

pauseAllAudioEffects

Pauses all playing audio effects.

- (int)pauseAllAudioEffects;

Returns

0 indicates success; a non-zero value indicates failure.

resumeAudioEffectWithSoundId

Resumes playing the specified audio effect.

- (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The user-assigned ID of the audio effect.

Returns

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

resumeAllAudioEffects

Resumes playback of all paused audio effects.

- (int)resumeAllAudioEffects;

Return value

Returns 0 on success. Any other value indicates failure.

setAudioEffectPublishVolumeWithSoundId

Sets the mixing volume of a specified audio effect for the published stream.

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

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID of the audio effect.

volume

NSInteger

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

Return value

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

getAudioEffectPublishVolumeWithSoundId

Gets the publish volume of a specific audio effect.

- (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The user-assigned ID for the audio effect.

Return Value

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

HTML

setAllAudioEffectsPublishVolume

Sets the publish volume for all audio effects.

- (int)setAllAudioEffectsPublishVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The publish volume. The value ranges from 0 to 100. The default value is 50.

Return value

Returns 0 for a successful method call and a non-zero value on failure.

setAudioEffectPlayoutVolumeWithSoundId

Sets the local playout volume of a specified audio effect.

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

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID of the audio effect.

volume

NSInteger

The local playout volume. Valid values: [0, 100]. Default: 50.

Returns

0: Success.
<0: Failure.

getAudioEffectPlayoutVolumeWithSoundId

Gets the local playout volume for a specified audio effect.

- (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;

Parameters

Parameter

Type

Description

soundId

NSInteger

The ID of the audio effect file.

Return value

Returns the local playout volume (from 0 to 100) on success, or a negative value on failure.

setAllAudioEffectsPlayoutVolume

Sets the local playout volume for all audio effects.

- (int)setAllAudioEffectsPlayoutVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The playout volume of all audio effects. Valid values: [0, 100]. Default value: 50.

Return value

Returns 0 on success, and a non-zero value on failure.

setLocalViewConfig

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

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

Parameters

Parameter

Type

Description

viewConfig

AliVideoCanvas _Nullable

The rendering parameters, including the rendering window and render mode.

track

AliRtcVideoTrack

Specifies the video track type.

Returns

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

Note

You can call this method to switch the rendering window before or after calling other AliRtcEngine APIs. If viewConfig or viewConfig.view is set to nil, video rendering stops. To change the render or mirror mode during playback, modify only the renderMode or mirrorMode member of the viewConfig object.

setCameraCapturerConfiguration

Sets the camera capture preferences.

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

Parameters

Parameter

Type

Description

config

AliRtcCameraCapturerConfiguration _Nonnull

The camera capture preferences. The default values are as follows:
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.


































































Returns

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

enableLocalVideo

Enables or disables local video capture.

- (int)enableLocalVideo:(BOOL)enable;

Parameters

Parameter

Type

Description

enable

BOOL

Whether to enable local video capture.

Return value

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

muteLocalCamera

Stops or resumes sending local video data.

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

This method only controls whether to send black frames on a specified video stream. The local preview freezes on the last frame, but capture and data sending continue. To stop capture or video data transmission, use the AliRtcEngine API.

Parameters

Parameter

Type

Description

mute

BOOL

Specifies whether to send black frames. YES: Send black frames. NO: (Default) Resume sending normal local video data.

track

AliRtcVideoTrack

The video track whose publishing state you want to change.

Returns

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

setRemoteViewConfig

Sets the render window and rendering parameters for a remote video stream.

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

You can call this method to switch the render window before or after calling other AliRtcEngine interface methods. If you set the canvas parameter or its view property to nil, the SDK stops rendering the corresponding stream. To change the render mode or mirror mode during playback, modify only the renderMode or mirrorMode property of the canvas object and keep all other properties unchanged.

Parameters

Parameter

Type

Description

canvas

AliVideoCanvas _Nullable

The video canvas, which includes the render window and render mode.

uid

NSString _Nonnull

The user ID.

track

AliRtcVideoTrack

The video track to configure.

Returns

A return value of 0 indicates a successful method call; any other value indicates a failure.

isCameraOn

Checks whether the camera is on.

- (BOOL)isCameraOn;

Return value

Returns YES if the camera is on, or NO otherwise.

setVideoEncoderConfiguration

Sets the video encoder configuration.

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

Parameters

Parameter

Type

Description

config

AliRtcVideoEncoderConfiguration _Nonnull

The video encoder configuration. The default values are as follows:
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
For the preceding parameters, a value of -1 indicates that the SDK's internal default setting will be used.












































































































setVideoDecoderConfiguration

Sets the video decoder configuration.

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

Parameters

Parameter

Type

Description

config

AliRtcVideoDecoderConfiguration _Nonnull

The video decoder configuration. The default values are as follows:
codecType: AliRtcVideoCodecTypeDefault
enableDecoderBframe: -1
backgroundHardwareToSoftware: -1
The SDK uses its default settings for properties set to -1.
























startPreview

Starts the local preview and automatically turns on the camera.

- (int)startPreview;

You cannot start the local preview if a view has not been set. You can call this method before calling other AliRtcEngine methods.

Returns

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

stopPreview

Stops the local preview.

- (int)stopPreview;

Calling leaveChannel automatically stops the local preview and deactivates the camera. However, the camera remains active if you are currently publishing the camera stream.

Return value

Returns 0 on success, and a non-zero value otherwise.

setExternalVideoSource

Enables or disables an external video source.

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

Parameters

Parameter

Type

Description

enable

BOOL

Pass YES to enable the external video source, or NO to disable it.

type

AliRtcVideoSource

The stream type.

renderMode

AliRtcRenderMode

The render mode.

pushExternalVideoFrame

Pushes an external video frame to the SDK for encoding and transmission.

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

Parameters

Parameter

Type

Description

frame

AliRtcVideoDataSample _Nonnull

Specifies the frame data.

type

AliRtcVideoSource

Specifies the stream type.

Return value

Returns 0 on success; any other value indicates failure.

startScreenShareWithDesktopId

Starts sharing the screen of the specified desktop.

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

Parameters

Parameter

Type

Description

desktopId

int

The ID of the desktop to share.

config

AliRtcScreenShareConfig

Screen sharing configuration.

Return value

  • 0 indicates success.

  • A non-zero value indicates failure.

startScreenShareWithWindowId

Shares the content of a window specified by its ID and publishes it as a video stream.

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

Parameters

Parameter

Type

Description

windowId

int

The window ID.

config

AliRtcScreenShareConfig

The screen sharing configuration.

Return value

  • 0: Success.

  • Non-zero: Failure.

Stop screen share

Stops screen sharing.

- (int)stopScreenShare;

Parameters

None.

Returns

  • 0: Success.

  • A non-zero value: Failure.

updateScreenShareConfig

Updates the screen share configuration.

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

Parameters

Parameter

Type

Description

config

AliRtcScreenShareConfig

The screen share configuration.

Returns

  • 0: Success.

  • Any other value: Failure.

isScreenSharePublished

Checks if screen share publishing is in progress.

- (BOOL)isScreenSharePublished;

Parameters

None.

Return value

  • TRUE: Publishing is in progress.

  • FALSE: Publishing is not in progress.

startPublishLiveStreamWithURL

Starts CDN live streaming.

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

Parameters

Parameter

Type

Description

streamURL

NSString _Nonnull

The stream URL.

trancoding

AliRtcLiveTranscodingParam _Nonnull

The stream publishing parameters.

Return value

Returns 0 on success. Any other value indicates failure.

updatePublishLiveStreamWithURL

Updates live streaming parameters.

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

Parameters

Parameter

Type

Description

streamURL

NSString _Nonnull

The stream URL.

trancoding

AliRtcLiveTranscodingParam _Nonnull

Parameters for stream publishing.

Return value

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

stopPublishLiveStreamWithURL

Stops CDN live streaming.

- (int)stopPublishLiveStreamWithURL:(NSString * _Nonnull)streamURL;

Parameters

Parameter

Type

Description

streamURL

NSString _Nonnull

The push URL.

Return value

A return value of 0 indicates success; any other value indicates failure.

GetPublishLiveStreamStateWithURL

Gets the state of the live stream transcoding.

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

Parameters

Parameter

Type

Description

streamURL

NSString _Nonnull

The publishing stream URL.

Returns

The current state of the live stream transcoding.

startLastmileDetect

Starts a last-mile network quality probe.

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

Parameters

Parameter

Type

Description

config

AliRtcNetworkQualityProbeConfig _Nonnull

The probe configuration.

Return value

Returns 0 on success, a non-zero value otherwise.

stopLastmileDetect

Stops last-mile network detection.

- (int)stopLastmileDetect;

Return value

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

setParameter

Sets a custom parameter.

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

Parameters

Parameter

Type

Description

param

NSString _Nonnull

The custom parameter to set.

getParameter

Gets a custom parameter.

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

Parameters

Parameter

Type

Description

param

NSString _Nonnull

The custom parameter to retrieve.

enableAudioFrameObserver

Configures the audio callback parameters.

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

Parameters

Parameter

Type

Description

enable

bool

Whether to enable the data callback.

audioSource

AliRtcAudioSource

Specifies the type of audio source for the callback.

config

AliRtcAudioFrameObserverConfig _Nullable

Specifies the callback configuration.

registerAudioFrameObserver

Registers an audio frame observer.

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

Parameters

Parameter

Type

Description

observer

id<AliRtcAudioFrameDelegate> _Nullable

The audio frame observer.

registerVideoSampleObserver

Registers a callback for video data output.

- (void)registerVideoSampleObserver;

unregisterVideoSampleObserver

Unregisters the video sample observer.

- (void)unregisterVideoSampleObserver;

setLogDirPath

Sets the storage path for SDK log files.

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

Parameters

Parameter

Type

Description

logDirPath

NSString _Nullable

The absolute path of the log storage directory. The default storage path is Library/Caches/Ali_RTC_Log on iOS and /Users/xxx/Documents/Ali_RTC_Log on macOS.

Important

Call this method before making any other calls to the SDK to prevent log loss. Ensure the specified directory exists and is writable.

setLogLevel

Sets the log level.

- (void)setLogLevel:(AliRtcLogLevel)logLevel;

Parameters

Parameter

Type

Description

logLevel

AliRtcLogLevel

The log level. The default is AliRtcLogLevelInfo.

setVideoMirrorMode

Sets the video mirror mode.

- (int)setVideoMirrorMode:(AliRtcVideoPipelineMirrorMode)mirrorMode;

Parameters

Parameter

Type

Description

mirrorMode

AliRtcVideoPipelineMirrorMode

The mirror type.

Return value

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

Important

You can call this method to dynamically set the video mirror mode either before or after you join the channel. The SDK records this state and applies it when preview and encoding are active. This method overrides the mirror settings in setLocalViewConfig and setVideoEncoderConfig. To avoid conflicts from this overlap, use only one method to configure the mirror mode.

setCapturePipelineScaleMode

Sets the capture pipeline scale mode.

- (void)setCapturePipelineScaleMode:(AliRtcCapturePipelineScaleMode)mode;

Parameters

Parameter

Type

Description

mode

AliRtcCapturePipelineScaleMode

Specifies the scale mode for the capture pipeline.

Returns

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

Important

This method controls when scaling occurs in the capture pipeline. By default, video is scaled immediately upon capture. You must call this method before calling the startPreview or joinChannel method.

getSdkVersion

Gets the SDK version.

+ (NSString _Nonnull)getSdkVersion;

Returns

A string representing the current SDK version (e.g., "2.5.0.x"). This is a static method and can be called at any time.

setScreenShareEncoderConfiguration

Sets the encoder configuration for screen sharing.

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

Parameters

Parameter

Type

Description

config

AliRtcScreenShareEncoderConfiguration _Nonnull

The encoder configuration for the screen stream. It specifies parameters such as resolution, frame rate, bitrate, and video orientation. All these parameters have valid ranges.

Important

Use this method to set the encoder configuration for the screen stream, such as resolution, frame rate, bitrate, and video orientation. Each parameter has a valid range. If you set a parameter outside its valid range, the SDK automatically adjusts it. You can call this method before or after you join a meeting. For a one-time configuration per meeting, call this method before joining.

setRemoteAudioVolume

Sets the playback volume of the remote audio.

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

Parameters

Parameter

Type

Description

uid

NSString _Nonnull

The unique identifier of the remote user, assigned by your application server.

volume

NSInteger

The playback volume. The value ranges from 0 (mute) to 100 (original volume).

Returns

A return value of 0 indicates a successful method call; any other value indicates failure.

Important

Call this method only after the remote user has joined the meeting. The method call fails if the specified uid belongs to a user who is not in the meeting.

subscribeRemoteVideoStream

Subscribes to or unsubscribes from the video stream of a specified remote user.

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

Parameters

Parameter

Type

Description

uid

NSString _Nonnull

The user ID, a unique identifier assigned by your app server.

track

AliRtcVideoTrack

The video stream type.

sub

BOOL

Set to YES to subscribe or NO to unsubscribe.

Returns

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

Important

This method has no effect if you have previously called subscribeAllRemoteVideoStreams to unsubscribe from all remote video streams. subscribeAllRemoteVideoStreams is a global control, while subscribeRemoteVideoStream provides individual control.

subscribeRemoteDestChannelStream

Subscribes to or unsubscribes from the stream of a specified user in the destination channel.

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

Parameters

Parameter

Type

Description

channelId

NSString _Nonnull

The destination channel.

uid

NSString _Nonnull

The unique user ID assigned by your app server.

videoTrack

AliRtcVideoTrack

The type of video track to subscribe to.

audioTrack

AliRtcAudioTrack

The type of audio track to subscribe to.

sub

BOOL

Set to true to subscribe to the stream, or false to unsubscribe.

Returns

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

subscribeRemoteDestChannelAllStream

Subscribes to all user streams in the destination channel.

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

Parameters

Parameter

Type

Description

channelId

NSString _Nonnull

The ID of the destination channel.

track

AliRtcVideoTrack

The video track type.

subAudio

BOOL

Specifies whether to subscribe to the audio streams.

sub

BOOL

Specifies whether to subscribe to the video streams.

Returns

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

setRecordingVolume

Sets the recording volume.

- (int)setRecordingVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

Value range: [0, 400]. The range [0, 100] represents the original volume, while the range [100, 400] is for volume amplification.

Return value

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

setPlayoutVolume

Sets the playout volume.

- (int)setPlayoutVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The playout volume. The value range is from 0 to 400. A value of 100 represents the original volume, and values above 100 amplify the volume.

Returns

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

startAudioCaptureTest

Starts a pre-call test of the audio capture device.

- (int)startAudioCaptureTest;
Important

Call this method before joinChannel. The method fails if called after joining a channel.

stopAudioCaptureTest

Stops the pre-call audio capture device test.

- (int)stopAudioCaptureTest;
Important

Call this method only before joinChannel. Otherwise, the call fails.

getAudioFileInfo

Retrieves audio file information.

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

Parameters

Parameter

Type

Description

filePath

NSString *

The path to the audio file.

Important

This method is asynchronous, and the audio file information is returned in the {@link onAudioFileInfo:errorCode:} callback.

startAudioAccompanyWithFile

Starts audio mixing.

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

Parameters

Parameter

Type

Description

filePath

NSString *

The audio file path.

config

AliRtcAudioAccompanyConfig *

The audio mixing configuration.

Returns

0 indicates the method call was successful; a non-zero value indicates failure.

Important

This is an asynchronous interface. You can monitor the player's state via the {@link onAudioAccompanyStateChanged:errorCode:} callback.

stopAudioAccompany

Stops audio accompaniment mixing.

- (int)stopAudioAccompany;

return value

0 indicates a successful call; any other value indicates failure.

setAudioAccompanyVolume

Sets the accompaniment volume.

- (int)setAudioAccompanyVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The accompaniment volume. The value must be an integer between 0 and 100, inclusive.

Returns

Returns 0 if the method call succeeds, or a non-zero value if it fails.

Important

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

setAudioAccompanyPublishVolume

Sets the volume of the audio accompaniment for publishing.

- (int)setAudioAccompanyPublishVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

Audio accompaniment volume. Range: [0, 100].

Returns

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

Important

This setting affects the volume of the accompaniment in the published stream.

getAudioAccompanyPublishVolume

Gets the audio accompaniment publish volume.

- (int)getAudioAccompanyPublishVolume;

Returns

A value in the range of [0, 100] is returned on success. Other values indicate failure.

setAudioAccompanyPlayoutVolume

Sets the audio accompaniment's local playback volume.

- (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The volume of the audio accompaniment, in the range [0, 100].

Returns

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

getAudioAccompanyPlayoutVolume

Gets the audio accompaniment playback volume.

- (int)getAudioAccompanyPlayoutVolume;

Return value

A value from 0 to 100 is returned on success; any other value indicates failure.

pauseAudioAccompany

Pauses the audio accompaniment.

- (int)pauseAudioAccompany;

Return value

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

resumeAudioAccompany

Resumes the audio accompaniment.

- (int)resumeAudioAccompany;

Returns

0 indicates success, and a non-zero value indicates failure.

getAudioAccompanyDuration

Returns the duration of the accompaniment file in milliseconds.

- (int)getAudioAccompanyDuration;

Return value

The duration of the accompaniment file in milliseconds. A negative value indicates failure.

getAudioAccompanyCurrentPosition

Returns the current position of the audio accompaniment file in ms.

- (int)getAudioAccompanyCurrentPosition;

Return value

>=0: The current position; <0: Failure.

setAudioAccompanyPosition

Sets the playback position of the accompaniment file.

- (int)setAudioAccompanyPosition:(int)pos;

Parameters

Parameter

Type

Description

pos

int

The playback position in milliseconds.

Returns

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

setEarBackVolume

Sets the in-ear monitoring volume.

- (int)setEarBackVolume:(NSInteger)volume;

Parameters

Parameter

Type

Description

volume

NSInteger

The volume level, ranging from 0 to 100. The default is 100.

Returns

Returns 0 if the method call succeeds, or a non-zero value if it fails.

snapshotVideo

Captures a video snapshot.

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

Parameters

Parameter

Type

Description

userId

NSString *

The ID of the user for whom to capture the snapshot. To capture a snapshot of the local user, set this parameter to nil or an empty string.

type

AliRtcVideoTrack

The type of the video stream to capture. Only AliRtcVideoTrackCamera and AliRtcVideoTrackScreen are supported.

Return value

Returns 0 if the call succeeds, or a non-zero value if it fails.

sendMediaExtensionMsg

Sends a media extension message.

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

Parameters

Parameter

Type

Description

data

NSData *

The content of the media extension message. The maximum size is 4 KB.

repeatCount

int

The number of times the message is repeated. This setting controls message redundancy to mitigate packet loss. A value of -1 means the message is sent indefinitely until sendMediaExtensionMsg is called again.

delay

int

The delay in milliseconds (ms) before sending the SEI message. Because the SDK attaches the SEI message to the H.264/H.265 encoded stream, the actual delay may be slightly longer than this value.

isKeyFrame

bool

Specifies whether to attach the SEI message only to key frames.

Return value

Returns 0 on success, or a non-zero error code on failure.

Important

This method reuses the audio and video data channel to send media extension messages. Therefore, you must control the frequency and size of the custom messages. The following limitations apply:

  1. The number of messages you can send per second cannot exceed the frame rate (fps) set in the profile.

  2. To avoid degrading media quality, each custom message is limited to 4 KB. This size is ideal for transmitting small amounts of data.

  3. A repeatCount value greater than 1 causes the message to be sent multiple times to mitigate packet loss. Other users will receive duplicate messages and must perform deduplication.

  4. Subscribers in relayed live streaming also receive these custom messages. If repeatCount is -1, the SDK sends the message indefinitely until you call sendMediaExtensionMsg again.

  5. The web client support for SEI messages is as follows:

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

















  6. A new call to this method overwrites any previous call that has not yet been completed.

sendMediaExtensionMsgEx

Sends a media extension message. This method uses SEI.

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

Parameters

Parameter

Type

Description

data

NSData *

The media extension message payload. The maximum size is 4 KB.

repeatCount

int

The number of times to repeat the message. This value specifies the message redundancy to prevent message loss due to network packet loss. A value of -1 repeats the message until sendMediaExtensionMsgEx is called again.

delay

int

The delay in milliseconds (ms) before sending the SEI message. The actual delay may be slightly longer than the specified value because the SEI message is attached to the encoded H.264/H.265 stream.

isKeyFrame

bool

Set to true to attach the SEI message only to keyframes.

payloadType

int

The payload type. Use 5 for payloads that include a UUID. The valid range is [5, 100..254].

Return value

Returns 0 on success, or a non-zero error code on failure.

Important

This method reuses the audio/video data channel to send media extension messages. Therefore, you must control the frequency and size of custom messages. The following limitations apply:

  1. The number of messages sent per second cannot exceed the frames per second (fps) value set in the profile.

  2. To avoid affecting media transmission quality, the custom message size is limited to 4 KB.

  3. If you set repeatCount to a value greater than 1 to prevent message loss, subscribers will receive the same message multiple times. Your application is responsible for deduplication on the receiving end.

  4. Subscribers in sideload streaming also receive these custom messages.

  5. Web client support for SEI:

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

















  6. A new call to this method overwrites any previous call that has not yet completed.

startAudioPlayer

Starts audio playback.

- (void)startAudioPlayer;
Important

Call this API to start audio playback in advance. Otherwise, the SDK automatically starts playback after subscribing to an audio stream.

stopAudioPlayer

Stops audio playback.

- (void)stopAudioPlayer;
Important

This method stops audio playback.

removeExternalAudioStream

Removes an external audio stream.

- (int)removeExternalAudioStream:(int)streamId;

Parameters

Parameter

Type

Description

streamId

int

The external audio stream ID.

Return value

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

getNetworkTime

Returns the current time of the timeline.

-(long long)getNetworkTime;

Parameters

Parameter

Type

Description

Returns

The timeline's current timestamp.

sendDataChannelMessage

Sends a data channel message.

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

The ARTC SDK enables you to send and receive custom messages through a dedicated data channel. You can call this method to transmit real-time data, such as control commands, state synchronization information, or other business messages, alongside audio and video streams. For more details, see Send and receive custom messages.

Note
  • The data channel is disabled by default. To use this feature, you must call the setParameter method with the following JSON string to enable it: "{\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}". You can enable the data channel before or after joining a channel.

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

  • The ARTC DataChannel feature requires active stream publishing from the sender. Ensure an audio or video stream is being published.

Related callbacks

  • After the sender enables the data channel, they can call this method to send a custom message. The receiver receives the custom message through the onDataChannelMessage callback.

Usage limits

  • Users with the broadcaster role can send and receive messages. Users with the audience role can only receive messages.

  • You must call setParameter to enable the data channel.

  • The following data sending limits apply:

    • The maximum bitrate is 30 KB/s.

    • The data channel is limited to 60 data packets per second, and each packet can be up to 1 KB.

Parameters

Parameter

Type

Description

controlMsg

AliRtcDataChannelMsg *

The control message.

Returns

Returns 0 for success and a non-zero value for failure.

setDeviceOrientationMode

Sets the device orientation.

- (int)setDeviceOrientationMode:(AliRtcOrientationMode)mode;

Parameters

Parameter

Type

Description

mode

AliRtcOrientationMode

The device orientation.

Return value

Returns 0 for success, or a non-zero value for failure.

registerVideoFrameWithObserver

Registers a video frame observer.

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

Parameters

Parameter

Type

Description

observer

AliRtcVideoFrameDelegate

The video frame observer object.

unregisterVideoSampleWithObserver

Unregisters a video frame observer.

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

Parameters

Parameter

Type

Description

observer

AliRtcVideoFrameDelegate

The video frame observer to unregister.

Callback

onConnectionStatusChange

Triggered when the connection status changes.

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

Parameters

Parameter

Type

Description

status

AliRtcConnectionStatus

The current connection status.

reason

AliRtcConnectionStatusChangeReason

The reason for the status change.

onLocalDeviceException

A callback that triggers when an exception occurs on a local device. You should handle this callback.

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

Parameters

Parameter

Type

Description

deviceType

AliRtcLocalDeviceType

The device type.

exceptionType

AliRtcLocalDeviceExceptionType

The device exception type.

msg

NSString *

Information about the exception.

onAuthInfoWillExpire

This required callback notifies you that your authentication information will expire in 30 seconds.

- (void)onAuthInfoWillExpire;

onAuthInfoExpired

Occurs when a user calls an interface that requires authentication, and the server responds that the authentication information has expired.

- (void)onAuthInfoExpired;

onJoinChannelResult[1/2]

Reports the result of joining a channel. This callback and the block in the joinChannel method serve the same purpose, so you only need to handle one.

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

Parameters

Parameter

Type

Description

result

int

A value of 0 indicates success, while any non-zero value is an error code.

channel

NSString *

The channel ID.

userId

NSString *

The user ID.

elapsed

int

The time elapsed, in milliseconds, from calling the joinChannel method until this callback is triggered.

onJoinChannelResult[2/2]

Reports the result of joining a channel. This callback is equivalent to the completion block for the joinChannel method, so you only need to implement one of them.

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

Parameters

Parameter

Type

Description

result

int

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

channel

NSString *

The ID of the joined channel.

elapsed

int

The time elapsed (in milliseconds) to join the channel.

onLeaveChannelResult

Reports the result of leaving a channel. This callback occurs after you call the leaveChannel method. If you call the destroy method immediately after leaveChannel, this callback is not triggered.

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

Parameters

Parameter

Type

Description

result

int

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

stats

AliRtcStats

Session statistics.

onRemoteUserOffLineNotify

Triggered when a remote user goes offline.

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

Parameters

Parameter

Type

Description

uid

NSString *

The unique user ID assigned by your app server.

reason

AliRtcUserOfflineReason

The reason the remote user goes offline.

onRemoteUserOnLineNotify

Occurs when a remote user joins the channel.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID, a unique identifier assigned by your app server.

elapsed

int

The time it took the remote user to join the channel.

onRemoteTrackAvailableNotify

Triggered when a remote user's track becomes available or unavailable.

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

Parameters

Parameter

Type

Description

uid

NSString *

The unique user ID assigned by your app server.

audioTrack

AliRtcAudioTrack

The remote user's updated audio track.

videoTrack

AliRtcVideoTrack

The remote user's updated video track.

onBye

Triggered when the server removes you from the channel or the channel closes.

- (void)onBye:(int)code;

Parameters

Parameter

Type

Description

code

int

Indicates the reason for the disconnection. Valid values:
1: You were removed by the server.
2: The channel was closed.
3: You logged in on another device with the same user ID.

















onAudioPublishStateChanged

Called when the audio publishing state changes.

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

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The previous audio publishing state.

newState

AliRtcPublishState

The current audio publishing state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The current channel ID.

onAudioSubscribeStateChanged

Called 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

Parameter

Type

Description

uid

NSString *

The ID of the user whose subscription state changed.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The current channel ID.

onUserAudioMuted

Occurs when a remote user mutes or unmutes their audio.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

isMute

BOOL

YES if the user's audio is muted; NO otherwise.

onUserAudioInterruptedBegin

Occurs when a user's audio is interrupted. This typically happens when a system event, such as an incoming phone call, preempts the app's audio.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the interrupted user.

onUserAudioInterruptedEnded

Triggered when a user's audio interruption ends.

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

Parameters

Parameter

Type

Description

uid

NSString *

The ID of the user whose audio interruption ended.

onVideoPublishStateChanged

Occurs when the video publishing state changes.

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

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The current publish state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The channel ID.

onVideoSubscribeStateChanged

Occurs when the subscription state of a camera stream changes.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the stream publisher.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

NSInteger

Time elapsed since the last state change, in milliseconds.

channel

NSString *

The channel ID.

onUserVideoMuted

Called when a user mutes or unmutes their video.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the user who muted or unmuted their video.

isMute

BOOL

YES means black frames are pushed; NO means a normal stream is pushed.

onUserVideoEnabled

Occurs when a remote user enables or disables local video capture.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

isEnable

BOOL

YES: Video capture is enabled. NO: Video capture is disabled.

onUserWillResignActive

Occurs when a remote user's application moves to the background.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

onUserWillBecomeActive

Occurs when a remote user's application returns to the foreground.

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

Parameters

Parameter

Type

Description

uid

NSString *

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

onRtcStats

This callback reports real-time statistics every 2 seconds.

- (void)onRtcStats:(AliRtcStats)stats;

Parameters

Parameter

Type

Description

stats

AliRtcStats

The callback statistics.

onAudioEffectFinished

Occurs when a local audio effect finishes playing.

- (void)onAudioEffectFinished:(int)soundId;

Parameters

Parameter

Type

Description

soundId

int

The ID of the audio effect that has finished playing.

onAudioVolumeCallback

Reports the audio volume, voice status, and UID of subscribed users.

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

Parameters

Parameter

Type

Description

array

NSArray <AliRtcUserVolumeInfo *> *

An array where each element specifies the UID, voice status, and audio volume of a user. A UID of 0 identifies the local speaker.

totalVolume

int

The total volume of all speakers after audio mixing. The value ranges from 0 to 255.

onActiveSpeaker

Reports the active speaker.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the active speaker.

onPublishLiveStreamStateChanged

Reports a change in the live streaming state.

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

Parameters

Parameter

Type

Description

streamURL

NSString *

The URL of the affected live stream.

state

AliRtcLiveTranscodingState

The new state of the live stream.

errCode

AliRtcTrascodingLiveStreamErrorCode

The associated error code.

onPublishTaskStateChanged

Triggered when the state of a live streaming task changes.

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

Parameters

Parameter

Type

Description

streamURL

NSString *

The stream URL.

state

AliRtcTrascodingLiveTaskStatus

The state of the live streaming task.

onNetworkQualityChanged

The SDK triggers this callback when the network quality changes.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID. If this parameter is empty, the callback reports the network quality of the local user.

upQuality

AliRtcNetworkQuality

The uplink network quality.

downQuality

AliRtcNetworkQuality

The downlink network quality.

onLastmileDetectResultWithQuality

Reports the result of the last-mile network quality detection.

- (void)onLastmileDetectResultWithQuality:(AliRtcNetworkQuality)networkQuality;

Parameters

Parameter

Type

Description

networkQuality

AliRtcNetworkQuality

The detected last-mile network quality.

onLastmileDetectResultWithBandWidth

This callback reports the last-mile network quality probe result.

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

Parameters

Parameter

Type

Description

code

int

The probe result code. 0: Success. -1: Failure caused by a poor network condition.

result

AliRtcNetworkQualityProbeResult *

The detailed network quality probe result.

onAudioPublishStateChanged

Triggers when the audio publishing state changes.

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

Parameters

Parameter

Type

Description

track

AliRtcAudioTrack

The track whose publish state changed.

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The current publish state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The current channel ID.

onScreenSharePublishStateChanged

Occurs when the publish state of the screen sharing stream changes.

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

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The new publish state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The channel ID.

onAudioSubscribeStateChanged

Occurs when the subscription state of an audio stream changes.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID.

track

AliRtcAudioTrack

The track whose subscription state changed.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

NSInteger

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

channel

NSString *

The channel ID.

onScreenShareSubscribeStateChanged

Occurs when the subscription state of a screen share stream changes.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The new subscription state.

elapseSinceLastState

NSInteger

Time elapsed since the last state change, in milliseconds.

channel

NSString *

The channel ID.

onUpdateRoleNotifyWithOldRole

This callback fires when the user's role changes.

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

Parameters

Parameter

Type

Description

oldRole

AliRtcClientRole

The previous role.

newRole

AliRtcClientRole

The new role.

onOccurError

Called when an error occurs in the engine.

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

Parameters

Parameter

Type

Description

error

int

The error code. For details, see {@link AliRtcErrorCode}.

message

NSString *

The error description.

onFirstAudioPacketSentWithTimecost

Called when the first audio packet is sent.

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

Parameters

Parameter

Type

Description

track

AliRtcAudioTrack

The audio track.

timeCost

int

The time elapsed to send the packet, in milliseconds (ms).

onFirstVideoFrameReceivedWithUid

Triggered when the first video frame from a remote user is received.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID.

videoTrack

AliRtcVideoTrack

The video track.

timeCost

int

The time elapsed, in milliseconds.

onFirstVideoPacketSentWithVideoTrack

Indicates that the first video packet of a video track has been sent.

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

Parameters

Parameter

Type

Description

videoTrack

AliRtcVideoTrack

The video track.

timeCost

int

The time taken, in milliseconds.

onFirstAudioPacketReceivedWithUid

Occurs when the SDK receives the first audio packet from a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

track

AliRtcAudioTrack

The audio track.

timeCost

int

The elapsed time from sending to receiving, in milliseconds (ms).

onFirstRemoteAudioDecodedWithUid

Occurs when the first audio frame from a remote user is decoded.

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

Parameters

Parameter

Type

Description

uid

NSString *

The ID of the remote user.

track

AliRtcAudioTrack

The audio track type.

elapsed

int

The time elapsed, in milliseconds, since the local user joined the channel.

onFirstRemoteVideoFrameDrawn

Called when the SDK renders the first video frame of a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

The ID of the remote user.

videoTrack

AliRtcVideoTrack

The rendered video track.

width

int

The width of the video frame in pixels.

height

int

The height of the video frame in pixels.

elapsed

int

The time elapsed (in milliseconds) since the local user joined the channel.

onFirstLocalVideoFrameDrawn

Occurs when the first frame of the local preview video is drawn.

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

Parameters

Parameter

Type

Description

width

int

Width of the local preview video, in pixels.

height

int

Height of the local preview video, in pixels.

elapsed

int

The time elapsed, in milliseconds, since the local user joined the channel.


onTestAudioVolumeCallback

Reports the volume during a pre-call audio capture test.

- (void)onTestAudioVolumeCallback:(int)volume;

Parameters

Parameter

Type

Description

volume

int

The volume level, ranging from 0 to 100.

onAudioAccompanyStateChanged

Occurs when the playback state of the local audio accompaniment changes.

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

Parameters

Parameter

Type

Description

playState

AliRtcAudioAccompanyStateCode

The state of the audio accompaniment.

errorCode

AliRtcAudioAccompanyErrorCode

The error code.

onRemoteAudioAccompanyStarted

Reports that a remote user has started playing the accompaniment.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

onRemoteAudioAccompanyFinished

Occurs when a remote user finishes playing the audio accompaniment.

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

Parameters

Parameter

Type

Description

uid

NSString *

The ID of the remote user.

onVideoResolutionChanged

Called when the video resolution changes.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID.

videoTrack

AliRtcVideoTrack

The video track.

width

int

The video width, in pixels.

height

int

The video height, in pixels.

onRtcLocalVideoStats

Reports the local video stats every two seconds.

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

Parameters

Parameter

Type

Description

localVideoStats

AliRtcLocalVideoStats *

Contains stats for the local video stream.

onRtcRemoteVideoStats

Reports remote video stats every 2 seconds.

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

Parameters

Parameter

Type

Description

remoteVideoStats

AliRtcRemoteVideoStats *

The statistics for the remote video stream.

onRtcLocalAudioStats

Reports the local audio stats. This callback is triggered every two seconds.

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

Parameters

Parameter

Type

Description

localAudioStats

AliRtcLocalAudioStats *

Statistics for the local audio stream.

onRtcRemoteAudioStats

Reports remote audio statistics. This callback is triggered every 2 seconds.

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

Parameters

Parameter

Type

Description

remoteAudioStats

AliRtcRemoteAudioStats *

The remote audio statistics.

onMediaExtensionMsgReceived

Triggered when a media extension message is received.

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

Parameters

Parameter

Type

Description

uid

NSString *

The ID of the user who sent the message.

payloadType

int

The payload type.

message

NSData *

The received media extension message.

onSnapshotComplete

Notifies the application of the result of a snapshot request.

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

Parameters

Parameter

Type

Description

image

UIImage *

The snapshot image.

success

BOOL

'true' if the snapshot was successful; 'false' otherwise.

onLocalAudioStateChanged

Called when the state of the local audio capture device changes.

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

Parameters

Parameter

Type

Description

state

AliRtcLocalAudioStateType

The device state. For possible values, see AliRtcLocalAudioStateType.

msg

NSString *

A message describing the state change.

Important

This callback reports the results of startAudioCapture and stopAudioCapture.

onLocalVideoStateChanged

The system triggers this callback when the state of the local video capture device changes.

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

Parameters

Name

Type

Description

state

AliRtcLocalVideoStateType

The new device state. For more information, see AliRtcLocalVideoStateType.

msg

NSString *

A descriptive message about the state change.

onRemoteUserSubscribedDataChannel

Triggered when the data channel is ready to send messages to a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID of the remote user.

onDataChannelMessage

Invoked when a message is received through the data channel.

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

The ARTC data channel depends on an active audio/video stream. Sending a message requires active stream publishing, and receiving a message requires an active stream subscription.

Parameters

Parameter

Type

Description

uid

NSString *

The sender's user ID.

controlMsg

AliRtcDataChannelMsg

The received message.

AliRtcVideoFrameDelegate

onCaptureVideoSample

Callback for captured raw video data.

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

Parameters

Parameter

Type

Description

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return Value

YES: Write the modified data back to the SDK. This is valid only for I420 and CVPixelBuffer formats on iOS and macOS.
NO: Do not write the data back to the SDK.



onPreEncodeVideoSample

Callback for local raw video data before encoding.

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

Parameters

Parameter

Type

Description

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return Value

YES: Write the modified data back to the SDK. This is valid only for I420 and CVPixelBuffer formats on iOS and macOS.
NO: Do not write the data back to the SDK.



onRemoteVideoSample

Callback for raw video data from a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

The user ID.

videoSource

AliRtcVideoSource

The video stream type.

videoSample

AliRtcVideoDataSample *

The raw video data.

Return Value

YES: Write the modified data back to the SDK. This is valid only for I420 and CVPixelBuffer formats on iOS and macOS.
NO: Do not write the data back to the SDK.



onGetVideoFormatPreference

Callback for specifying the preferred format for video data output.

- (AliRtcVideoFormat)onGetVideoFormatPreference;

Return Value

The desired video output format.

Important

Your application can return the desired video data format. The default is AliRtcYUV420.

onGetVideoObservedFramePosition

Callback for specifying the desired position in the video pipeline for data observation.

- (NSInteger)onGetVideoObservedFramePosition;

Return Value

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

AliRtcAudioFrameDelegate

onCapturedAudioFrame

Receives captured raw audio data.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important
  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

onProcessCapturedAudioFrame

Receives captured audio data after 3A processing.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important
  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

onPublishAudioFrame

Receives audio data for stream publishing.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important
  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

onPlaybackAudioFrame

Receives audio data for playback.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important
  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

onMixedAllAudioFrame

Receives mixed audio data from both stream publishing and playback.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important

This feature is not currently supported.

  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

onRemoteUserAudioFrame

Receives audio data from a remote user's stream.

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame *

The audio frame.

Return value

Returns true on success.

Important
  1. To prevent audio glitches, avoid performing time-consuming operations in this callback function.

  2. This API supports configuring the sample rate and the number of channels.

  3. This API supports read/write mode.

AliRtcEngineDestroyDelegate

onDestroyCompletion

Fired when the engine is completely destroyed. The destruction process is not complete until this callback is received.

- (void)onDestroyCompletion;
Important

To avoid blocking the main thread, wait for this callback before calling any other methods.

onTextureUpdate

Callback for OpenGL texture updates.

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

Parameters

Parameter

Type

Description

textureId

int

The OpenGL texture ID.

width

int

The video width, in pixels.

height

int

The video height, in pixels.

videoSample

AliRtcVideoDataSample *

The video frame data.

Return value

Returns the new texture ID or the original texture ID. A return value of less than 0 indicates that the texture ID was not updated.

Important

This callback is triggered after each video frame is uploaded to an OpenGL texture. If a texture data observer is registered, you can process the texture in this callback and return the ID of the processed texture.
The return value must be a valid texture ID. If you do not perform any processing, you must return the input textureId.



onTextureDestroy

A callback called when the OpenGL context is destroyed.

- (void)onTextureDestroy;
Important

The SDK triggers this callback when it destroys its internal OpenGL context.