All Products
Search
Document Center

ApsaraVideo Live:AliRtcEngine interface

Last Updated:Dec 17, 2025

This topic describes the interfaces of the ApsaraVideo Real-time Communication software development kit (SDK) for iOS.

Table of contents

Basic interfaces

API

Description

sharedInstance

Creates an AliRtcEngine instance (singleton pattern).

destroy[1/2]

Destroys the AliRtcEngine instance (synchronous).

destroy[2/2]

Destroys the AliRtcEngine instance (asynchronous).

setH5CompatibleMode

Sets the H5 compatible mode.

getH5CompatibleMode

Checks whether the current mode is H5 compatible.

getSdkVersion

Gets the SDK version number.

Channel interfaces

API

Description

setChannelProfile

Sets the channel profile.

setAudioProfile

Sets the audio profile.

isAudioOnly

Queries whether the current mode is audio-only.

setAudioOnlyMode

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

joinChannel[1/3]

Joins a channel.

joinChannel[2/3]

Joins a channel.

joinChannel[3/3]

Joins a channel.

leaveChannel

Leaves a channel.

isInCall

Checks if the user is in a channel.

setClientRole

Sets the user role.

getCurrentClientRole

Gets the user role.

refreshAuthInfo

Refreshes the authentication information.

refreshAuthInfoWithToken

Refreshes the authentication information.

Publishing and subscription interfaces

API

Description

publishLocalAudioStream

Sets whether to publish the audio stream. By default, the audio stream is published.

isLocalAudioStreamPublished

Queries whether the audio stream is currently being published.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to receive audio streams by default. By default, all remote audio streams are subscribed to.

Call this method before joining a channel.

subscribeRemoteAudioStream

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

subscribeAllRemoteAudioStreams

Stops or resumes receiving all remote audio streams.

publishLocalVideoStream

Sets whether to publish the video stream.

isLocalVideoStreamPublished

Queries whether the video stream is currently being published.

setDefaultSubscribeAllRemoteVideoStreams

Sets whether to receive video streams by default. By default, all remote video streams are subscribed to.

Call this method before joining a channel.

subscribeRemoteVideoStream

Stops or resumes subscribing to a remote user's video stream.

subscribeAllRemoteVideoStreams

Stops or resumes receiving all remote video streams.

subscribeRemoteMediaStream[1/2]

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

Use this interface when both audio and video are present and need to be controlled.

subscribeRemoteMediaStream[2/2]

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

Use this interface when both audio and video are present and need to be controlled.

subscribeRemoteDestChannelStream

Stops or resumes subscribing to the media stream of a specific remote user across channels.

subscribeRemoteDestChannelAllStream

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

setRemoteAudioVolume

Sets the volume of the remote audio.

Audio device management interfaces

API

Description

muteLocalMic

Sets whether to stop publishing local audio.

muteRemoteAudioPlaying

Sets whether to stop playing remote audio streams.

muteAllRemoteAudioPlaying

Stops or resumes all remote audio playback.

startAudioCapture[1/2]

Starts audio collection.

startAudioCapture[2/2]

Starts audio collection.

stopAudioCapture

Stops audio collection.

enableSpeakerphone

Sets the audio output to the earpiece or the speaker.

isEnableSpeakerphone

Gets whether the current audio output is the earpiece or the speaker.

enableAudioVolumeIndication

Enables the volume detection feature.

enableEarBack

Enables in-ear monitoring.

setEarBackVolume

Sets the in-ear monitoring volume (iOS only).

startAudioPlayer

Starts audio playback.

stopAudioPlayer

Stops audio playback.

setPlayoutVolume

Sets the playback volume.

setRecordingVolume

Sets the collection volume.

playAudioFileTest

Starts testing the audio playback device.

stopAudioFileTest

Stops testing the audio playback device.

startAudioCaptureTest

Starts testing the audio collection device.

stopAudioCaptureTest

Stops testing the audio collection device.

setDefaultAudioRoutetoSpeakerphone

Sets the default output device.

Audio voice changing and reverberation

API

Description

setAudioEffectVoiceChangerMode

Sets the voice changer effect mode.

setAudioEffectPitchValue

Sets the pitch shifting parameter.

setAudioEffectReverbMode

Sets the reverberation effect mode.

setAudioEffectReverbParamType

Sets the reverberation effect type and specific parameters.

setAudioEffectBeautifyMode

Sets the preset voice beautification effect mode.

setAudioEffectEqualizationParam

Sets the audio equalizer (EQ) parameter to adjust the gain of a specified frequency band.

Custom audio input

API

Description

addExternalAudioStream

Adds an external audio stream.

pushExternalAudioStream

Inputs external audio stream data.

setExternalAudioStream:publishVolume

Sets the stream ingest volume.

getExternalAudioStreamPublishVolume

Gets the stream ingest volume.

setExternalAudioStream:playoutVolume

Sets the external audio stream playback volume.

getExternalAudioStreamPlayoutVolume

Gets the external audio stream playback volume.

removeExternalAudioStream

Deletes the external stream ingest.

Audio mixing

API

Description

getAudioFileInfo

Gets audio mixing file information.

startAudioAccompanyWithFile

Starts playing the audio mixing file.

stopAudioAccompany

Stops playing the audio mixing file.

setAudioAccompanyVolume

Sets the audio mixing volume.

setAudioAccompanyPublishVolume

Sets the stream ingest volume for the audio mixing file.

getAudioAccompanyPublishVolume

Gets the stream ingest volume for the audio mixing file.

setAudioAccompanyPlayoutVolume

Sets the playback volume for the audio mixing file.

getAudioAccompanyPlayoutVolume

Gets the playback volume for the audio mixing file.

pauseAudioAccompany

Pauses audio mixing playback.

resumeAudioAccompany

Resumes audio mixing playback.

getAudioAccompanyDuration

Gets the duration of the audio mixing file.

getAudioAccompanyCurrentPosition

Gets the current audio mixing playback position.

setAudioAccompanyPosition

Sets the audio mixing playback position.

Sound effect files

API

Description

preloadAudioEffectWithSoundId

Preloads a sound effect file.

unloadAudioEffectWithSoundId

Deletes a preloaded sound effect file.

playAudioEffectWithSoundId

Starts playing a sound effect.

stopAudioEffectWithSoundId

Stops playing a sound effect.

stopAllAudioEffects

Stops playing all sound effects.

pauseAudioEffectWithSoundId

Pauses a sound effect.

pauseAllAudioEffects

Pauses all sound effects.

resumeAudioEffectWithSoundId

Resumes a specified sound effect file.

resumeAllAudioEffects

Resumes all sound effect files.

setAudioEffectPublishVolumeWithSoundId

Sets the mixing volume for sound effect stream ingest.

getAudioEffectPublishVolumeWithSoundId

Gets the mixing volume for sound effect stream ingest.

setAllAudioEffectsPublishVolume

Sets the mixing volume for all sound effect stream ingests.

setAudioEffectPlayoutVolumeWithSoundId

Sets the local playback volume for a sound effect.

getAudioEffectPlayoutVolumeWithSoundId

Gets the local playback volume for a sound effect.

setAllAudioEffectsPlayoutVolume

Sets the local playback volume for all sound effects.

Record audio and video files

API

Description

startRecord

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

stopRecord

Stops recording audio and video files.

Video device management interfaces

API

Description

setLocalViewConfig

Sets the rendering window and drawing parameters for local preview.

setCameraCapturerConfiguration

Sets camera capture preferences.

enableLocalVideo

Disables or re-enables local video collection.

muteLocalCamera

Sets whether to stop publishing the local video stream.

setRemoteViewConfig

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

isCameraOn

Checks if the camera is on.

setVideoEncoderConfiguration

Sets video encoding properties.

setVideoDecoderConfiguration

Sets video decoding properties.

switchCamera

Switches between the front and rear cameras (defaults to the front camera).

getCurrentCameraDirection

Gets the current camera direction.

startPreview

Starts local preview.

stopPreview

Stops local preview.

setCameraZoom

Sets the camera zoom.

GetCameraMaxZoomFactor

Gets the maximum camera zoom factor.

GetCurrentZoom

Gets the maximum camera zoom factor.

SetExposure

Sets the camera exposure.

GetCurrentExposure

Gets the camera exposure.

GetMinExposure

Gets the minimum camera exposure.

GetMaxExposure

Gets the maximum camera exposure.

setCameraFlash

Turns the camera flash on or off.

isCameraFocusPointSupported

Checks if the camera supports manual focus.

isCameraExposurePointSupported

Checks if the camera supports setting an exposure point.

setCameraFocusPoint

Sets the manual focus point for the camera.

setCameraExposurePoint

Sets the camera exposure point.

isCameraAutoFocusFaceModeSupported

Checks if the camera supports face-based autofocus.

setCameraAutoFocusFaceModeEnabled

Sets face-based autofocus for the camera.

setVideoMirrorMode

Sets the preview and stream ingest image capabilities.

SetCapturePipelineScaleMode

Sets the capture scaling time. Video data is scaled either immediately upon capture or during encoding.

Configure video data callbacks

API

Description

registerVideoFrameWithObserver

Registers a video data callback.

unregisterVideoSampleWithObserver

Unregisters a video data callback.

registerLocalVideoTextureObserver

Registers a video texture callback.

unregisterLocalVideoTextureObserver

Unregisters a video texture callback.

snapshotVideo

Takes a camera snapshot.

registerVideoSampleObserver

Registers a video data output callback.

unRegisterVideoSampleObserver

Unregisters a video data output callback.

Configure audio data callbacks

API

Description

enableAudioFrameObserver

Sets audio callback parameters.

registerAudioFrameObserver

Registers an audio data callback.

Custom video input

API

Description

setExternalVideoSource

Enables an external video input source.

pushExternalVideoFrame

Inputs video data.

Desktop sharing interfaces

API

Description

startScreenShare

Starts screen sharing stream ingest.

startScreenShare

Starts screen sharing stream ingest.

Note

This interface is about to be deprecated.

stopScreenShare

Stops screen sharing stream ingest.

setAudioShareAppVolume

Sets the shared audio stream volume.

isScreenSharePublished

Queries whether screen sharing is set to be published.

setScreenShareEncoderConfiguration

Configures screen sharing encoding parameters.

Live stream bypass interfaces

API

Description

startPublishLiveStreamWithURL

Starts a bypass live stream.

updatePublishLiveStreamWithURL

Updates bypass live stream parameters.

stopPublishLiveStreamWithURL

Stops a bypass live stream.

GetPublishLiveStreamStateWithURL

Gets the bypass live stream status.

Network quality probing interfaces

API

Description

startLastmileDetect

Starts network quality probing.

stopLastmileDetect

Stops network quality probing.

SEI

API

Description

sendMediaExtensionMsg

Pushes an SEI stream.

sendMediaExtensionMsgEx

Pushes an SEI stream (extended).

Other interfaces

API

Description

setParameter

Sets custom parameters.

getParameter

Gets custom parameters.

setLogDirPath

Sets the save path for SDK log files.

setLogLevel

Sets the log level.

setAudioSessionOperationRestriction

Sets the SDK's control permissions for AVAudioSession.

setDeviceOrientationMode

Sets the device orientation.

getNetworkTime

Gets the network timestamp.

sendDataChannelMessage

Sends a data channel message.

Callback events

AliRtcEngineDelegate

API

Description

onConnectionStatusChange

Network connection status callback. Customers need to pay attention to this callback.

onLocalDeviceException

Local device exception callback. Customers need to pay attention to this callback.

onAuthInfoWillExpire

Notification that user authentication information is about to expire. Authentication will expire 30 seconds after this notification is received. Customers need to pay attention to this callback.

onAuthInfoExpired

The server returns that the information has expired when the user calls an interface that requires authentication.

onJoinChannelResult

Join channel result callback.

onLeaveChannelResult

Leave channel result callback.

onRemoteUserOffLineNotify

Remote user offline notification.

onRemoteUserOnLineNotify

Remote user online notification.

onRemoteTrackAvailableNotify

Remote stream ingest information notification.

onBye

Message for being removed from the server or when the channel ends.

onAudioPublishStateChanged

Audio stream ingest status notification.

onAudioSubscribeStateChanged

Audio stream pulling status notification.

onUserAudioMuted

Remote user mute notification.

onUserAudioInterruptedBegin

Audio device interruption start notification.

onUserAudioInterruptedEnded

Audio device interruption end notification.

onVideoPublishStateChanged

Video stream ingest change callback.

onVideoSubscribeStateChanged

Camera stream subscription change callback.

onUserVideoMuted

Notification that the remote user is sending black video frames.

onUserVideoEnabled

Notification that the remote user has disabled camera stream collection.

onUserWillResignActive

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

onUserWillBecomeActive

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

onAudioEffectFinished

Local sound effect playback finished callback.

onAudioVolumeCallback

Callback for subscribed audio volume, voice status, and UID.

onActiveSpeaker

Voice activity detection, callback when an active user is detected.

onPublishLiveStreamStateChanged

Bypass stream ingest state change callback.

onPublishTaskStateChanged

Bypass task state change callback.

onNetworkQualityChanged

Network quality change callback.

onLastmileDetectResultWithQuality

Network quality probing callback.

onLastmileDetectResultWithBandWidth

Network quality probing result callback.

onOccurError

Notifies the app via this callback if an error occurs in the engine.

onFirstAudioPacketSentWithTimecost

First audio packet sent callback.

onFirstVideoFrameReceivedWithUid

First video frame received callback.

onFirstVideoPacketSentWithVideoTrack

First video packet sent callback.

onFirstAudioPacketReceivedWithUid

First audio packet received callback.

onFirstRemoteAudioDecodedWithUid

First remote audio frame decoded callback.

onFirstRemoteVideoFrameDrawn

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

onFirstLocalVideoFrameDrawn

This message is triggered when the preview starts displaying the first video frame.

onTestAudioVolumeCallback

Volume callback for pre-call audio collection test.

onAudioAccompanyStateChanged

Local audio mixing playback state callback.

onRemoteAudioAccompanyStarted

Remote user audio mixing playback start callback.

onRemoteAudioAccompanyFinished

Remote user audio mixing playback end callback.

onRtcStats

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

onRtcLocalVideoStats

Local video statistics (triggered every 2 seconds).

onRtcRemoteVideoStats

Remote video statistics (triggered every 2 seconds).

onRtcLocalAudioStats

Local audio statistics (triggered every 2 seconds).

onRtcRemoteAudioStats

Remote audio statistics (triggered every 2 seconds).

onMediaExtensionMsgReceived

Media extension message received callback.

onAudioRouteChanged

Audio route change callback.

onSnapshotComplete

Snapshot callback.

onLocalAudioStateChanged

Local audio collection device state callback.

onLocalVideoStateChanged

Local video collection device state callback.

onRemoteUserSubscribedDataChannel

Callback indicating that data channel messages can be sent.

onDataChannelMessage

Data channel message callback.

onScreenSharePublishStateChanged

Screen sharing stream ingest change callback.

AliRtcAudioFrameDelegate

API

Description

onCapturedAudioFrame

Raw data collection callback.

onProcessCapturedAudioFrame

Data callback after 3A processing.

onPublishAudioFrame

Stream ingest data callback.

onPlaybackAudioFrame

Playback data callback.

onRemoteUserAudioFrame

Remote stream pulling data callback.

AliRtcEngineDestroyDelegate

API

Description

onDestroyCompletion

Callback for releasing the engine. The engine is released after this callback is executed.

AliRtcTextureDelegate

API

Description

onTextureCreate

OpenGL context creation callback.

onTextureUpdate

OpenGL texture update callback.

onTextureDestory

OpenGL context destruction callback.

