AliRtcEngine interface

更新时间:
复制 MD 格式

This topic describes the AliRtcEngine interface for the iOS and Mac SDKs.

Contents

Basic APIs

APIDescriptionThe versions listed above are supported.
setH5CompatibleModeSets the H5 compatibility mode.1.1
getH5CompatibleModeChecks whether H5 compatibility mode is enabled.1.1
sharedInstanceCreates an AliRtcEngine instance. Only one instance can exist at a time.1.1
destroyReleases SDK resources.1.1

Channel-related APIs

APIDescriptionSupported in the specified versions
setAutoPublishSets whether to automatically publish and subscribe to streams.1.1
joinChannelJoins a channel.1.1
leaveChannelLeaves a channel.1.1
isInCallChecks whether the user is in a channel.1.1
setChannelProfileSets the channel mode.1.15

Publishing-related APIs

APIDescriptionSupported in the preceding versions
isAutoPublishChecks whether automatic publishing is enabled.1.1
configLocalCameraPublishSets whether to allow publishing the camera stream.1.1
isLocalCameraPublishEnabledChecks whether publishing the camera stream is allowed.1.1
configLocalScreenPublishSets whether to allow publishing the screen stream (Mac only).1.1
isLocalScreenPublishEnabledChecks whether publishing the screen stream is allowed (Mac only).1.1
configLocalAudioPublishSets whether to allow publishing the audio stream.1.1
isLocalAudioPublishEnabledChecks whether publishing the audio stream is allowed.1.1
configLocalSimulcastSets whether to allow publishing the secondary video stream.1.1
isLocalSimulcastEnabledChecks whether publishing the secondary video stream is allowed.1.1
publishManually publishes video and audio streams.1.1

Subscription-related APIs

APIDescriptionSupported since version
isAutoSubscribeChecks whether automatic subscription is enabled.1.1
configRemoteCameraTrackSets whether to subscribe to the remote camera stream.1.1
configRemoteScreenTrackSets whether to subscribe to the remote screen stream.1.1
configRemoteAudioSets whether to subscribe to the remote audio stream.1.1
subscribeManually subscribes to video and audio streams.1.1
subscribeVideoRGBDataSubscribes to video RGB data.1.17
unSubscribeVideoRGBDataUnsubscribes from video RGB data.1.17
subscribeVideoTextureSubscribes to video texture data.1.17
unSubscribeVideoTextureUnsubscribes from video texture data.1.17

Video-related APIs

APIDescriptionSupported in the preceding versions
setVideoProfileSets the parameters for the video stream.1.1
setLocalViewConfigSets the rendering window and drawing parameters for the local preview.1.1
muteLocalCameraSets whether to stop publishing the local video stream.1.1
setRemoteViewConfigSets the rendering window and drawing parameters for the remote video.1.1
getCameraListGets the camera list (Mac only).1.1
getCurrentCameraGets the name of the current camera (Mac only).1.1
setCurrentCameraSelects a camera (Mac only).1.1
switchCameraSwitches between the front and rear cameras (iOS only).1.1
setCameraZoomSets camera parameters (iOS only).1.1
isCameraOnChecks whether the camera is on (iOS only).1.1
isCameraFocusPointSupportedChecks whether the camera supports manual focus (iOS only).1.14
isCameraExposurePointSupportedChecks whether the camera supports manual exposure (iOS only).1.14
setCameraFocusPointSets the coordinates for manual focus (iOS only).1.14
setCameraExposurePointSets the coordinates for manual exposure (iOS only).1.14
subscribeVideoPreprocessDataSubscribes to raw data from pre-processing of captured video (iOS only).1.14
unSubscribeVideoPreprocessDataDisables pre-processing of raw data before you subscribe to data collection (iOS only).1.14
enableHighDefinitionPreviewSets whether to allow high-definition preview. This feature is enabled by default (iOS only).1.14
registerVideoSampleObserverSubscribes to video data output.1.16.2
unregisterVideoSampleObserverUnsubscribes from video data output.1.16.2
setVideoSwapWidthAndHeightSets whether to swap the width and height for the video track.1.16.2
muteAllRemoteVideoRenderingMutes or unmutes the rendering of all remote video tracks.1.16.2
getCurrentCameraIDGets the ID of the current camera (Mac only).1.16.2
setCurrentCameraWithIDSelects a camera by its device ID (Mac only).1.16.2
setExternalVideoSourceEnables an external video input source.1.17.9
pushExternalVideoFrameInputs external video.
  • Mac: 1.16.2
  • iOS: 1.17.9
