This topic describes the AliRtcEngine interface for the iOS and Mac SDKs.
Contents
Basic APIs
| API | Description | The versions listed above are supported. |
| setH5CompatibleMode | Sets the H5 compatibility mode. | 1.1 |
| getH5CompatibleMode | Checks whether H5 compatibility mode is enabled. | 1.1 |
| sharedInstance | Creates an AliRtcEngine instance. Only one instance can exist at a time. | 1.1 |
| destroy | Releases SDK resources. | 1.1 |
Channel-related APIs
| API | Description | Supported in the specified versions |
| setAutoPublish | Sets whether to automatically publish and subscribe to streams. | 1.1 |
| joinChannel | Joins a channel. | 1.1 |
| leaveChannel | Leaves a channel. | 1.1 |
| isInCall | Checks whether the user is in a channel. | 1.1 |
| setChannelProfile | Sets the channel mode. | 1.15 |
Publishing-related APIs
| API | Description | Supported in the preceding versions |
| isAutoPublish | Checks whether automatic publishing is enabled. | 1.1 |
| configLocalCameraPublish | Sets whether to allow publishing the camera stream. | 1.1 |
| isLocalCameraPublishEnabled | Checks whether publishing the camera stream is allowed. | 1.1 |
| configLocalScreenPublish | Sets whether to allow publishing the screen stream (Mac only). | 1.1 |
| isLocalScreenPublishEnabled | Checks whether publishing the screen stream is allowed (Mac only). | 1.1 |
| configLocalAudioPublish | Sets whether to allow publishing the audio stream. | 1.1 |
| isLocalAudioPublishEnabled | Checks whether publishing the audio stream is allowed. | 1.1 |
| configLocalSimulcast | Sets whether to allow publishing the secondary video stream. | 1.1 |
| isLocalSimulcastEnabled | Checks whether publishing the secondary video stream is allowed. | 1.1 |
| publish | Manually publishes video and audio streams. | 1.1 |
Subscription-related APIs
| API | Description | Supported since version |
| isAutoSubscribe | Checks whether automatic subscription is enabled. | 1.1 |
| configRemoteCameraTrack | Sets whether to subscribe to the remote camera stream. | 1.1 |
| configRemoteScreenTrack | Sets whether to subscribe to the remote screen stream. | 1.1 |
| configRemoteAudio | Sets whether to subscribe to the remote audio stream. | 1.1 |
| subscribe | Manually subscribes to video and audio streams. | 1.1 |
| subscribeVideoRGBData | Subscribes to video RGB data. | 1.17 |
| unSubscribeVideoRGBData | Unsubscribes from video RGB data. | 1.17 |
| subscribeVideoTexture | Subscribes to video texture data. | 1.17 |
| unSubscribeVideoTexture | Unsubscribes from video texture data. | 1.17 |
Video-related APIs
| API | Description | Supported in the preceding versions |
| setVideoProfile | Sets the parameters for the video stream. | 1.1 |
| setLocalViewConfig | Sets the rendering window and drawing parameters for the local preview. | 1.1 |
| muteLocalCamera | Sets whether to stop publishing the local video stream. | 1.1 |
| setRemoteViewConfig | Sets the rendering window and drawing parameters for the remote video. | 1.1 |
| getCameraList | Gets the camera list (Mac only). | 1.1 |
| getCurrentCamera | Gets the name of the current camera (Mac only). | 1.1 |
| setCurrentCamera | Selects a camera (Mac only). | 1.1 |
| switchCamera | Switches between the front and rear cameras (iOS only). | 1.1 |
| setCameraZoom | Sets camera parameters (iOS only). | 1.1 |
| isCameraOn | Checks whether the camera is on (iOS only). | 1.1 |
| isCameraFocusPointSupported | Checks whether the camera supports manual focus (iOS only). | 1.14 |
| isCameraExposurePointSupported | Checks whether the camera supports manual exposure (iOS only). | 1.14 |
| setCameraFocusPoint | Sets the coordinates for manual focus (iOS only). | 1.14 |
| setCameraExposurePoint | Sets the coordinates for manual exposure (iOS only). | 1.14 |
| subscribeVideoPreprocessData | Subscribes to raw data from pre-processing of captured video (iOS only). | 1.14 |
| unSubscribeVideoPreprocessData | Disables pre-processing of raw data before you subscribe to data collection (iOS only). | 1.14 |
| enableHighDefinitionPreview | Sets whether to allow high-definition preview. This feature is enabled by default (iOS only). | 1.14 |
| registerVideoSampleObserver | Subscribes to video data output. | 1.16.2 |
| unregisterVideoSampleObserver | Unsubscribes from video data output. | 1.16.2 |
| setVideoSwapWidthAndHeight | Sets whether to swap the width and height for the video track. | 1.16.2 |
| muteAllRemoteVideoRendering | Mutes or unmutes the rendering of all remote video tracks. | 1.16.2 |
| getCurrentCameraID | Gets the ID of the current camera (Mac only). | 1.16.2 |
| setCurrentCameraWithID | Selects a camera by its device ID (Mac only). | 1.16.2 |
| setExternalVideoSource | Enables an external video input source. | 1.17.9 |
| pushExternalVideoFrame | Inputs external video. |
|
| setBeautyEffect | Sets basic retouching effects. | 1.17.9 |
| getCurrentCameraDirection | Gets the current camera direction (iOS only). | 1.17.20 |
| setVideoEncoderConfiguration | Sets the video encoding properties. | 1.17.31 |
| enableLocalVideo | Disables or re-enables local video capture. | 1.17.39 |
Audio-related APIs
| API | Description | Supported in the above versions |
| setAudioOnlyMode | Sets the mode to audio-only or audio and video. | 1.1 |
| isAudioOnly | Checks whether the current mode is audio-only. | 1.1 |
| muteLocalMic | Sets whether to stop publishing the local audio. | 1.1 |
| muteRemoteAudioPlaying | Sets whether to stop playing the remote audio stream. | 1.1 |
| enableSpeakerphone | Switches between the earpiece and speaker for audio output (iOS only). | 1.1 |
| getAudioCaptures | Gets the list of audio recording devices in the system (Mac only). | 1.1 |
| getCurrentAudioCapture | Gets the name of the current audio capture device (Mac only). | 1.1 |
| setCurrentAudioCapture | Selects an audio capture device (Mac only). | 1.1 |
| getAudioRenderers | Gets the list of speakers in the system (Mac only). | 1.1 |
| getCurrentAudioRenderer | Gets the current audio playback device (Mac only). | 1.1 |
| setCurrentAudioRenderer | Selects an audio playback device (Mac only). | 1.1 |
| startAudioCapture | Starts audio capture. | 1.11 |
| stopAudioCapture | Stops audio capture. | 1.11 |
| startAudioPlayer | Starts audio playback. | 1.11 |
| stopAudioPlayer | Stops audio playback. | 1.11 |
| startAudioAccompanyWithFile | Starts playing an accompaniment (iOS only). | 1.15 |
| stopAudioAccompany | Stops the accompaniment (iOS only). | 1.15 |
| setAudioAccompanyVolume | Sets the accompaniment volume (iOS only). | 1.15 |
| setAudioAccompanyPublishVolume | Sets the volume of the published stream after audio mixing (iOS only). | 1.15 |
| getAudioAccompanyPublishVolume | Gets the publishing volume of the accompaniment (iOS only). | 1.15 |
| setAudioAccompanyPlayoutVolume | Sets the local volume of the accompaniment (iOS only). | 1.15 |
| getAudioAccompanyPlayoutVolume | Gets the local volume of the accompaniment (iOS only). | 1.15 |
| pauseAudioAccompany | Pauses playing the accompaniment (iOS only). | 1.15 |
| resumeAudioAccompany | Resumes playing the accompaniment (iOS only). | 1.15 |
| preloadAudioEffectWithSoundId | Preloads a sound effect (iOS only). | 1.15 |
| unloadAudioEffectWithSoundId | Purges a preloaded sound effect (iOS only). | 1.15 |
| playAudioEffectWithSoundId | Starts playing a sound effect (iOS only). | 1.15 |
| stopAudioEffectWithSoundId | Stops playing a sound effect (iOS only). | 1.15 |
| setAudioEffectPublishVolumeWithSoundId | Sets the publishing volume of a sound effect (iOS only). | 1.15 |
| getAudioEffectPublishVolumeWithSoundId | Gets the publishing volume of a sound effect (iOS only). | 1.15 |
| setAudioEffectPlayoutVolumeWithSoundId | Sets the local volume of a sound effect (iOS only). | 1.15 |
| getAudioEffectPlayoutVolumeWithSoundId | Gets the local volume of a sound effect (iOS only). | 1.15 |
| pauseAudioEffectWithSoundId | Pauses playing a sound effect (iOS only). | 1.15 |
| resumeAudioEffectWithSoundId | Resumes playing a sound effect (iOS only). | 1.15 |
| enableEarBack | Enables in-ear monitoring (iOS only). | 1.15 |
| setEarBackVolume | Sets the in-ear monitoring volume (iOS only). | 1.15 |
| setSubscribeAudioNumChannel | Sets the number of sound channels for the audio callback. | 1.15 |
| setSubscribeAudioSampleRate | Sets the audio sampling rate for the callback. | 1.15 |
| setAudioSessionOperationRestriction | Sets the SDK's control permission for AVAudioSession (iOS only). | 1.15 |
| setRecordingVolume | Sets the recording volume (iOS only). | 1.16 |
| setPlayoutVolume | Sets the playback volume (iOS only). | 1.16 |
| subscribeAudioData | Subscribes to audio data. | 1.16 |
| unSubscribeAudioData | Unsubscribes from audio data. | 1.16 |
| muteAllRemoteAudioPlaying | Stops playing all remote audio streams. | 1.16.2 |
| setExteranlAudioRender | Sets whether to enable external audio playback. | 1.16.2 |
| pushExternalAudioRenderRawData | Inputs audio playback data. | 1.16.2 |
| isEnableSpeakerphone | Gets whether the current audio output is the earpiece or speaker (iOS only). | 1.16.2 |
| getCurrentAudioCaptureID | Gets the ID of the recording device in use (Mac only). | 1.16.2 |
| setCurrentAudioCaptureWithID | Selects a recording device by its device ID (Mac only). | 1.16.2 |
| getCurrentAudioRendererID | Gets the ID of the current speaker (Mac only). | 1.16.2 |
| setCurrentAudioRendererWithID | Selects a speaker by its device ID (Mac only). | 1.16.2 |
| startTestAudioRecordWithName | Starts testing an audio capture device (Mac only). | 1.16.2 |
| stopTestAudioRecord | Stops testing an audio capture device (Mac only). | 1.16.2 |
| startTestAudioPlayoutWithName | Starts testing an audio playback device (Mac only). | 1.16.2 |
| stopTestAudioPlayout | Stops testing an audio playback device (Mac only). | 1.16.2 |
| setExternalAudioSource | Sets whether to use external audio data as the input source for stream publishing. |
|
| pushExternalAudioFrameRawData | Inputs audio data. |
|
| setExternalAudioVolume | Sets the external audio input volume. |
|
| getExternalAudioVolume | Gets the external audio input volume. |
|
| setMixedWithMic | Sets whether to mix external audio input with audio captured by the microphone. |
|
| setExternalAudioRenderVolume | Sets the external audio playback volume (Mac only). | 1.16.2 |
| getExternalAudioRenderVolume | Gets the audio playback volume (Mac only). | 1.16.2 |
| setVolumeCallbackIntervalMs | Sets the volume callback interval and smoothing coefficient. | 1.17 |
| setAudioEffectReverbMode | Sets the reverb effect mode. | 1.17 |
| setAudioEffectReverbParamType | Sets the reverb effect type. | 1.17 |
| setDeviceVolumeType | Sets the SDK device volume type (iOS only). | 1.17.39 |
Sound effect APIs
| API | Description | Supported in the specified versions |
| getAudioAccompanyDuration | Gets the duration of the accompaniment file. | 1.17.30 |
| getAudioAccompanyCurrentPosition | Gets the playback progress of the music file. | 1.17.30 |
| setAudioAccompanyPosition | Sets the playback position of the audio file. | 1.17.30 |
| stopAllAudioEffects | Stops playing all sound effects. | 1.17.30 |
| setAllAudioEffectsPublishVolume | Sets the publishing volume for all sound effects. | 1.17.30 |
| setAllAudioEffectsPlayoutVolume | Sets the local playback volume for all sound effects. | 1.17.30 |
| pauseAllAudioEffects | Pauses all sound effects. | 1.17.30 |
| resumeAllAudioEffects | Resumes playing all sound effects. | 1.17.30 |
Preview APIs
| API | Description | Supported since version |
| startPreview | Starts the local preview. | 1.1 |
| stopPreview | Stops the local preview. | 1.1 |
Remote user query APIs
| API | Description | Supported since version |
| getOnlineRemoteUsers | Gets the list of online remote users. | 1.1 |
| getUserInfo | Queries remote user information. | 1.1 |
| isUserOnline | Queries whether a user is online. | 1.1 |
Other APIs
| API | Description | Supported in the above versions |
| setLogLevel | Sets the log level. | 1.1 |
| getSdkVersion | Gets the SDK version number. | 1.1 |
| uploadLog | Uploads logs. | 1.15 |
| startIntelligentDenoise | Enables intelligent noise reduction (Mac only). | 1.15 |
| stopIntelligentDenoise | Disables intelligent noise reduction (Mac only). | 1.15 |
| setClientRole | Sets the user role. | 1.16 |
| setLogDirPath | Sets the path to save SDK log files. | 1.16.2 |
| setDeviceOrientationMode | Sets the device orientation. | 1.16.2 |
| startLastmileDetect | Starts a network quality probe test. | 1.16.2 |
| stopLastmileDetect | Stops the network quality probe test. | 1.16.2 |
| startRecord | Starts recording. | 1.17.1 |
| stopRecord | Stops recording. | 1.17 |
| getCurrentClientRole | Gets the current user role (iOS only). | 1.17.9 |
| postFeedbackWithUid | Feedback on SDK issues |
|
| sendMediaExtensionMsg | Sends media extension messages. | 1.17.1 |
| getClientRole | Gets the current user role (Mac only). | 1.17.19 |
| refreshAuthInfo | Refreshes the token. | 1.17.41 |
API details
setH5CompatibleMode: Sets the H5 compatibility mode.
Parameters+ (void)setH5CompatibleMode:(BOOL)comp;Name Type Description comp BOOL Specifies whether to enable H5 compatibility mode. YES: Enables H5 compatibility mode. NO: Disables H5 compatibility mode. The default value is NO. Important You can call this method only before you create an AliRtcEngine instance.getH5CompatibleMode: Checks whether H5 compatibility mode is enabled.
+ (BOOL)getH5CompatibleMode;Return value
YES if H5 compatibility mode is enabled. NO if H5 compatibility mode is disabled.
Important You can call this method only before you create an AliRtcEngine instance.sharedInstance: Creates an AliRtcEngine instance.
Parameters+ (instancetype)sharedInstance:(id<AliRtcEngineDelegate>)delegate extras:(NSString *)extras;Name Type Description delegate AliRtcEngineDelegate delegate The delegate that listens for callbacks. extras NSString * The special features of the SDK that are configured in the JSON format. For more information, see extras features. If you do not need to configure special features, enter an empty string: @"". Important Only one instance can exist at a time.destroy: Destroys the SDK instance.
+ (void)destroy;Important Call this method after you complete all operations.setAutoPublish: Sets whether to automatically publish and subscribe to streams.
Parameters- (int)setAutoPublish:(BOOL)autoPub withAutoSubscribe:(BOOL)autoSub;Name Type Description autoPub BOOL YES: Enables automatic publishing. NO: Enables manual publishing. The default value is YES. autoSub BOOL YES: Enables automatic subscription. NO: Enables manual subscription. The default value is YES. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must set this parameter before you join a channel.joinChannel: Joins a channel.
Parameters- (void)joinChannel:(AliRtcAuthInfo *)authInfo name:(NSString *)userName onResult:(void(^)(NSInteger errCode))onResult;Name Type Description authInfo AliRtcAuthInfo * The authentication information. userName NSString * The display name of the user. This is not the user ID. onResult void(^)(NSInteger errCode) The callback that is invoked after the joinChannel operation is complete. Important After you join a channel, you must call leaveChannel to leave the current channel before you can join another one. If you fail to join a channel and want to retry, you do not need to call leaveChannel.leaveChannel: Leaves a channel.
- (void)leaveChannel;In versions 1.15 and later, you can destroy the engine only by calling the destroy method.
In versions earlier than 1.15, the AliRtcEngine instance is destroyed when you leave a channel. Consequently, you must create a new instance by calling getInstance before performing any subsequent operations, such as joining a channel.
isInCall: Checks whether the user is in a channel.
- (BOOL)isInCall;Return value
YES if the user is in the channel. NO if the user is not in the channel.
setChannelProfile: Sets the channel mode.
Parameters- (int)setChannelProfile:(AliRtcChannelProfile)profile;Name Type Description profile AliRtcChannelProfile The channel mode. The default is AliRtcCommunication mode. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You can call this method only before you join a channel. You cannot reset the channel mode during a session. You can reset it after you leave the channel.isAutoPublish: Checks whether automatic publishing is enabled.
- (BOOL)isAutoPublish;Return value
YES if automatic publishing is enabled. NO if manual publishing is enabled.
configLocalCameraPublish: Sets whether to allow publishing the camera stream.
Parameters- (void)configLocalCameraPublish:(BOOL)enable;Name Type Description enable BOOL YES: Allows publishing the camera stream. NO: Disallows publishing. The default value is YES. Important For manual publishing, you must call publish for the setting to take effect.isLocalCameraPublishEnabled: Checks whether publishing the camera stream is allowed.
- (BOOL)isLocalCameraPublishEnabled;Return value
YES if publishing the camera stream is allowed. NO if publishing the camera stream is not allowed.
configLocalScreenPublish (Mac only): Sets whether to allow publishing the screen stream.
Parameters- (void)configLocalScreenPublish:(BOOL)enable;Name Type Description enable BOOL YES: Allows publishing the screen stream. NO: Disallows publishing. The default value is NO. Important For manual publishing, you must call publish for the setting to take effect.isLocalScreenPublishEnabled (Mac only): Checks whether publishing the screen stream is allowed.
- (BOOL)isLocalScreenPublishEnabled;Return value
YES if publishing the screen stream is allowed. NO if publishing the screen stream is not allowed.
configLocalAudioPublish: Sets whether to allow publishing the audio stream.
Parameters- (void)configLocalAudioPublish:(BOOL)enable;Name Type Description enable BOOL YES: Allows publishing the audio stream. NO: Disallows publishing. The default value is YES. Important For manual publishing, you must call publish for the setting to take effect.isLocalAudioPublishEnabled: Checks whether publishing the audio stream is allowed.
- (BOOL)isLocalAudioPublishEnabled;Return value
YES if publishing the audio stream is allowed. NO if publishing the audio stream is not allowed.
configLocalSimulcast: Sets whether to allow publishing the secondary video stream.
Parameters- (int)configLocalSimulcast:(BOOL)enabled forTrack:(AliRtcVideoTrack)track;Name Type Description enabled BOOL YES: Allows publishing the secondary video stream. NO: Disallows publishing. The default value is YES. track AliRtcVideoTrack The stream type. Currently, only AliVideoTrackCamera (camera stream) is supported. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important For manual publishing, you must call publish for the setting to take effect.isLocalSimulcastEnabled: Checks whether publishing the secondary video stream is allowed.
- (BOOL)isLocalSimulcastEnabled;Return value
YES if publishing the secondary video stream is allowed. NO if publishing the secondary video stream is not allowed.
publish: Manually publishes video and audio streams.
- (void)publish:(void (^)(int errCode))onResult;- The behavior of this method depends on the settings of methods such as configLocalCameraPublish, configLocalAudioPublish, and configLocalSimulcast.
- You can configure the parameters of these three methods to publish the corresponding video and audio streams.
- To stop publishing, set the parameters of all three configuration methods to NO, and then call publish.
Name Type Description onResult void (^)(int errCode) The callback that is invoked after the publish operation is complete. isAutoSubscribe: Checks whether automatic subscription is enabled.
- (BOOL)isAutoSubscribe;Return value
YES if automatic subscription is enabled. NO if manual subscription is enabled.
configRemoteCameraTrack: Sets whether to subscribe to the remote camera stream.
Parameters- (void)configRemoteCameraTrack:(NSString *)uid preferMaster:(BOOL)master enable:(BOOL)enable;Name Type Description uid NSString * The user ID. master BOOL YES: Subscribes to the high-quality stream. NO: Subscribes to the low-quality stream. The default value is YES. enable BOOL YES: Subscribes to the remote camera stream. NO: Stops subscribing to the remote camera stream. The default value is NO. Important When you need to operate on a stream, such as manually subscribing or unsubscribing, you must call subscribe for the setting to take effect.configRemoteScreenTrack: Specifies whether to subscribe to the remote screen stream.
Parameters- (void)configRemoteScreenTrack:(NSString *)uid enable:(BOOL)enable;Name Type Description uid NSString * The user ID. enable BOOL YES: Subscribes to the remote screen stream. NO: Stops subscribing to the remote screen stream. The default value is NO. Important To perform an operation on a stream, such as subscribing or unsubscribing, you must call subscribe for the changes to take effect.configRemoteAudio: Sets whether to subscribe to the remote audio stream.
Parameters- (void)configRemoteAudio:(NSString *)uid enable:(BOOL)enable;Name Type Description uid NSString * The user ID. enable BOOL YES: Subscribes to the remote audio stream. NO: Stops subscribing to the remote audio stream. The default value is YES. Important When you need to operate on a stream, such as manually subscribing or unsubscribing, you must call subscribe for the setting to take effect.subscribe: Manually subscribes to video and audio streams.
- (void)subscribe:(NSString *)uid onResult:(void (^)(NSString *uid, AliRtcVideoTrack vt, AliRtcAudioTrack at))onResult;- The behavior of this method depends on the settings of methods such as configRemoteCameraTrack, configRemoteScreenTrack, and configRemoteAudio.
- You can configure the parameters of these three methods to subscribe to the corresponding video and audio streams.
- You can call subscribe to both start and stop a subscription.
- To stop a subscription, set the parameters of all three configuration methods to false, and then call subscribe.
Name Type Description uid NSString * The user ID. onResult void (^)(NSString *uid, AliRtcVideoTrack vt, AliRtcAudioTrack at) The callback that is invoked after the subscribe operation is complete. subscribeVideoRGBData: Subscribes to video RGB data.
Parameters- (void)subscribeVideoRGBData:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource;Name Type Description uid NSString * The UID of the user. videoSource AliRtcVideoSource The type of raw video data source. unSubscribeVideoRGBData: Unsubscribes from video RGB data.
Parameters- (void)unSubscribeVideoRGBData:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource;Name Type Description uid NSString * The UID of the user. videoSource AliRtcVideoSource The type of raw video data source. subscribeVideoTexture: Subscribes to video texture data.
Parameters- (void)subscribeVideoTexture:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoTextureType:(AliRtcVideoTextureType)videoTextureType;Name Type Description uid NSString * The UID of the user. videoSource AliRtcVideoSource The type of raw video data source. videoTextureType AliRtcVideoTextureType The texture type. unSubscribeVideoTexture: Unsubscribes from video texture data.
Parameters- (void)unSubscribeVideoTexture:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoTextureType:(AliRtcVideoTextureType)videoTextureType;Name Type Description uid NSString * The UID of the user. videoSource AliRtcVideoSource The type of raw video data source. videoTextureType AliRtcVideoTextureType The texture type. setVideoProfile: Sets the parameters for the video stream.
Parameters- (void)setVideoProfile:(AliRtcVideoProfile)profile forTrack:(AliRtcVideoTrack)track;Name Type Description profile AliRtcVideoProfile The video stream parameters. The default is a camera stream with a resolution of 480 × 640 and a frame rate of 15 fps. track AliRtcVideoTrack The video track type to set. The default is the camera stream. setLocalViewConfig: Sets the rendering window and drawing parameters for the local preview.
- (int)setLocalViewConfig:(AliVideoCanvas *)viewConfig forTrack:(AliRtcVideoTrack)track;- You can switch windows before and after you call joinChannel. If viewConfig or its member rendering view is NULL, rendering stops.
- To reset the rendering mode during playback, keep the other member variables in viewConfig unchanged and modify only the renderMode.
- The default rendering mode in viewConfig is AliRtcRenderModeAuto.
Name Type Description viewConfig AliVideoCanvas * The rendering parameters, including the rendering window and rendering mode. track AliRtcVideoTrack Preview only allows AliVideoTrackCamera (camera stream). Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
muteLocalCamera: Mutes or unmutes the local video stream.
Parameters- (int)muteLocalCamera:(BOOL)mute forTrack:(AliRtcVideoTrack)track;Name Type Description mute BOOL YES: Stops publishing the video stream. NO: Resumes publishing. The default value is NO. track AliRtcVideoTrack The video track type whose publishing state needs to be changed. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important This method does not change the capture state of the current video stream.setRemoteViewConfig: Sets the rendering window and drawing parameters for the remote video.
Parameters- (int)setRemoteViewConfig:(AliVideoCanvas *)canvas uid:(NSString *)uid forTrack:(AliRtcVideoTrack)track;Name Type Description canvas AliVideoCanvas * The rendering parameters, including the rendering window and rendering mode. uid NSString * The user ID. track AliRtcVideoTrack The video track type to set. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
getCameraList (Mac only): Retrieves the camera list.
- (NSArray<AliRtcDeviceInfo *> *)getCameraList;getCurrentCamera (Mac only): Retrieves the name of the current camera.
- (NSString *)getCurrentCamera;setCurrentCamera (Mac only): Selects a camera.
Parameters- (void)setCurrentCamera:(NSString *)camera;Name Type Description camera NSString * The camera name. Important You must call the getCameraList method to obtain the device list before you call this method.switchCamera (iOS only): Switches between the front and rear cameras.
- (int)switchCamera;Return value
0 indicates that the switch was successful. Other values indicate that the switch failed.
setCameraZoom (iOS only): Sets the camera zoom factor.
Parameters- (int)setCameraZoom:(float)zoom flash:(BOOL)flash autoFocus:(BOOL)autoFocus;Name Type Description zoom float The zoom level. The value ranges from -3.0 to 3.0. The default value is 1.0. flash BOOL Specifies whether to turn on the flash. YES: Turns on the flash. NO: Does not turn on the flash. The default value is NO. autoFocus BOOL Specifies whether to enable autofocus. YES: Enables autofocus. NO: Disables autofocus. The default value is NO. Return value
0 indicates that the operation was successful. Other values indicate that the operation failed.
isCameraOn (iOS only): Checks whether the camera is on.
- (BOOL)isCameraOn;Return value
YES if the camera is on. NO if the camera is off.
isCameraFocusPointSupported (iOS only): Checks whether the camera supports manual focus.
- (BOOL)isCameraFocusPointSupported;Return value
YES if manual focus is supported. NO if manual focus is not supported.
isCameraExposurePointSupported (iOS only): Checks whether the camera supports manual exposure.
- (BOOL)isCameraExposurePointSupported;Return value
YES if manual exposure is supported. NO if manual exposure is not supported.
setCameraFocusPoint (iOS only): Sets the coordinates for manual focus.
Parameters- (int)setCameraFocusPoint:(CGPoint)point;Name Type Description point CGPoint The focus point coordinates. Return value
0 indicates that the operation was successful. Other values indicate that the operation failed.
setCameraExposurePoint (iOS only): Sets the coordinates for manual exposure.
Parameters- (int)setCameraExposurePoint:(CGPoint)point;Name Type Description point CGPoint The exposure point coordinates. Return value
0 indicates that the operation was successful. Other values indicate that the operation failed.
subscribeVideoPreprocessData (iOS only): Subscribes to the raw data from the pre-processing of captured video.
Parameters- (void)subscribeVideoPreprocessData:(AliRtcVideoSource)videoSource;Name Type Description videoSource AliRtcVideoSource The video stream type. unSubscribeVideoPreprocessData (iOS only): Unsubscribes from the raw data from the pre-processing of captured video.
Parameters- (void)unSubscribeVideoPreprocessData:(AliRtcVideoSource)videoSource;Name Type Description videoSource AliRtcVideoSource The video stream type. enableHighDefinitionPreview (iOS only): Enables or disables high-definition preview.
Parameters- (BOOL)enableHighDefinitionPreview:(BOOL)enable;Name Type Description enable BOOL YES: Allows high-definition preview. NO: Disallows high-definition preview. The default value is YES. Return value
YES if the operation was successful. NO if the operation failed.
Important You must call this method before you start the preview and publish the stream.setVideoSwapWidthAndHeight: Sets whether to swap the width and height for the video track.
Parameters- (void)setVideoSwapWidthAndHeight:(BOOL)swapWidthAndHeight forTrack:(AliRtcVideoTrack)track;Name Type Description swapWidthAndHeight BOOL YES: Swaps the width and height. NO: Does not swap. The default value is NO. track AliRtcVideoTrack The video track type to set. muteAllRemoteVideoRendering: Mutes or unmutes the rendering of all remote video tracks.
Parameters- (int)muteAllRemoteVideoRendering:(BOOL)mute;Name Type Description mute BOOL YES: Stops rendering. NO: Resumes rendering. The default value is NO. Return value
0 indicates success. Other values are error codes.
getCurrentCameraID (Mac only): Retrieves the ID of the current camera.
- (NSString *)getCurrentCameraID;setCurrentCameraWithID (Mac only): Selects a camera by its device ID.
Parameters- (void)setCurrentCameraWithID:(NSString *)cameraID;Name Type Description cameraID NSString * The camera ID. setExternalVideoSource: Enables an external video input source.
Parameters- (int)setExternalVideoSource:(BOOL)enable useTexture:(BOOL)useTexture sourceType:(AliRtcVideoSource)type renderMode:(AliRtcRenderMode)renderModeName Type Description enable BOOL YES: Enables external video data as the input source for stream publishing. NO: Stops using it. useTexture BOOL Specifies whether to use texture mode. This is not currently supported. type AliRtcVideoSource The video stream type. renderMode AliRtcRenderMode The rendering mode. If the aspect ratio of the input video is different from the publishing profile, the video is processed according to the specified renderMode. Return value
A value greater than or equal to 0 indicates success. A value less than 0 indicates failure.
pushExternalVideoFrame: Pushes an external video frame to the SDK.
Parameters- (int)pushExternalVideoFrame:(AliRtcVideoDataSample *)frame sourceType:(AliRtcVideoSource)type;Name Type Description frame AliRtcVideoDataSample * The frame data. type AliRtcVideoSource The video stream type. Return value
A value greater than or equal to 0 indicates success. A value less than 0 indicates failure.
setBeautyEffect: Sets basic retouching effects.
- iOS code and parameters are as follows:
Parameters- (int)setBeautyEffect:(BOOL)enable config:(AliRtcBeautyConfig)config;Name Type Description enable BOOL YES: Enables basic retouching. NO: Disables basic retouching. The default value is NO. config AliRtcBeautyConfig The retouching parameter settings. - Mac code and parameters are as follows:
Parameters- (int)setBeatutyEffect:(bool)enable config:(AliRtcBeautyConfig)config;Name Type Description enable bool true: Enables basic retouching. false: Disables basic retouching. The default value is false. config AliRtcBeautyConfig The retouching parameter settings.
Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
- iOS code and parameters are as follows:
- getCurrentCameraDirection (iOS only): Retrieves the current camera direction.
- (AliRtcCameraDirection)getCurrentCameraDirection;The default is the front camera.
- setVideoEncoderConfiguration: Sets the video encoding configuration.
Parameters- (void)setVideoEncoderConfiguration:(AliRtcVideoEncoderConfiguration* _Nonnull )config;Name Type Description config AliRtcVideoEncoderConfiguration The predefined video encoding properties. - enableLocalVideo: Disables or re-enables local video capture.
Parameters- (int)enableLocalVideo:(BOOL)enable;Name Type Description enable BOOL Specifies whether to disable or re-enable local video capture. Valid values: - YES (default): Enables local video capture.
- NO: Disables local video capture.
Return value
0 indicates that the operation was successful. Other values indicate that the operation failed.
registerVideoSampleObserver: Subscribes to video data output.
- (void)registerVideoSampleObserver;unregisterVideoSampleObserver: Unsubscribes from video data output.
- (void)unregisterVideoSampleObserver;setAudioOnlyMode: Sets the mode to audio-only or audio and video. The default is audio and video mode.
Parameters- (int)setAudioOnlyMode:(BOOL)audioOnly;Name Type Description audioOnly BOOL YES: Only audio is published and subscribed. NO: Both audio and video are supported. The default is audio and video mode. Return value
0 indicates that the operation was successful. Other values indicate that the operation failed.
Important You must call this method before you call joinChannel.isAudioOnly: Checks whether the current mode is audio-only.
- (BOOL)isAudioOnly;Return value
YES if the mode is audio-only. NO if the mode is audio and video.
muteLocalMic: Mutes or unmutes the local microphone.
Parameters- (int)muteLocalMic:(BOOL)mute;Name Type Description mute BOOL YES: Stops publishing the local audio. NO: Resumes publishing. The default value is NO. Return value
0 indicates that the operation was successful. -1 indicates that the operation failed.
Important This method does not change the state of local audio capture.muteRemoteAudioPlaying: Mutes or unmutes a remote audio stream.
Parameters- (int)muteRemoteAudioPlaying:(NSString *)uid mute:(BOOL)mute;Name Type Description uid NSString * The user ID. mute BOOL YES: Stops playback. NO: Resumes playback. The default value is NO. Return value
0 indicates that the operation was successful. -1 indicates that the operation failed.
enableSpeakerphone (iOS only): Switches the audio output between the earpiece and the speaker.
Parameters- (int)enableSpeakerphone:(BOOL)enable;Name Type Description enable BOOL YES: Speaker mode. NO (default): Earpiece mode. Return value
0 indicates that the operation was successful. Other values are error codes.
getAudioCaptures (Mac only): Retrieves the list of audio recording devices in the system.
- (NSArray<AliRtcDeviceInfo *> *)getAudioCaptures;getCurrentAudioCapture (Mac only): Retrieves the name of the current audio capture device.
- (NSString *)getCurrentAudioCapture;setCurrentAudioCapture (Mac only): Selects an audio capture device.
Parameters- (void)setCurrentAudioCapture:(NSString *)capture;Name Type Description capture NSString * The name of the audio capture device. Important You must call the getCurrentAudioCapture interface to obtain the device list before using this interface to apply settings.getAudioRenderers (Mac only): Retrieves the list of audio playback devices in the system.
- (NSArray<AliRtcDeviceInfo *> *)getAudioRenderers;getCurrentAudioRenderer (Mac only): Retrieves the current audio playback device.
- (NSString *)getCurrentAudioRenderer;setCurrentAudioRenderer (Mac only): Selects an audio playback device.
Parameters- (void)setCurrentAudioRenderer:(NSString *)renderer;Name Type Description renderer NSString * The name of the audio playback device. Important You must call the getAudioRenderers method to obtain the device list before you call this method.startAudioCapture: Starts audio capture.
- (void)startAudioCapture;Important You can start audio capture in advance. If you do not, the SDK starts audio capture when stream publishing begins.stopAudioCapture: Stops audio capture.
- (void)stopAudioCapture;startAudioPlayer: Starts audio playback.
- (void)startAudioPlayer;Important You can start audio playback in advance. If you do not, the SDK starts audio playback after a successful subscription.stopAudioPlayer: Stops audio playback.
- (void)stopAudioPlayer;Important Call this method before you join a channel.startAudioAccompanyWithFile (iOS only): Starts playing an audio file as an accompaniment.
Parameters- (int)startAudioAccompanyWithFile:(NSString *)filePath onlyLocalPlay:(BOOL)onlyLocalPlay replaceMic:(BOOL)replaceMic loopCycles:(NSInteger)loopCycles;Name Type Description filePath NSString * The file path. onlyLocalPlay BOOL Specifies whether to play only locally. Valid values: YES and NO. replaceMic BOOL Specifies whether to replace the microphone. Valid values: YES and NO. loopCycles NSInteger The number of loops. You can set this to -1 or a positive integer. Return value
0 indicates that the operation was successful. Other values are error codes.
Important This method supports playback of local and network resources.stopAudioAccompany (iOS only): Stops the accompaniment.
- (int)stopAudioAccompany;Return value
0 indicates that the operation was successful. Other values are error codes.
setAudioAccompanyVolume: Sets the accompaniment volume.
Parameters- (int)setAudioAccompanyVolume:(NSInteger)volume;Name Type Description volume NSInteger The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates that the operation was successful. Other values are error codes.
Important The volume setting takes effect only after you call startAudioAccompanyWithFile.setAudioAccompanyPublishVolume (iOS only): Sets the volume of the published stream after audio mixing.
Parameters- (int)setAudioAccompanyPublishVolume:(NSInteger)volume;Name Type Description volume NSInteger The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates that the operation was successful. Other values are error codes.
Important The volume setting takes effect only after you call startAudioAccompanyWithFile.getAudioAccompanyPublishVolume (iOS only): Retrieves the publishing volume of the accompaniment.
- (int)getAudioAccompanyPublishVolume;Return value
0 indicates that the operation was successful. Other values are error codes.
setAudioAccompanyPlayoutVolume (iOS only): Sets the local volume of the accompaniment.
Parameters- (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;Name Type Description volume NSInteger The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates that the operation was successful. Other values are error codes.
Important The volume setting takes effect only after you call startAudioAccompanyWithFile.getAudioAccompanyPlayoutVolume (iOS only): Retrieves the local volume of the accompaniment.
- (int)getAudioAccompanyPlayoutVolume;Return value
0 indicates that the operation was successful. Other values are error codes.
pauseAudioAccompany (iOS only): Pauses the accompaniment.
- (int)pauseAudioAccompany;Return value
0 indicates that the operation was successful. Other values are error codes.
resumeAudioAccompany (iOS only): Resumes the accompaniment.
- (int)resumeAudioAccompany;Return value
0 indicates that the operation was successful. Other values are error codes.
preloadAudioEffectWithSoundId (iOS only): Preloads a sound effect.
Parameters- (int)preloadAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. filePath NSString * The path of the sound effect file. Return value
0 indicates that the operation was successful. Other values are error codes.
unloadAudioEffectWithSoundId (iOS only): Unloads a preloaded sound effect.
Parameters- (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
0 indicates that the operation was successful. Other values are error codes.
playAudioEffectWithSoundId (iOS only): Starts playing a sound effect.
Parameters- (int)playAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath cycles:(NSInteger)cycles publish:(BOOL)publish;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. filePath NSString * The path of the sound effect file. cycles NSInteger The number of loops. You can set this to -1 or a positive integer. publish BOOL Specifies whether to publish the sound effect. Valid values: YES and NO. Return value
0 indicates that the operation was successful. Other values are error codes.
stopAudioEffectWithSoundId (iOS only): Stops playing a sound effect.
Parameters- (int)stopAudioEffectWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
0 indicates that the operation was successful. Other values are error codes.
setAudioEffectPublishVolumeWithSoundId (iOS only): Sets the publishing volume of a sound effect.
Parameters- (int)setAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. volume NSInteger The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates that the operation was successful. Other values are error codes.
getAudioEffectPublishVolumeWithSoundId (iOS only): Retrieves the publishing volume of a sound effect.
Parameters- (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
A value from 0 to 100 indicates success. Otherwise, the method returns an error code.
setAudioEffectPlayoutVolumeWithSoundId (iOS only): Sets the local volume of a sound effect.
Parameters- (int)setAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. volume NSInteger The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates that the operation was successful. Other values are error codes.
getAudioEffectPlayoutVolumeWithSoundId (iOS only): Retrieves the local volume of a sound effect.
Parameters- (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
0 indicates that the operation was successful. Other values are error codes.
pauseAudioEffectWithSoundId (iOS only): Pauses a sound effect.
Parameters- (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
0 indicates that the operation was successful. Other values are error codes.
resumeAudioEffectWithSoundId (iOS only): Resumes a sound effect.
Parameters- (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;Name Type Description soundId NSInteger The ID assigned to the sound effect file by the user. Return value
0 indicates that the operation was successful. Other values are error codes.
enableEarBack (iOS only): Enables in-ear monitoring.
Parameters- (int)enableEarBack:(BOOL)enable;Name Type Description enable BOOL Specifies whether to enable in-ear monitoring. YES: Enables in-ear monitoring. NO: Disables in-ear monitoring. The default value is NO. Return value
0 indicates that the operation was successful. Other values are error codes.
setEarBackVolume (iOS only): Sets the in-ear monitoring volume.
Parameters- (int)setEarBackVolume:(NSInteger)volume;Name Type Description volume NSInteger The volume. The value ranges from 0 to 100. The default value is 100. Return value
0 indicates that the operation was successful. Other values are error codes.
setSubscribeAudioNumChannel: Sets the number of sound channels for the audio data callback.
Parameters- (void)setSubscribeAudioNumChannel:(AliRtcAudioNumChannel)audioNumChannel;Name Type Description audioNumChannel AliRtcAudioNumChannel The audio channel number. The default is mono. setSubscribeAudioSampleRate: Sets the audio sampling rate for the audio data callback.
Parameters- (void)setSubscribeAudioSampleRate:(AliRtcAudioSampleRate)audioSampleRate;Name Type Description audioSampleRate AliRtcAudioSampleRate The audio sample rate. The default is 44.1 kHz. setAudioSessionOperationRestriction (iOS only): Sets the SDK's control permission for AVAudioSession.
Parameters- (int)setAudioSessionOperationRestriction:(AliRtcAudioSessionOperationRestriction)restriction;Name Type Description restriction AliRtcAudioSessionOperationRestriction The permission type. The default value is AliRtcAudioSessionOperationRestrictionNone. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
setRecordingVolume (iOS only): Sets the recording volume.
Parameters- (int)setRecordingVolume:(NSInteger)volume;Name Type Description volume NSInteger The volume. The value ranges from 0 to 400. 0 means mute. The default value is 100. - A value greater than 100 increases the volume.
- A value less than 100 decreases the volume.
Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You can call this method to adjust the recording volume if a remote user finds the playback sound too low even after turning their physical volume to the maximum. The recommended value is 100 to 200. Values over 200 may affect audio quality.setPlayoutVolume (iOS only): Sets the playback volume.
Parameters- (int)setPlayoutVolume:(NSInteger)volume;Name Type Description volume NSInteger The volume. The value ranges from 0 to 400. 0 means mute. The default value is 100. - A value greater than 100 increases the volume.
- A value less than 100 decreases the volume.
Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You can call this method to adjust the playback volume if you find the playback sound too low even after turning your local physical volume to the maximum. The recommended value is 100 to 200. Values over 200 may affect audio quality.subscribeAudioData: Subscribes to audio data callbacks.
- (void)subscribeAudioData:(AliRtcAudioSource)audioSource;unSubscribeAudioData: Unsubscribes from audio data callbacks.
- (void)unSubscribeAudioData:(AliRtcAudioSource)audioSource;muteAllRemoteAudioPlaying: Stops the playback of all remote audio streams.
Parameters- (int)muteAllRemoteAudioPlaying:(BOOL)mute;Name Type Description mute BOOL YES: Stops playback. NO: Resumes playback. The default is playback state. Return value
0 indicates that the operation was successful. Other values are error codes.
setExternalAudioRender: Enables or disables external audio playback.
Parameters- (int)setExteranlAudioRender:(BOOL)enable sampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame;Name Type Description enable BOOL YES: Enables external audio data as the input source for stream publishing. NO: Stops using it. sampleRate NSUInteger The sample rate of the external audio data. channelsPerFrame NSUInteger The number of sound channels for the external audio data. Mono and stereo are currently supported. Return value
0 indicates that the operation was successful. Other values are error codes.
pushExternalAudioRenderRawData: Pushes external audio playback data.
Parameters- (int)pushExternalAudioRenderRawData:(const void* _Nullable)audioSamples sampleLength:(NSUInteger)sampleLength sampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame timestamp:(long long)timestamp;Name Type Description audioSamples const void* _Nullable The audio data. sampleLength NSUInteger The length of the audio data. sampleRate NSUInteger The audio sample rate. channelsPerFrame NSUInteger The number of audio channels. timestamp long long The timestamp. Return value
A value greater than or equal to 0 indicates success. A value less than 0 indicates failure.
isEnableSpeakerphone (iOS only): Checks whether the audio output is the earpiece or the speaker.
- (BOOL)isEnableSpeakerphone;Return value
YES if the speaker is used. NO if the earpiece is used.
getCurrentAudioCaptureID (Mac only): Retrieves the ID of the recording device in use.
- (NSString *)getCurrentAudioCaptureID;setCurrentAudioCaptureWithID (Mac only): Selects a recording device by its device ID.
Parameters- (void)setCurrentAudioCaptureWithID:(NSString *)captureID;Name Type Description captureID NSString * The recording device ID. getCurrentAudioRendererID (Mac only): Retrieves the ID of the current audio playback device.
- (NSString *)getCurrentAudioRendererID;setCurrentAudioRendererWithID (Mac only): Selects a speaker by its device ID.
Parameters- (void)setCurrentAudioRendererWithID:(NSString *)rendererID;Name Type Description rendererID NSString * The speaker ID. startTestAudioRecordWithName (Mac only): Starts testing an audio capture device.
Parameters- (int)startTestAudioRecordWithName:(NSString *)deviceName;Name Type Description deviceName NSString * The name of the audio capture device. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must call this method before you join a channel.stopTestAudioRecord (Mac only): Stops testing an audio capture device.
- (int)stopTestAudioRecord;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must call this method before you join a channel.startTestAudioPlayoutWithName (Mac only): Starts testing an audio playback device.
Parameters- (int)startTestAudioPlayoutWithName:(NSString *)deviceName filePath:(NSString *)filePath loopCycles:(NSInteger)loopCycles;Name Type Description deviceName NSString * The name of the audio playback device. filePath NSString * The path of the audio file. loopCycles NSInteger The number of times to repeat playback. -1 means loop playback. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must call this method before you join a channel.stopTestAudioPlayout (Mac only): Stops testing an audio playback device.
- (int)stopTestAudioPlayout;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must call this method before you join a channel.setExternalAudioSource: Enables or disables using an external audio source for stream publishing.
Parameters- (int)setExternalAudioSource:(BOOL)enable withSampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame;Name Type Description enable BOOL YES: Enables external audio data as the input source for stream publishing. NO: Stops using it. sampleRate NSUInteger The sample rate of the external audio data. channelsPerFrame NSUInteger The number of sound channels for the external audio data. Mono and stereo are currently supported. Return value
A value greater than or equal to 0 indicates success. A value less than 0 indicates failure.
pushExternalAudioFrameRawData: Pushes external audio frame data.
Parameters- (int)pushExternalAudioFrameRawData:(void *_Nonnull)data samples:(NSUInteger)samples timestamp:(NSTimeInterval)timestamp;Name Type Description data void *_Nonnull The audio data. Data exceeding 40 ms is not recommended. samples NSUInteger The sample rate. timestamp NSTimeInterval The timestamp. You can pass 0 for now. Return value
A value greater than or equal to 0 indicates success. A value less than 0 indicates failure.
setExternalAudioVolume: Sets the external audio input volume.
Parameters- (int)setExternalAudioVolume:(int)vol;Name Type Description vol int The volume. The value ranges from 0 to 100. The default is 50. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
getExternalAudioVolume: Retrieves the external audio input volume.
- (int)getExternalAudioVolume;setMixedWithMic: Enables or disables mixing external audio with the audio captured by the microphone.
Parameters- (int)setMixedWithMic:(BOOL)mixed;Name Type Description mixed BOOL YES: Mixes the audio. NO: Completely replaces the data captured by the microphone. The default is YES. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
setExternalAudioRenderVolume (Mac only): Sets the external audio playback volume.
Parameters- (int)setExternalAudioRenderVolume:(int)vol;Name Type Description vol int The volume. The value ranges from 0 to 100. The default is 50. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
getExternalAudioRenderVolume (Mac only): Retrieves the external audio playback volume.
- (int)getExternalAudioRenderVolume;setVolumeCallbackIntervalMs: Sets the volume callback interval and smoothing coefficient.
Parameters- (int)setVolumeCallbackIntervalMs:(NSInteger)interval smooth:(NSInteger)smooth reportVad:(NSInteger)reportVad;Name Type Description interval NSInteger The time interval in ms. The minimum value is 10 ms. The default value is 160 ms. smooth NSInteger The smoothing coefficient. A larger value indicates a higher degree of smoothing, while a smaller value indicates lower smoothing and better real-time performance. The value ranges from 0 to 9. The default value is 3. reportVad NSInteger The local voice activity detection (VAD) switch. - 1: On. The callback is through the onAudioVolumeCallback interface.
- 0: Off.
Return value
0 indicates success. -1 indicates that the interval is less than 10. -2 indicates that the smoothing coefficient is out of range.
setAudioEffectReverbMode: Sets the reverb effect mode.
Parameters- (int)setAudioEffectReverbMode:(AliRtcAudioEffectReverbMode)mode;Name Type Description mode AliRtcAudioEffectReverbMode The reverb mode type. The default is off. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
setAudioEffectReverbParamType: Sets the reverb effect type.
Parameters- (int)setAudioEffectReverbParamType:(AliRtcAudioEffectReverbParamType)type value:(float)value;Name Type Description type AliRtcAudioEffectReverbParamType The reverb effect type. value float The value for the corresponding reverb effect type. Return value
0 indicates success. An error code is returned on failure.
setDeviceVolumeType: Sets the SDK device volume type (iOS only).
Parameters- (int)setDeviceVolumeType:(AliRtcDeviceVolumeType)type;Name Type Description type AliRtcDeviceVolumeType The device volume type. Return value
0 indicates success. An error code is returned on failure.
- getAudioAccompanyDuration: Retrieves the duration of the accompaniment file in milliseconds.
- (int)getAudioAccompanyDuration; - getAudioAccompanyCurrentPosition: Retrieves the playback progress of the music file in milliseconds.
- (int)getAudioAccompanyCurrentPosition; - setAudioAccompanyPosition: Sets the playback position of the audio file.
Parameters- (int)setAudioAccompanyPosition:(int)pos;Name Type Description posMs int The position of the progress bar in milliseconds. Return value
0 indicates success. An error code is returned on failure.
- stopAllAudioEffects: Stops playing all sound effects.
- (int)stopAllAudioEffects;Return value
0 indicates success. An error code is returned on failure.
- setAllAudioEffectsPublishVolume: Sets the publishing volume for all sound effects.
Parameterspublic abstract int setAllAudioEffectsPublishVolume(int volume);Name Type Description volume int The mixing volume. The value ranges from 0 to 100. The default value is 50. - setAllAudioEffectsPlayoutVolume: Sets the local playback volume for all sound effects.
Parameters- (int)setAllAudioEffectsPlayoutVolume:(NSInteger)volume;Name Type Description volume int The mixing volume. The value ranges from 0 to 100. The default value is 50. Return value
0 indicates success. An error code is returned on failure.
- pauseAllAudioEffects: Pauses all sound effects.
- (int)pauseAllAudioEffects;Return value
0 indicates success. An error code is returned on failure.
- resumeAllAudioEffects: Resumes playing all sound effects.
- (int)resumeAllAudioEffects;Return value
0 indicates success. An error code is returned on failure.
startPreview: Starts the local preview.
- (int)startPreview;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You can start the local preview before you join a channel. You must call setLocalViewConfig before you start the preview.stopPreview: Stops the local preview.
- (int)stopPreview;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
getOnlineRemoteUsers: Retrieves a list of online remote users.
- (NSArray<NSString *> *)getOnlineRemoteUsers;Return value
Returns a list of user IDs.
getUserInfo: Queries for remote user information.
Parameters- (NSDictionary *)getUserInfo:(NSString *)uid;Name Type Description uid NSString * The user ID. isUserOnline: Queries whether a user is online.
Parameters- (BOOL)isUserOnline:(NSString *)uid;Name Type Description uid NSString * The user ID. Return value
YES if the user is online. NO if the user is not online.
getMediaInfoWithUserId: Retrieves the current media stream information.
Parameters- (NSString *)getMediaInfoWithUserId:(NSString *)userId videoTrack:(AliRtcVideoTrack)videoTrack keys:(NSArray<NSString *> *)keys;Name Type Description userId NSString * The ID of the user to query. To query the local user, assign an empty string. videoTrack AliRtcVideoTrack The type of media stream to query. keys NSArray<NSString *> * An array of key values to query. Return value
A JSON formatted string of key-value pairs.
setLogLevel: Sets the log level.
Parameters- (void)setLogLevel:(AliRtcLogLevel)logLevel;Name Type Description logLevel AliRtcLogLevel The log level. The default is AliRtcLogLevelInfo. getSdkVersion: Retrieves the SDK version number.
+ (NSString *)getSdkVersion;uploadLog: Uploads log files.
+ (void)uploadLog;startIntelligentDenoise (Mac only): Enables intelligent noise reduction.
- (void)startIntelligentDenoise;You can call this method to enable intelligent noise reduction during a call.
stopIntelligentDenoise (Mac only): Disables intelligent noise reduction.
- (void)stopIntelligentDenoise;You can call this method to disable intelligent noise reduction during a call.
setClientRole: Sets the user role.
Parameters- (int)setClientRole:(AliRtcClientRole)role;Name Type Description role AliRtcClientRole The user role type. The default is AliRtcClientRolelive. Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
setLogDirPath: Sets the path for saving SDK log files.
Parameters+ (int)setLogDirPath:(NSString *)logDirPath;Name Type Description logDirPath NSString * 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.
Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
setDeviceOrientationMode: Sets the device orientation.
Parameters- (int)setDeviceOrientationMode:(AliRtcOrientationMode)mode;Name Type Description mode AliRtcOrientationMode The device orientation. Valid values: - AliRtcOrientationModePortrait (default): Fixed portrait mode.
- AliRtcOrientationModeLandscapeLeft: Fixed landscape left mode.
- AliRtcOrientationModeLandscapeRight: Fixed landscape right mode.
- AliRtcOrientationModeAuto: Automatic rotation mode.
Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important This method currently supports only fixed portrait and landscape modes. You can set the orientation only before you publish a stream or start a preview.startLastmileDetect: Starts a network quality probe.
- (int)startLastmileDetect;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
Important You must call this method before you join a channel. The test stops automatically after you join the channel. The probe results are returned in the onLastmileDetectResultWithQuality callback.stopLastmileDetect: Stops the network quality probe.
- (int)stopLastmileDetect;Return value
0 indicates that the operation was successful. A non-zero value indicates that the operation failed.
startRecord: Starts recording.
Parameters- (BOOL)startRecord:(AliRtcRecordType)recordType recordFormat:(AliRtcRecordFormat)recordFormat filePath:(NSString*)filePath audioConfig:(AliRtcRecordAudioConfig*)audioConfig videoConfig:(AliRtcRecordVideoConfig*)videoConfig isFragment:(BOOL)isFragmentName Type Description recordType AliRtcRecordType The record type. recordFormat AliRtcRecordFormat The record file format. filePath NSString* The file path. audioConfig AliRtcRecordAudioConfig* The audio recording settings. videoConfig AliRtcRecordVideoConfig* The video recording settings (Mac only). isFragment BOOL Specifies whether to support internal segmentation for MP4 files. This is valid only when recording in MP4 format (Mac only). Return value
YES if the operation was successful. NO if the operation failed.
stopRecord: Stops recording.
- (void)stopRecord;getCurrentClientRole (iOS only): Retrieves the current user role.
- (AliRtcClientRole)getCurrentClientRole;Return value
Returns the current user role.
postFeedbackWithUid: Submits SDK feedback.
Parameters- (void)postFeedbackWithUid:(NSString *_Nullable)uid channleId:(NSString *_Nullable)channelId description:(NSString *_Nonnull)description type:(AliRtcFeedbackType)type timeStamp:(NSTimeInterval)timeStampName Type Description uid NSString * The current UID. Can be nil. channelId NSString * The current channel ID. Can be nil. description NSString * The problem description. Supports Chinese and English. Non-null. type AliRtcFeedbackType The problem type. See the AliRtcFeedbackType comment. timeStamp NSTimeInterval The timestamp when the problem occurred. This is a Unix timestamp. An approximate time is sufficient. You can pass 0. - sendMediaExtensionMsg: Sends media extension messages.
Parameters- (int)sendMediaExtensionMsg:(NSData *)data repeatCount:(int)repeatCount;Name Type Description data NSData The custom message data. The current length limit is 8 bytes. repeatCount int The number of times the message is sent. Return value- 0: The message was sent successfully.
- -1: Failed to send the message because you are not publishing a stream.
- -2: A parameter is invalid. The message length exceeds 8 bytes, or repeatCount is less than or equal to 0.
- -3: The message is sent too frequently. Reduce the sending frequency.
Important To send custom messages to other users in the channel through the audio and video data tunnel, the following prerequisites must be met:- You have joined the channel and are publishing a stream.
- Other users in the channel must subscribe to your audio and video stream. You will receive the result in the onMediaExtensionMsgReceived callback after a message is successfully sent.
- getClientRole (Mac only): Retrieves the user role.
- (AliRtcClientRole)getClientRole;Return value
Returns the current user role.
- refreshAuthInfo: Refreshes the token.
Parameters- (int)refreshAuthInfo:(AliRtcAuthInfo *)info;Name Type Description info AliRtcAuthInfo * The new authentication information. Return value
0 indicates that the token was refreshed successfully. Other values indicate that the token refresh failed.