AliRtcVideoFrameDelegate

API

Description

onCaptureVideoSample

Captured video frame callback.

onPreEncodeVideoSample

Callback for subscribed local pre-encoded video data.

onRemoteVideoSample

Callback for subscribed remote video data.

onGetVideoFormatPreference

Video data output format.

onGetVideoObservedFramePosition

Video data output position.

Interface details

sharedInstance

Creates an AliRtcEngine instance (singleton pattern).

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

When to call

You must call this method to create an AliRtcEngine instance before you call any other Alibaba Real-Time Communication (ARTC) SDK APIs.

Limits

  • This method is a synchronous call and can be invoked only in the main thread.

  • The SDK supports the creation of only one AliRtcEngine instance for each application.

Related callbacks

When you create an engine instance, you must implement the callbacks in AliRtcEngineDelegate based on your business scenario. If the SDK encounters an exception during operation, it first attempts to recover automatically using an internal retry mechanism. For errors that cannot be resolved, the SDK notifies your application through predefined callback interfaces. The following are key callbacks that the SDK cannot handle and require the application layer to listen for and respond to:

Reason for exception

Callback and parameters

Solution

Description

Authentication failed

The result in the onJoinChannelResult callback returns AliRtcErrJoinBadToken.

When an error occurs, the app needs to check if the token is correct.

When a user actively calls an API, if authentication fails, the system will return an authentication failure error message in the API's callback.

Network connection exception

The onConnectionStatusChange callback returns AliRtcConnectionStatusFailed.

When this exception occurs, the app needs to rejoin the channel.

The SDK has the ability to automatically recover from a network disconnection for a certain period. However, if the disconnection time exceeds the preset threshold, a timeout will be triggered and the connection will be dropped. At this point, the app should check the network status and guide the user to rejoin the meeting.

Local device exception

onLocalDeviceException

When this exception occurs, the app needs to check if permissions and device hardware are normal.

The RTC service supports device detection and exception diagnosis. When a local device exception occurs, the RTC service will notify the customer of the local device exception through a callback. At this point, if the SDK cannot solve the problem on its own, the app needs to intervene to check if the device is normal.

Kicked offline

onBye

  • AliRtcOnByeUserReplaced: When this exception occurs, check if the user IDs are the same.

  • AliRtcOnByeBeKickedOut: When this exception occurs, it means the user has been kicked offline by the business and needs to rejoin the channel.

  • AliRtcOnByeChannelTerminated: When this exception occurs, it means the channel has been destroyed and the user needs to rejoin.

The RTC service provides a feature for administrators to actively remove participants.

Authentication is about to expire

onWillAuthInfoExpire

When this exception occurs, the app needs to get the latest authentication information and then call refreshAuthInfo to refresh the authentication information.

Authentication expiration errors occur in two situations: when a user calls an API or during program execution. Therefore, the error feedback will be notified through an API callback or a separate error callback.

Authentication expired

onAuthInfoExpired

When this exception occurs, the app needs to rejoin the channel.

Authentication expiration errors occur in two situations: when a user calls an API or during program execution. Therefore, the error feedback will be notified through an API callback or a separate error callback.

Parameters

Name

Type

Description

delegate

id<AliRtcEngineDelegate>_Nullable

The delegate for listening to callbacks.

extras

NSString *_Nullable

Used to receive parameters for grayscale features from the customer. Configure special SDK features via JSON. Can be an empty string.

destroy[1/2]

Destroys the AliRtcEngine instance.

+ (void)destroy;

Destroys the AliRtcEngine singleton object. After this method is called, all internal resources are released, and you can no longer use any other methods of AliRtcEngine or any callbacks. To use the engine again, you must call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#2db21d4f16s77" id="96631a9306wq8">sharedInstance</a> to create a new instance.

Both this method and destroy[2/2] destroy the engine instance. However, destroy[2/2] also accepts a listener object to be notified upon completion.

Note
  • Wait for this method to finish executing before you create a new AliRtcEngine instance.

  • After you call this method, set the engine object to null.

When to call

When the audio and video communication ends and the AliRtcEngine features are no longer needed, call this method to release the instance and its associated resources.

Limits

To avoid deadlocks, do not call this method within an SDK callback.

destroy[2/2]

Destroys the AliRtcEngine instance.

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

This method destroys the AliRtcEngine singleton object and releases all internal resources. After this method is called, you can no longer use other methods of AliRtcEngine or any callbacks. To use the engine again, you must call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#2db21d4f16s77" id="115fd691743nx">sharedInstance</a> to create a new instance.

Note

Both this method and destroy[1/2] can release the AliRtcEngine instance. The difference is that this method is an asynchronous call that allows a developer to pass an observer to monitor the completion of the destruction. You can create the next instance only after the onDestroyCompletion callback is returned.

When to call

You can call this method to release the instance after an audio and video session is complete.

Limits

To avoid deadlocks, do not call this method in any SDK callback.

Parameters

Name

Type

Description

delegate

AliRtcEngineDestroyDelegate

The callback object after release.

setH5CompatibleMode

Configures the H5 compatibility mode.

Important

The H5 compatibility mode cannot be changed after an AliRtcEngine instance is created. You must call this method before you create the instance.

+ (void)setH5CompatibleMode:(BOOL)comp;

Parameters

Name

Type

Description

comp

BOOL

YES means compatible with H5, NO means not compatible with H5. The default is not compatible with H5.

getH5CompatibleMode

Checks if the H5 compatible mode is set.

+ (BOOL)getH5CompatibleMode;

Return value

Returns YES if the H5 compatible mode is set, and NO otherwise.

getSdkVersion

Retrieves the SDK version number.

+ (NSString *_Nonnull)getSdkVersion;

Return value

The current SDK version number as a string, for example, "2.5.0.x".

Description

This is a static method that you can use to retrieve the version number at any time.

setChannelProfile

Sets the channel profile.

- (int)setChannelProfile:(AliRtcChannelProfile)profile;

This method sets the channel profile. The available scenarios are video call and interactive live streaming:

  • Video call: All users are streamers and can publish and subscribe to streams.

  • Interactive live streaming: You must call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#892915dd4edcy" id="d88dccff391by">setClientRole</a> to set the user role. To publish streams, a user's role must be set to streamer (AliRTCSdkInteractive). To only subscribe to streams without publishing, a user's role must be set to viewer (AliRTCSdkLive). This mode is recommended for RTC scenarios.

Note
  • We recommend using the interactive live streaming mode for all RTC scenarios. To do this, call this method and set the profile to AliRTCSdkInteractiveLive.

  • Users in the same channel must use the same channel scenario.

When to call

You can only call this method before joining a channel. The channel profile cannot be changed while you are in the channel. You can change it after you leave the channel.

Parameters

Name

Type

Description

profile

AliRtcChannelProfile

Channel type. For all RTC scenarios, it is recommended to set it to AliRtcChannelProfileInteractiveLive, which is the interactive live streaming mode.

Return value

If the method call is successful, 0 is returned. Otherwise, an error code is returned.

setAudioProfile

Sets the audio profile.

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

This method sets the audio encoding and scenario modes. For more information, see Common audio operations and configurations. By default, the ARTC SDK uses the high-quality audio mode (AliRtcEngineHighQualityMode) and the music scenario mode (AliRtcSceneMusicMode). If the default settings do not meet your requirements, you must call this method to change them.

When to call

You can call this method only before you join a channel. The settings cannot be changed after you join a channel. However, you can change them after you leave the channel.

Parameters

Name

Type

Description

audio_profile

AliRtcAudioProfile

Audio collection or encoding mode parameter. It is recommended to use high-quality mode (AliRtcEngineHighQualityMode).

Note

To interoperate with the web, you need to set the sample rate to 48k.

  • AliRtcEngineLowQualityMode: Low-quality audio mode, default 8000 Hz sample rate, mono, maximum encoding bitrate 12 kbps.

  • AliRtcEngineBasicQualityMode: Standard quality audio mode, default 16000 Hz sample rate, mono, maximum encoding bitrate 24 kbps.

  • AliRtcEngineHighQualityMode: Default 48000 Hz sample rate, mono, maximum encoding bitrate 64 kbps.

  • AliRtcEngineStereoHighQualityMode: Stereo high-quality audio mode, default 48000 Hz sample rate, dual-channel, maximum encoding bitrate 80 kbps.

  • AliRtcEngineSuperHighQualityMode: Super high-quality audio mode, default 48000 Hz sample rate, mono, maximum encoding bitrate 96 kbps.

  • AliRtcEngineStereoSuperHighQualityMode: Stereo super high-quality audio mode, default 48000 Hz sample rate, dual-channel, maximum encoding bitrate 128 kbps.

audio_scene

AliRtcAudioScenario

Audio scenario mode parameter, mainly includes:

  • AliRtcSceneMusicMode (recommended): Music scenario, uses software 3A, collects from the phone (higher audio quality).

  • AliRtcSceneDefaultMode: Uses hardware 3A, can collect from Bluetooth devices.

Return description

A return value of 0 indicates that the method was called successfully. Any other value indicates that the call failed.

isAudioOnly

Checks if the current mode is audio-only.

- (BOOL)isAudioOnly;

Response Description

Returns YES if the current mode is audio-only, or NO if the current mode is audio and video.

setAudioOnlyMode

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

- (int)setAudioOnlyMode:(BOOL)audioOnly;

Parameters

Name

Type

Description

audioOnly

BOOL

  • YES means only audio is published and pulled.

  • NO means both audio and video are supported. The default value is NO.

Return value

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

joinChannel[1/3]

Joins a channel (single-parameter join).

- (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;

This method is used to join a channel. In ARTC, users are organized into channels. To publish or subscribe to audio and video streams, users must join a channel. You can use this method, joinChannel[2/3], or joinChannel[3/3] to join a channel. The differences between these methods relate to the authentication method and the user information that is passed:

  • This method joins a channel using a single parameter. You must pass a single-parameter token generated by Token authentication to join the channel. This method is recommended for joining a channel in RTC scenarios.

  • joinChannel[2/3] is a method for joining a channel with multiple parameters. You must pass a multi-parameter token generated by Token authentication and the user information that was used to generate the token.

  • joinChannel[3/3] is used for AI real-time interaction scenarios. You must pass a single-parameter token and set the capabilityProfile user attribute based on the scenario.

Note

By default, when you join a channel, you subscribe to the audio and video streams of all other users in the channel and publish your audio and video streams to remote users. If you want to cancel the default subscription, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="2e9165006d7tz">setDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="96cf16cf8a4us">setDefaultSubscribeAllRemoteVideoStreams</a> before you call this method to disable the subscription to audio or video streams.

When to call

Call this method after you create the engine instance.

Limits

  • After you successfully join a channel, if you want to join another channel, you must first call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#449873b819cz2" id="37299758eavvg">leaveChannel</a> to leave the current channel. You can join a new channel only after you receive the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3721f1f2a3kpd" id="50039f328fdk7">onLeaveChannelResult</a> callback.

  • A user can join only one channel at a time.

  • Apps with different App IDs cannot communicate with each other.

  • You do not need to call this method to retry joining a channel after an initial failure.

Related callbacks

After you successfully call this method, the following callbacks are triggered:

  • The <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#e6d2a213d7sl2" id="903005c54be4d">onJoinChannelResult</a> callback returns the result of the local client joining the channel.

  • After you successfully join a channel, remote clients in the channel receive the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#634626babfq9x" id="4b11b846b1f4t">onRemoteUserOnLineNotify</a> callback.

Parameters

Parameter

Type

Description

token

String

Authentication information for single-parameter join.

channelId

String

The channel to join, which must be the same as the value used to generate the token.

userId

String

The user ID for joining, which must be the same as the value used to generate the token.

userName

String

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

onResultWithUserId

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

This callback is called when this interface finishes executing.

Return description

0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

joinChannel[2/3]

Joins a channel using multiple parameters.

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

This method is used to join a channel. In ARTC, users are organized into channels. Users must join a channel to publish or subscribe to audio and video streams. You can use this method, joinChannel[1/3], or joinChannel[3/3] to join a channel. The main differences between these methods are the authentication method and the user information that is passed, as follows:

  • joinChannel[1/3] is a single-parameter method. To use this method, you must pass a single-parameter token generated using Token authentication. This method is recommended for joining a channel in RTC scenarios.

  • This method is a multi-parameter method. To use this method, you must pass a multi-parameter token generated using Token authentication and the user information that was used to generate the token.

  • joinChannel[3/3] is used in AI real-time interaction scenarios. To use this method, you must pass a single-parameter token and set the capabilityProfile user attribute.

Note
  • By default, after you join a channel, you subscribe to the audio and video streams of all other users in the channel and push your audio and video streams to remote users. To cancel this default behavior, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="fb54669796mxq">setDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="abb190b699jg7">setDefaultSubscribeAllRemoteVideoStreams</a> before you call this method to disable the subscription to audio or video streams.

  • This is a multi-parameter method. Before you call this method, generate a multi-parameter token. For more information, see Token authentication.

Limits

  • After you join a channel, if you want to join another channel, you must first call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#449873b819cz2" id="4283c6cc013bz">leaveChannel</a> to leave the current channel. You can join the new channel only after you receive the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3721f1f2a3kpd" id="9e6478b2f0hen">onLeaveChannelResult</a> callback.

  • This method allows a user to join only one channel at a time.

  • Apps with different App IDs cannot communicate with each other.

Related callbacks

After you successfully call this method, the following callbacks are triggered:

  • The <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#e6d2a213d7sl2" id="df00346ea8928">onJoinChannelResult</a> callback returns the result of the local client joining the channel.

  • After you join the channel, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#634626babfq9x" id="c3832e71e8vck">onRemoteUserOnLineNotify</a> callback is triggered on remote clients.

Parameters

Name

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)

This callback is called when this interface finishes executing.

joinChannel[3/3]

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;

This method is used to join a channel. In ARTC, users are organized into channels and must join one to publish or subscribe to audio and video streams. You can use this method, joinChannel[1/3], or joinChannel[2/3] to join a channel. The methods differ in their authentication process and the user information they require:

  • joinChannel[1/3] is a single-parameter method for RTC scenarios. To join a channel, you must pass a single-parameter token generated by Token authentication. This is the recommended method for joining a channel in RTC scenarios.

  • joinChannel[2/3] is a multi-parameter method. To join a channel, you must pass a multi-parameter token generated by Token authentication and the user information that was used to generate the token.

  • This method is used for AI real-time interaction scenarios. To join a channel, you must pass a single-parameter token and set the capabilityProfile user attribute. To interact with an AI agent, set this attribute to AliRtcCapabilityProfileAiHuman.

Note

By default, when you join a channel, you subscribe to the audio and video streams of all other users in the channel and push your audio and video streams to remote users. To cancel the default subscription to audio or video streams, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="ce6cfa82f9xzc">setDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="e65b420fd5kj6">setDefaultSubscribeAllRemoteVideoStreams</a> before calling this method.

Limits

  • To join a new channel, you must first call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#449873b819cz2" id="923190466431o">leaveChannel</a> to leave the current channel. You can join the new channel only after you receive the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3721f1f2a3kpd" id="dfd794c32covq">onLeaveChannelResult</a> callback.

  • This method allows a user to join only one channel at a time.

  • Apps with different App IDs cannot communicate with each other.

  • You do not need to call this method again when retrying to join a channel after a failure.

Related callbacks

A successful call to this interface triggers the following callbacks:

  • The <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#e6d2a213d7sl2" id="f83d0aff9btwh">onJoinChannelResult</a> callback returns the result of a local user joining a channel.

  • After you successfully join a channel, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#634626babfq9x" id="aeef817be3a0b">onRemoteUserOnLineNotify</a> callback is triggered on the remote side.