setBeautyEffectSets basic retouching effects.1.17.9
getCurrentCameraDirectionGets the current camera direction (iOS only).1.17.20
setVideoEncoderConfigurationSets the video encoding properties.1.17.31
enableLocalVideoDisables or re-enables local video capture.1.17.39

Audio-related APIs

APIDescriptionSupported in the above versions
setAudioOnlyModeSets the mode to audio-only or audio and video.1.1
isAudioOnlyChecks whether the current mode is audio-only.1.1
muteLocalMicSets whether to stop publishing the local audio.1.1
muteRemoteAudioPlayingSets whether to stop playing the remote audio stream.1.1
enableSpeakerphoneSwitches between the earpiece and speaker for audio output (iOS only).1.1
getAudioCapturesGets the list of audio recording devices in the system (Mac only).1.1
getCurrentAudioCaptureGets the name of the current audio capture device (Mac only).1.1
setCurrentAudioCaptureSelects an audio capture device (Mac only).1.1
getAudioRenderersGets the list of speakers in the system (Mac only).1.1
getCurrentAudioRendererGets the current audio playback device (Mac only).1.1
setCurrentAudioRendererSelects an audio playback device (Mac only).1.1
startAudioCaptureStarts audio capture.1.11
stopAudioCaptureStops audio capture.1.11
startAudioPlayerStarts audio playback.1.11
stopAudioPlayerStops audio playback.1.11
startAudioAccompanyWithFileStarts playing an accompaniment (iOS only).1.15
stopAudioAccompanyStops the accompaniment (iOS only).1.15
setAudioAccompanyVolumeSets the accompaniment volume (iOS only).1.15
setAudioAccompanyPublishVolumeSets the volume of the published stream after audio mixing (iOS only).1.15
getAudioAccompanyPublishVolumeGets the publishing volume of the accompaniment (iOS only).1.15
setAudioAccompanyPlayoutVolumeSets the local volume of the accompaniment (iOS only).1.15
getAudioAccompanyPlayoutVolumeGets the local volume of the accompaniment (iOS only).1.15
pauseAudioAccompanyPauses playing the accompaniment (iOS only).1.15
resumeAudioAccompanyResumes playing the accompaniment (iOS only).1.15
preloadAudioEffectWithSoundIdPreloads a sound effect (iOS only).1.15
unloadAudioEffectWithSoundIdPurges a preloaded sound effect (iOS only).1.15
playAudioEffectWithSoundIdStarts playing a sound effect (iOS only).1.15
stopAudioEffectWithSoundIdStops playing a sound effect (iOS only).1.15
setAudioEffectPublishVolumeWithSoundIdSets the publishing volume of a sound effect (iOS only).1.15
getAudioEffectPublishVolumeWithSoundIdGets the publishing volume of a sound effect (iOS only).1.15
setAudioEffectPlayoutVolumeWithSoundIdSets the local volume of a sound effect (iOS only).1.15
getAudioEffectPlayoutVolumeWithSoundIdGets the local volume of a sound effect (iOS only).1.15
pauseAudioEffectWithSoundIdPauses playing a sound effect (iOS only).1.15
resumeAudioEffectWithSoundIdResumes playing a sound effect (iOS only).1.15
enableEarBackEnables in-ear monitoring (iOS only).1.15
setEarBackVolumeSets the in-ear monitoring volume (iOS only).1.15
setSubscribeAudioNumChannelSets the number of sound channels for the audio callback.1.15
setSubscribeAudioSampleRateSets the audio sampling rate for the callback.1.15
setAudioSessionOperationRestrictionSets the SDK's control permission for AVAudioSession (iOS only).1.15
setRecordingVolumeSets the recording volume (iOS only).1.16
setPlayoutVolumeSets the playback volume (iOS only).1.16
subscribeAudioDataSubscribes to audio data.1.16
unSubscribeAudioDataUnsubscribes from audio data.1.16
muteAllRemoteAudioPlayingStops playing all remote audio streams.1.16.2
setExteranlAudioRenderSets whether to enable external audio playback.1.16.2
pushExternalAudioRenderRawDataInputs audio playback data.1.16.2
isEnableSpeakerphoneGets whether the current audio output is the earpiece or speaker (iOS only).1.16.2
getCurrentAudioCaptureIDGets the ID of the recording device in use (Mac only).1.16.2
setCurrentAudioCaptureWithIDSelects a recording device by its device ID (Mac only).1.16.2
getCurrentAudioRendererIDGets the ID of the current speaker (Mac only).1.16.2
setCurrentAudioRendererWithIDSelects a speaker by its device ID (Mac only).1.16.2
startTestAudioRecordWithNameStarts testing an audio capture device (Mac only).1.16.2
stopTestAudioRecordStops testing an audio capture device (Mac only).1.16.2
startTestAudioPlayoutWithNameStarts testing an audio playback device (Mac only).1.16.2
stopTestAudioPlayoutStops testing an audio playback device (Mac only).1.16.2
setExternalAudioSourceSets whether to use external audio data as the input source for stream publishing.
  • Mac: 1.16.2
  • iOS: 1.17.9
pushExternalAudioFrameRawDataInputs audio data.
  • Mac: 1.16.2
  • iOS: 1.17.9
setExternalAudioVolumeSets the external audio input volume.
  • Mac: 1.16.2
  • iOS: 1.17.9
getExternalAudioVolumeGets the external audio input volume.
  • Mac: 1.16.2
  • iOS: 1.17.9
setMixedWithMicSets whether to mix external audio input with audio captured by the microphone.
  • Mac: 1.16.2
  • iOS: 1.17.9
setExternalAudioRenderVolumeSets the external audio playback volume (Mac only).1.16.2
getExternalAudioRenderVolumeGets the audio playback volume (Mac only).1.16.2
setVolumeCallbackIntervalMsSets the volume callback interval and smoothing coefficient.1.17
setAudioEffectReverbModeSets the reverb effect mode.1.17
setAudioEffectReverbParamTypeSets the reverb effect type.1.17
setDeviceVolumeTypeSets the SDK device volume type (iOS only).1.17.39

Sound effect APIs

APIDescriptionSupported in the specified versions
getAudioAccompanyDurationGets the duration of the accompaniment file.1.17.30
getAudioAccompanyCurrentPositionGets the playback progress of the music file.1.17.30
setAudioAccompanyPositionSets the playback position of the audio file.1.17.30
stopAllAudioEffectsStops playing all sound effects.1.17.30
setAllAudioEffectsPublishVolumeSets the publishing volume for all sound effects.1.17.30
setAllAudioEffectsPlayoutVolumeSets the local playback volume for all sound effects.1.17.30
pauseAllAudioEffectsPauses all sound effects.1.17.30
resumeAllAudioEffectsResumes playing all sound effects.1.17.30

Preview APIs

APIDescriptionSupported since version
startPreviewStarts the local preview.1.1
stopPreviewStops the local preview.1.1

Remote user query APIs

APIDescriptionSupported since version
getOnlineRemoteUsersGets the list of online remote users.1.1
getUserInfoQueries remote user information.1.1
isUserOnlineQueries whether a user is online.1.1

Other APIs

APIDescriptionSupported in the above versions
setLogLevelSets the log level.1.1
getSdkVersionGets the SDK version number.1.1
uploadLogUploads logs.1.15
startIntelligentDenoiseEnables intelligent noise reduction (Mac only).1.15
stopIntelligentDenoiseDisables intelligent noise reduction (Mac only).1.15
setClientRoleSets the user role.1.16
setLogDirPathSets the path to save SDK log files.1.16.2
setDeviceOrientationModeSets the device orientation.1.16.2
startLastmileDetectStarts a network quality probe test.1.16.2
stopLastmileDetectStops the network quality probe test.1.16.2
startRecordStarts recording.1.17.1
stopRecordStops recording.1.17
getCurrentClientRoleGets the current user role (iOS only).1.17.9
postFeedbackWithUidFeedback on SDK issues
  • Mac: 1.17.10
  • iOS: 1.17.13
sendMediaExtensionMsgSends media extension messages.1.17.1
getClientRoleGets the current user role (Mac only).1.17.19
refreshAuthInfoRefreshes the token.1.17.41