Parameters

Name

Type

Description

token

NSString*

Authentication information, obtained from the App Server.

channelParam

AliRtcChannelParam

Join channel parameters.

onResultWithUserId

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

This callback is called when this interface finishes executing.

leaveChannel

Leaves the current channel.

- (int)leaveChannel;

Calling this method terminates all audio and video interactions and causes the user to leave the current channel.

Note
  • This method is an asynchronous operation. A successful method call does not mean that the user has left the channel. The user leaves the channel only after the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3721f1f2a3kpd" id="e7c0222bacrpa">onLeaveChannelResult</a> callback is triggered.

  • After the call to leaveChannel completes, destroy the engine and set it to null.

When to call

  • You can call this method to leave a channel that you have joined.

  • If you are in a channel and want to join another channel, you must call this method to leave the current channel first.

Related callbacks

  • Local client: The SDK triggers the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3721f1f2a3kpd" id="ea2e36a41csu0">onLeaveChannelResult</a> callback to report the result of leaving the channel.

  • A successful call to this API triggers the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#34876c27d7zv7" id="a50f534f21mew">onRemoteUserOffLineNotify</a> callback for the remote user.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the method call failed.

isInCall

Checks if the user is in a channel.

- (BOOL)isInCall;

Return value

Returns YES if the user is in a channel, or NO otherwise.

setClientRole

Sets the user role.

- (int)setClientRole:(AliRtcClientRole)role;

This method sets the user role to either streamer or viewer.

In interactive mode, if you set the role before joining a channel:

  • Streamer: The SDK will automatically publish local audio and video streams and receive audio and video streams from other streamers.

  • Viewer: The SDK will not publish local audio and video streams but will receive audio and video streams from other streamers.

When to call

You can call this method before joining a channel to set the user role, or after joining to switch the user role.

Limits

This method is effective only in interactive mode. To use this method, you must call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#fc9626a99f5kj" id="cd8138c77fv4r">setChannelProfile</a> method and set the channel profile to AliRtcInteractivelive.

In interactive mode, we recommend making an explicit call to set the user role before joining.

Parameters

Name

Type

Description

role

AliRtcClientRole

User role type. The default value is AliRtcClientRolelive (viewer role). The role type is only valid in non-communication mode.

Returns

A return value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

getCurrentClientRole

Retrieves the user role (iOS only).

- (AliRtcClientRole)getCurrentClientRole;

Return value

Returns the current user role.

refreshAuthInfo

Refreshes the authentication information.

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

This method updates the authentication information. A token expires after a specific period. When the token expires, the SDK cannot establish a connection with the server.

Note

Both this method and refreshAuthInfoWithToken are used to update authentication information. This method is for updating a multi-parameter join token, while refreshAuthInfoWithToken is for updating a single-parameter join token. For more information about token generation, see Token authentication.

When to call

Consider the following scenarios:

  • When you receive the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#6766cdfb40z1a" id="c1cc6cbddb22o">onAuthInfoWillExpire</a> callback indicating that the authentication information is about to expire, we recommend that you regenerate a token on your server and call this method to pass the new token.

  • If you do not update the token in time, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#b04cd67880ptu" id="13c9ccb2b6ghh">onAuthInfoExpired</a> callback is triggered, indicating that the authentication has expired. In this case, you must regenerate a token and call joinChannel to rejoin the channel.

Parameters

Name

Type

Description

authInfo

AliRtcAuthInfo *_Nonnull

Authentication information.

Return value

0 indicates that the method call was successful. Any other value indicates that the call failed.

refreshAuthInfoWithToken

Refreshes the authentication information.

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

This method is used to update the token. The token expires after a certain period, at which point the SDK cannot establish a connection with the server.

Note
  • Both this method and the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#e6a4495191bmd" id="eb171f6dc0n9p">refreshAuthInfo</a> operation update authentication information. This method updates the token for single-parameter channel joins, while refreshAuthInfo updates the token for multi-parameter channel joins. For more information about token generation, see Token Authentication.

  • If you do not update the token in time, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#b04cd67880ptu" id="3fd3c64767aq8">onAuthInfoExpired</a> callback is triggered to notify you that your authentication information has expired. In this case, you must call joinChannel to rejoin the channel.

When to call

You should regenerate a token on your server and then call this method to pass the new token in the following situation:

When the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#6766cdfb40z1a" id="b1dbfcb71d5ys">onAuthInfoWillExpire</a> callback indicates that the authentication information is about to expire.

Parameters

Name

Type

Description

token

NSString *_Nonnull

Authentication information for single-parameter join.

Return value

0 indicates that the method call was successful. Otherwise, the call failed.

publishLocalAudioStream

Sets whether to publish the local audio stream.

- (int)publishLocalAudioStream:(BOOL)enable;

This method controls whether to publish the local audio stream. By default, the SDK publishes the audio stream. To disable publishing, you can call publishLocalAudioStream(false) before you join a channel.

When to call

You can call this method before or after joining a channel. If you call this method before joining a channel, the setting modifies the default configuration and takes effect when you join the channel.

Related callbacks

When the publishing state of the local audio stream changes, the local client triggers the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#86b2d8735bm71" id="e5ef180ba6e2i">onAudioPublishStateChanged</a> callback to report the latest publishing state. Remote clients trigger the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#6da9cf330aoer" id="299ef35806ttb">onRemoteTrackAvailableNotify</a> callback to report changes to the audio and video streams of a remote user.

Parameters

Name

Type

Description

enable

boolean

  • YES means send the local audio stream.

  • NO means stop publishing. The default is YES.

Returns

0 indicates that the method call was successful. A non-zero value indicates that the call failed.

isLocalAudioStreamPublished

Checks if the local audio stream is allowed to be published.

- (BOOL)isLocalAudioStreamPublished;

Returns

YES: Publishing is allowed. NO: Publishing is not allowed.

setDefaultSubscribeAllRemoteAudioStreams

Sets whether to subscribe to remote audio streams by default.

- (int)setDefaultSubscribeAllRemoteAudioStreams:(BOOL)sub;

You can use this method to configure whether to subscribe to the audio streams of remote users by default. This setting affects the subscription behavior for the audio streams of users who subsequently join the channel. We recommend setting this parameter to true for most scenarios.

When to call

You can call this method before or after joining a channel.

  • Before joining a channel:

    • By default, the SDK subscribes to the audio streams of all remote users after you join a channel. To change this default behavior, you can call this method before joining the channel.

  • After joining a channel:

    • To stop the default subscription, call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="a467e60e4eyhk">setDefaultSubscribeAllRemoteAudioStreams</a>(false) to prevent subscribing to the audio streams of users who subsequently join the channel.

    • To resume subscribing to a specific user's audio stream after stopping the default subscription, call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#c8249fb568gms" id="9806dd9a750pf">subscribeRemoteAudioStream</a> method. To resume subscribing to multiple users, call this method multiple times.

    • After you stop the default subscription, calling <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="9507d6d3121uh">setDefaultSubscribeAllRemoteAudioStreams</a>(true) resumes the subscription to audio streams only from users who join the channel after this method is called. This call does not subscribe to the audio streams of users who are already in the channel.

Parameters

Name

Type

Description

sub

BOOL

  • YES means receive the user's audio stream.

  • NO means stop receiving the user's audio stream. The default value is YES.

Return value

A value of 0 indicates that the method call was successful. Otherwise, the call failed.

subscribeRemoteAudioStream

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

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

You can call this method to stop or resume subscribing to the audio stream of a specific remote user. In most scenarios, we recommend subscribing to the audio stream.

Note

By default, the SDK subscribes to the audio streams of all remote users when you join a channel. To cancel this default configuration, call <a baseurl="t2309850_v10_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="044cc0f710rfg">setDefaultSubscribeAllRemoteAudioStreams</a>(false) before you join the channel.

Parameters

Name

Type

Description

uid

NSString *_Nonnull

Remote user ID.

sub

BOOL

  • YES means receive the specified user's audio stream.

  • NO means stop receiving the specified user's audio stream. The default value is YES.

Return value

A value of 0 indicates that the method call was successful. Otherwise, the call failed.

subscribeAllRemoteAudioStreams

Stops or resumes receiving all remote audio streams.

- (int)subscribeAllRemoteAudioStreams:(BOOL)sub;

This method is a master switch for subscribing to remote audio streams. If you set the parameter to NO, the following occurs:

  • The SDK stops subscribing to all remote audio streams in the current meeting.

  • New users who join later will no longer be subscribed.

  • You cannot use <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#c8249fb568gms" id="846b0dd501epf">subscribeRemoteAudioStream</a> to individually control the audio stream of a specific user.

To resume subscribing, call this method again and set the parameter to YES.

Note

By default, the SDK subscribes to the audio streams of all remote users when you join a meeting. If you want to change this behavior, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#8b515d9855osk" id="86e8c09213k9y">setDefaultSubscribeAllRemoteAudioStreams</a>(false) before you join the meeting to cancel this default configuration.

Parameters

Name

Type

Description

sub

BOOL

  • YES means receive all users' audio streams.

  • NO means stop receiving all users' audio streams. The default value is YES.

Return value

0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

publishLocalVideoStream

Enables or disables publishing the video stream from the camera.

- (int)publishLocalVideoStream:(BOOL)enable;

This method controls whether to publish the local video stream.

Note

By default, the SDK publishes the video stream. To disable video stream publishing, call publishLocalVideoStream(false) before you join a channel.

When to call

You can call this method before or after joining a channel.

If you call this method before joining a channel, the setting takes effect when you join the channel.

Related callbacks

When the local audio stream ingest status changes, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#bd67711e63tnk" id="f966292202q3d">onVideoPublishStateChanged</a> callback is triggered on the local client to report the latest audio stream ingest status. The <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#6da9cf330aoer" id="2fdc208ccczr1">onRemoteTrackAvailableNotify</a> callback is triggered on the remote client to report changes in the audio and video streams of a remote user.

Parameters

Name

Type

Description

enable

boolean

  • YES means send video.

  • NO means stop sending. The default is YES.

isLocalVideoStreamPublished

Checks whether the local video stream is published.

- (BOOL)isLocalVideoStreamPublished;

Return value

Returns YES if the local video stream is published, or NO otherwise.

setDefaultSubscribeAllRemoteVideoStreams

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

- (int)setDefaultSubscribeAllRemoteVideoStreams:(BOOL)sub;

This interface sets the default subscription behavior for video streams. By default, the SDK subscribes to all remote video streams.

Note

By default, the SDK subscribes to the audio and video streams of remote users when you join a channel. To change this behavior, you can call this interface before you join the channel.

When to call

You can call this method before or after joining a channel.

  • Before joining a channel:

    • You can call this interface to cancel the default subscription behavior.

  • After joining a channel:

    • If you want to stop the default subscription, you can call setDefaultSubscribeAllRemoteVideoStreams(false). This prevents the SDK from automatically subscribing to the video streams of users who subsequently join the channel.

    • After stopping the default subscription, if you want to resume subscribing to a specific user's video stream, call the subscribeRemoteVideoStream interface. To resume subscribing to multiple users, call the interface for each user.

    • After you stop the default subscription, a call to setDefaultSubscribeAllRemoteVideoStreams(false) resumes only the audio streams of users who join the channel afterward.

Parameters

Name

Type

Description

sub

boolean

  • YES means receive the user's video stream.

  • NO means do not receive the user's video stream. The default value is YES.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

subscribeRemoteVideoStream

Stops or resumes subscribing to a remote user's video stream.

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

This method subscribes to or unsubscribes from the video stream of a specified remote user.

Note

By default, the SDK subscribes to the video streams of all remote users when you join a meeting. To change this default behavior, you can call <a baseurl="t2309850_v10_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="97d89be88bvan">setDefaultSubscribeAllRemoteVideoStreams</a>(false) before you join the meeting.

When to call

You can call this method before or after you join a meeting.

Parameters

Name

Type

Description

uid

NSString *

User ID, a unique identifier assigned by the App server.

track

AliRtcVideoTrack

Video stream type.

sub

BOOL

Whether to subscribe.

subscribeAllRemoteVideoStreams

Stops or resumes receiving all remote video streams.

Note

This method is a master switch for subscribing to remote video streams. If this parameter is set to false, you stop receiving all current remote video streams and will not receive video streams from new users who join the meeting later. This occurs even if you have called setDefaultSubscribeAllRemoteVideoStreams and set the parameter to true.

- (int)subscribeAllRemoteVideoStreams:(BOOL)sub;

This method is a master switch for subscribing to remote video streams. If this parameter is set to false, the following occurs:

  • You stop subscribing to all remote video streams in the current meeting.

  • New users who join the meeting later will not be subscribed either (even if you have used <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="0464849a17dks">setDefaultSubscribeAllRemoteVideoStreams</a> to set a default subscription).

  • You cannot use <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#1cc7ef76fdawz" id="498e782f414zz">subscribeRemoteVideoStream</a> to independently control a specific user's audio stream.

Call this interface again and set the parameter to true to resume the subscription.

Note

By default, the SDK subscribes to the video streams of all remote users when you join a meeting. To disable this default behavior, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#a975297480yoj" id="317fa38ecf6ya">setDefaultSubscribeAllRemoteVideoStreams</a> before joining the meeting.

Parameters

Name

Type

Description

sub

BOOL

  • YES means receive all users' video streams.

  • NO means stop allowing receiving all users' video streams. The default value is YES.

Return value

A value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

subscribeRemoteMediaStream[1/2]

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

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

This interface is used to subscribe to remote audio and video streams simultaneously.

Related interfaces

Compared to subscribeRemoteMediaStream[2/2], this interface uses two boolean parameters, subVideo and subAudio, to determine whether to subscribe to remote audio and video streams. The videoTrack parameter controls which video stream to pull.

Note: In this interface, the AliRtcVideoTrackNo value of AliRtcVideoTrack is not supported, and setting it has no effect.

Parameters

Parameter

Type

Description

uid

String

Remote user ID.

videoTrack

AliRtcVideoTrack

Video stream type.

subVideo

boolean

Stops or resumes pulling the video stream of a specific remote user. Values:

  • true (default): Resume.

  • false: Stop.

subAudio

boolean

Stops or resumes pulling the audio stream of a specific remote user. Values:

  • true (default): Resume.

  • false: Stop.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

subscribeRemoteMediaStream[2/2]

Stops or resumes the subscription to a media stream from a specific remote user.

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

This interface is used to merge subscriptions for remote audio and video streams.

Note

This interface uses the videoTrack and audioTrack parameters to set the desired subscription state in a single call.

Related interfaces

Unlike subscribeRemoteMediaStream[1/2], this interface sets the desired subscription state in a single call using the videoTrack and audioTrack parameters. For example:

  • To subscribe to the camera and microphone streams, set videoTrack to AliRtcVideoTrackCamera and audioTrack to AliRtcAudioTrackMic in the method call.

  • To unsubscribe from the camera stream but maintain the microphone subscription, call the method again with videoTrack set to AliRtcVideoTrackNo and audioTrack set to AliRtcAudioTrackMic.

  • To cancel both subscriptions, call the method again with videoTrack set to AliRtcVideoTrackNo and audioTrack set to AliRtcAudioTrackNo.

  • To subscribe to both the camera and screen sharing streams, set videoTrack to AliRtcVideoTrackBoth. The same principle applies to audio.

Parameters

Parameter

Type

Description

uid

NSString *

Remote user ID.

videoTrack

AliRtcVideoTrack

Video stream type.

audioTrack

AliRtcAudioTrack

Audio stream type.

Return description

A return value of 0 indicates that the method call was successful. Otherwise, the call failed.

subscribeRemoteDestChannelStream

Subscribes to a specific user's stream across channels.

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

Parameters

Parameter

Type

Description

channelId

String

Remote channel ID.

uid

String

Remote user ID.

track

AliRtcVideoTrack

The video stream to subscribe to.

sub_audio

boolean

Stops or resumes pulling the audio stream of a specific remote user. Values:

  • true (default): Resume.

  • false: Stop.

sub

boolean

Stops or resumes cross-channel subscription to a specific user's stream.

Response Description

0 is returned when the method call is successful. A non-zero value is returned when the method call fails.

subscribeRemoteDestChannelAllStream

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

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

Parameters

Name

Type

Description

channelId

NSString *

Destination channel.

videotrack

AliRtcVideoTrack

Video stream type.

audioTrack

AliRtcAudioTrack

Audio stream type.

subAudio

BOOL

Whether to subscribe to the audio stream.

sub

BOOL

Whether to subscribe to the video streams of remote channel users.

Return value

Returns 0 on success. A non-zero value indicates failure.

setRemoteAudioVolume

Sets the volume of the remote audio.

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

This method must be called after the remote user joins the channel. The method call fails if the specified user is not in the channel.

Parameters

Name

Type

Description

uid

NSString *

User ID, a unique identifier assigned by the App server.

volume

NSInteger

Playback volume, range [0,100]. 0: mute; 100: original volume.

Return value

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

muteLocalMic

Stops or resumes sending the local audio stream.

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

When you mute the local audio, silent audio frames are sent. The audio collection and encoding modules continue to work.

When to call

You can call this method before or after you join a room.

Related callbacks

After the call is successful, the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3189c59d9fipb" id="1579c3523779c">onUserAudioMuted</a> callback is triggered to notify you whether the remote user is muted.

Parameters

Name

Type

Description

mute

BOOL

  • YES means local audio sends empty frames.

  • NO means resume normal. The default value is NO.

mode

AliRtcMuteLocalAudioMode

Mute mode, defaults to muting all.

  • AliRtcMuteAudioModeDefault: Mutes all, including microphone and external audio input.

  • AliRtcMuteAllAudioMode: Mutes all, including microphone and external audio input.

  • AliRtcMuteOnlyMicAudioMode: Mutes only the microphone.

Return value

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the call failed.

muteRemoteAudioPlaying

Stops or resumes remote audio playback.

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

This method only stops or resumes a specified remote user's audio playback and does not affect the pulling and decoding of the remote audio stream. To unsubscribe from a user's audio stream, call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#c8249fb568gms" id="dd9dbbad0bkni">subscribeRemoteAudioStream</a>.

When to call

You can call this method before or after joining a channel.

Parameters

Name

Type

Description

uid

NSString *_Nonnull

User ID.

mute

BOOL

  • YES means stop playback.

  • NO means resume playback. The default value is NO.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the method call failed.

muteAllRemoteAudioPlaying

Stops or resumes all remote audio playback.

- (int)muteAllRemoteAudioPlaying:(BOOL)mute;

This interface stops or resumes all remote audio playback.

Note

This method only stops playback. Stream pulling and decoding are not affected.

When to call

You can call this method before or after joining a channel.

Parameters

Name

Type

Description

mute

BOOL

  • YES means stop playback.

  • NO means resume playback. The default value is NO.

Return value

0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

startAudioCapture[1/2]

Starts audio capture.

- (void)startAudioCapture;

This method starts audio capture. You can call this method before joining a channel to enable audio capture in advance. If this method is not called, the SDK automatically manages the audio capture device. To restart audio capture after calling stopAudioCapture, you must call this method.

When to call

You can call this method before or after joining a channel.

Related interfaces

You can use the parameters of the startAudioCapture[2/2] method to control whether the audio capture device remains active after you leave the channel.

Related callbacks

After you call this method, the SDK triggers the onLocalAudioStateChanged callback to report the change in the local audio capture state.

Returns

0 indicates that the method call was successful. Any other value indicates that the method call failed.

startAudioCapture[2/2]

Starts audio capture.

- (void)startAudioCapture:(BOOL)keepAlive;

Audio capture stops when the microphone is muted.

You can call this method before joining a channel to start audio capture in advance. If you do not call this method, the SDK automatically controls the audio capture device.

When to call

Call this method before or after joining a channel.

Related methods

Compared to startAudioCapture[1/2], this method lets you control whether the capture device remains on after you leave the channel using the keepAlive parameter.

Related callbacks

After you call this method to modify the local audio capture status, you will receive the status change in the onLocalAudioStateChanged callback.

Parameters

Parameter

Type

Description

keepAlive

boolean

Status of the collection device after leaving the meeting. Values:

  • true: The collection device remains on after leaving the meeting.

  • false (default): The collection device is turned off after leaving the meeting.

Return value

0 indicates that the method call was successful. Other values indicate that the method call failed.

stopAudioCapture

Stops audio capture.

- (void)stopAudioCapture;

After you call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#3103c368bexf8" id="ddef64f9b93zq">startAudioCapture</a>, you can call this method to stop audio capture.

Related callbacks

After calling this interface to modify the local audio collection status, you will receive the status change through the onLocalAudioStateChanged callback.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

enableSpeakerphone

Sets the audio output to the earpiece or speaker (iOS only).

- (int)enableSpeakerphone:(BOOL)enable;

This interface sets the audio playback device to either the earpiece or the speaker after you join a channel. If you do not call this interface, the default audio routing device is used for playback.

The SDK defines the audio routing priority and automatically switches the audio route based on the peripheral connection status. The priority is as follows: Wired headset > Bluetooth headset > User settings > Default settings. Therefore, this interface call has no effect when a peripheral is connected. For more information about audio route settings, see Audio route settings.

When to call

You can call this method before or after joining a channel.

Related interfaces

The <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#83be8cc066qqq" id="f8de149ef8so0">setDefaultAudioRoutetoSpeakerphone</a> method modifies the default audio route settings. In contrast, this method sets the current routing device.

Parameters

Name

Type

Description

enable

BOOL

  • YES means speaker mode.

  • NO means earpiece mode. The default is YES.

Return value

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

isEnableSpeakerphone

Checks whether the current audio output is the earpiece or the speaker (iOS only).

- (BOOL)isEnableSpeakerphone;

Return value

YES indicates that speaker mode is enabled. NO indicates that earpiece mode is enabled.

enableAudioVolumeIndication

Sets the frequency of the volume callback and the smoothing coefficient.

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

This method allows the SDK to periodically report volume information about the local publishing user and the remote user with the highest instantaneous volume to the app.

When to call

You can call this method before or after joining a channel.

Related callbacks

After you successfully call this method, if users are publishing in the channel, the SDK triggers the following two callbacks at the set time interval:

  • The onAudioVolumeCallback callback reports the audio volume of each speaker at the specified interval.

  • For voice activity detection, the onActiveSpeaker callback reports the UID of the active speaker.

Parameters

Name

Type

Description

interval

NSInteger

Time interval in milliseconds. The minimum value must not be less than 10 ms. It is recommended to set it to 300-500 ms. A value less than or equal to 0 means that the volume prompt and speaker prompt functions are not enabled.

smooth

NSInteger

Smoothing coefficient, range: [0,9]. The larger the value, the higher the smoothing degree, and vice versa, the better the real-time performance. It is recommended to set it to 3.

reportVad

NSInteger

Speaker detection switch. Values:

  • 1: On. The status of each speaker is reported through the onAudioVolumeCallback interface.

  • 0: Off.

Return value

0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

enableEarBack

Enables in-ear monitoring.

- (int)enableEarBack:(BOOL)enable;

This method enables or disables the in-ear monitoring feature. We recommend enabling in-ear monitoring when you use headphones (wired or Bluetooth) for a better experience.

When to call

You can call this method before or after joining a channel.

Parameters

Name

Type

Description

enable

BOOL

  • YES means enable in-ear monitoring.

  • NO means disable in-ear monitoring. The default value is NO.

Returns

0 indicates that the method call was successful. A negative value indicates that the method call failed.

setEarBackVolume

Sets the in-ear monitoring volume.

- (int)setEarBackVolume:(NSInteger)volume;

This method sets the volume for in-ear monitoring. This setting takes effect only after you enable the in-ear monitoring feature by calling <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#bd665d0f894ux" id="b0fa86c9bcuq">enableEarBack</a>.

When to call

You can call this method before or after joining a channel.

Parameters

Name

Type

Description

volume

NSInteger

Range: [0,100], default 100.

Return value

0 indicates that the method call was successful. A non-zero value indicates that the call failed.

startAudioPlayer

Starts audio playback.

- (void)startAudioPlayer;
Note

You can call this interface to start audio playback early. If you do not call this interface, the SDK automatically starts audio playback after it subscribes to an audio stream.

stopAudioPlayer

Stops audio playback.

- (void)stopAudioPlayer;
Note

You can use this interface to stop audio playback.

setPlayoutVolume

Sets the playback volume.

- (int)setPlayoutVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

Volume

Range: [0..400], where [0..100] is the original volume range and [100..400] is volume amplification.

Return value

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

setRecordingVolume

Sets the recording volume.

- (int)setRecordingVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

Range: [0..400]. [0..100] is the original volume, [100..400] is volume amplification.

Return value

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

playAudioFileTest

Plays an audio file.

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

Call this method before calling JoinChannel.

Parameters

Parameter

Type

Description

filePath

NSString *_Nonnull

Playback file path.

Return value

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

stopAudioFileTest

Stops the playback of the audio file.

- (int)stopAudioFileTest;
Note

Call this method before joining a channel.

Return value

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

startAudioCaptureTest

Starts a test of the audio capture device before you join a channel.

- (void)startAudioCaptureTest;
Note

The method call fails if you call it after you have joined a channel.

stopAudioCaptureTest

Stops the pre-call test of the audio capture device.

- (void)stopAudioCaptureTest;
Note

You can only call this method before joinchannel. Calling it after joinchannel will fail.

setDefaultAudioRoutetoSpeakerphone

Sets whether to route the default audio output to the speaker. By default, audio is routed to the speaker.

- (int)setDefaultAudioRouteToSpeakerphone:(BOOL)defaultToSpeakerphone;

You can use this interface to set the default audio routing device before you join a meeting. You can choose to route the audio output to either the earpiece or the speaker. By default, the SDK routes audio to the speaker. To change this default configuration, you can call this interface before you join the meeting.

The audio routing priority is predefined in the SDK. The SDK automatically switches the audio route based on the connection status of peripheral devices. The priority is as follows: Wired headset > Bluetooth headset > User settings > Default settings. Therefore, if no peripheral device is connected and you do not call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#f7d0d8b64fzkz" id="30798b686b5qk">enableSpeakerphone</a> method, the default settings are applied.

For more information about audio route settings, see Audio route settings.

Mobile devices typically have two audio output devices: the earpiece and the speaker.

  • When audio is routed to the earpiece, the sound is quieter and provides better privacy. This is suitable for phone calls because the audio can only be heard clearly when the device is held close to your ear.

  • When audio is routed to the speaker, the sound is louder and enables a hands-free function. The audio can be heard clearly without holding the device to your ear.

Related interfaces

This API modifies the default audio routing settings, whereas the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#f7d0d8b64fzkz" id="6001aa98ebapw">enableSpeakerphone</a> API sets the current routing device.

When to call

You can call this method before or after you join a meeting.

Parameters

Name

Type

Description

defaultToSpeakerphone

BOOL

Whether to route audio to the speaker. YES for speaker, NO for earpiece.

Return value

Returns 0 on success. A non-zero value indicates failure.

setAudioEffectVoiceChangerMode

Sets the voice changer effect mode.

- (int)setAudioEffectVoiceChangerMode:(AliRtcAudioEffectVoiceChangerMode)mode;

Parameters

Name

Type

Description

mode

AliRtcAudioEffectVoiceChangerMode

Mode value. The default value is AliRtcSdk_AudioEffect_Voice_Changer_OFF.

Return value

A return value of 0 indicates that the method call was successful. Otherwise, the call failed.

setAudioEffectPitchValue

Sets the pitch shifting parameter.

- (int)setAudioEffectPitchValue:(double)value;

Parameters

Name

Type

Description

value

double

Range: [0.5, 2.0]. The default is 1.0, which means no pitch change.

Return value

A value of 0 indicates that the method call is successful. A non-zero value indicates that the method call failed.

setAudioEffectReverbMode

Sets the reverberation effect mode.

- (int)setAudioEffectReverbMode:(AliRtcAudioEffectReverbMode)mode;

Parameters

Name

Type

Description

mode

AliRtcAudioEffectReverbMode

Sound effect mode. The default value is AliRtcAudioEffectReverb_Off.

Response description

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

setAudioEffectReverbParamType

Sets the type and parameters for the reverberation effect.

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

Parameters

Name

Type

Description

type

AliRtcAudioEffectReverbParamType

Sound effect reverberation mode.

value

float

Specific parameter value.

Return value

0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

setAudioEffectBeautifyMode

Sets the preset voice beautification effect mode.

- (int)setAudioEffectBeautifyMode:(AliRtcAudioEffectBeautifyMode)mode;

You can call this interface to set preset voice beautification modes for scenarios that require voice beautification, such as voice live streaming, karaoke, and voice-based social networking. By selecting a mode, you can change the auditory effect of the human voice, for example, by enhancing its magnetic quality or improving its clarity, to create a better listening experience for remote users.

When to call

You can call this interface before or after joining a channel.

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectBeatifyMode

Voice beautification effect mode. See the enumeration definition for details.

Return values

  • 0: The mode was set successfully.

  • A non-zero value: Failed to set the mode.

setAudioEffectEqualizationParam

Sets the audio equalizer (EQ) parameter to adjust the gain of a specified frequency band.

- (int)setAudioEffectEqualizationParam:(AliRtcAudioEffectEqualizationBandFrequency)bandIndex gain:(float)gain;

You can use this interface to adjust the graphic equalizer for locally captured voice or audio signals. By adjusting the gain in decibels (dB) for one of the 10 fixed frequency bands, you can achieve customized sound processing. This feature is suitable for scenarios such as voice clarity optimization, human voice highlighting, and assisted noise reduction.

The equalizer supports adjustments across the full audio spectrum from 31 Hz to 16 kHz, which is divided into 10 standard frequency bands. The gain for each band can be set independently from -15 dB to 15 dB. The default value is 0 dB, which indicates no enhancement or attenuation.

Limits

  • You must enable the voice beautification mode by calling setAudioEffectBeautifyMode before you call this interface.

Parameters

Parameter

Type

Description

bandIndex

AliRtcAudioEffectEqualizationBandFrequency

The frequency band index to be adjusted, corresponding to a segment of the center frequency (31Hz ~ 16kHz).

gain

float

Gain value, in dB, ranging from [-15, 15].

Response Description

0: The parameter was set successfully.

A non-zero value: The parameter failed to be set.

addExternalAudioStream

Adds an external audio stream.

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

This method adds a new external audio stream. The steps are as follows:

  1. Call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#d71bbfd2f242b" id="c310321e9eu35">addExternalAudioStream</a> method to add an external audio stream and obtain the external audio stream ID.

  2. Call pushExternalAudioStream to push audio data to the created audio stream.

  3. When the call ends, call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#282d70095duaw" id="16f621608d94x">removeExternalAudioStream</a> to remove the external audio stream.

To publish custom captured audio in a channel, see Custom audio collection.

Parameters

Name

Type

Description

config

AliRtcExternalAudioStreamConfig

External audio stream configuration.

Returns

If the method call is successful, it returns the ID of the external audio stream, which is a value greater than 0. Other values indicate failure.

pushExternalAudioStream

Inputs external audio stream data.

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