API details

  • setH5CompatibleMode: Sets the H5 compatibility mode.

    + (void)setH5CompatibleMode:(BOOL)comp;
    Parameters
    NameTypeDescription
    compBOOLSpecifies 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.

    + (instancetype)sharedInstance:(id<AliRtcEngineDelegate>)delegate extras:(NSString *)extras;
    Parameters
    NameTypeDescription
    delegateAliRtcEngineDelegate delegateThe delegate that listens for callbacks.
    extrasNSString *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.

    - (int)setAutoPublish:(BOOL)autoPub withAutoSubscribe:(BOOL)autoSub;
    Parameters
    NameTypeDescription
    autoPubBOOLYES: Enables automatic publishing. NO: Enables manual publishing. The default value is YES.
    autoSubBOOLYES: 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.

    - (void)joinChannel:(AliRtcAuthInfo *)authInfo name:(NSString *)userName onResult:(void(^)(NSInteger errCode))onResult;
    Parameters
    NameTypeDescription
    authInfoAliRtcAuthInfo *The authentication information.
    userNameNSString *The display name of the user. This is not the user ID.
    onResultvoid(^)(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.

    - (int)setChannelProfile:(AliRtcChannelProfile)profile;
    Parameters
    NameTypeDescription
    profileAliRtcChannelProfileThe 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.

    - (void)configLocalCameraPublish:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: 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.

    - (void)configLocalScreenPublish:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: 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.

    - (void)configLocalAudioPublish:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: 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.

    - (int)configLocalSimulcast:(BOOL)enabled forTrack:(AliRtcVideoTrack)track;
    Parameters
    NameTypeDescription
    enabledBOOLYES: Allows publishing the secondary video stream. NO: Disallows publishing. The default value is YES.
    trackAliRtcVideoTrackThe 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.
    Parameters
    NameTypeDescription
    onResultvoid (^)(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.

    - (void)configRemoteCameraTrack:(NSString *)uid preferMaster:(BOOL)master enable:(BOOL)enable;
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
    masterBOOLYES: Subscribes to the high-quality stream. NO: Subscribes to the low-quality stream. The default value is YES.
    enableBOOLYES: 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.

    - (void)configRemoteScreenTrack:(NSString *)uid enable:(BOOL)enable;
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
    enableBOOLYES: 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.

    - (void)configRemoteAudio:(NSString *)uid enable:(BOOL)enable;
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
    enableBOOLYES: 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.
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
    onResultvoid (^)(NSString *uid, AliRtcVideoTrack vt, AliRtcAudioTrack at)The callback that is invoked after the subscribe operation is complete.
  • subscribeVideoRGBData: Subscribes to video RGB data.

    - (void)subscribeVideoRGBData:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource;
    Parameters
    NameTypeDescription
    uidNSString *The UID of the user.
    videoSourceAliRtcVideoSourceThe type of raw video data source.
  • unSubscribeVideoRGBData: Unsubscribes from video RGB data.

    - (void)unSubscribeVideoRGBData:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource;
    Parameters
    NameTypeDescription
    uidNSString *The UID of the user.
    videoSourceAliRtcVideoSourceThe type of raw video data source.
  • subscribeVideoTexture: Subscribes to video texture data.

    - (void)subscribeVideoTexture:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoTextureType:(AliRtcVideoTextureType)videoTextureType;
    Parameters
    NameTypeDescription
    uidNSString *The UID of the user.
    videoSourceAliRtcVideoSourceThe type of raw video data source.
    videoTextureTypeAliRtcVideoTextureTypeThe texture type.
  • unSubscribeVideoTexture: Unsubscribes from video texture data.

    - (void)unSubscribeVideoTexture:(NSString *)uid videoSource:(AliRtcVideoSource)videoSource videoTextureType:(AliRtcVideoTextureType)videoTextureType;
    Parameters
    NameTypeDescription
    uidNSString *The UID of the user.
    videoSourceAliRtcVideoSourceThe type of raw video data source.
    videoTextureTypeAliRtcVideoTextureTypeThe texture type.
  • setVideoProfile: Sets the parameters for the video stream.

    - (void)setVideoProfile:(AliRtcVideoProfile)profile forTrack:(AliRtcVideoTrack)track;
    Parameters
    NameTypeDescription
    profileAliRtcVideoProfileThe video stream parameters. The default is a camera stream with a resolution of 480 × 640 and a frame rate of 15 fps.
    trackAliRtcVideoTrackThe 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.
    Parameters
    NameTypeDescription
    viewConfigAliVideoCanvas *The rendering parameters, including the rendering window and rendering mode.
    trackAliRtcVideoTrackPreview 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.

    - (int)muteLocalCamera:(BOOL)mute forTrack:(AliRtcVideoTrack)track;
    Parameters
    NameTypeDescription
    muteBOOLYES: Stops publishing the video stream. NO: Resumes publishing. The default value is NO.
    trackAliRtcVideoTrackThe 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.

    - (int)setRemoteViewConfig:(AliVideoCanvas *)canvas uid:(NSString *)uid forTrack:(AliRtcVideoTrack)track;
    Parameters
    NameTypeDescription
    canvasAliVideoCanvas *The rendering parameters, including the rendering window and rendering mode.
    uidNSString *The user ID.
    trackAliRtcVideoTrackThe 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.

    - (void)setCurrentCamera:(NSString *)camera;
    Parameters
    NameTypeDescription
    cameraNSString *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.

     - (int)setCameraZoom:(float)zoom flash:(BOOL)flash autoFocus:(BOOL)autoFocus;
    Parameters
    NameTypeDescription
    zoomfloatThe zoom level. The value ranges from -3.0 to 3.0. The default value is 1.0.
    flashBOOLSpecifies whether to turn on the flash. YES: Turns on the flash. NO: Does not turn on the flash. The default value is NO.
    autoFocusBOOLSpecifies 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.

    - (int)setCameraFocusPoint:(CGPoint)point;
    Parameters
    NameTypeDescription
    pointCGPointThe 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.

    - (int)setCameraExposurePoint:(CGPoint)point;
    Parameters
    NameTypeDescription
    pointCGPointThe 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.

    - (void)subscribeVideoPreprocessData:(AliRtcVideoSource)videoSource;
    Parameters
    NameTypeDescription
    videoSourceAliRtcVideoSourceThe video stream type.
  • unSubscribeVideoPreprocessData (iOS only): Unsubscribes from the raw data from the pre-processing of captured video.

    - (void)unSubscribeVideoPreprocessData:(AliRtcVideoSource)videoSource;
    Parameters
    NameTypeDescription
    videoSourceAliRtcVideoSourceThe video stream type.
  • enableHighDefinitionPreview (iOS only): Enables or disables high-definition preview.

    - (BOOL)enableHighDefinitionPreview:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: 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.

    - (void)setVideoSwapWidthAndHeight:(BOOL)swapWidthAndHeight forTrack:(AliRtcVideoTrack)track;
    Parameters
    NameTypeDescription
    swapWidthAndHeightBOOLYES: Swaps the width and height. NO: Does not swap. The default value is NO.
    trackAliRtcVideoTrackThe video track type to set.
  • muteAllRemoteVideoRendering: Mutes or unmutes the rendering of all remote video tracks.

    - (int)muteAllRemoteVideoRendering:(BOOL)mute;
    Parameters
    NameTypeDescription
    muteBOOLYES: 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.

    - (void)setCurrentCameraWithID:(NSString *)cameraID;
    Parameters
    NameTypeDescription
    cameraIDNSString *The camera ID.
  • setExternalVideoSource: Enables an external video input source.

    - (int)setExternalVideoSource:(BOOL)enable useTexture:(BOOL)useTexture sourceType:(AliRtcVideoSource)type renderMode:(AliRtcRenderMode)renderMode
    Parameters
    NameTypeDescription
    enableBOOLYES: Enables external video data as the input source for stream publishing. NO: Stops using it.
    useTextureBOOLSpecifies whether to use texture mode. This is not currently supported.
    typeAliRtcVideoSourceThe video stream type.
    renderModeAliRtcRenderModeThe 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.

    - (int)pushExternalVideoFrame:(AliRtcVideoDataSample *)frame sourceType:(AliRtcVideoSource)type;
    Parameters
    NameTypeDescription
    frameAliRtcVideoDataSample *The frame data.
    typeAliRtcVideoSourceThe 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:
      - (int)setBeautyEffect:(BOOL)enable config:(AliRtcBeautyConfig)config;
      Parameters
      NameTypeDescription
      enableBOOLYES: Enables basic retouching. NO: Disables basic retouching. The default value is NO.
      configAliRtcBeautyConfigThe retouching parameter settings.
    • Mac code and parameters are as follows:
      - (int)setBeatutyEffect:(bool)enable config:(AliRtcBeautyConfig)config;
      Parameters
      NameTypeDescription
      enablebooltrue: Enables basic retouching. false: Disables basic retouching. The default value is false.
      configAliRtcBeautyConfigThe retouching parameter settings.

    Return value

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

  • getCurrentCameraDirection (iOS only): Retrieves the current camera direction.
    - (AliRtcCameraDirection)getCurrentCameraDirection;

    The default is the front camera.

  • setVideoEncoderConfiguration: Sets the video encoding configuration.
    - (void)setVideoEncoderConfiguration:(AliRtcVideoEncoderConfiguration* _Nonnull )config;
    Parameters
    NameTypeDescription
    configAliRtcVideoEncoderConfigurationThe predefined video encoding properties.
  • enableLocalVideo: Disables or re-enables local video capture.
    - (int)enableLocalVideo:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLSpecifies 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.

    - (int)setAudioOnlyMode:(BOOL)audioOnly;
    Parameters
    NameTypeDescription
    audioOnlyBOOLYES: 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.

    - (int)muteLocalMic:(BOOL)mute;
    Parameters
    NameTypeDescription
    muteBOOLYES: 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.

    - (int)muteRemoteAudioPlaying:(NSString *)uid mute:(BOOL)mute;
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
    muteBOOLYES: 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.

     - (int)enableSpeakerphone:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLYES: 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.

    - (void)setCurrentAudioCapture:(NSString *)capture;
    Parameters
    NameTypeDescription
    captureNSString *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.

    - (void)setCurrentAudioRenderer:(NSString *)renderer;
    Parameters
    NameTypeDescription
    rendererNSString *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.

    - (int)startAudioAccompanyWithFile:(NSString *)filePath onlyLocalPlay:(BOOL)onlyLocalPlay replaceMic:(BOOL)replaceMic loopCycles:(NSInteger)loopCycles;
    Parameters
    NameTypeDescription
    filePathNSString *The file path.
    onlyLocalPlayBOOLSpecifies whether to play only locally. Valid values: YES and NO.
    replaceMicBOOLSpecifies whether to replace the microphone. Valid values: YES and NO.
    loopCyclesNSIntegerThe 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.

    - (int)setAudioAccompanyVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (int)setAudioAccompanyPublishVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (int)setAudioAccompanyPlayoutVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (int)preloadAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe ID assigned to the sound effect file by the user.
    filePathNSString *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.

    - (int)unloadAudioEffectWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)playAudioEffectWithSoundId:(NSInteger)soundId filePath:(NSString *)filePath cycles:(NSInteger)cycles publish:(BOOL)publish;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe ID assigned to the sound effect file by the user.
    filePathNSString *The path of the sound effect file.
    cyclesNSIntegerThe number of loops. You can set this to -1 or a positive integer.
    publishBOOLSpecifies 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.

    - (int)stopAudioEffectWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)setAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe ID assigned to the sound effect file by the user.
    volumeNSIntegerThe 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.

    - (int)getAudioEffectPublishVolumeWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)setAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId volume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe ID assigned to the sound effect file by the user.
    volumeNSIntegerThe 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.

    - (int)getAudioEffectPlayoutVolumeWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)pauseAudioEffectWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)resumeAudioEffectWithSoundId:(NSInteger)soundId;
    Parameters
    NameTypeDescription
    soundIdNSIntegerThe 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.

    - (int)enableEarBack:(BOOL)enable;
    Parameters
    NameTypeDescription
    enableBOOLSpecifies 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.

    - (int)setEarBackVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (void)setSubscribeAudioNumChannel:(AliRtcAudioNumChannel)audioNumChannel;
    Parameters
    NameTypeDescription
    audioNumChannelAliRtcAudioNumChannelThe audio channel number. The default is mono.
  • setSubscribeAudioSampleRate: Sets the audio sampling rate for the audio data callback.

    - (void)setSubscribeAudioSampleRate:(AliRtcAudioSampleRate)audioSampleRate;
    Parameters
    NameTypeDescription
    audioSampleRateAliRtcAudioSampleRateThe audio sample rate. The default is 44.1 kHz.
  • setAudioSessionOperationRestriction (iOS only): Sets the SDK's control permission for AVAudioSession.

    - (int)setAudioSessionOperationRestriction:(AliRtcAudioSessionOperationRestriction)restriction;
    Parameters
    NameTypeDescription
    restrictionAliRtcAudioSessionOperationRestrictionThe 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.

    - (int)setRecordingVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (int)setPlayoutVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeNSIntegerThe 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.

    - (int)muteAllRemoteAudioPlaying:(BOOL)mute;
    Parameters
    NameTypeDescription
    muteBOOLYES: 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.

    - (int)setExteranlAudioRender:(BOOL)enable sampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame;
    Parameters
    NameTypeDescription
    enableBOOLYES: Enables external audio data as the input source for stream publishing. NO: Stops using it.
    sampleRateNSUIntegerThe sample rate of the external audio data.
    channelsPerFrameNSUIntegerThe 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.

    - (int)pushExternalAudioRenderRawData:(const void* _Nullable)audioSamples sampleLength:(NSUInteger)sampleLength sampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame timestamp:(long long)timestamp;
    Parameters
    NameTypeDescription
    audioSamplesconst void* _NullableThe audio data.
    sampleLengthNSUIntegerThe length of the audio data.
    sampleRateNSUIntegerThe audio sample rate.
    channelsPerFrameNSUIntegerThe number of audio channels.
    timestamplong longThe 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.

    - (void)setCurrentAudioCaptureWithID:(NSString *)captureID;
    Parameters
    NameTypeDescription
    captureIDNSString *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.

    - (void)setCurrentAudioRendererWithID:(NSString *)rendererID;
    Parameters
    NameTypeDescription
    rendererIDNSString *The speaker ID.
  • startTestAudioRecordWithName (Mac only): Starts testing an audio capture device.

    - (int)startTestAudioRecordWithName:(NSString *)deviceName;
    Parameters
    NameTypeDescription
    deviceNameNSString *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.

    - (int)startTestAudioPlayoutWithName:(NSString *)deviceName filePath:(NSString *)filePath loopCycles:(NSInteger)loopCycles;
    Parameters
    NameTypeDescription
    deviceNameNSString *The name of the audio playback device.
    filePathNSString *The path of the audio file.
    loopCyclesNSIntegerThe 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.

    - (int)setExternalAudioSource:(BOOL)enable withSampleRate:(NSUInteger)sampleRate channelsPerFrame:(NSUInteger)channelsPerFrame;
    Parameters
    NameTypeDescription
    enableBOOLYES: Enables external audio data as the input source for stream publishing. NO: Stops using it.
    sampleRateNSUIntegerThe sample rate of the external audio data.
    channelsPerFrameNSUIntegerThe 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.

    - (int)pushExternalAudioFrameRawData:(void *_Nonnull)data samples:(NSUInteger)samples timestamp:(NSTimeInterval)timestamp;
    Parameters
    NameTypeDescription
    datavoid *_NonnullThe audio data. Data exceeding 40 ms is not recommended.
    samplesNSUIntegerThe sample rate.
    timestampNSTimeIntervalThe 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.

    - (int)setExternalAudioVolume:(int)vol;
    Parameters
    NameTypeDescription
    volintThe 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.

    - (int)setMixedWithMic:(BOOL)mixed;
    Parameters
    NameTypeDescription
    mixedBOOLYES: 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.

    - (int)setExternalAudioRenderVolume:(int)vol;
    Parameters
    NameTypeDescription
    volintThe 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.

    - (int)setVolumeCallbackIntervalMs:(NSInteger)interval smooth:(NSInteger)smooth reportVad:(NSInteger)reportVad;
    Parameters
    NameTypeDescription
    intervalNSIntegerThe time interval in ms. The minimum value is 10 ms. The default value is 160 ms.
    smoothNSIntegerThe 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.
    reportVadNSIntegerThe 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.

    - (int)setAudioEffectReverbMode:(AliRtcAudioEffectReverbMode)mode;
    Parameters
    NameTypeDescription
    modeAliRtcAudioEffectReverbModeThe 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.

    - (int)setAudioEffectReverbParamType:(AliRtcAudioEffectReverbParamType)type value:(float)value;
    Parameters
    NameTypeDescription
    typeAliRtcAudioEffectReverbParamTypeThe reverb effect type.
    valuefloatThe 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).

    - (int)setDeviceVolumeType:(AliRtcDeviceVolumeType)type;
    Parameters
    NameTypeDescription
    typeAliRtcDeviceVolumeTypeThe 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.
    - (int)setAudioAccompanyPosition:(int)pos;
    Parameters
    NameTypeDescription
    posMsintThe 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.
    public abstract int setAllAudioEffectsPublishVolume(int volume);
    Parameters
    NameTypeDescription
    volumeintThe mixing volume. The value ranges from 0 to 100. The default value is 50.
  • setAllAudioEffectsPlayoutVolume: Sets the local playback volume for all sound effects.
    - (int)setAllAudioEffectsPlayoutVolume:(NSInteger)volume;
    Parameters
    NameTypeDescription
    volumeintThe 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.

    - (NSDictionary *)getUserInfo:(NSString *)uid;
    Parameters
    NameTypeDescription
    uidNSString *The user ID.
  • isUserOnline: Queries whether a user is online.

    - (BOOL)isUserOnline:(NSString *)uid;
    Parameters
    NameTypeDescription
    uidNSString *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.

    - (NSString *)getMediaInfoWithUserId:(NSString *)userId videoTrack:(AliRtcVideoTrack)videoTrack keys:(NSArray<NSString *> *)keys;
    Parameters
    NameTypeDescription
    userIdNSString *The ID of the user to query. To query the local user, assign an empty string.
    videoTrackAliRtcVideoTrackThe type of media stream to query.
    keysNSArray<NSString *> *An array of key values to query.

    Return value

    A JSON formatted string of key-value pairs.

  • setLogLevel: Sets the log level.

    - (void)setLogLevel:(AliRtcLogLevel)logLevel;
    Parameters
    NameTypeDescription
    logLevelAliRtcLogLevelThe 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.

    - (int)setClientRole:(AliRtcClientRole)role;
    Parameters
    NameTypeDescription
    roleAliRtcClientRoleThe 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.

    + (int)setLogDirPath:(NSString *)logDirPath;
    Parameters
    NameTypeDescription
    logDirPathNSString *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.

    - (int)setDeviceOrientationMode:(AliRtcOrientationMode)mode;
    Parameters
    NameTypeDescription
    modeAliRtcOrientationModeThe 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.

    - (BOOL)startRecord:(AliRtcRecordType)recordType recordFormat:(AliRtcRecordFormat)recordFormat filePath:(NSString*)filePath audioConfig:(AliRtcRecordAudioConfig*)audioConfig videoConfig:(AliRtcRecordVideoConfig*)videoConfig isFragment:(BOOL)isFragment
    Parameters
    NameTypeDescription
    recordTypeAliRtcRecordTypeThe record type.
    recordFormatAliRtcRecordFormatThe record file format.
    filePathNSString*The file path.
    audioConfigAliRtcRecordAudioConfig*The audio recording settings.
    videoConfigAliRtcRecordVideoConfig*The video recording settings (Mac only).
    isFragmentBOOLSpecifies 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.

    - (void)postFeedbackWithUid:(NSString *_Nullable)uid channleId:(NSString *_Nullable)channelId description:(NSString *_Nonnull)description type:(AliRtcFeedbackType)type timeStamp:(NSTimeInterval)timeStamp
    Parameters
    NameTypeDescription
    uidNSString *The current UID. Can be nil.
    channelIdNSString *The current channel ID. Can be nil.
    descriptionNSString *The problem description. Supports Chinese and English. Non-null.
    typeAliRtcFeedbackTypeThe problem type. See the AliRtcFeedbackType comment.
    timeStampNSTimeIntervalThe timestamp when the problem occurred. This is a Unix timestamp. An approximate time is sufficient. You can pass 0.
  • sendMediaExtensionMsg: Sends media extension messages.
    - (int)sendMediaExtensionMsg:(NSData *)data repeatCount:(int)repeatCount;
    Parameters
    NameTypeDescription
    dataNSDataThe custom message data. The current length limit is 8 bytes.
    repeatCountintThe 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.
    - (int)refreshAuthInfo:(AliRtcAuthInfo *)info;
    Parameters
    NameTypeDescription
    infoAliRtcAuthInfo *The new authentication information.

    Return value

    0 indicates that the token was refreshed successfully. Other values indicate that the token refresh failed.