This method inputs data into a specified audio stream. Follow these steps:

  1. Call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#d71bbfd2f242b" id="0a353f7272shu">addExternalAudioStream</a> method to add an external audio stream and obtain the external audio stream ID.

  2. Call this method to input audio data into the created audio stream.

  3. When the call ends, call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#282d70095duaw" id="a9ebc8d599dz4">removeExternalAudioStream</a> method to remove the external audio stream.

For more information about publishing custom collected audio in a channel, see Custom audio collection.

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

audioFrame

AliRtcAudioFrame

Audio data.

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that it failed.

setExternalAudioStream:publishVolume

Sets the publishing volume of the external audio stream.

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

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

publishVolume

int

Stream ingest volume.

Return value

Returns 0 if the method call is successful, or a non-zero value if the call failed.

getExternalAudioStreamPublishVolume

Retrieves the publishing volume of the external audio stream.

- (int)getExternalAudioStreamPublishVolume:(int)streamId;

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

Response Description

The stream ingest volume. The value ranges from 0 to 100. A value less than 0 indicates that the call failed.

setExternalAudioStream:playoutVolume

Sets the playback volume of the external audio stream.

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

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

playoutVolume

int

Playback volume.

Returns

The method returns 0 if the call is successful, or a non-zero value if the call fails.

getExternalAudioStreamPlayoutVolume

Retrieves the playback volume of the external audio stream.

- (int)getExternalAudioStreamPlayoutVolume:(int)streamId;

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

Return value

The playback volume. The value ranges from 0 to 100. A value less than 0 indicates that the method call failed.

removeExternalAudioStream

Deletes an external audio stream.

- (int)removeExternalAudioStream:(int)streamId;

This method removes the external audio stream that corresponds to the specified streamId. It is the counterpart to the addExternalAudioStream method.

When to call

To use the custom audio input feature, you must first call the addExternalAudioStream method to add an audio stream and obtain its stream ID. Then, you can call the pushExternalAudioStream interface to push your audio data to the SDK. When you want to stop using the custom audio input, call this method to remove the corresponding external audio stream and release its resources.

Parameters

Name

Type

Description

streamId

int

External audio stream ID.

Return value

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

getAudioFileInfo

Retrieves information about an audio file.

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

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

Parameters

Name

Type

Description

filePath

NSString *

File path.

startAudioAccompanyWithFile

Starts audio mixing.

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

This is an asynchronous method. You can monitor the player status in the {@link onAudioAccompanyStateChanged:errorCode:} callback.

Parameters

Name

Type

Description

filePath

NSString *

File path.

config

AliRtcAudioAccompanyConfig *

Configuration for audio mixing.

Return value

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

stopAudioAccompany

Stops audio mixing.

- (int)stopAudioAccompany;

Return value

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

setAudioAccompanyVolume

Sets the audio mixing volume.

- (int)setAudioAccompanyVolume:(NSInteger)volume;
Note

This method sets the volume of mixed audio for both local playback and stream ingest.

Parameters

Name

Type

Description

volume

NSInteger

volume Audio mixing volume, range [0,100].

Return value

Returns 0 on success, or an error code on failure.

setAudioAccompanyPublishVolume

Sets the publishing volume for the audio mixing stream.

- (int)setAudioAccompanyPublishVolume:(NSInteger)volume;
Note

Sets the volume for the outgoing stream.

Parameters

Name

Type

Description

volume

NSInteger

volume Audio mixing volume, range [0,100].

Return value

Returns 0 on success. A non-zero value indicates failure.

getAudioAccompanyPublishVolume

Retrieves the volume of the audio mixing stream ingest.

- (int)getAudioAccompanyPublishVolume;

Return value

A value in the range of 0 to 100 is returned on success. Other values indicate a failure.

setAudioAccompanyPlayoutVolume

Sets the local playback volume for audio mixing.

- (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

volume Audio mixing volume, range [0,100].

Return value

Returns 0 on success. A non-zero value indicates failure.

getAudioAccompanyPlayoutVolume

Retrieves the local playback volume for audio mixing.

- (int)getAudioAccompanyPlayoutVolume;

Return value

A value from 0 to 100 indicates success. Any other value indicates failure.

pauseAudioAccompany

Pauses audio mixing.

- (int)pauseAudioAccompany;

Return value

0 indicates success. Other values indicate failure.

resumeAudioAccompany

Resumes audio mixing.

- (int)resumeAudioAccompany;

Return value

0 indicates success, and any other value indicates failure.

getAudioAccompanyDuration

Returns the duration of the audio mixing file in milliseconds.

- (int)getAudioAccompanyDuration;

Return value

A return value of 0 or greater indicates the duration of the audio mixing file in milliseconds. A return value of less than 0 indicates a failure.

getAudioAccompanyCurrentPosition

Retrieves the playback progress of the audio mixing file in milliseconds.

- (int)getAudioAccompanyCurrentPosition;

Return value

A value greater than or equal to 0 indicates the playback progress. A value less than 0 indicates that the call failed.

setAudioAccompanyPosition

Sets the playback position of the accompanying audio file.

- (int)setAudioAccompanyPosition:(int)pos;

Parameters

Name

Type

Description

pos

int

pos Progress bar position, in milliseconds.

Return value

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

preloadAudioEffectWithSoundId

Preloads a sound effect file.

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

Parameters

Name

Type

Description

soundId

NSInteger

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

filePath

NSString *_Nonnull

Sound effect file path.

Returns

0 indicates a successful method call, and a non-zero value indicates a failed method call.

unloadAudioEffectWithSoundId

Unloads a preloaded sound effect file.

- (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Returns

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

playAudioEffectWithSoundId

Starts playing a sound effect.

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

Parameters

Name

Type

Description

soundId

NSInteger

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

filePath

NSString *_Nonnull

Sound effect file path.

cycles

NSInteger

Number of loops (can be set to -1 or a positive integer).

publish

BOOL

Whether to publish.

Return value

A return value of 0 indicates that the method was called successfully. A non-zero value indicates that the method call failed.

stopAudioEffectWithSoundId

Stops playing a sound effect.

- (int)stopAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Return value

0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

stopAllAudioEffects

Stops playing all sound effects.

- (int)stopAllAudioEffects;

Return value

0 indicates that the method call was successful. A non-zero value indicates that the call failed.

pauseAudioEffectWithSoundId

Pauses a sound effect.

- (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Returns

0 indicates that the method call was successful. Otherwise, the method call failed.

pauseAllAudioEffects

Pauses all sound effects.

- (int)pauseAllAudioEffects;

Returns

A value of 0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

resumeAudioEffectWithSoundId

Resumes playing a specified sound effect.

- (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Return value

Returns 0 if the method call is successful, or a non-zero value if the method call failed.

resumeAllAudioEffects

Resumes playing all sound effects.

- (int)resumeAllAudioEffects;

Return value

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

setAudioEffectPublishVolumeWithSoundId

Sets the sound effect stream ingest volume.

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

Parameters

Name

Type

Description

soundId

NSInteger

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

volume

NSInteger

Mixing volume, range: [0,100], default value is 50.

Return Value

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

getAudioEffectPublishVolumeWithSoundId

Retrieves the volume of the published sound effect for stream ingest.

- (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Return value

A value of 0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

setAllAudioEffectsPublishVolume

Sets the mixing volume of all sound effects for stream ingest.

- (int)setAllAudioEffectsPublishVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

Mixing volume, range: [0,100], default value is 50.

Returns

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the call failed.

setAudioEffectPlayoutVolumeWithSoundId

Sets the local playback volume for a sound effect.

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

Parameters

Name

Type

Description

soundId

NSInteger

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

volume

NSInteger

Mixing volume, range: [0,100], default value is 50.

Returns

A return value of 0 indicates that the method call was successful. Any other value indicates that the call failed.

getAudioEffectPlayoutVolumeWithSoundId

Retrieves the local playback volume for a sound effect.

- (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;

Parameters

Name

Type

Description

soundId

NSInteger

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

Return value

Returns 0 if the method call is successful. Returns a non-zero value if the method call failed.

setAllAudioEffectsPlayoutVolume

Sets the local playback volume for all sound effects.

- (int)setAllAudioEffectsPlayoutVolume:(NSInteger)volume;

Parameters

Name

Type

Description

volume

NSInteger

Mixing volume, range: [0,100], default value is 50.

Return value

0 indicates that the method call was successful. Otherwise, the call failed.

startRecord

Starts recording a media file.

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

Parameters

Parameter

Type

Description

recordType

AliRtcRecordType

Recording type.

recordFormat

AliRtcRecordFormat

Recording format.

filePath

NSString *

Recording file name and path.

audioConfig

AliRtcRecordAudioConfig *

Audio configuration.

videoConfig

AliRtcRecordVideoConfig *

Video configuration.

Return value

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

Note
  • To record a video stream, call this interface after the stream is successfully published, which is indicated by the onVideoPublishStateChanged callback. This call records the locally encoded video stream to a local file.

  • When you record an audio stream, the recorded file contains a mix of local and remote audio.

stopRecord

Stops recording the media file.

- (void)stopRecord 

Parameters

None.

setLocalViewConfig

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

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

You can call this method to bind the display view to the local video stream and set the rendering mode, image mode, and rotation angle for the local user's view. These settings only affect the local preview and do not apply to the published video stream. To set the view for a remote user, call setRemoteViewConfig.

Note

When to call

This method can be called before or after joining a channel.

Parameters

Name

Type

Description

viewConfig

AliVideoCanvas

*_Nullable

Rendering parameters, including the rendering window and rendering method.

track

AliRtcVideoTrack

The type of video track.

Return value

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the call failed.

setCameraCapturerConfiguration

Sets the camera capture preferences.

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

This method is used to configure camera capture preferences, such as the camera direction and capture frame rate.

When to call

You must call this method before you open the camera, for example, before you call the following methods:

  • startPreview

  • joinChannel

Parameters

Name

Type

Description

config

AliRtcCameraCapturerConfiguration

* _Nonnull

Camera capture preferences. Default values:

  • preference: 0

  • cameraDirection: 0

  • fps: 0

  • cameraCaptureProfile: 0

  • disableVideoCaptureReverse: -1

  • enableCameraMacroFocus: -1

  • captureObserverOriginal: -1

  • nativeBufferObserver: -1

  • captureCallbackCvpixelbufferToRaw: -1

A value of -1 for the above indicates using the SDK's internal default settings.

Return value

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the call failed.

enableLocalVideo

Enables or disables local video capture.

- (int)enableLocalVideo:(BOOL)enable;

This method enables or disables local video capture. When local video capture is disabled, the SDK stops sending video data for the local preview and stream ingest, which causes them to freeze on the last captured frame. This action does not affect receiving remote video.

Note

Local video capture is enabled by default.

When to call

You can call this method before or after you join a channel.

Related callbacks

  • After you successfully call this method, remote users in the channel receive the onUserVideoEnabled callback.

Parameters

Name

Type

Description

enable

BOOL

YES means resume normal, NO means stop video collection. The default is YES.

Return description

0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

muteLocalCamera

Stops or resumes sending local video data.

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

When you publish a stream, you can call this interface to send black video frames. The local preview is not affected. The collection, encoding, and sending modules continue to work, but the sent video consists of black frames.

Note

This interface only controls whether to send black frames on the specified video stream. Video collection and data sending do not stop. To disable video collection, call the enableLocalVideo interface. To stop sending video data, call the publishLocalVideoStream interface.

Parameters

Name

Type

Description

mute

BOOL

YES means send black frames for video data, NO means resume normal. The default value is NO.

track

AliRtcVideoTrack

The type of video track whose publishing status needs to be changed.

Return description

A return value of 0 indicates that the method call was successful. Otherwise, the method call failed.

setRemoteViewConfig

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

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

This method attaches a display view to a specified video stream from a remote user and sets rendering properties for the view on the local display, such as the rendering mode, mirror mode, and rotation angle. This affects only the video image that the local user sees. To set the local preview view, you can call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#fea843803078q" id="b6f22fe87a2es">setLocalViewConfig</a>.

When to call

We recommend that you call this method when the onRemoteTrackAvailableNotify callback is received. This callback indicates that the remote user's video is available.

Parameters

Name

Type

Description

canvas

AliVideoCanvas

*_Nullable

Rendering parameters, including the rendering window and rendering method.

uid

NSString *_Nonnull

User ID.

track

AliRtcVideoTrack

The type of video track to set.

Returns

0 indicates that the method call was successful. Any other value indicates that the method call failed.

isCameraOn

Checks if the camera is on.

- (BOOL)isCameraOn;

Return value

Returns YES if the camera is on, or NO if it is off.

setVideoEncoderConfiguration

Sets video encoding properties.

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

This method sets video encoding properties, such as resolution, frame rate, bitrate, and video orientation. We recommend that you call this interface in all video scenarios.

Note

Each parameter has a valid range. If you set a parameter to a value outside its valid range, the SDK automatically adjusts the value to be within the range.

When to call

You can call this method before or after joining a meeting. If you only need to set the video encoding properties for the camera stream once per meeting, we recommend that you call this method before joining.

Limits

The mirrorMode parameter of this method and setVideoMirrorMode both control the mirroring of the video stream ingest image. We recommend that you use only one. Using both at the same time causes the image effects to stack, which may result in setting failures or unexpected behavior.

Parameters

Name

Type

Description

config

AliRtcVideoEncoderConfiguration

* _Nonnull

Predefined encoding properties. Default values:

  • dimensions: [640,480]

  • frameRate: 15

  • bitrate: 0

  • mirrorMode: 0

  • keyFrameInterval: Keyframe interval, in milliseconds. The default is 0, which means it is controlled by the SDK internally.

  • forceStrictKeyFrameInterval: Whether to force the encoder to strictly produce keyframes according to the set keyframe interval. The default value is false.

  • orientationMode: 0

  • rotation: 0

  • codecType: AliRtcVideoCodecTypeDefault

  • encoderType: AliRtcVideoEncodeCodecTypeDefault

  • seiForceFrontIFrame: -1

  • enableDynamicEncode: -1

  • disableDipenseResolutionChange: -1

  • enableDowngrade: -1

  • enableH264BFrame: -1

  • enableHevcBFrame: -1

  • backgroundHardwareToSoftware: -1

A value of -1 for the above indicates using the SDK's internal default settings.

setVideoDecoderConfiguration

Sets video decoding properties.

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

This method sets the video decoding properties for a camera stream.

When to call

We recommend calling this method before joining a meeting.

Parameters

Name

Type

Description

config

AliRtcVideoDecoderConfiguration

* _Nonnull

Predefined decoding properties. Default values:

  • codecType: AliRtcVideoCodecTypeDefault

  • enableDecoderBframe: -1

  • backgroundHardwareToSoftware: -1

A value of -1 for the above indicates using the SDK's internal default settings.

switchCamera

Switches between the front and rear cameras. The front camera is used by default.

- (int)switchCamera;

You can call this method to dynamically switch cameras during runtime without restarting the video stream or reconfiguring the video source.

When to call

You must call this method after the camera is successfully opened.

Limits

This method is available only on Android and iOS platforms.

Return description

A return value of 0 indicates that the method call was successful. Otherwise, the call failed.

getCurrentCameraDirection

Retrieves the current camera direction. The default is the front camera (iOS only).

- (AliRtcCameraDirection)getCurrentCameraDirection;

Return value

The camera direction enumeration value.

startPreview

Starts the local video preview and automatically opens the camera.

- (int)startPreview;

This interface starts the local video preview and automatically opens the camera. To stop the local preview, you can call the stopPreview interface.

Note

leaveChannel automatically stops the local preview when you leave the channel. If a camera stream is not being published, the camera is automatically closed.

When to call

  • Before you call this interface, you must call setLocalViewConfig to set the view for the local preview. Otherwise, the preview cannot be started. This does not affect stream ingest.

  • You can call this interface before you call joinChannel to start the preview. This automatically opens the camera.

Return value

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

stopPreview

Stops the local preview.

- (int)stopPreview;

This method stops the local video preview and turns off the camera. After the preview is stopped, the local view remains on the last captured frame, which does not affect stream ingest.

Note

The leaveChannel method automatically stops the local preview when you leave the channel. If a camera stream is not being published, the camera is also turned off automatically.

When to call

You can call this method to stop the preview after you have started it.

Return value

0 indicates that the method call was successful. Otherwise, the call failed.

setCameraZoom

Sets the zoom level of the camera.

 - (int)setCameraZoom:(float)zoom;

Parameters

Name

Type

Description

zoom

float

Zoom level, ranging from 1 to the maximum zoom value supported by the camera.

Return value

Returns 0 on success. A non-zero value indicates failure.

GetCameraMaxZoomFactor

Retrieves the maximum camera zoom factor.

 - (float)GetCameraMaxZoomFactor;

Return value

The maximum camera zoom factor.

GetCurrentZoom

Returns the current zoom factor of the camera.

- (float)GetCurrentZoom;

Return value

The current camera zoom factor.

SetExposure

Sets the camera exposure.

- (int)SetExposure:(float)exposure;

Parameters

Name

Type

Description

exposure

float

Exposure

Return value

Returns 0 on success. Other values indicate a failure.

GetCurrentExposure

Returns the current camera exposure.

- (float)GetCurrentExposure;

Return value

The current camera exposure.

GetMinExposure

Retrieves the minimum camera exposure.

- (float)GetMinExposure;

Return value

The minimum camera exposure.

GetMaxExposure

Retrieves the maximum camera exposure.

- (float)GetMaxExposure;

Return value

The maximum camera exposure.

setCameraFlash

Turns the camera flash on or off.

- (int)setCameraFlash:(BOOL)flash;

Parameters

Name

Type

Description

flash

BOOL

Whether to allow the flash to be turned on.

Return value

0 indicates success. Other values indicate failure.

isCameraFocusPointSupported

Checks if the camera supports manual focus.

- (BOOL)isCameraFocusPointSupported;

Return value

TRUE: Manual focus is supported. FALSE: Manual focus is not supported.

isCameraExposurePointSupported

Checks whether the camera supports setting an exposure point.

- (BOOL)isCameraExposurePointSupported;

Return value

Returns TRUE if the camera supports setting an exposure point, or FALSE otherwise.

setCameraFocusPoint

Sets the manual focus point for the camera.

- (int)setCameraFocusPoint:(CGPoint)point;

Parameters

Name

Type

Description

point

CGPoint

The focus point coordinates to set, which will be maintained.

Return value

Returns 0 if the operation is successful. Otherwise, an error code is returned.

setCameraExposurePoint

Sets the exposure point and exposure value.

- (int)setCameraExposurePoint:(CGPoint)point;

Parameters

Name

Type

Description

point

CGPoint

The focus point coordinates to set, which will be maintained.

Return value

Returns 0 on success. Other values indicate failure.

isCameraAutoFocusFaceModeSupported

Checks whether the camera supports face-based autofocus.

- (BOOL)isCameraAutoFocusFaceModeSupported;

Return value

Returns TRUE if face-based autofocus is supported, or FALSE otherwise.

setCameraAutoFocusFaceModeEnabled

Enables or disables face-based autofocus for the camera.

- (BOOL)setCameraAutoFocusFaceModeEnabled:(BOOL)enable;

Parameters

Name

Type

Description

point

CGPoint

The focus point coordinates to set, which will be maintained.

Return value

Returns TRUE if the method call is successful, or FALSE otherwise.

setVideoMirrorMode

Sets the video mirror mode.

- (int)setVideoMirrorMode:(AliRtcVideoPipelineMirrorMode)mirrorMode;

Sets the mirror mode for the local video preview and the published video stream.

Note

This interface has a higher priority than setLocalViewConfig and setVideoEncoderConfiguration. We recommend that you use this interface to set the video mirror mode.

When to call

You can call this interface before or after joining a meeting. The SDK internally records the setting and applies it when the video preview and encoding (stream ingest) are available.

Limits

This interface's functionality overlaps with the mirrorMode setting in setLocalViewConfig and setVideoEncoderConfiguration. We recommend that you use only this interface.

Parameters

Name

Type

Description

mirrorMode

AliRtcVideoPipelineMirrorMode

Image type.

SetCapturePipelineScaleMode

Sets the scaling mode of the video capture pipeline.

-(void)setCapturePipelineScaleMode:(AliRtcCapturePipelineScaleMode)mode;

This method sets whether video data is scaled immediately upon capture or only during encoding. For example, if the capture resolution differs from the encoding resolution, you can use this setting to determine whether the preview data is consistent with the stream ingest data.

Note

This method controls when scaling occurs during video capture. By default, scaling occurs immediately upon capture. You must call this method before you open the camera, and before you call startPreview or joinChannel.

When to call

You must call this method before you open the camera, for example, before you call startPreview or joinChannel.

Parameters

Name

Type

Description

mode

AliRtcCapturePipelineScaleMode

Scaling type.

Return value

0 indicates success. Other values indicate failure.

registerVideoFrameWithObserver

Registers a video data output object.

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

You can use this interface to register a video data output object. To unregister the object, call the unregisterVideoSampleWithObserver interface.

When to call

To obtain raw video data (such as data in YUV or RGBA format), you can call this interface to register a video data observer to retrieve video data at each stage.

Related callbacks

After you successfully register a video data observer, the SDK triggers your implemented callbacks for each video frame. You can implement the following callbacks as needed:

Parameters

Name

Type

Description

observer

AliRtcVideoFrameDelegate

Video data output object.

unregisterVideoSampleWithObserver

Unregisters the observer object that is used to export video data.

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

This interface is the counterpart to the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#9a3437ab16j1w" id="f524bad30a6ys">registerVideoSampleObserver</a> interface and unregisters the video sample observer.

Parameters

Name

Type

Description

observer

AliRtcVideoFrameDelegate

Video data output object.

registerLocalVideoTextureObserver

Registers an observer for OpenGL texture data from the local camera video stream.

- (void)registerLocalVideoTextureObserver:(id<AliRtcTextureDelegate> _Nullable)observer;

To obtain raw video data, call the registerVideoSampleObserver method to register the corresponding callback. To obtain internal texture data, call this method. To unregister the observer, call the unRegisterLocalVideoTextureObserver method.

Note

Related callbacks

After you successfully register the observer, the SDK triggers the callbacks that you implemented in the AliRtcTextureObserver interface each time a video frame is captured. Implement the callbacks that you need as needed:

  • onTextureCreate: This callback is triggered when the SDK creates its internal OpenGL context.

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

  • onTextureDestroy: This callback is triggered when the SDK destroys its internal OpenGL context.

Parameters

Name

Type

Description

observer

AliRtcTextureDelegate

OpenGL texture data observer.

unregisterLocalVideoTextureObserver

Unregisters the observer for OpenGL video texture data from the local camera stream.

- (void)unregisterLocalVideoTextureObserver:(id<AliRtcTextureDelegate> _Nullable)observer;

This method is the counterpart of registerLocalVideoTextureObserver.

Parameters

Name

Type

Description

observer

AliRtcTextureDelegate

OpenGL texture data observer.

snapshotVideo

Captures a snapshot of the current video stream.

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

Parameters

Name

Type

Description

userId

NSString *

User ID. If userId is null or "", it represents the local user.

type

AliRtcVideoTrack

Video stream type, only supports {@link AliRtcVideoTrack::AliRtcVideoTrackCamera} and {@link AliRtcVideoTrack::AliRtcVideoTrackScreen}.

Return value

Returns 0 on success and an error code on failure.

setExternalVideoSource

Enables an external video source.

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

Parameters

Name

Type

Description

enable

BOOL

YES means enable, NO means disable.

type

AliRtcVideoSource

Stream type.

renderMode

AliRtcRenderMode

Rendering mode.

pushExternalVideoFrame

Enter the video data.

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

Parameters

Name

Type

Description

frame

AliRtcVideoDataSample

*_Nonnull

Frame data.

type

AliRtcVideoSource

Stream type.

Return value

0 indicates that the method call was successful. A value other than 0 indicates that the call failed.

startPublishLiveStreamWithURL

Starts a bypass live stream.

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

Parameters

Name

Type

Description

streamUrl

NSString *

Ingest URL.

transcoding

AliRtcLiveTranscodingParam

*

Parameters required for stream ingest.

Return Value

A return value of 0 indicates that the method call was successful. Otherwise, the call failed.

updatePublishLiveStreamWithURL

Updates the parameters of a bypass live stream.

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

Parameters

Name

Type

Description

streamUrl

NSString *

Ingest URL.

transcoding

AliRtcLiveTranscodingParam

*

Parameters required for stream ingest.

Return value

A return value of 0 indicates that the method call was successful, and a non-zero value indicates that the call failed.

stopPublishLiveStreamWithURL

Stops a bypass live stream.

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

Parameters

Name

Type

Description

streamUrl

NSString *_Nonnull

Ingest URL.

Returns

0 indicates that the method call was successful. A value other than 0 indicates that the method call failed.

GetPublishLiveStreamStateWithURL

Retrieves the status of the bypass live stream.

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

Parameters

Parameter

Type

Description

streamURL

NSString *

Ingest URL.

Return Value

Returns the status of the bypass live stream.

startLastmileDetect

Starts a last-mile network quality probe.

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

Parameters

Parameter

Type

Description

config

AliRtcNetworkQualityProbeConfig

Parameters for the probing configuration.

Returns

0 indicates success. A value other than 0 indicates failure.

stopLastmileDetect

Stops network quality probing.

- (int)stopLastmileDetect;

Response Description

0 indicates success. Any other value indicates failure.

sendMediaExtensionMsg

Sends Supplemental Enhancement Information (SEI).

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

The SDK lets you send and receive media extension information. This method sends media extension information using the SEI protocol. Subscribers can obtain the information by listening for the onMediaExtensionMsgReceived callback.

Common use cases include the following:

  • Transmitting timestamps to calculate end-to-end network latency or synchronize data with other business operations.

  • Transmitting descriptive information. You can send up to 4 KB of data, which is suitable for transferring small amounts of data. We recommend using the JSON or plain string format.

When to call

Call this method after you start to publish the stream.

Limits

Media extension information reuses the audio and video data channel. Therefore, you must control the sending frequency and the length of the message data. The usage limits are as follows:

  • The maximum number of messages that you can send per second is equal to the frames per second (fps) set in the profile. This is because SEI is transmitted within the H.264/H.265 stream, and the extension information can only be attached during video frame encoding.

  • To avoid affecting media transmission quality, the message body is limited to 4 KB.

  • The repeatCount parameter in the sendMediaExtensionMsg function specifies the redundancy for the message. If you set this parameter to a value greater than 1, the message is sent multiple times.

  • Sending a message multiple times helps prevent message loss from network packet loss. However, subscribers in the channel will also receive multiple identical messages and must perform deduplication.

  • If you send media extension messages during a bypass live stream, subscribers in the channel will also receive the messages.

  • Only one media extension message can be transmitted at a time. If you call sendMediaExtensionMsg multiple times, the new data overwrites the previous data.

Related callbacks

After the publisher sends media extension information, subscribers can obtain the information by listening for the onMediaExtensionMsgReceived callback.

Parameters

Name

Type

Description

data

NSData *

Extension information content, with a maximum length limit of 4 KB.

repeatCount

int

Number of repetitions, representing message redundancy to prevent message loss due to network packet loss. -1 means infinite resending, unless sendMediaExtensionMsg is called again.

delay

int

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

isKeyFrame

bool

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

Return value

0 indicates success, and other values indicate failure.

sendMediaExtensionMsgEx

Sends media extension information using Supplemental Enhancement Information (SEI) at the underlying layer.

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

The SDK lets you send and receive media extension information. This method sends the information, and receivers can obtain it by listening for the onMediaExtensionMsgReceived callback. If the payloadType parameter is set to 5, this method is equivalent to the sendMediaExtensionMsg interface.

Common use cases include the following:

  • Transmitting timestamps to calculate end-to-end network latency or synchronize data with other business operations.

  • Transmitting descriptive information. You can send up to 4 KB of data, which is ideal for transferring small amounts of information in JSON or plain string format.

When to call

You can call this method after you publish a stream.

Limits

Media extension information reuses the audio and video data channel. Therefore, you must control the sending frequency and message data length. The limits are as follows:

  • The maximum number of messages that you can send per second is limited by the frames per second (fps) that is set in the profile. This is because SEI information is transmitted in the H.264 or H.265 stream, and video frame encoding is required to attach the extension information.

  • To avoid affecting media transmission quality, the message body is limited to 4 KB. This size is suitable for transmitting small amounts of information.

  • The repeatCount parameter specifies the number of redundant transmissions for the message. If this parameter is set to a value greater than 1, the message is sent multiple times.

  • This redundancy helps prevent message loss that is caused by network packet loss. However, subscribers in the channel receive multiple identical messages and must perform deduplication.

  • If you send custom messages during a bypass live stream, subscribers in the channel also receive the messages.

  • Only one MediaExtensionMsg can be transmitted at a time. If you call sendMediaExtensionMsg multiple times, the new data overwrites the previous data.

Parameters

Name

Type

Description

data

NSData *

Extension information content, with a maximum length limit of 4 KB.

repeatCount

int

Number of repetitions, representing message redundancy to prevent message loss due to network packet loss. -1 means infinite resending, unless sendMediaExtensionMsg is called again.

delay

int

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

isKeyFrame

bool

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

payloadType

int

Type. Use 5 for UUIDs. The range is [5, 100..254].

Return values

  • 0: The call was successful.

  • <0: The call failed. An error code is returned.

    • ERR_INNER(-1): Internal SDK error. Possible causes include that the SDK is not initialized or the method is called after the SDK is destroyed.

onConnectionStatusChange

This callback is triggered when the network connection status changes.

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

Parameters

Parameter

Type

Description

status

AliRtcConnectionStatus

Current status value.

reason

AliRtcConnectionStatusChangeReason

The specific reason for the status change.

onLocalDeviceException

A callback for exceptions that occur on the local device. You must handle the exceptions that are reported in this callback.

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

Parameters

Parameter

Type

Description

deviceType

AliRtcLocalDeviceType

Device type

exceptionType

AliRtcLocalDeviceExceptionType

Device exception type

msg

NSString

Information carried during the exception

onAuthInfoWillExpire

This callback is triggered when the user authentication information is about to expire. The authentication expires 30 seconds after this callback is received.

- (void)onAuthInfoWillExpire;

After you receive this callback, you must obtain a new token and update the authentication information in one of the following ways:

  • Call the <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#e6a4495191bmd" id="918ba91977wi6">refreshAuthInfo</a> API to update the authentication information.

  • Call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#449873b819cz2" id="ad8235d30dprb">leaveChannel</a> to leave the current channel, and then call joinChannel to rejoin the channel.

Trigger time

The SDK triggers this callback 30 seconds before the user's authentication information expires. You must update the authentication information promptly after you receive this callback.

onAuthInfoExpired

This callback is triggered when a user calls an interface that requires authentication, but the authentication information has expired.

- (void)onAuthInfoExpired;

This callback indicates that the user's authentication information has expired. To continue in the meeting, you need to generate a new token on the server and then update the authentication information using the following method:

  • Call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#449873b819cz2" id="21390e77a1307">leaveChannel</a> to leave the current channel, and then call joinChannel to rejoin the channel.

Trigger time

This callback is triggered when the user's authentication information expires.

onJoinChannelResult

This callback reports the result of joining a channel. It is the asynchronous result of the joinChannel method call and is used to handle events after the user joins the channel.

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

Trigger condition

When the application calls the joinChannel method, this callback reports whether the user successfully joined the channel and provides the time elapsed for the operation.

Parameters

Parameter

Type

Description

result

int

Join channel result. 0 for success, error code for failure.

channel

NSString *_Nonnull

The ID of the channel joined.

elapsed

int

Time taken to join the channel.

onLeaveChannelResult

This callback is returned after the leaveChannel interface is called, providing the result of leaving the channel. It is not triggered if destroy is called immediately after leaveChannel.

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

Parameters

Parameter

Type

Description

result

int

Leave channel result. 0 for success, error code for failure.

stats

AliRtcStats

Summary of data statistics for this channel session.

onRemoteUserOffLineNotify

A callback that is triggered when a remote user goes offline.

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

This callback notifies the local user that a remote user has left the channel for various reasons. This callback is triggered when a remote user goes offline.

Trigger conditions

  • The callback is triggered when a remote user actively leaves the channel.

  • This callback is triggered when a remote streamer calls <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#892915dd4edcy" id="78b1952ad5lwp">setClientRole</a> to switch their role to viewer (`AliRtcClientRolelive`).

  • The callback is triggered when the remote streamer is considered dropped because no data has been received for an extended period.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

User ID, a unique identifier assigned by the App server.

reason

AliRtcUserOfflineReason

The reason the user went offline.

onRemoteUserOnLineNotify

A callback that is triggered when a remote user goes online.

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

This callback notifies the local client that a remote user has joined the channel.

Trigger conditions

  • A remote user successfully joins the channel.

  • After the local user joins the channel, this callback is triggered for each remote user who is already in the channel. This provides the local user with a list of existing users.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

User ID, a unique identifier assigned by the App server.

elapsed

int

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

onRemoteTrackAvailableNotify

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

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

This callback is triggered when a remote user's stream ingest status changes. Developers can use this callback to determine in real time whether a remote user is publishing audio and video streams and then display or hide the remote user's audio and video information on the interface accordingly.

Note

This callback returns the remote user's stream ingest status. To determine which stream went offline, you need to record the status before and after the callback is triggered.

Trigger conditions

This callback is triggered in the following scenarios:

  • When a remote user starts publishing a stream (audio and/or video).

  • When a remote user stops publishing a stream (audio and/or video).

  • In interactive mode, when a remote user calls setClientRole to switch from a viewer to a streamer and starts publishing a stream.

For example, if a remote user disables video stream ingest, this callback does not trigger:

  • When the remote user starts publishing the camera stream (stream ingest status changes from no video stream to only camera stream), the callback returns AliRtcVideoTrackCamera. This indicates that the remote user's camera stream is available.

  • When the remote user also publishes the screen sharing stream (stream ingest status changes from only camera stream to camera stream and screen sharing stream), the callback returns AliRtcVideoTrackBoth. This indicates that both the remote user's camera stream and screen sharing stream are available.

  • When the remote user stops publishing the camera stream but continues to publish the screen sharing stream (stream ingest status changes from camera stream and screen sharing stream to only screen sharing stream), the callback returns AliRtcVideoTrackScreen. This indicates that only the screen sharing stream is available.

  • When the remote user also stops publishing the screen sharing stream (stream ingest status changes from only screen sharing stream to no video stream), the callback returns AliRtcVideoTrackNo. This indicates that no video stream is available.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

User ID, a unique identifier assigned by the App server.

audioTrack

AliRtcAudioTrack

The audio stream after the remote user's change.

videoTrack

AliRtcVideoTrack

The video stream after the remote user's change.

onBye

A callback that is triggered when you are removed from the server or the channel is closed.

- (void)onBye:(int)code;

This callback is triggered when a user is disconnected or the meeting ends. You can use the code parameter to determine the reason for the disconnection and take appropriate action.

Trigger conditions

  • The current user is removed from the server.

  • The meeting ends because the server closes the channel.

  • An unexpected disconnection occurs, which requires the client to attempt to restore the session or reconnect.

Parameters

Parameter

Type

Description

code

int

Message type. Values:

  • 1: Removed from the server.

  • 2: Channel closed.

  • 3: The same user ID logged in on another device and was removed from the server.

onAudioPublishStateChanged

Callback for changes in the audio stream ingest state.

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

This callback is triggered when the audio stream ingest state of the local user changes.

Triggers

This callback is triggered when the user's audio stream ingest state changes. For example:

  • Stream ingest stops.

  • The user calls <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#892915dd4edcy" id="81771ef0798we">setClientRole</a> to switch their role to viewer.

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

Previous stream ingest status.

newStat

AliRtcPublishState

Current stream ingest status.

elapseSinceLastState

NSInteger

Time interval since the last state change, in milliseconds.

channel

NSString *_Nonnull

Current channel ID.

onAudioSubscribeStateChanged

Callback for audio subscription state changes.

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

This callback notifies the local user that the subscription state of a remote user's audio stream has changed. The callback provides the new subscription state and the time elapsed since the previous state.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID whose subscription has changed.

oldState

AliRtcSubscribeState

Previous subscription status.

newState

AliRtcSubscribeState

Current subscription status.

elapseSinceLastState

NSInteger

Time interval since the last state change, in milliseconds.

channel

NSString *_Nonnull

Current channel ID.

onUserAudioMuted

Occurs when a user mutes their audio.

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID of the user who executed muteAudio.

isMute

BOOL

YES means muted, NO means not muted.

onUserAudioInterruptedBegin

This notification is triggered when a user's audio is interrupted, for example, when it is preempted by an incoming phone call.

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID whose audio was interrupted.

onUserAudioInterruptedEnded

Occurs when a user's audio interruption ends. This callback corresponds to onUserAudioInterruptedBegin.

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID whose audio interruption ended.

onVideoPublishStateChanged

Callback for changes in the video stream ingest state.

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

This callback is triggered when the ingest state of the local user's video stream changes.

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

Previous stream ingest status.

newState

AliRtcPublishState

Current stream ingest status.

elapseSinceLastState

NSInteger

Time interval since the last state change, in milliseconds.

channel

NSString *_Nonnull

Current channel ID.

onVideoSubscribeStateChanged

Callback for camera stream subscription state changes.

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

This callback notifies the local user that the subscription state of a remote user's camera stream has changed. This callback provides the new subscription state and the time elapsed since the previous state.

Related callbacks

A video stream primarily consists of a camera stream and a screen sharing stream. This interface reports changes in the subscription state of a camera stream. The corresponding callback interface for a screen sharing stream is onScreenShareSubscribeStateChanged.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID whose subscription has changed.

oldState

AliRtcSubscribeState

Previous subscription status.

newState

AliRtcSubscribeState

Current subscription status.

elapseSinceLastState

NSInteger

Time interval since the last state change, in milliseconds.

channel

NSString *_Nonnull

Current channel ID.

onUserVideoMuted

A notification that a user has muted their video.

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID of the user who executed muteVideo.

isMute

BOOL

YES means publishing black frames, NO means normal publishing.

onUserVideoEnabled

Occurs when local video capture is disabled or re-enabled.

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The user ID of the user who executed EnableLocalVideo.

isMute

BOOL

YES means enable camera stream collection, NO means disable camera stream collection.

onUserWillResignActive

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

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

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

onUserWillBecomeActive

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

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

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

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

onRtcStats

This callback is triggered every 2 seconds to report real-time statistics.

- (void)onRtcStats:(AliRtcStats)stats;

Parameters

Parameter

Type

Description

stats

AliRtcStats

Data callback.

onRtcLocalVideoStats

Reports the statistics of the local video stream every two seconds.

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

Parameters

Parameter

Type

Description

localVideoStats

AliRtcLocalVideoStats

Local video statistics.

onRtcRemoteVideoStats

Reports remote video statistics every 2 seconds.

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

Parameters

Parameter

Type

Description

remoteVideoStats

AliRtcRemoteVideoStats

Remote video statistics.

onRtcLocalAudioStats

Reports the statistics of the local audio stream. This callback is triggered every 2 seconds.

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

Parameters

Parameter

Type

Description

localAudioStats

AliRtcLocalAudioStats

Local audio statistics.

onRtcRemoteAudioStats

Reports the statistics of a remote audio stream every two seconds.

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

Parameters

Parameter

Type

Description

remoteAudioStats

AliRtcRemoteAudioStats

Remote audio statistics.

onMediaExtensionMsgReceived

Callback for receiving media extension messages.

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

When a party sends a message by calling sendMediaExtensionMsg, other parties receive the message through this callback.

Parameters

Parameter

Type

Description

uid

NSString

User ID.

payloadType

int

Payload type.

message

NSData *

Media extension message.

onAudioRouteChanged

This callback is triggered when the audio route changes. It is supported only on Android and iOS.

- (void)onAudioRouteChanged:(AliRtcAudioRouteType)routing;

Parameters

Parameter

Type

Description

routing

AliRtcAudioRouteType

Routing type.

onSnapshotComplete

The callback for snapshots.

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

Parameters

Parameter

Type

Description

image

UIImage *

Image type.

success

BOOL

Whether it was successful.

onLocalAudioStateChanged

Callback for changes in the state of the local audio capture device.

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

This callback is triggered after you call startAudioCapture or stopAudioCapture.

Parameters

Parameter

Type

Description

state

AliRtcLocalAudioStateType

Device state, of type AliRtcLocalAudioStateType.

msg

NSString *

Description of the device state change.

onLocalVideoStateChanged

This callback is triggered when the state of the local video capture device changes.

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

Parameters

Parameter

Type

Description

state

AliRtcLocalVideoStateType

Device state, of type AliRtcLocalVideoStateType.

msg

NSString *

Description of the device state change.

onRemoteUserSubscribedDataChannel

A callback that indicates you can send data channel messages.

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

This callback is triggered when a remote user subscribes to the data channel. It indicates that the remote user is ready to receive custom messages, so you can safely call sendDataChannelMessage. This callback is essential for reliable message delivery because it prevents packet loss or failures from sending messages to a user who has not subscribed to the data channel.

Note

This callback is only triggered in AI scenarios.

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

onDataChannelMessage

This callback is triggered when a data channel message is received.

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

The Alibaba Real-Time Communication (ARTC) SDK lets you send and receive custom real-time messages along with audio and video data. This callback notifies your application when a custom data channel message is received. For more information, see Send and receive custom messages.

Note
  • In interactive scenarios, streamers can send and receive messages, but viewers can only receive messages.

  • This feature is disabled by default. To enable this feature, call the setParameter method after you create the engine and set the parameter to {\"data\":{\"enablePubDataChannel\":true,\"enableSubDataChannel\":true}}.

Trigger condition

This callback is triggered on the receiver's end when a sender calls the sendDataChannelMessage method. The receiver must have the data channel feature enabled.

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

controlMsg

AliRtcDataChannelMsg

Data channel message.

onScreenSharePublishStateChanged

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

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

Parameters

Parameter

Type

Description

oldState

AliRtcPublishState

Probe result: 0 indicates success. -1 indicates failure due to a poor network connection.

newState

AliRtcPublishState

Status of the previous stream ingest.

newState

AliRtcPublishState

New stream ingest status.

elapseSinceLastState

NSInteger

Time interval since the last state change (milliseconds).

channel

NSString *

The current channel ID.

onCapturedAudioFrame

A callback for raw audio data collection.

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

This callback retrieves the raw audio data collected by the current device. This callback is disabled by default. To retrieve this audio data:

  • Enable this callback by calling enableAudioFrameObserver(true, audioSource, config). You can also use the config parameter to set the sample rate, the number of sound channels, and the read/write pattern for the audio data.

  • Call registerAudioFrameObserver to register an object for receiving audio data.

Note
  • You can use this interface to set the sample rate, the number of sound channels, and the read/write pattern.

  • To prevent abnormal sound, do not perform any time-consuming operations in this callback function.

  • You can use this interface to set the sample rate, number of channels, and read/write mode.

  • This interface supports both read and write operations.

Limits

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame

Video frame

Return value

true: Success

onProcessCapturedAudioFrame

This callback provides the audio data after it has been processed by the 3A algorithm.

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

This callback is disabled by default. To receive this audio data:

  • Enable this callback by calling enableAudioFrameObserver(true,audioSource,config). You can use the config parameter to set the sample rate, the number of sound channels, and the read/write pattern for the audio data.

  • Call registerAudioFrameObserver to register the object that receives the audio data.

Note
  • You can use this interface to set the sample rate, the number of sound channels, and the read/write pattern.

  • Do not perform time-consuming operations in this callback function because they can cause abnormal sound.

  • This interface lets you set the sample rate, the number of sound channels, and the read/write pattern.

  • This interface supports read and write operations.

Limits

To prevent audio abnormalities, do not perform any time-consuming operations in this callback function.

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame

Video frame.

Return value

true: The operation is successful.

onPublishAudioFrame

The callback for stream ingest audio data.

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

This callback retrieves audio data for stream ingest. The callback is disabled by default. To retrieve this audio data:

  • Enable this callback by calling enableAudioFrameObserver(true,audioSource,config). You can use the config parameter to set the sample rate, the number of sound channels, and the read/write mode for the audio data.

  • Call registerAudioFrameObserver to register an object to receive the audio data.

Note
  • This interface lets you set the sample rate and the number of sound channels, but it operates only in read-only mode.

  • Do not perform time-consuming operations in this callback function. This may cause audio issues.

  • You can use this API to set the sample rate and the number of sound channels.

  • This is a read/write interface.

Limits

Do not perform any time-consuming operations in this callback function. Otherwise, audio issues may occur.

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame

Video frame

Return value

true: Success.

onPlaybackAudioFrame

This callback provides the audio data for playback.

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

This callback retrieves the audio data for playback. By default, this callback is disabled. To receive this audio data:

  • Enable this callback by calling enableAudioFrameObserver(true, audioSource, config). You can also use the config parameter to set the sample rate, the number of sound channels, and the read/write mode for the audio data.

  • Call registerAudioFrameObserver to register the observer object for the audio data.

Note
  • You can use this interface to set the sample rate, the number of sound channels, and the read/write pattern.

  • Avoid performing time-consuming operations in this callback function. Doing so can cause abnormal sound.

  • This interface lets you set the sample rate, the number of sound channels, and the read/write mode.

  • This interface is read-write.

Limits

Do not perform any time-consuming operations in this callback function. This may cause abnormal audio playback.

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame

Video frame

Return value

true: The operation is successful.

onRemoteUserAudioFrame

A callback for remote audio data during stream pulling.

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

This callback is used to retrieve the remote audio data from a specified user. This callback is disabled by default. To retrieve this audio data:

  • Enable this callback by calling enableAudioFrameObserver(true, audioSource, config). You can also use the config parameter to set the sample rate, number of channels, and read/write mode for the audio data.

  • Call registerAudioFrameObserver to register the audio frame observer object.

Note
  • This callback does not support setting the sample rate or number of channels, but it lets you set the read/write mode.

  • Do not perform time-consuming operations in this callback function because this may cause audio issues.

  • The interface does not support the configuration of the sample rate or the number of channels.

  • This callback supports read/write mode.

Limits

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

Parameters

Parameter

Type

Description

frame

AliRtcAudioFrame

Video frame

Return value

true: Indicates that the callback was processed successfully.

onDestroyCompletion

A callback that is triggered after the engine is released.

- (void)onDestroyCompletion;

This callback indicates that the SDK engine instance is completely destroyed. You can create a new instance after this callback is triggered.

Note

To avoid blocking the main thread, wait for this callback to complete before you execute other methods.

Trigger condition

When you call the destroy method, this callback is triggered after the engine is completely destroyed.

onTextureCreate

A callback that is invoked when an OpenGL context is created.

- (void)onTextureCreate:(void *_Nullable)context;
Note

This callback is triggered when the internal OpenGL context of the SDK is created.

Trigger condition

This callback is triggered when the internal OpenGL context of the SDK is created. You can use this callback to initialize related resources.

Parameters

Parameter

Type

Description

context

void *

OpenGL context.

onTextureUpdate

OpenGL texture update callback.

- (int)onTextureUpdate:(int)textureId width:(int)width height:(int)height videoSample:(AliRtcVideoDataSample *_Nonnull)videoSample;
Note
  • This callback is triggered after each video data frame is uploaded to an OpenGL texture. If you have registered an external OpenGL texture data observer, you can process the texture in this callback and return the processed texture ID.

  • The return value of this callback must be a valid texture ID. If no processing is performed, you must return the textureId parameter.

Trigger condition

This callback is triggered after each video data frame is uploaded to an OpenGL texture. If you have registered an external OpenGL texture data observer, you can process the texture in this callback and return the processed texture ID.

Parameters

Parameter

Type

Description

textureId

int

OpenGL context.

width

int

Video width.

height

int

Video height.

videoSample

AliRtcVideoDataSample

Video frame data.

Return value

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

onTextureDestory

A callback that is triggered when the OpenGL context is destroyed.

- (void)onTextureDestory;
Note

This callback is specific to the destruction of the SDK's internal OpenGL context.

Triggering Condition

This callback is triggered when the SDK's internal OpenGL context is destroyed. You must use this callback to release all related resources.

onCaptureVideoSample

Callback for a captured video frame.

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

This callback retrieves the raw video frames, such as YUV data, that are captured by the local camera. You can use this callback to implement custom video processing logic, such as adding filters, watermarks, and transcoding. After processing, you can decide whether to return the processed data to the SDK for subsequent encoding and rendering.

Trigger condition

After you successfully call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#9a3437ab16j1w" id="6c93b9cf8e771">registerVideoSampleObserver</a> to register the video data observer, the SDK triggers this callback each time it captures a video frame.

Parameters

Parameter

Type

Description

videoSource

AliRtcVideoSource

Video stream type.

videoSample

AliRtcVideoDataSample

Raw video data.

Return value

YES: The processed video frame is sent to the SDK. This is valid only for I420 and CVPixelBuffer (iOS/macOS).

NO: The processed video frame is not sent to the SDK.

onPreEncodeVideoSample

A callback that provides local video data before it is encoded.

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

This callback provides the raw local video data, such as data in YUV format, before the SDK encodes a video frame. You can use this callback to implement custom processing logic, such as adding watermarks, adjusting colors, or transcoding. You can then decide whether to return the processed data to the SDK for subsequent encoding.

Parameters

Parameter

Type

Description

videoSource

AliRtcVideoSource

Video stream type.

videoSample

AliRtcVideoDataSample

Raw video data.

Return value

YES: The processed data is returned to the SDK. This option is valid only for data in the I420 or CVPixelBuffer (iOS/macOS) format.

NO: The processed data is not returned to the SDK.

onRemoteVideoSample

Callback for subscribed remote video data.

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

This callback provides the raw video frame data, such as data in YUV format, from a subscribed remote user. You can use this callback to implement custom processing logic, such as adding filters, applying watermarks, or performing transcoding. You can then decide whether to return the processed data to the SDK for subsequent rendering.

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

videoSource

AliRtcVideoSource

Video stream type.

videoSample

AliRtcVideoDataSample

Raw video data.

Return value

YES: Write the data back to the SDK. This option is valid only for I420 and CVPixelBuffer (iOS/mac) formats.

NO: Do not write the data back to the SDK.

onGetVideoFormatPreference

Specifies the preferred output format for video data.

- (AliRtcVideoFormat)onGetVideoFormatPreference;
Note

The application can return the preferred output format for video data. The default value is AliRtcYUV420.

Return value

The preferred video output format.

onGetVideoObservedFramePosition

The output position of the video data.

- (NSInteger)onGetVideoObservedFramePosition;

Return value

The desired video output position. For more information, see AliRtcVideoObserPosition.

onAudioEffectFinished

This callback is triggered when the playback of a local sound effect is complete.

- (void)onAudioEffectFinished:(int)soundId;

Parameters

Parameter

Type

Description

soundId

int

The ID of the sound effect that has finished playing.

onAudioVolumeCallback

A callback for the audio volume, voice status, and UID of subscribed users.

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

This callback provides the raw video frame data, such as data in YUV format, from subscribed remote users. You can use it to implement custom processing logic, such as adding filters, watermarks, or performing transcoding, and then decide whether to return the processed data to the SDK for rendering.

Parameters

Parameter

Type

Description

array

NSArray <AliRtcUserVolumeInfo

*> *_Nullable

An array of user volume information, including user UID, voice status, and volume.

  • When UID is 0, it represents the local speaker.

  • When UID is 1, it represents the mixed volume of all remote users.

  • Other values represent the volume information of the specified remote user's UID.

totalVolume

int

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

onActiveSpeaker

This callback reports the most active speaker in the channel.

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

After you call <a baseurl="t2309850_v9_0_0.xdita" data-node="4087266" data-root="16090" data-tag="xref" href="#85b41ef251dg0" id="a41de41e279og">enableAudioVolumeIndication</a>, the SDK continuously identifies the loudest remote user and counts how many times each user is the loudest. The user with the highest count within a specific time period is considered the most active speaker.

Trigger conditions

When a channel has two or more users and at least one remote user is active, the SDK triggers this callback to report the UID of the most active remote user.

  • If the most active remote user remains the same, the SDK does not trigger the onActiveSpeaker callback again.

  • If the most active remote user changes, the SDK triggers this callback again and reports the UID of the new active speaker.

Parameters

Parameter

Type

Description

uid

NSString *_Nonnull

The ID of the person currently speaking.

onPublishLiveStreamStateChanged

This callback is triggered when the state of the bypass live stream ingest changes.

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

Parameters

Parameter

Type

Description

streamURL

NSString *

Stream URL.

state

AliRtcLiveTranscodingState

State.

errCode

AliRtcTrascodingLiveStreamErrorCode

Error code.

onPublishTaskStateChanged

This callback is triggered when the state of a bypass task changes.

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

Parameters

Parameter

Type

Description

streamURL

NSString *

Stream URL.

state

AliRtcTrascodingLiveTaskStatus

State.

onNetworkQualityChanged

This callback is triggered when the network quality changes.

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

Parameters

Parameter

Type

Description

uid

NSString*

User ID. If empty, it indicates the local user's uplink and downlink network status.

upQuality

AliRtcNetworkQuality

Uplink network status.

downQuality

AliRtcNetworkQuality

Downlink network status.

onLastmileDetectResultWithQuality

Reports the results of the last-mile network quality test.

- (void)onLastmileDetectResultWithQuality:(AliRtcNetworkQuality)networkQuality;

Parameters

Parameter

Type

Description

networkQuality

AliRtcNetworkQuality

Network quality

onLastmileDetectResultWithBandWidth

The callback for the results of the network quality probe.

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

Parameters

Parameter

Type

Description

code

int

Probing result. 0 for success, -1 for failure, poor network condition.

result

AliRtcNetworkQualityProbeResult

Network quality

onOccurError

This callback notifies the app when an error occurs in the engine.

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

Parameters

Parameter

Type

Description

error

int

Error type. See {@link AliRtcErrorCode}.

message

NSString *

Error description.

onFirstAudioPacketSentWithTimecost

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

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

Parameters

Parameter

Type

Description

track

AliRtcAudioTrack

The track.

timeCost

int

Sending time cost.

onFirstVideoFrameReceivedWithUid

This callback is triggered when the first video frame is received from a specified remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

videoTrack

AliRtcVideoTrack

Video stream tag.

timeCost

int

Time cost (milliseconds).

onFirstVideoPacketSentWithVideoTrack

Occurs when the first video packet is sent.

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

Parameters

Parameter

Type

Description

videoTrack

AliRtcVideoTrack

Video stream tag.

timeCost

int

Time cost (milliseconds).

onFirstAudioPacketReceivedWithUid

This callback is triggered when the first audio packet from a remote user is received.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

videoTrack

AliRtcAudioTrack

Audio stream tag.

timeCost

int

Time cost (milliseconds).

onFirstRemoteAudioDecodedWithUid

Occurs when the first remote audio frame is decoded.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

track

AliRtcAudioTrack

Audio stream tag.

elapsed

int

Time cost (milliseconds).

onFirstRemoteVideoFrameDrawn

This message is triggered when the first video frame from a remote user is drawn.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

videoTrack

AliRtcVideoTrack

Audio stream tag.

width

int

Width.

height

int

Height.

elapsed

int

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

onFirstLocalVideoFrameDrawn

This message is triggered when the first local video frame is rendered.

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

Parameters

Parameter

Type

Description

width

int

Local preview video width.

height

int

Local preview video height.

elapsed

int

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

onTestAudioVolumeCallback

The callback for the audio volume during a pre-call test.

- (void)onTestAudioVolumeCallback:(int)volume;

Parameters

Parameter

Type

Description

volume

int

Volume [0..100].

onAudioAccompanyStateChanged

This callback is triggered when the playback state of local audio mixing changes.

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

Parameters

Parameter

Type

Description

playState

AliRtcAudioAccompanyStateCode

Audio mixing state.

errorCode

AliRtcAudioAccompanyErrorCode

Error code.

onRemoteAudioAccompanyStarted

This callback is triggered when the playback of a remote user's audio mixing file starts.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

onRemoteAudioAccompanyFinished

The callback for the end of audio mixing playback for a remote user.

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

Parameters

Parameter

Type

Description

uid

NSString *

User ID.

setParameter

This method sets custom parameters.

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

Parameters

Parameter

Type

Description

param

String

Custom parameters.

getParameter

Retrieves custom parameters.

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

Parameters

Parameter

Type

Description

param

String

Custom parameters.

enableAudioFrameObserver

Sets the parameters for audio callbacks.

- (int)enableAudioFrameObserver:(bool)enable audioSource: (AliRtcAudioSource)audioSource config:(AliRtcAudioFrameObserverConfig*_Nullable)config;

This method enables or disables a specified type of audio data callback, which allows developers to obtain various types of raw and encoded audio data. This feature is disabled by default, and you must call this method to enable it.

Note

When you call this method to enable the AliRtcAudioSource audio data callback, you must call the registerAudioFrameObserver method to pass the audio data receiving object.

When to call

Call this method when you need to obtain audio data.

Parameters

Parameter

Type

Description

enable

bool

Whether to allow data callbacks.

audioSource

AliRtcAudioSource

Callback data source type.

config

AliRtcAudioFrameObserverConfig

Callback parameter settings.

registerAudioFrameObserver

Registers a callback for audio data.

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

This method registers an observer object to receive audio data callbacks from the SDK.

When to call

Call this method to register an audio data observer. After you register the observer, the SDK triggers callbacks such as onCapturedAudioFrame, onProcessCapturedAudioFrame, onPublishAudioFrame, onPlaybackAudioFrame, and onRemoteUserAudioFrame to provide you with various types of audio data. To unregister the observer, call this method again and pass in nil.

Limits

You must call enableAudioFrameObserver to enable the callback for a specific AliRtcAudioSource. Otherwise, the registered observer cannot receive data.

Parameters

Parameter

Type

Description

observer

AliRtcAudioFrameDelegate

Audio data callback.

registerVideoSampleObserver

Registers a video frame observer.

- (void)registerVideoSampleObserver;

unRegisterVideoSampleObserver

Unregisters the video sample observer.

- (void)unregisterVideoSampleObserver;

setLogDirPath

Sets the storage path for SDK log files.

Important

To prevent log loss, call this interface before you call any other SDK interfaces. The specified directory must exist and be writable.

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

Parameters

Name

Type

Description

logDirPath

NSString *_Nullable

The absolute path to save the log file.

  • The default log storage path for iOS is Library/Caches/Ali_RTC_Log.

  • The default log storage path for Mac is /Users/xxx/Documents/Ali_RTC_Log.

Response Description

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

setLogLevel

Sets the log level.

- (void)setLogLevel:(AliRtcLogLevel)logLevel;

Parameters

Name

Type

Description

logLevel

AliRtcLogLevel

Log level. The default value is AliRtcLogLevelInfo.

setAudioSessionOperationRestriction

Sets the SDK's operational restrictions for AVAudioSession.

- (int)setAudioSessionOperationRestriction:(AliRtcAudioSessionOperationRestriction)restriction;

Parameters

Name

Type

Description

restriction

AliRtcAudioSessionOperationRestriction

SDK control permissions. The default value is AliRtcAudioSessionOperationRestrictionNone.

setDeviceOrientationMode

Sets the device orientation.

- (int)setDeviceOrientationMode:(AliRtcOrientationMode)mode;

Parameters

Name

Type

Description

mode

AliRtcOrientationMode

Device orientation.

Return value

Returns 0 on success. Other values indicate failure.

getNetworkTime

You can obtain the time from the timeline.

-(long long)getNetworkTime;

Return value

A timestamp.

sendDataChannelMessage

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

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

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

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

Related callbacks

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

Limits

  • Streamers can send and receive messages. Viewers can only receive messages.

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

  • The following limits apply to sending data:

    • The bitrate is capped at 30 KB/s.

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

Parameters

Name

Type

Description

controlMsg

AliRtcDataChannelMsg *

Audio mixing control message.

Return value

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

startScreenShare

Starts sharing the screen and audio stream.

- (int)startScreenShare:(NSString * _Nonnull)appGroup
mode:(AliRtcScreenShareMode)mode;

Parameters

Name

Description

appGroup

APP package name, such as @"group.com.aliyun.rtc.demo".

mode

Screen sharing type. For more information, see AliRtcScreenShareMode..

Returns

A return value of 0 indicates that the method call was successful. A non-zero value indicates that the method call failed.

startScreenShare

Starts sharing the screen video stream.

Important

This method will be deprecated. We recommend using the new startScreenShare method instead.

- (int)startScreenShare;

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the method call failed.

stopScreenShare

Stops the screen sharing stream and the associated audio stream.

- (int)stopScreenShare;

Return value

A return value of 0 indicates that the method call was successful. Any other value indicates that the method call failed.

isScreenSharePublished

Checks if screen sharing is published.

- (BOOL)isScreenSharePublished;

Response description

true: Screen sharing is published. false: Screen sharing is not published.

setScreenShareEncoderConfiguration

Sets the screen sharing encoder settings.

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

This method sets the video encoding parameters for the screen sharing stream, such as resolution, frame rate, bitrate, and video orientation. Each parameter has a valid range. If a specified parameter is outside its valid range, the SDK automatically adjusts it. You can call this method before or after you join a meeting. To set the encoding properties only once for a meeting, we recommend that you call this method before you join.

Parameters

Name

Type

Description

config

AliRtcScreenShareEncoderConfiguration

Screen sharing video encoding parameters, such as resolution, frame rate, bitrate, and video orientation. All set parameters have corresponding range limits. If a set parameter is outside the valid range.

setAudioShareAppVolume

Sets the volume of the shared audio stream.

- (int)setAudioShareAppVolume:(int)volume;

Parameters

Name

Description

volume

Volume level, range [0, 100]. Default value: 50.

Return value

0 indicates that the method call was successful. A value other than 0 indicates that the call failed.