AliRtcEngine class

更新时间:
复制 MD 格式

This topic describes the methods of the AliRtcEngine class provided by ApsaraVideo Real-time Communication (ARTC) SDK for HarmonyOS.

Contents

Basic APIs

API

Description

getInstance

Returns an AliRtcEngine instance.

destroyInstance

Destroys the AliRtcEngine instance.

getSDKVersion

Returns the current SDK version.

setH5CompatibleMode

Sets the H5 compatible mode.

getH5CompatibleMode

Returns the H5 compatible mode.

setRtcEngineEventListener

Sets the listener for engine event callbacks.

getNativeHandle

Returns the instance handle from the native layer.

Channel APIs

API

Description

setChannelProfile

Sets the channel mode.

setClientRole

Sets the user role in a live streaming scenario.

getCurrentClientRole

Gets the current user role.

joinChannel

Joins a channel. Users in the same channel can make calls with each other.

joinChannelWithToken

Joins a channel.

joinChannelWithChannelParam

Joins a channel.

joinAIChannel

Joins an AI channel.

leaveChannel

Leaves the channel and ends the call.

getCurrentConnectionStatus

Gets the current network connection status.

isInCall

Checks if the user is in a channel.

refreshAuthInfo

Refreshes the authentication information.

refreshAuthInfoWithToken

Refreshes the authentication information.

isAudioOnlyMode

Checks if the call is in audio-only mode.

Publish and subscribe APIs

API

Description

publishLocalVideoStream

Publishes or unpublishes the local camera stream.

isLocalVideoStreamPublished

Checks if the local video stream is published.

publishLocalDualVideoStream

Publishes or unpublishes the secondary video stream.

isLocalDualVideoStreamPublished

Checks if the secondary video stream is published.

publishLocalAudioStream

Publishes or unpublishes the local audio stream.

isLocalAudioStreamPublished

Checks if the local audio stream is published.

publishLocalDualAudioStream

Publishes or unpublishes the secondary audio stream.

isLocalDualAudioStreamPublished

Checks if the secondary audio stream is published.

setDefaultSubscribeAllRemoteAudioStreams

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

setDefaultSubscribeAllRemoteVideoStreams

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

setRemoteVideoStreamType

Sets the subscribed camera stream type: high-quality stream or low-quality stream.

setRemoteDefaultVideoStreamType

Sets the default subscribed camera stream type: high-quality stream or low-quality stream.

subscribeAllRemoteAudioStreams

Stops or resumes subscribing to all remote audio streams.

subscribeAllRemoteDualAudioStreams

Stops or resumes subscribing to all remote secondary audio streams.

subscribeAllRemoteVideoStreams

Stops or resumes subscribing to all remote video streams.

subscribeRemoteAudioStream

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

subscribeRemoteAudioStreamByTrack

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

subscribeRemoteVideoStream

Stops or resumes subscribing to a remote video stream.

subscribeRemoteMediaStream

Stops or resumes subscribing to a remote media stream.

subscribeRemoteDestChannelStream

Stops or resumes subscribing to a specific user's stream in a destination channel.

Audio device management APIs

API

Description

setAudioProfile

Sets the audio profile.

SetAudioCapability

Sets the audio capability.

startAudioCapture

Starts audio capture.

stopAudioCapture

Stops audio capture.

startAudioPlayer

Starts the audio player.

stopAudioPlayer

Stops the audio player.

muteLocalMic

Mutes or unmutes the local audio stream.

setRecordingVolume

Sets the recording volume.

setPlayOutVolume

Sets the playback volume.

setDefaultAudioRouteToSpeakerphone

Sets whether the speakerphone is the default audio output route. This behavior is enabled by default.

enableSpeakerphone

Enables or disables the speakerphone for audio output. When disabled, audio is routed to the earpiece.

isSpeakerOn

Checks whether the speakerphone is enabled.

setRemoteAudioVolume

Adjusts the local playback volume of a specified remote user.

muteRemoteAudioPlaying

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

muteAllRemoteAudioPlaying

Mutes or unmutes all remote audio streams.

enableAudioVolumeIndication

Sets the frequency and smoothing factor for audio volume indication.

enableEarBack

Enables in-ear monitoring.

setEarBackVolume

Sets the in-ear monitoring volume.

startAudioCaptureTest

Starts an audio capture device test before a call.

stopAudioCaptureTest

Stops the audio capture device test.

playAudioFileTest

Starts an audio file playback test.

stopAudioFileTest

Stops the audio file playback test.

Video device management APIs

API

Description

setLocalViewConfig

Sets the display view for the local preview.

startPreview

Starts the local video preview.

stopPreview

Stops the local video preview.

setCameraCaptureConfiguration

Sets the camera capture preferences.

enableLocalVideo

Enables or disables local video capture.

enableVideoCapture

Stops or resumes local camera capture.

muteLocalCamera

Stops or resumes sending the local video stream.

isCameraOn

Checks if the camera is on.

muteAllRemoteVideoRendering

Mutes or unmutes the rendering of all remote video tracks.

setVideoEncoderConfiguration

Sets the video encoding properties for the camera stream.

setVideoDecoderConfiguration

Sets the video decoding properties for the camera stream.

setVideoMirrorMode

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

setCapturePipelineScaleMode

Sets when video scaling occurs in the capture pipeline: either immediately after capture or during encoding.

setRemoteViewConfig

Sets the display view for a remote video stream.

switchCamera

Switches between the front and rear cameras.

getCurrentCameraDirection

Gets the current camera direction (front or rear).

setCameraZoom

Sets the camera zoom factor.

getCameraMaxZoomFactor

Gets the maximum camera zoom factor.

getCurrentZoom

Gets the current camera zoom factor.

setExposure

Sets the camera exposure.

getCurrentExposure

Gets the current camera exposure.

getMinExposure

Gets the minimum camera exposure.

getMaxExposure

Gets the maximum camera exposure.

setCameraFlash

Turns the camera flash on or off.

isCameraFocusPointSupported

Checks if the camera supports manual focus.

isCameraExposurePointSupported

Checks if the camera supports setting a custom exposure point.

setCameraFocusPoint

Sets the manual focus point for the camera.

setCameraExposurePoint

Sets the camera exposure point.

getVideoCodecType

Gets the video codec type.

getCurrentEncoderManufacturer

Gets the manufacturer of the currently used encoder. If stream publishing has not started, this method returns an invalid type.

snapshotVideo

Takes a video snapshot.

Screen sharing

API

Description

setScreenShareEncoderConfiguration

Configures the video encoding properties for the screen-sharing stream.

startScreenShare

Starts screen sharing.

stopScreenShare

Stops screen sharing.

isScreenSharePublished

Checks whether the screen-sharing stream is published.

Configure audio data callback

API

Description

registerAudioFrameObserver

Registers an audio data callback.

enableAudioFrameObserver

Enables the audio data callback.

Custom audio input

API

Description

addExternalAudioStream

Adds an external audio stream.

pushExternalAudioStreamRawData

Pushes external audio data.

setExternalAudioStreamPlayoutVolume

Sets the playout volume for an external audio stream.

getExternalAudioStreamPlayoutVolume

Gets the playout volume for an external audio stream.

setExternalAudioStreamPublishVolume

Sets the publish volume for an external audio stream.

getExternalAudioStreamPublishVolume

Gets the publish volume for an external audio stream.

removeExternalAudioStream

Removes an external audio stream.

Custom video input

API

Description

setExternalVideoSource

Enables the external video source.

pushExternalVideoFrame

Pushes a video frame.

setExternalImageData

Inputs image data to use as a video frame.

Voice changer and reverb

API

Description

setAudioEffectPitchValue

Sets the pitch value.

setAudioEffectVoiceChangerMode

Sets the voice changer mode.

setAudioEffectReverbMode

Sets the reverb mode.

setAudioEffectBeautifyMode

Sets the voice beautification mode.

setAudioEffectReverbParamType

Sets the reverb effect type.

setAudioEffectEqualizationParam

Sets the equalizer parameters.

Audio accompaniment

API

Description

startAudioAccompany

Starts the audio accompaniment.

stopAudioAccompany

Stops the audio accompaniment.

setAudioAccompanyVolume

Sets the volume of the audio accompaniment.

setAudioAccompanyPublishVolume

Sets the publishing volume of the audio accompaniment.

getAudioAccompanyPublishVolume

Gets the publishing volume of the audio accompaniment.

setAudioAccompanyPlayOutVolume

Sets the local playback volume of the audio accompaniment.

getAudioAccompanyPlayOutVolume

Gets the local playback volume of the audio accompaniment.

pauseAudioAccompany

Pauses the audio accompaniment.

resumeAudioAccompany

Resumes the audio accompaniment.

getAudioAccompanyDuration

Gets the duration of the audio accompaniment file in milliseconds.

getAudioAccompanyCurrentPosition

Gets the current playback position of the audio accompaniment file in milliseconds.

setAudioAccompanyPosition

Sets the playback position of the audio accompaniment file.

Play audio effects

API

Description

preloadAudioEffect

Preloads an audio effect file.

unloadAudioEffect

Unloads a preloaded audio effect file.

playAudioEffect

Plays an audio effect.

pauseAudioEffect

Pauses an audio effect.

pauseAllAudioEffects

Pauses all audio effects.

resumeAudioEffect

Resumes a specified audio effect.

resumeAllAudioEffects

Resumes all audio effects.

stopAudioEffect

Stops an audio effect.

stopAllAudioEffects

Stops all audio effects.

setAudioEffectPublishVolume

Sets the publishing volume of an audio effect.

getAudioEffectPublishVolume

Gets the publishing volume of an audio effect.

setAudioEffectPlayOutVolume

Sets the local playout volume of an audio effect.

getAudioEffectPlayOutVolume

Gets the local playout volume of an audio effect.

setAllAudioEffectsPublishVolume

Sets the publishing volume for all audio effects.

setAllAudioEffectsPlayoutVolume

Sets the local playout volume for all audio effects.

SEI

API

Description

enableSEIVideoStream

Enables or disables the SEI video stream. When enabled, the SDK sends a 16x16 black frame at 20 fps.

sendMediaExtensionMsg

Sends a media extension message.

sendMediaExtensionMsgEx

Sends a media extension message.

Data channel

API

Description

sendDataChannelMsg

Sends a data message.

File recording

API

Description

startRecord

Starts file recording.

stopRecord

Stops file recording.

Server-side live streaming

API

Description

startPublishLiveStream

Starts server-side live streaming.

updatePublishLiveStream

Updates server-side live streaming parameters.

stopPublishLiveStream

Stops server-side live streaming.

getPublishLiveStreamState

Gets the state of server-side live streaming.

updatePublishLiveStreamWithTaskId

Updates server-side live streaming parameters by task ID.

stopPublishLiveStreamWithTaskId

Stops server-side live streaming by task ID.

getPublishLiveStreamStateWithTaskId

Gets the state of server-side live streaming by task ID.

Push and pull RTS raw streams

API

Description

publishStreamByRtsUrl

Pushes a stream via an RTS URL. Currently, only one stream can be pushed at a time.

stopPublishStreamByRtsUrl

Stops pushing the stream for the specified RTS URL.

subscribeStreamByRtsUrl

Subscribes to a stream from an RTS URL. Currently, only one stream can be subscribed to at a time.

stopSubscribeStreamByRtsUserId

Stops the stream subscription for the specified RTS user ID.

pauseRtsStreamByRtsUserId

Pauses the subscription to an RTS stream for the specified RTS user ID.

resumeRtsStreamByRtsUserId

Resumes the subscription to an RTS stream for the specified RTS user ID.

Last-mile network quality detection

API

Description

startLastmileDetect

Starts last-mile network quality detection.

stopLastmileDetect

Stops last-mile network quality detection.

Other APIs

API

Description

setLogDirPath

Sets the storage path for SDK log files.

setLogLevel

Sets the log level.

enableUploadLog

Toggles log file uploads. Enabled by default.

setExtras

Updates external input parameters with a JSON string.

setParameter

Sets a custom attribute with a JSON string.

getParameter

Gets a custom attribute.

enableStatsReport

Toggles telemetry data uploads. Enabled by default.

getNetworkTime

Gets the network time.

Callbacks

API

Description

onRemoteUserOnline

Occurs when a remote user in communication mode or a host in interactive mode joins the channel.

onRemoteUserOffline

Occurs when a remote user in communication mode or a host in interactive mode leaves the channel.

onJoinChannel

Occurs when the local user successfully joins a channel.

onLeaveChannel

Occurs when the local user leaves the channel.

onConnectionStatusChange

Occurs when the network connection state changes.

onBye

Occurs when the server removes the local user from the channel, or when the meeting ends.

onAudioPublishStateChanged

Occurs when the audio publishing state changes.

onVideoPublishStateChanged

Occurs when the video publishing state changes.

onScreenSharePublishStateChanged

Occurs when the screen sharing publishing state changes.

onDualVideoStreamPublishStateChanged

Occurs when the publishing state of the secondary video stream changes.

onAudioSubscribeStateChanged

Occurs when the audio subscription state changes.

onVideoSubscribeStateChanged

Occurs when the camera stream subscription state changes.

onSubscribeStreamTypeChanged

Occurs when the subscribed stream type of a dual stream changes.

onRemoteTrackAvailableNotify

Occurs when the audio or video stream of a remote user becomes available or unavailable.

onFirstRemoteVideoFrameDrawn

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

onFirstLocalVideoFrameDrawn

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

onFirstVideoPacketSend

Occurs when the first video packet is sent.

onFirstVideoPacketReceived

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

onFirstVideoFrameReceived

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

onVideoResolutionChanged

Occurs when the video resolution changes.

onFirstAudioPacketSend

Occurs when the first audio packet is sent.

onFirstAudioPacketReceived

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

onFirstRemoteAudioDecoded

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

onAudioVolumeCallback

Reports the volume of subscribed audio streams.

onTestAudioVolumeCallback

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

onActiveSpeaker

Reports the active speaker in the channel.

onAudioAccompanyStateChanged

Occurs when the local audio mixing state changes.

onAudioEffectFinished

Occurs when a local audio effect finishes playing.

onNetworkQualityChanged

Reports changes in network quality.

onLastmileDetectResultWithQuality

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

onLastmileDetectResultWithBandWidth

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

onStats

Reports the statistics of the current session.

onLocalVideoStats

Reports the statistics of the local video stream.

onRemoteVideoStats

Reports the statistics of a remote video stream.

onLocalAudioStats

Reports the statistics of the local audio stream.

onRemoteAudioStats

Reports the statistics of a remote audio stream.

onPublishLiveStreamStateChanged

Occurs when the state of CDN live streaming changes.

onPublishLiveStreamStateChangedWithTaskId

Occurs when the state of a CDN live streaming task changes, identified by a task ID.

onPublishLiveTaskStatusChanged

Occurs when the status of a CDN live streaming task changes.

onPublishLiveTaskStatusChangedWithTaskId

Occurs when the status of a CDN live streaming task changes, identified by a task ID.

onUserAudioMuted

Occurs when a remote user mutes or unmutes their audio.

onUserVideoMuted

Occurs when a remote user starts or stops sending black frames.

onUserVideoEnabled

Occurs when a remote user enables or disables camera capture.

onUpdateRoleNotify

Occurs when a user's role changes.

onRemoteAudioAccompanyStarted

Occurs when a remote user starts audio mixing.

onRemoteAudioAccompanyFinished

Occurs when a remote user finishes audio mixing.

onMediaExtensionMsgReceived

Occurs when a media extension message is received.

onLocalDeviceException

Occurs when an exception is detected in a local device.

onDataChannelMessage

Occurs when a message is received through the data channel.

onRemoteVideoChanged

Occurs when a remote video stream changes.

onAuthInfoWillExpire

Occurs when the user's authentication information is about to expire.

onAuthInfoExpired

Occurs when an API call fails because the user's authentication has expired.

onAIAgentResult

Reports the processing result from an AI agent.

onRemoteUserSubscribedDataChannel

Indicates that you can start sending data channel messages.

onAudioDelayInfo

Reports audio delay information.

onLocalAudioCaptureStateChanged

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

onLocalVideoCaptureStateChanged

Occurs when the state of the local video capture device changes.

onRecordEvent

Reports events related to file recording.

onOccurWarning

Reports a warning.

onOccurError

Reports an error.

onPublishStreamByRtsUrlResult

Reports the result of publishing a stream using an RTS URL.

onStopPublishStreamByRtsUrlResult

Reports the result of stopping publishing a stream using an RTS URL.

onSubscribeStreamByRtsUrlResult

Reports the result of subscribing to a stream using an RTS URL.

onStopSubscribeStreamByRtsUrlResult

Reports the result of unsubscribing from a stream using an RTS URL.

onSubscribedRtsStreamBeyondLimit

Occurs when the number of pre-established RTS URL connections exceeds the limit.

onPauseRtsStreamResult

Reports the result of pausing a subscription to an RTS stream using the RTS user ID.

onResumeRtsStreamResult

Reports the result of resuming a subscription to an RTS stream using the RTS user ID.

onCapturedAudioFrame

Provides the captured raw audio data.

onProcessCapturedAudioFrame

Provides the audio data after 3A processing.

onPublishAudioFrame

Provides the audio data for publishing.

onPlaybackAudioFrame

Provides the audio data for playback.

onMixedAllAudioFrame

Provides the mixed audio data from both publishing and playback.

onRemoteUserAudioFrame

Provides the raw audio data from a subscribed remote user.

API

getInstance

Returns the singleton instance of AliRtcEngine.

public static getInstance(extras: string | null, context: common.Context): AliRtcEngine | undefined
Note
  • This is a synchronous call that returns a singleton. If the method returns undefined, it means the internal singleton is still being released. Try again later.

Parameters

Parameter

Type

Description

extras

string | null

A JSON string for configuring special SDK features, such as feature flags. Pass an empty string if no special configuration is needed.

context

common.Context

The app context.

Returns

Returns the singleton AliRtcEngine instance, or undefined if the instance is still being released.

destroyInstance

Destroys the AliRtcEngine instance.

public static destroyInstance(): void

getSDKVersion

Gets the current version number of the SDK.

public static getSDKVersion(): string
Note
  • You can call this method at any time.

Returns

A string representing the current SDK version number. For example, "7.10.0".

setH5CompatibleMode

Sets H5 compatible mode.

public static setH5CompatibleMode(enable: boolean): void
Note
  • You must call this method before creating an AliRtcEngine instance. You cannot change the H5 compatible mode after the instance is created.

Parameters

Parameter

Type

Description

enable

boolean

true: enables H5 compatible mode; false: enables traditional mode, incompatible with H5.

getH5CompatibleMode

Checks whether the H5 compatible mode is enabled.

public static getH5CompatibleMode(): boolean

Returns

A boolean value: true for H5 compatible mode, false for traditional mode.

setRtcEngineEventListener

Sets the event listener to receive callbacks for engine events.

public setRtcEngineEventListener(listener: AliRtcEngineEventListener | null) : void
Note
  • Avoid time-consuming operations in callback methods, as they can block the SDK's main thread and degrade performance.

Parameters

Parameter

Type

Description

listener

AliRtcEngineEventListener | null

The event listener that receives callbacks from the engine. Pass null to unregister the current listener.

getNativeHandle

Gets the native layer instance handle.

public getNativeHandle() : number
Note
  • Use this instance handle to build features in the native layer, such as listening for and writing back raw audio and video data.

Returns

number - The native layer's instance handle.

setChannelProfile

Sets the channel profile.

public setChannelProfile(channelProfile: AliRtcChannelProfile): number
Note
  • All users in the same channel must use the same channel profile.

Parameters

Parameter

Type

Description

channelProfile

AliRtcChannelProfile

Specifies the channel profile. See AliRtcChannelProfile for details.

Returns

0 indicates success, while a negative value indicates failure.

setClientRole

Sets the user role in a live streaming scenario.

public setClientRole(clientRole: AliRtcClientRole): number

Parameters

Parameter

Type

Description

clientRole

AliRtcClientRole

The user role. For details, see AliRtcClientRole.

Returns

Returns 0 on success or a negative value on failure.

getCurrentClientRole

Gets the current user role.

public getCurrentClientRole(): AliRtcClientRole

Returns

The current user role. For details, see AliRtcClientRole.

joinChannel

Allows a user to join a channel. Users in the same channel can call each other.

public joinChannel(authInfo: AliRtcEngineAuthInfo, userName: string) : number

Parameters

Parameter

Type

Description

authInfo

AliRtcEngineAuthInfo

Authentication information obtained from your App Server.

userName

string

A display name for the user. This is not the user ID.

Returns

A number, where 0 indicates success and a negative value indicates failure.

joinChannelWithToken

Joins a channel.

public joinChannelWithToken(token: string, channelId: string, userId: string, userName: string): number

Parameters

Parameter

Type

Description

token

string

The authentication token obtained from your app server.

channelId

string

The ID of the channel to join. This must match the channelId used to generate the token. This parameter is optional. If omitted, the channelId from the token is used by default.

userId

string

The user ID of the joining user. This must match the userId used to generate the token. This parameter is optional. If omitted, the userId from the token is used by default.

userName

string

The user's display name. This is not the user ID. This parameter is optional. If omitted, no user name is specified.

Returns

A number where 0 indicates success and a negative value indicates failure.

joinChannelWithChannelParam

Joins a channel.

public joinChannelWithChannelParam(token: string,  channelParam: AliRtcSDKChannelParam) : number

Parameters

Parameter

Type

Description

token

string

Authentication information from your application server.

channelParam

AliRtcSDKChannelParam

The channel parameters. For details, see AliRtcSDKChannelParam.

Returns

A number: 0 indicates success, and a negative value indicates failure.

joinAIChannel

Joins an AI channel.

public joinAIChannel(token: string, channelParam: AliRtcSDKChannelParam, agentParam: AliRtcSDKAIAgentParam) : number

Parameters

Parameter

Type

Description

token

string

Authentication information from your App Server.

channelParam

AliRtcSDKChannelParam

The channel parameters. See AliRtcSDKChannelParam for details.

agentParam

AliRtcSDKAIAgentParam

The parameters for the AI agent. See AliRtcSDKAIAgentParam for details.

Returns

Returns 0 on success, or a negative value on failure.

leaveChannel

Leaves the channel, ending the call.

public leaveChannel(): number

Returns

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

getCurrentConnectionStatus

Retrieves the current network connection status.

public getCurrentConnectionStatus(): AliRtcConnectionStatus

Returns

An AliRtcConnectionStatus enum value representing the current connection status.

isInCall

Checks if the user is in a channel.

public isInCall(): boolean

Returns

true if the user is in a channel; false otherwise.

refreshAuthInfo

Refreshes the authentication information.

public refreshAuthInfo(authInfo: AliRtcEngineAuthInfo): number

Parameters

Parameter

Type

Description

authInfo

AliRtcEngineAuthInfo

The authentication information.

Return value

0: Success. A negative value: Failure.

refreshAuthInfoWithToken

Refreshes authentication information.

public refreshAuthInfoWithToken(token: string): number

Parameters

Parameter

Type

Description

token

string

The authentication token. The channelid and userid must match those used when joining the channel.

Returns

Returns 0 on success, or a value less than 0 on failure.

isAudioOnlyMode

Checks if the session is in audio-only mode.

public isAudioOnlyMode(): boolean

Return value

true if the session is in audio-only mode; false otherwise.

publishLocalVideoStream

Enables or disables local video stream publishing.

public publishLocalVideoStream(enabled: boolean): number

Parameters

Parameter

Type

Description

enabled

boolean

Specifies whether to publish the local video stream: true to publish, false to stop.

Returns

Returns 0 on success, or a negative error code on failure.

isLocalVideoStreamPublished

Checks if the local video stream is published.

public isLocalVideoStreamPublished(): boolean

Returns

true if the local video stream is published; false otherwise.

publishLocalDualVideoStream

Publishes or unpublishes the secondary video stream.

public publishLocalDualVideoStream(enable: boolean): number

Parameters

Parameter

Type

Description

enable

boolean

Whether to publish the secondary video stream. true: Publishes the secondary video stream. false: Stops publishing the secondary video stream.

Return value

number - 0 indicates a successful call. A negative value indicates an error code.

isLocalDualVideoStreamPublished

Checks if the secondary video stream is published.

public isLocalDualVideoStreamPublished(): boolean

returns

boolean - true if the secondary video stream is published; false otherwise.

publishLocalAudioStream

Publishes or unpublishes the local audio stream.

public publishLocalAudioStream(enabled: boolean): number

Parameters

Parameter

Type

Description

enabled

boolean

Set to true to publish the local audio stream, or false to unpublish it.

Returns

number - 0 indicates that the method call was successful. A negative value indicates a failure, where the value is the error code.

isLocalAudioStreamPublished

Checks whether the local audio stream is published.

public isLocalAudioStreamPublished(): boolean

Returns

boolean - true indicates that the local audio stream is published; false otherwise.

publishLocalDualAudioStream

Publishes or unpublishes the secondary audio stream.

public publishLocalDualAudioStream(enabled: boolean): number

Parameters

Parameter

Type

Description

enabled

boolean

Whether to publish the secondary audio stream.

Returns

A number. 0 indicates the method call succeeded. A negative value is an error code.

isLocalDualAudioStreamPublished

Checks if the second audio stream is published.

public isLocalDualAudioStreamPublished(): boolean

Returns

boolean - true if the second audio stream is published; false otherwise.

setDefaultSubscribeAllRemoteAudioStreams

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

public setDefaultSubscribeAllRemoteAudioStreams(sub: boolean): number

Parameters

Parameter

Type

Description

sub

boolean

true: Subscribes to all remote audio streams. false: Does not subscribe to any remote audio streams.

Returns

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

setDefaultSubscribeAllRemoteVideoStreams

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

public setDefaultSubscribeAllRemoteVideoStreams(sub: boolean): number

Parameters

Parameter

Type

Description

sub

boolean

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

Returns

number - 0 on success; a value less than 0 on failure.

setRemoteVideoStreamType

Sets the video stream type (high stream or low stream) to receive from a remote user.

public setRemoteVideoStreamType(uid: string, streamType: AliRtcVideoStreamType): number

Parameters

Parameter

Type

Description

uid

string

The ID of the remote user.

streamType

AliRtcVideoStreamType

The video stream type to receive. For details, see AliRtcVideoStreamType.

Return value

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

setRemoteDefaultVideoStreamType

Sets the default video stream type for subscriptions to either the high stream or the low stream.

public setRemoteDefaultVideoStreamType(streamType: AliRtcVideoStreamType): number

Parameters

Parameter

Type

Description

streamType

AliRtcVideoStreamType

The default video stream type to subscribe to.

Returns

0 indicates success; any other value indicates failure.

subscribeAllRemoteAudioStreams

Subscribes to or unsubscribes from all remote audio streams.

public subscribeAllRemoteAudioStreams(sub: boolean): number

Parameters

Parameter

Type

Description

sub

boolean

true: Subscribes to all remote audio streams. false: Unsubscribes from all remote audio streams.

Return value

A number where 0 indicates success and a non-zero value indicates failure.

subscribeAllRemoteDualAudioStreams

Subscribes to or unsubscribes from all remote dual audio streams.

public subscribeAllRemoteDualAudioStreams(sub: boolean): number

Parameters

Parameter

Type

Description

sub

boolean

Whether to subscribe to all remote dual audio streams.

Returns

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

subscribeAllRemoteVideoStreams

Subscribes to or unsubscribes from all remote video streams.

public subscribeAllRemoteVideoStreams(sub: boolean): number

Parameters

Parameter

Type

Description

sub

boolean

true: Subscribes to remote video streams from all users. false: Unsubscribes from remote video streams from all users.

Returns

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

subscribeRemoteAudioStream

Subscribes to or unsubscribes from a remote user's microphone audio stream.

public subscribeRemoteAudioStream(uid: string, sub: boolean): number

Parameters

Parameter

Type

Description

uid

string

The ID of the remote user.

sub

boolean

Sets the subscription state for the user's audio stream. Set to true to subscribe or false to unsubscribe.

Returns

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

subscribeRemoteAudioStreamByTrack

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

public subscribeRemoteAudioStreamByTrack(uid: string, track: AliRtcAudioTrack, sub: boolean): number

Parameters

Parameter

Type

Description

uid

string

The remote user ID.

track

AliRtcAudioTrack

The audio stream type. AliRtcAudioTrackNo: An invalid parameter. This value is ignored. AliRtcAudioTrackMic: The microphone stream. AliRtcAudioTrackDual: The second audio stream. AliRtcAudioTrackBoth: Both the microphone stream and the second audio stream.

sub

boolean

Specifies whether to subscribe to the remote user's audio stream. true: Subscribe to the stream. false: Unsubscribe from the stream.

Returns

A number where 0 indicates success and a non-zero value indicates failure.

subscribeRemoteVideoStream

Subscribes to or unsubscribes from a remote video stream.

public subscribeRemoteVideoStream(uid: string, track: AliRtcVideoTrack, sub: boolean): number

Parameters

Parameter

Type

Description

uid

string

The ID of the remote user.

track

AliRtcVideoTrack

The video track to subscribe to.

sub

boolean

Sets whether to subscribe to the stream.

Returns

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

subscribeRemoteMediaStream

Stops or resumes a subscription to a remote audio/video stream.

public subscribeRemoteMediaStream(uid: string, videoTrack: AliRtcVideoTrack, subVideo: boolean, audioTrack: AliRtcAudioTrack, subAudio: boolean): number

Parameters

Parameter

Type

Description

uid

string

The remote user ID.

videoTrack

AliRtcVideoTrack

The type of the remote video stream.

subVideo

boolean

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

audioTrack

AliRtcAudioTrack

The type of the remote audio stream.

subAudio

boolean

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

Returns

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

subscribeRemoteDestChannelStream

Subscribes to a stream from a specified remote user in the target channel.

public subscribeRemoteDestChannelStream(channelId: string, uid: string, videoTrack: AliRtcVideoTrack, audioTrack: AliRtcAudioTrack, sub: boolean): number

Parameters

Parameter

Type

Description

channelId

string

The ID of the target channel.

uid

string

The ID of the remote user.

videoTrack

AliRtcVideoTrack

The type of video track. Use AliRtcVideoTrackNo to unsubscribe from all video tracks; this action ignores the sub parameter. Other options are AliRtcVideoTrackCamera for the camera track, AliRtcVideoTrackScreen for the screen sharing track, and AliRtcVideoTrackBoth for both tracks.

audioTrack

AliRtcAudioTrack

The type of audio track. Use AliRtcAudioTrackNo to unsubscribe from all audio tracks; this action ignores the sub parameter. Other options are AliRtcAudioTrackMic for the microphone track, AliRtcAudioTrackDual for the dual audio track, and AliRtcAudioTrackBoth for both tracks.

sub

boolean

true: Subscribe to the specified track(s). false: Unsubscribe from the specified track(s).

Returns

A number. 0 indicates the call was successful, while a non-zero value indicates failure.

setAudioProfile

Sets the audio profile and audio scenario.

public setAudioProfile(profile: AliRtcAudioProfile, scenario: AliRtcAudioScenario): number
Note
  • You must call this method before calling joinChannel.

Parameters

Parameter

Type

Description

profile

AliRtcAudioProfile

The audio profile, which specifies the audio capture and encoding mode. For details, see AliRtcAudioProfile.

scenario

AliRtcAudioScenario

The audio scenario. For details, see AliRtcAudioScenario.

Returns

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

SetAudioCapability

Sets the audio capability.

public SetAudioCapability(ability: AliRtcAudioCapability): number

Parameters

Parameter

Type

Description

ability

AliRtcAudioCapability

The audio capability to set.

Returns

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

startAudioCapture

Starts audio capture.

public startAudioCapture(): number

Returns

0 on success; a non-zero value indicates an error code.

stopAudioCapture

Stops audio capture.

public stopAudioCapture(): number

Return value

Returns 0 on success or an error code on failure.

startAudioPlayer

Starts the audio player.

public startAudioPlayer(): number

Return value

Returns 0 for success or a non-zero error code.

stopAudioPlayer

Stops audio playback.

public stopAudioPlayer(): number

Returns

0 indicates success; a non-zero value is an error code.

muteLocalMic

Mutes or unmutes the local audio stream.

public muteLocalMic(mute: boolean, mode:  AliRtcMuteLocalAudioMode): number
Note
  • When muted, the audio stream sends silent frames, but the capture and encoding modules remain active.

Parameters

Parameter

Type

Description

mute

boolean

Specifies whether to mute the local audio stream. true mutes the stream by sending silent frames; false unmutes it.

mode

AliRtcMuteLocalAudioMode

Specifies the mute mode. By default, the local microphone and all external audio inputs are muted.

Returns

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

setRecordingVolume

Sets the recording volume.

public setRecordingVolume(volume: number): number

Parameters

Parameter

Type

Description

volume

number

The recording volume. The valid range is [0, 400]. A value of 0 mutes the audio. Values greater than 100 amplify the volume, while values less than 100 reduce it.

Returns

number: 0 for success; a non-zero value for failure.

setPlayOutVolume

Sets the playout volume.

public setPlayOutVolume(volume: number): number

Parameters

Parameter

Type

Description

volume

number

The playout volume. The valid range is [0, 400], where 100 represents the original volume. A value of 0 mutes the audio. Values greater than 100 amplify the volume, and values less than 100 attenuate it.

Returns

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

setDefaultAudioRouteToSpeakerphone

Sets whether to route audio to the speakerphone by default.

public setDefaultAudioRouteToSpeakerphone(defaultToSpeakerphone: boolean): number

Parameters

Parameter

Type

Description

defaultToSpeakerphone

boolean

true: speakerphone mode (default). false: earpiece mode.

Returns

number - 0 on success; a negative value on failure.

enableSpeakerphone

Switches the audio output between the earpiece and the speakerphone.

public enableSpeakerphone(enable: boolean): number

Parameters

Parameter

Type

Description

enable

boolean

true for speakerphone mode; false for earpiece mode (default).

Returns

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

isSpeakerOn

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

public isSpeakerOn(): boolean

Returns

true if the audio output is the speaker; false otherwise.

setRemoteAudioVolume

Adjusts the playback volume of a specified remote user.

public setRemoteAudioVolume(uid: string, volume: number): number

Parameters

Parameter

Type

Description

uid

string

The remote user ID.

volume

number

The playback volume. The value ranges from 0 to 100, where 0 is mute and 100 is the original volume.

Returns

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

muteRemoteAudioPlaying

Stops or resumes playing a specified remote user's audio stream.

public muteRemoteAudioPlaying(uid: string, mute: boolean): number
Note
  • This method does not affect stream pulling or decoding. You can call this method before or after joining a channel.

Parameters

Parameter

Type

Description

uid

string

The remote user ID.

mute

boolean

Specifies whether to stop or resume playing the audio stream.

Returns

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

muteAllRemoteAudioPlaying

Mutes or unmutes all remote audio streams.

public muteAllRemoteAudioPlaying(mute: boolean): number
Note
  • This method does not affect stream pulling or decoding. You can call this method either before or after joining a channel.

Parameters

Parameter

Type

Description

mute

boolean

Specifies whether to mute (true) or unmute (false) all remote audio streams.

Return value

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

enableAudioVolumeIndication

Enables audio volume indication and sets the interval and smoothing factor for the volume callback.

public enableAudioVolumeIndication(interval: number, smooth: number, reportVad: number): number
Note
  • After you call this method, the SDK reports the audio volume and the active speaker's UID through the AliRtcEngineEventListener#onAudioVolumeCallback and AliRtcEngineEventListener#onActiveSpeaker callbacks, respectively.

Parameters

Parameter

Type

Description

interval

number

The time interval in milliseconds (ms) for the volume callback. The minimum value is 10 ms. The recommended range is 300–500 ms. A value of 0 or less disables both volume indication and speaker indication.

smooth

number

The smoothing factor. A larger value results in a smoother but less responsive volume indication. The value range is [0, 9]. The recommended value is 3.

reportVad

number

Specifies whether to enable voice activity detection. 1: Enable. 0: Disable.

Returns

0 indicates success, and a negative value indicates failure.

enableEarBack

Enables in-ear monitoring.

public enableEarBack(enable: boolean): number
Note
  • This feature is supported on all devices. For the best experience and minimal latency, use wired headphones.

Parameters

Parameter

Type

Description

enable

boolean

Set to true to enable in-ear monitoring, or false (the default) to disable it.

Returns

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

setEarBackVolume

Sets the ear back volume.

public setEarBackVolume(volume: number): number

Parameters

Parameter

Type

Description

volume

number

The volume level. The value must be within the range [0, 100], and the default is 100.

Returns

Returns a number, where 0 indicates success and any non-zero value indicates failure.

startAudioCaptureTest

Tests the audio capture device before a call.

public startAudioCaptureTest(): number
Note
  • Call this API before joining a call.

Returns

A number is returned, where 0 indicates success and any non-zero value indicates failure.

stopAudioCaptureTest

Stops the audio capture test.

public stopAudioCaptureTest(): number
Note
  • This method can only be called before joining a meeting.

Returns

0 indicates success; a non-zero value indicates an error code.

playAudioFileTest

Plays an audio file for testing.

public playAudioFileTest(filePath: string): number
Note
  • This method can only be called before joining a meeting.

Parameters

Parameter

Type

Description

filePath

string

The path to the audio file.

Returns

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

stopAudioFileTest

Stops the audio file playback test.

public stopAudioFileTest(): number
Note
  • Call this method only before joining a meeting.

Returns

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

setLocalViewConfig

Sets the local preview view.

public setLocalViewConfig(canvas: AliRtcVideoCanvas, xComponentController: AliRtcXComponentController | null, track: AliRtcVideoTrack): number

Parameters

Parameter

Type

Description

canvas

AliRtcVideoCanvas

The properties for displaying the local video.

xComponentController

AliRtcXComponentController | null

The controller bound to the XComponent view.

track

AliRtcVideoTrack

The video track.

startPreview

Starts the local video preview.

public startPreview(): number
Note
  • You must call setLocalViewConfig to set the view; otherwise, the preview cannot be started. Calling this method before joinChannel automatically enables the camera.

Returns

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

stopPreview

Stops the local video preview.

public stopPreview(): number
Note
  • The leaveChannel method automatically stops the local video preview and, if you are not publishing a camera stream, also turns off the camera.

Returns

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

setCameraCaptureConfiguration

Sets the camera capture configuration.

public setCameraCaptureConfiguration(cameraCaptureConfiguration: AliRtcCameraCaptureConfiguration): number
Note
  • Call this method before the camera is enabled, for example, before calling startPreview or joinChannel.

Parameters

Parameter

Type

Description

cameraCaptureConfiguration

AliRtcCameraCaptureConfiguration

The camera capture configuration includes the preference and cameraDirection properties. The preference property sets the capture preference: AliRtcCaptureOutputPreferencePreview enables high-definition preview and prioritizes preview quality; AliRtcCaptureOutputPreferencePerformance selects a capture resolution closest to the stream publishing resolution to prioritize device performance; AliRtcCaptureOutputPreferenceAuto automatically adjusts the capture resolution. The cameraDirection property sets the camera direction to either front or rear.

Returns

Returns a number where 0 indicates success and a non-zero value indicates failure.

enableLocalVideo

Enables or disables local video capture.

public enableLocalVideo(enabled: boolean): number
Note
  • Local video capture is enabled by default. To check if a user has enabled or disabled local video capture, listen for the AliRtcEngineEventListener#onUserVideoEnabled callback.

Parameters

Parameter

Type

Description

enabled

boolean

Whether to enable local video capture. true: Enables local video capture. false: Disables local video capture.

Return value

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

enableVideoCapture

Enables or disables local camera capture.

public enableVideoCapture(enabled: boolean): number
Note
  • When local camera capture is disabled, the SDK sends black video frames. The encoding and sending modules remain active.

Parameters

Parameter

Type

Description

enabled

boolean

Set to true to enable local camera capture, or false to disable it.

Returns

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

muteLocalCamera

Stops or resumes sending the local video stream.

public muteLocalCamera(mute: boolean, track: AliRtcVideoTrack): number
Note
  • This method only controls whether the specified video stream sends black frames. It does not stop video capture or data transmission.

Parameters

Parameter

Type

Description

mute

boolean

Whether to mute the video stream. true: Mutes the stream by sending black frames. false: Unmutes the stream and resumes normal video transmission.

track

AliRtcVideoTrack

The video track to mute. Only AliRtcVideoTrackCamera is supported.

Return value

A number where 0 indicates success and a non-zero value indicates failure.

isCameraOn

Checks if the camera is on.

public isCameraOn(): boolean
Note
  • Checks the current state of the camera.

Return value

true if the camera is on; false if it is off.

muteAllRemoteVideoRendering

Stops or resumes rendering all remote video tracks.

public muteAllRemoteVideoRendering(mute: boolean): number
Note
  • This method does not affect stream subscription or decoding. You can call this method either before or after you join a channel.

Parameters

Parameter

Type

Description

mute

boolean

true: Stop rendering. Remote videos are displayed as a black frame. false: Resume rendering.

Returns

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

setVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

public setVideoEncoderConfiguration(config: AliRtcVideoEncoderConfiguration): number
Note
  • You can call this method either before or after joining a channel. If you only need to set the video encoder configuration once per session, we recommend calling this method before you join a channel.

Parameters

Parameter

Type

Description

config

AliRtcVideoEncoderConfiguration

The predefined video encoder configuration. For details, see AliRtcVideoEncoderConfiguration.

Return value

0 indicates success; a negative value indicates failure.

setVideoDecoderConfiguration

Sets the video decoder configuration for the camera stream.

public setVideoDecoderConfiguration(config: AliRtcVideoDecoderConfiguration): void
Note
  • Call this method before joining a channel.

Parameters

Parameter

Type

Description

config

AliRtcVideoDecoderConfiguration

The video decoder configuration. For details, see AliRtcVideoDecoderConfiguration.

setVideoMirrorMode

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

public setVideoMirrorMode(mirrorMode: AliRtcVideoPipelineMirrorMode): number
Note
  • You can call this API before or after joining a channel. The SDK saves this setting and applies it to the preview and encoding pipeline. This setting overrides the mirror settings in setLocalViewConfig and setVideoEncoderConfiguration. To avoid conflicts, we recommend using only one method to configure the mirror mode.

Parameters

Parameter

Type

Description

mirrorMode

AliRtcVideoPipelineMirrorMode

The mirror mode to apply.

Returns

number - 0 on success; a negative value on failure.

setCapturePipelineScaleMode

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

public setCapturePipelineScaleMode(mode: AliRtcCapturePipelineScaleMode): void
Note
  • Call this method before enabling the camera, for example, before calling startPreview or joinChannel.

Parameters

Parameter

Type

Description

mode

AliRtcCapturePipelineScaleMode

Specifies when scaling occurs in the capture pipeline. By default, scaling is applied immediately after capture.

setRemoteViewConfig

Configures the remote video view.

public setRemoteViewConfig(canvas: AliRtcVideoCanvas, xComponentController: AliRtcXComponentController | null, uid: string, track: AliRtcVideoTrack): number
Note
  • You can call this method to switch the view both before and after joining a channel. If either the canvas object or its view property is set to null, video rendering for the specified track stops.

Parameters

Parameter

Type

Description

canvas

AliRtcVideoCanvas

The canvas object for rendering the remote video.

xComponentController

AliRtcXComponentController | null

The controller bound to the XComponent view.

uid

string

The remote user ID.

track

AliRtcVideoTrack

The video track type. Only AliRtcVideoTrackCamera and AliRtcVideoTrackScreen are supported.

Returns

Returns 0 for success or a negative value for failure.

switchCamera

Switches between the front and rear cameras.

public switchCamera(): number

Return value

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

getCurrentCameraDirection

Gets the current camera direction (front or back).

public getCurrentCameraDirection(): AliRtcCameraDirection
Note
  • AliRtcCameraDirectionFront: front. AliRtcCameraDirectionBack: back. AliRtcCameraDirectionInvalid: invalid.

Return value

The camera direction as an AliRtcCameraDirection enum.

setCameraZoom

Sets the camera zoom ratio.

public setCameraZoom(zoom: number): number

Parameters

Parameter

Type

Description

zoom

number

The camera zoom ratio.

Returns

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

getCameraMaxZoomFactor

Gets the maximum zoom factor of the camera.

public getCameraMaxZoomFactor(): number

Return value

number - The maximum zoom factor of the camera.

getCurrentZoom

Returns the camera zoom ratio.

public getCurrentZoom(): number

Returns

number - The camera zoom ratio.

setExposure

Sets the camera exposure.

public setExposure(exposure: number): number

Parameters

Parameter

Type

Description

exposure

number

The exposure value.

Returns

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

getCurrentExposure

Gets the current camera exposure.

public getCurrentExposure(): number

Returns

number - The current camera exposure.

getMinExposure

Gets the minimum exposure of the camera.

public getMinExposure(): number

Returns

number - The minimum exposure.

getMaxExposure

Gets the maximum camera exposure.

public getMaxExposure(): number

Returns

number - The maximum exposure.

setCameraFlash

Enables or disables the camera flash.

public setCameraFlash(flash: boolean): number

Parameters

Parameter

Type

Description

flash

boolean

Whether to enable the camera flash. true: Enable the flash. false: Disable the flash.

Return value

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

Manual focus support

Checks if the camera supports manual focus.

public isCameraFocusPointSupported(): boolean

Return value

A boolean value: true if the camera supports manual focus; false otherwise.

isCameraExposurePointSupported

Checks whether the camera supports setting an exposure point.

public isCameraExposurePointSupported(): boolean

Returns

true if the camera supports setting an exposure point; false otherwise.

setCameraFocusPoint

Sets the manual focus point for the camera.

public setCameraFocusPoint(x: number, y: number): number

Parameters

Parameter

Type

Description

x

number

The x-coordinate of the focus point.

y

number

The y-coordinate of the focus point.

Returns

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

setCameraExposurePoint

Sets the camera exposure point.

public setCameraExposurePoint(x: number, y: number): number

Parameters

Parameter

Type

Description

x

number

The x-coordinate of the exposure point.

y

number

The y-coordinate of the exposure point.

Returns

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

getVideoCodecType

Gets the video codec type.

public getVideoCodecType(codeKind: AliRtcVideoCodecKindType): AliRtcVideoFormat

Parameters

Parameter

Type

Description

codeKind

AliRtcVideoCodecKindType

Specifies whether the operation is for encoding or decoding.

Returns

An AliRtcVideoFormat enum representing the video codec type.

getCurrentEncoderManufacturer

Gets the current encoder type. Returns an invalid type if stream publishing has not started.

public getCurrentEncoderManufacturer(track: AliRtcVideoTrack): AliRtcVideoCodecManufacturer

Parameters

Parameter

Type

Description

track

AliRtcVideoTrack

The video track.

Return value

An AliRtcVideoCodecManufacturer enum representing the encoder type.

snapshotVideo

Takes a snapshot of a video stream.

public snapshotVideo(userId: string, trackType: AliRtcVideoTrack): number
Note
  • This is an asynchronous method. The snapshot is returned in the AliRtcEngineEventListener#onSnapshotCompleted callback.

Parameters

Parameter

Type

Description

userId

string

The user ID. To specify the local user, pass an empty string ("").

trackType

AliRtcVideoTrack

The video stream type. Valid values are AliRtcVideoTrackCamera and AliRtcVideoTrackScreen.

Returns

Returns 0 if the method call is successful, or a value less than 0 if the call fails. A successful call only indicates that the request was initiated. The result of the snapshot operation is returned in the AliRtcEngineEventListener#onSnapshotCompleted callback.

setScreenShareEncoderConfiguration

Sets the encoder configuration for the screen share.

public setScreenShareEncoderConfiguration(config: AliRtcScreenShareEncoderConfiguration): number
Note
  • You can call this method before or after joining a channel. If you only need to set the screen share encoder configuration once per session, call the method before joining the channel.

Parameters

Parameter

Type

Description

config

AliRtcScreenShareEncoderConfiguration

The screen share encoder configuration.

startScreenShare

Starts screen sharing.

public startScreenShare(mode: AliRtcScreenShareMode): number

Parameters

Parameter

Type

Description

mode

AliRtcScreenShareMode

Specifies the screen sharing mode.

stopScreenShare

Stops screen sharing.

public stopScreenShare(): number

Returns

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

isScreenSharePublished

Checks if the screen sharing stream is published.

public isScreenSharePublished(): boolean
Note
  • By default, the SDK does not publish the screen sharing stream. To publish the stream, call startScreenShare.

Returns

boolean - true: Published; false: Not published.

registerAudioFrameObserver

Registers an audio data callback.

public registerAudioFrameObserver(observer: AliRtcEngineAudioFrameListener | null): void
Note
  • You must call enableAudioFrameObserver to enable callbacks for a specific AliRtcAudioSource.

Parameters

Parameter

Type

Description

observer

AliRtcEngineAudioFrameListener | null

The observer for audio data callbacks. Pass null to stop receiving callbacks.

enableAudioFrameObserver

Subscribes to raw audio data.

public enableAudioFrameObserver(enable: boolean, audioSource: AliRtcAudioSource, config: AliRtcAudioFrameObserverConfig | null): number
Note
  • This method supports only the read-only mode.

Parameters

Parameter

Type

Description

enable

boolean

Specifies whether to enable the data callback. true: Enable. false: Disable.

audioSource

AliRtcAudioSource

The raw audio data source. For details, see AliRtcAudioSource.

config

AliRtcAudioFrameObserverConfig | null

The configuration for the callback. For details, see AliRtcAudioFrameObserverConfig. If set to null, the SDK applies the default settings: a 48,000 Hz sample rate, a single channel, and read-only mode.

Returns

A number. 0 indicates success.

addExternalAudioStream

Adds an external audio stream.

public addExternalAudioStream(config: AliRtcExternalAudioStreamConfig): number

Parameters

Parameter

Type

Description

config

AliRtcExternalAudioStreamConfig

The external audio stream configuration. For details, see AliRtcExternalAudioStreamConfig.

Returns

A number. A value greater than 0 indicates success and is the external audio stream ID. A value less than 0 indicates failure.

pushExternalAudioStreamRawData

Pushes external audio data.

public pushExternalAudioStreamRawData(streamId: number, audioFrame: AliRtcAudioFrame): number
Note
  • To ensure audio continuity, the SDK internally creates a buffer for incoming audio data. For example, if you are sending 10 ms data frames and this method returns AliRtcErrorCode#ERR_SDK_AUDIO_INPUT_BUFFER_FULL, the internal buffer is full. Wait for 20 ms before resubmitting the current data frame.

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

audioFrame

AliRtcAudioFrame

The external raw audio data.

Returns

A number. 0 indicates success; a value less than 0 indicates failure. If the method returns AliRtcErrorCode.ERR_SDK_AUDIO_INPUT_BUFFER_FULL, you must wait for a period equal to the data submission interval before resubmitting the data frame.

setExternalAudioStreamPlayoutVolume

Sets the playout volume for an external audio stream.

public setExternalAudioStreamPlayoutVolume(streamId: number, volume: number): number

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

volume

number

The playout volume. The valid range is [0, 100].

Returns

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

getExternalAudioStreamPlayoutVolume

Gets the playout volume of the external audio stream.

public getExternalAudioStreamPlayoutVolume(streamId: number): number

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

Returns

The playout volume (0–100). A negative value indicates failure.

setExternalAudioStreamPublishVolume

Sets the publish volume for an external audio stream.

public setExternalAudioStreamPublishVolume(streamId: number, volume: number): number

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

volume

number

The volume level, ranging from 0 to 100.

Returns

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

getExternalAudioStreamPublishVolume

Gets the publish volume for an external audio stream.

public getExternalAudioStreamPublishVolume(streamId: number): number

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

Returns

The publish volume, a number in the range [0, 100]. A negative value indicates failure.

removeExternalAudioStream

Removes an external audio stream.

public removeExternalAudioStream(streamId: number): number

Parameters

Parameter

Type

Description

streamId

number

The external audio stream ID.

Returns

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

setExternalVideoSource

Enables an external video source.

setExternalVideoSource(enable: boolean, streamType: AliRtcVideoTrack, renderMode: AliRtcRenderMode): void

Parameters

Parameter

Type

Description

enable

boolean

Controls whether to enable the external video source. Set this to true to enable it, or false to disable it.

streamType

AliRtcVideoTrack

AliRtcVideoTrackCamera: The external video is sent through the camera stream channel. If camera capture is active, setting enable to true replaces the camera stream with the external source. AliRtcVideoTrackScreen: The external video is sent through the screen stream channel. If screen sharing is active, setting enable to true replaces the screen stream with the external source.

renderMode

AliRtcRenderMode

The render mode to use when the source video's aspect ratio differs from that of the publishing profile. For details, see AliRtcRenderMode. AliRtcRenderModeAuto (Default): Maintains the source video's aspect ratio, scaling it to fit within the publishing dimensions. Note that to preserve the original aspect ratio and content integrity, the actual publishing resolution may differ from the configured resolution. AliRtcRenderModeStretch: Stretches the input video to match the publishing dimensions, which may cause image distortion. AliRtcRenderModeFill: Preserves the aspect ratio by scaling the video to fit the publishing dimensions and adding black bars (letterboxing). AliRtcRenderModeCrop: Crops the video to match the publishing aspect ratio, which may remove parts of the original content.

Return value

This method does not return a value.

pushExternalVideoFrame

Pushes an external video frame.

pushExternalVideoFrame(videoFrame: AliRtcVideoFrame, streamType: AliRtcVideoTrack): number
Note
  • If this method returns AliRtcErrVideoBufferFull, the buffer is full. Wait before pushing the next frame.

Parameters

Parameter

Type

Description

videoFrame

AliRtcVideoFrame

The video frame to push. For details, see AliRtcVideoFrame.

streamType

AliRtcVideoTrack

The stream type. For details, see AliRtcVideoTrack. Use AliRtcVideoTrackCamera for the camera stream or AliRtcVideoTrackScreen for the screen stream.

Returns

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

setExternalImageData

Inputs external video data.

setExternalImageData(rawData: AliRtcVideoFrame, streamType: AliRtcVideoTrack): number

Parameters

Parameter

Type

Description

rawData

AliRtcVideoFrame

The frame data. See AliRtcVideoFrame for details.

streamType

AliRtcVideoTrack

The stream type. For details, see AliRtcVideoTrack. Set this to AliRtcVideoTrackCamera to send data through the camera stream channel, or AliRtcVideoTrackScreen to send data through the screen stream channel.

Returns

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

setAudioEffectPitchValue

Sets the pitch of the audio effect.

public setAudioEffectPitchValue(value: number): number
Note
  • You can call this method either before or after joining a channel.

Parameters

Parameter

Type

Description

value

number

The pitch, ranging from 0.5 to 2.0. The default value is 1.0, which means no change to the pitch. Values less than 1.0 lower the pitch, and values greater than 1.0 raise the pitch.

Returns

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

setAudioEffectVoiceChangerMode

Sets the voice changer mode.

public setAudioEffectVoiceChangerMode(mode: AliRtcAudioEffectVoiceChangerMode): number
Note
  • Call this method before joining or while in a channel.

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectVoiceChangerMode

Specifies the voice changer mode. For supported values, see AliRtcAudioEffectVoiceChangerMode.

Returns

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

setAudioEffectReverbMode

Sets the audio effect reverb mode.

public setAudioEffectReverbMode(mode: AliRtcAudioEffectReverbMode): number
Note
  • Call this method before or after joining a channel.

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectReverbMode

The reverb mode. See AliRtcAudioEffectReverbMode for available modes.

Returns

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

setAudioEffectBeautifyMode

Sets the audio effect beautify mode.

public setAudioEffectBeautifyMode(mode: AliRtcAudioEffectBeautifyMode): number
Note
  • You can call this method before or after joining a channel.

Parameters

Parameter

Type

Description

mode

AliRtcAudioEffectBeautifyMode

The audio effect beautify mode. For supported values, see AliRtcAudioEffectBeautifyMode.

Returns

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

setAudioEffectReverbParamType

Sets the reverb effect type.

public setAudioEffectReverbParamType(type: AliRtcAudioEffectReverbParamType, value: number): number
Note
  • Call this method after setAudioEffectReverbMode.

Parameters

Parameter

Type

Description

type

AliRtcAudioEffectReverbParamType

The reverb effect type. See AliRtcAudioEffectReverbParamType for details.

value

number

The reverb parameter value. See AliRtcAudioEffectReverbParamType for the value range of each reverb effect type.

Returns

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

setAudioEffectEqualizationParam

Sets the gain for a specific band of the audio equalizer.

public setAudioEffectEqualizationParam(bandIndex: AliRtcAudioEffectEqualizationBandFrequency, gain: number): number
Note
  • This method must be called after setAudioEffectBeautifyMode.

Parameters

Parameter

Type

Description

bandIndex

AliRtcAudioEffectEqualizationBandFrequency

The band index. Value range: [0, 9]. Center frequencies: [31, 62, 125, 250, 500, 1000, 2000, 4000, 8000, 16000] Hz.

gain

number

The gain in decibels (dB). Value range: [-15, 15]. Default: 0.

Returns

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

startAudioAccompany

Starts audio accompaniment mixing.

public startAudioAccompany(fileName: string, config: AliRtcAudioAccompanyConfig): number
Note
  • This is an asynchronous method. Use the AliRtcEngineEventListener#onAudioAccompanyStateChanged callback to monitor the player state.

Parameters

Parameter

Type

Description

fileName

string

Path to the accompaniment file.

config

AliRtcAudioAccompanyConfig

Configuration for accompaniment playback.

Return value

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

stopAudioAccompany

Stops accompaniment mixing.

public stopAudioAccompany(): number

Returns

0 indicates success; a non-zero value is an error code.

setAudioAccompanyVolume

Sets the audio accompaniment volume.

public setAudioAccompanyVolume(volume: number): number
Note
  • This method sets both the local playback volume and the publishing volume of the audio accompaniment. This change takes effect only after you call startAudioAccompany.

Parameters

Parameter

Type

Description

volume

number

The audio accompaniment volume. The value ranges from 0 to 100.

Return value

0 indicates success, and a non-zero value indicates an error code.

setAudioAccompanyPublishVolume

Sets the publish volume of the audio accompaniment.

public setAudioAccompanyPublishVolume(volume: number): number
Note
  • This setting takes effect only after you call startAudioAccompany.

Parameters

Parameter

Type

Description

volume

number

The publish volume of the audio accompaniment. The value range is [0, 100].

Returns

number - 0 indicates success; a non-zero value is an error code.

getAudioAccompanyPublishVolume

Gets the publishing volume of the audio accompaniment.

public getAudioAccompanyPublishVolume(): number

Returns

Returns the publishing volume (0-100) on success, or an error code on failure.

setAudioAccompanyPlayOutVolume

Sets the local playback volume of audio accompaniment.

public setAudioAccompanyPlayOutVolume(volume: number): number
Note
  • Call this method after startAudioAccompany for the setting to take effect.

Parameters

Parameter

Type

Description

volume

number

The local playback volume of audio accompaniment. The value range is [0, 100].

Returns

number, where 0 indicates success and a non-zero value is an error code.

getAudioAccompanyPlayOutVolume

Gets the local playback volume of the accompaniment.

public getAudioAccompanyPlayOutVolume(): number

Returns

A number indicating the local playback volume. A value in the range of [0, 100] indicates success; any other value is an error code.

pauseAudioAccompany

Pauses the audio accompaniment.

public pauseAudioAccompany(): number

Return value

0 for success; a non-zero value indicates an error code.

resumeAudioAccompany

Resumes the audio accompaniment.

public resumeAudioAccompany(): number

Return value

0 means success. Any other value is an error code.

getAudioAccompanyDuration

Returns the duration of the accompaniment file in milliseconds.

public getAudioAccompanyDuration(): number

Return value

A non-negative value indicates the duration of the accompaniment file; a negative value is an error code.

getAudioAccompanyCurrentPosition

Gets the current playback position of the accompaniment file, in milliseconds.

public getAudioAccompanyCurrentPosition(): number

Returns

The return value is a number. ≥0: The current playback position. <0: An error code.

setAudioAccompanyPosition

Sets the playback position of the accompaniment file.

public setAudioAccompanyPosition(pos: number): number

Parameters

Parameter

Type

Description

pos

number

Playback position in milliseconds.

Returns

Returns 0 for success; any non-zero value indicates an error code.

preloadAudioEffect

Preloads an audio effect file.

public preloadAudioEffect(soundId: number, filePath: string): number
Note
  • Audio effect APIs are synchronous interfaces. We recommend using local files.

Parameters

Parameter

Type

Description

soundId

number

The ID you assign to the audio effect file.

filePath

string

The path to the audio effect file. You can specify a local file path or a network URL.

Return value

A number. 0 indicates success, and any non-zero value indicates failure.

unloadAudioEffect

Unloads a preloaded audio effect file.

public unloadAudioEffect(soundId: number): number
Note
  • The soundId must match the ID you passed to preloadAudioEffect.

Parameters

Parameter

Type

Description

soundId

number

The unique ID you assigned to the audio effect file.

Returns

A number: 0 for success, or a non-zero value for failure.

playAudioEffect

Plays an audio effect.

public playAudioEffect(soundId: number, filePath: string, config: AliRtcAudioEffectConfig): number
Note
  • To play multiple audio effect files simultaneously, call this method multiple times with different soundId and filePath values. The SDK triggers the AliRtcEngineEventListener#onAudioEffectFinished callback after an audio effect finishes playing.

Parameters

Parameter

Type

Description

soundId

number

The unique ID of the audio effect file. This ID must be unique for each effect. If you preloaded the audio effect using preloadAudioEffect, this soundId must match the ID used in that call.

filePath

string

The audio effect file path. This can be a local file or a network URL.

config

AliRtcAudioEffectConfig

The audio effect playback configuration.

Returns

0 indicates success. Any other value indicates failure.

pauseAudioEffect

Pauses the specified audio effect.

public pauseAudioEffect(soundId: number):number

Parameters

Parameter

Type

Description

soundId

number

The ID of the audio effect.

Return value

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

pauseAllAudioEffects

Pauses all audio effects.

public pauseAllAudioEffects(): number

Return description

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

resumeAudioEffect

Resumes the specified audio effect.

public resumeAudioEffect(soundId: number): number

Parameters

Parameter

Type

Description

soundId

number

The ID of the audio effect.

Returns

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

resumeAllAudioEffects

Resumes all paused audio effects.

public resumeAllAudioEffects (): number

Returns

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

stopAudioEffect

Stops playing an audio effect.

public stopAudioEffect(soundId: number): number

Parameters

Parameter

Type

Description

soundId

number

The unique ID of the audio effect file. If you preloaded the audio effect file using preloadAudioEffect, this soundId must match the one provided in that call.

Returns

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

stopAllAudioEffects

Stops all audio effects.

public stopAllAudioEffects(): number

Returns

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

setAudioEffectPublishVolume

Sets the publishing volume of a specified audio effect.

public setAudioEffectPublishVolume(soundId: number, volume: number): number
Note
  • This method must be called after playAudioEffect.

Parameters

Parameter

Type

Description

soundId

number

The ID you assign to the audio effect.

volume

number

The publishing volume of the audio effect. The value ranges from 0 to 100, and the default is 50.

Returns

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

getAudioEffectPublishVolume

Gets the publishing volume of a specified sound effect.

public getAudioEffectPublishVolume(soundId: number): number
Note
  • You must call this method after calling playAudioEffect. The valid volume range is [0, 100].

Parameters

Parameter

Type

Description

soundId

number

The ID you assign to the sound effect file.

Return value

A number representing the publishing volume for the sound effect. The valid range is [0, 100]. A value outside this range indicates an error.

setAudioEffectPlayOutVolume

Sets the local playout volume of an audio effect.

public setAudioEffectPlayOutVolume(soundId: number, volume: number): number
Note
  • You must call this method after playAudioEffect.

Parameters

Parameter

Type

Description

soundId

number

The ID of the audio effect.

volume

number

The local playout volume of the audio effect. The value ranges from 0 to 100. The default value is 50.

Returns

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

getAudioEffectPlayOutVolume

Retrieves the local playout volume of an audio effect.

public getAudioEffectPlayOutVolume(soundId: number): number
Note
  • The local playout volume ranges from 0 to 100. You must call this method after playAudioEffect.

Parameters

Parameter

Type

Description

soundId

number

The user-assigned ID for the audio effect file.

Return value

number - The local playout volume, with a range of 0 to 100. Any other value indicates an error.

setAllAudioEffectsPublishVolume

Sets the publish volume for all sound effects.

public setAllAudioEffectsPublishVolume(volume: number): number

Parameters

Parameter

Type

Description

volume

number

The publish volume for all sound effects. The value ranges from 0 to 100. The default value is 50.

Returns

setAllAudioEffectsPlayoutVolume

Sets the local playout volume for all audio effects.

public setAllAudioEffectsPlayoutVolume(soundId: number): number

Parameters

Parameter

Type

Description

soundId

number

The local playout volume. The value ranges from 0 to 100, and the default is 50.

Returns

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

enableSEIVideoStream

Enables or disables the SEI video stream. If enabled, the stream uses a 16x16 black frame at 20 fps.

public enableSEIVideoStream(enabled: boolean): number

Parameters

Parameter

Type

Description

enabled

boolean

Whether to enable the SEI video stream. true: Enable. false: Disable.

Return value

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

sendMediaExtensionMsg

Sends a media extension message.

public sendMediaExtensionMsg(message: ArrayBuffer, repeatCount: number, delay: number, isKeyFrame: boolean): number
Note
  • This SDK lets you send and receive media extension messages. On the receiver side, you can handle incoming messages by listening for the AliRtcEngineEventListener#onMediaExtensionMsgReceived callback. This feature is useful for passing a timestamp to calculate end-to-end network latency, data synchronization with other services, or embedding descriptive information. You can send a payload of up to 4 KB, which is ideal for small amounts of data like JSON or plain strings. This feature uses the SEI extension protocol.

Parameters

Parameter

Type

Description

message

ArrayBuffer

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

repeatCount

number

Specifies how many times to repeat the message. This provides redundancy to compensate for network packet loss. A value of -1 sends the message indefinitely.

delay

number

The minimum delay in milliseconds after the API call before the message is sent.

isKeyFrame

boolean

Specifies whether to attach the message only to keyframes. true: Attach the message only to keyframes. false: Attach the message to all frames.

Return value

number - 0: success; <0: failure

sendMediaExtensionMsgEx

Sends a media extension message.

public sendMediaExtensionMsgEx(message: ArrayBuffer, repeatCount: number, delay: number, isKeyFrame: boolean, payloadType: number): number

Parameters

Parameter

Type

Description

message

ArrayBuffer

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

repeatCount

number

The repeat count, which provides redundancy to prevent message loss due to packet loss. A value of -1 sends the message indefinitely.

delay

number

The minimum delay in milliseconds to wait after the API call before sending the message.

isKeyFrame

boolean

Whether to attach the message only to a key frame. true: Attach only to a key frame. false: Attach to all frames.

payloadType

number

The payload type. The valid values are 5 or any integer in the range [100, 254]. A value of 5 is equivalent to calling the sendMediaExtensionMsg method.

Returns

0 on success; a negative value on failure.

sendDataChannelMsg

Sends a data message.

public sendDataChannelMsg(controlMsg: AliRtcDataChannelMsg): number
Note

The ARTC DataChannel feature relies on the publishing client to publish an audio or video stream. Ensure that an audio or video stream is being published.

The maximum bitrate is 30 KB/s. The data channel can send up to 60 data packets per second, and each packet can be a maximum of 1 KB.

Parameters

Parameter

Type

Description

controlMsg

AliRtcDataChannelMsg

The message content.

Returns

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

startRecord

Starts a file recording.

public startRecord(recordType: AliRtcRecordType,
    recordFormat: AliRtcRecordFormat,
    filePath: string,
    audioConfig: AliRtcRecordAudioConfig | undefined,
    videoConfig: AliRtcRecordVideoConfig | undefined): boolean

Parameters

Parameter

Type

Description

recordType

AliRtcRecordType

The recording type.

recordFormat

AliRtcRecordFormat

The recording file format. This parameter is ignored when recordType is AliRtcRecordTypeVideo.

filePath

string

The file path for the recording.

audioConfig

AliRtcRecordAudioConfig | undefined

The audio configuration.

videoConfig

AliRtcRecordVideoConfig | undefined

The video configuration.

Returns

Returns true if the method call is successful; false otherwise.

stopRecord

Stops recording to a file.

public stopRecord(): void

startPublishLiveStream

Starts server-side live streaming.

public startPublishLiveStream(streamURL: string, params: AliRtcLiveTranscodingParam) : number
Note
  • This method processes a real-time audio and video stream using live transcoding and audio mixing, converts it to a standard live stream, and publishes it to a CDN provider.

Parameters

Parameter

Type

Description

streamURL

string

The destination stream URL.

params

AliRtcLiveTranscodingParam

The parameters for live transcoding.

Returns

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

updatePublishLiveStream

Updates the parameters for an ongoing bypass live stream.

public updatePublishLiveStream(streamURL: string, params: AliRtcLiveTranscodingParam) : number
Note
  • The SDK lets you update the parameters for bypass live streaming in real time.

Parameters

Parameter

Type

Description

streamURL

string

The stream publishing URL.

params

AliRtcLiveTranscodingParam

The stream publishing parameters. For more information, see AliRtcLiveTranscodingParam.

Returns

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

stopPublishLiveStream

Stops server-side live streaming.

public stopPublishLiveStream(streamURL: string) : number
Note
  • This method stops a server-side live stream.

Parameters

Parameter

Type

Description

streamURL

string

The publishing URL.

Returns

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

getPublishLiveStreamState

Gets the live transcoding state.

public getPublishLiveStreamState(streamURL: string): AliRtcLiveTranscodingState

Parameters

Parameter

Type

Description

streamURL

string

The stream URL.

Returns

An AliRtcLiveTranscodingState enum that indicates the live transcoding state.

updatePublishLiveStreamWithTaskId

Updates live stream publishing parameters.

public updatePublishLiveStreamWithTaskId(taskId: string, params: AliRtcLiveTranscodingParam): number
Note
  • Use this method to update the parameters of a live stream publishing task in real time.

Parameters

Parameter

Type

Description

taskId

string

The task ID.

params

AliRtcLiveTranscodingParam

The stream publishing parameters.

Returns

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

stopPublishLiveStreamWithTaskId

Stops a live streaming task.

public stopPublishLiveStreamWithTaskId(taskId: string): number
Note
  • Stops an ongoing live streaming task.

Parameters

Parameter

Type

Description

taskId

string

The task ID.

Returns

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

getPublishLiveStreamStateWithTaskId

Retrieves the state of a server-side streaming task.

public getPublishLiveStreamStateWithTaskId(taskId: string): AliRtcLiveTranscodingState

Parameters

Parameter

Type

Description

taskId

string

The task ID.

Returns

AliRtcLiveTranscodingState - An enumeration representing the state of live transcoding.

publishStreamByRtsUrl

Publishes a stream to the specified RTS URL. You can only publish one stream at a time.

public publishStreamByRtsUrl(rtsUrl: string): number
Note
  • Publishes the local audio and video stream to the specified RTS URL.

Parameters

Parameter

Type

Description

rtsUrl

string

The URL for the RTS stream. Do not include room server information.

Returns

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

stopPublishStreamByRtsUrl

Stops publishing a stream to the specified RTS URL.

public stopPublishStreamByRtsUrl(rtsUrl: string): number
Note
  • Use this method to stop publishing the local audio and video stream.

Parameters

Parameter

Type

Description

rtsUrl

string

The RTS URL. This URL must not contain roomserver information.

Returns

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

subscribeStreamByRtsUrl

Subscribes to a stream using its RTS URL. You can only subscribe to one stream at a time.

public subscribeStreamByRtsUrl(rtsUrl: string, uid: string, preLoad: boolean = false): number
Note
  • This action is also known as a pull stream operation.

Parameters

Parameter

Type

Description

rtsUrl

string

The RTS URL. This URL should not include roomserver information.

uid

string

A unique identifier for the user, provided by the caller.

preLoad

boolean

Indicates whether to preload the stream. The default is false.

Returns

number - 0 for success; a non-zero value for failure.

stopSubscribeStreamByRtsUserId

Stops a stream subscription using the specified RTS user ID.

public stopSubscribeStreamByRtsUserId(uid: string): number
Note
  • Stops the subscription to an audio/video stream.

Parameters

Parameter

Type

Description

uid

string

The RTS user ID of the remote user.

Returns

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

pauseRtsStreamByRtsUserId

Pauses a subscription to a server-side RTS stream.

public pauseRtsStreamByRtsUserId(uid: string): number

Parameters

Parameter

Type

Description

uid

string

The rts user id.

Returns

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

resumeRtsStreamByRtsUserId

Resumes a subscription to a specific user's RTS stream.

public resumeRtsStreamByRtsUserId(uid: string): number

Parameters

Parameter

Type

Description

uid

string

The user ID for the RTS stream.

Returns

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

startLastmileDetect

Starts last-mile detection.

public startLastmileDetect(config: AliRtcNetworkProbeConfig): number
Note
  • Call this method before you join a channel. The SDK reports preliminary results in approximately 3 seconds through the onLastmileDetectResultWithQuality callback. The SDK then reports more comprehensive results in approximately 30 seconds through the onLastmileDetectResultWithBandWidth callback.

Parameters

Parameter

Type

Description

config

AliRtcNetworkProbeConfig

The probe configuration.

Returns

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

stopLastmileDetect

Stops the last-mile network quality probe.

public stopLastmileDetect(): number

Returns

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

setLogDirPath

Sets the directory path for SDK log files.

public static setLogDirPath(logDirPath: string): number
Note
  • To prevent log loss, call this API before calling any other SDK APIs. Ensure the specified directory exists and has write permissions.

Parameters

Parameter

Type

Description

logDirPath

string

The absolute path of the directory where log files are saved. This must be a directory path, not a file path.

Return value

number - Returns 0 for success or a non-zero value for failure. Possible error codes include: AliRtcError#ERR_LOG_ROOT_PATH_ERROR: The path already exists or is inaccessible due to insufficient permissions. AliRtcError#ERR_LOG_ALREADY_INIT: The log object has already been initialized.

setLogLevel

Sets the log level.

public static setLogLevel(logLevel: AliRtcLogLevel): void
Note
  • Sets the output log level for the SDK. The default value is a constant of the AliRtcLogLevel enum type. To prevent missing log entries when switching log levels, call this API immediately after calling the setLogDirPath API.

Parameters

Parameter

Type

Description

logLevel

AliRtcLogLevel

The log level. For available values, see the AliRtcLogLevel enum type.

enableUploadLog

Specifies whether to upload log files. This is enabled by default.

public static enableUploadLog(enable: boolean): void
Note
  • Call this method before you join a meeting and immediately after you call the setLogLevel method.

Parameters

Parameter

Type

Description

enable

boolean

true: Uploads log files.
false: Disables log file uploads.

setExtras

Updates external input parameters with a JSON string.

public setExtras(extras: string): number

Parameters

Parameter

Type

Description

extras

string

A JSON string. An empty string is a valid value.

Returns

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

setParameter

Sets a custom attribute using a JSON string.

public setParameter(param: string): number

Parameters

Parameter

Type

Description

param

string

The custom attribute to set, formatted as a JSON string.

Returns

A number where 0 indicates success and any other value indicates failure.

getParameter

Gets the value of a custom property.

public getParameter(paramKey: string): string

Parameters

Parameter

Type

Description

paramKey

string

The custom property key.

Returns

string - The value of the specified property.

enableStatsReport

Controls the upload of analytics data. Enabled by default.

public enableStatsReport(enabled: boolean): void
Note
  • You must call this method immediately after creating the AliRtcEngine instance to prevent unintended analytics data uploads.

Parameters

Parameter

Type

Description

enabled

boolean

true: Enables analytics data uploads. false: Disables analytics data uploads.

getNetworkTime

Gets the network time.

public getNetworkTime(): number

Returns

The timestamp as a number.

onRemoteUserOnline

Occurs when a remote user in communication mode or a host in interactive mode joins the channel.

onRemoteUserOnline : (func: OnRemoteUserOnLineNotify) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The unique user ID assigned by your app server.

online

boolean

Indicates whether the user is online.

onRemoteUserOffline

Occurs when a remote user in communication mode or a host in interactive live streaming mode leaves the channel.

onRemoteUserOffline : (func: OnRemoteUserOffLineNotify) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The unique user ID assigned by your App server.

reason

AliRtcUserOfflineReason

The reason the user is offline.

onJoinChannel

Occurs when the local user joins a channel.

onJoinChannel : (func: OnJoinChannelCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

result

number

The result of joining the channel. 0 indicates success; a non-zero value indicates failure.

channel

string

The channel name.

userId

string

The user ID.

elapsed

number

The time elapsed in milliseconds (ms) from calling joinChannel until this callback fires.

onLeaveChannel

Occurs when the local user leaves the channel.

onLeaveChannel : (func: OnLeaveChannelCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

result

number

The result of leaving the channel, where 0 indicates success and non-zero values are error codes.

stat

AliRtcStats

The statistics for the session.

onConnectionStatusChange

Triggered when the network connection status changes.

onConnectionStatusChange : (func: OnConnectionStatusChangeCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

status

number

The new network connection status.

reason

number

The reason for the network connection status change.

onBye

This callback is triggered when the local user is removed from the channel by the server, or when the meeting ends.

onBye : (func: OnByeCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

code

number

The reason for leaving the channel.

onAudioPublishStateChanged

Occurs when the audio publishing state changes.

onAudioPublishStateChanged : (func: OnAudioPublishStateChangedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

audioTrack

AliRtcAudioTrack

The audio track.

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The current publish state.

elapseSinceLastState

number

Time elapsed since the last state change, in milliseconds.

channel

string

The channel in which the event occurred.

onVideoPublishStateChanged

Fired when the video publishing state changes.

onVideoPublishStateChanged : (func: OnVideoPublishStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The publishing state before the change.

newState

AliRtcPublishState

The publishing state after the change.

elapseSinceLastState

number

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

channel

string

The channel in which the state change occurred.

onScreenSharePublishStateChanged

Triggered when the publish state of the screen stream changes.

onScreenSharePublishStateChanged : (func: OnScreenSharePublishStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The current publish state.

elapseSinceLastState

number

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

channel

string

The channel where the state change occurred.

onDualVideoStreamPublishStateChanged

Occurs when the publish state of the secondary video stream changes.

onDualVideoStreamPublishStateChanged : (func: OnDualVideoStreamPublishStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

oldState

AliRtcPublishState

The previous publish state.

newState

AliRtcPublishState

The current publish state.

elapseSinceLastState

number

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

channel

string

The current channel.

onAudioSubscribeStateChanged

Occurs when the audio subscription state changes.

onAudioSubscribeStateChanged : (func: OnAudioSubscribeStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The user ID.

audioTrack

AliRtcAudioTrack

The type of audio stream.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

number

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

channel

string

The current channel.

onVideoSubscribeStateChanged

Fires when the subscription state of a camera stream changes.

onVideoSubscribeStateChanged : (func: OnVideoSubscribeStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The user ID.

oldState

AliRtcSubscribeState

The previous subscription state.

newState

AliRtcSubscribeState

The current subscription state.

elapseSinceLastState

number

Elapsed time since the last state change, in milliseconds.

channel

string

The current channel.

onSubscribeStreamTypeChanged

Triggered when the subscribed dual-stream type changes.

onSubscribeStreamTypeChanged : (func: OnSubscribeStreamTypeChangedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The user ID.

oldStreamType

AliRtcVideoStreamType

The previous stream type.

newStreamType

AliRtcVideoStreamType

The current stream type.

elapseSinceLastState

number

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

channel

string

The current channel.

onRemoteTrackAvailableNotify

Notifies the app when a remote user's audio or video track becomes available or unavailable.

onRemoteTrackAvailableNotify : (func: OnRemoteTrackAvailableNotifyCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The user ID assigned by your app server.

audioTrack

AliRtcAudioTrack

The audio track.

videoTrack

AliRtcVideoTrack

The video track.

onFirstRemoteVideoFrameDrawn

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

onFirstRemoteVideoFrameDrawn : (func: OnFirstRemoteVideoFrameDrawnCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

A unique identifier for the user, assigned by your app server.

videoTrack

AliRtcVideoTrack

Indicates whether the stream is a screen stream or a camera stream.

width

number

The video width, in pixels.

height

number

The video height, in pixels.

elapsed

number

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

onFirstLocalVideoFrameDrawn

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

onFirstLocalVideoFrameDrawn : (func: OnFirstLocalVideoFrameDrawnCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

width

number

The width of the local video preview, in pixels.

height

number

The height of the local video preview, in pixels.

elapsed

number

The duration, in milliseconds, since the local user joined the channel.

onFirstVideoPacketSend

Occurs when the first video packet has been sent.

onFirstVideoPacketSend : (func: OnFirstVideoPacketSendCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

videoTrack

AliRtcVideoTrack

The video track associated with this event.

timeCost

number

The time elapsed (in ms) from calling joinChannel to sending the first video packet.

onFirstVideoPacketReceived

Triggered when the first video packet is received.

onFirstVideoPacketReceived : (func: OnFirstVideoPacketReceivedCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

uid

string

The remote user ID. This is a unique identifier assigned by your app server.

videoTrack

AliRtcVideoTrack

The video track object.

timeCost

number

The elapsed time in milliseconds.

onFirstVideoFrameReceived

Occurs when the SDK receives the first video frame from a remote user.

onFirstVideoFrameReceived : (func: OnFirstVideoFrameReceivedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The unique user ID assigned by your app server.

videoTrack

AliRtcVideoTrack

The remote user's video track.

timeCost

number

The time taken to receive the first video frame, in milliseconds.

onVideoResolutionChanged

Occurs when the video resolution changes.

onVideoResolutionChanged : (func: OnVideoResolutionChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The user ID.

track

AliRtcVideoTrack

The video track whose resolution has changed.

width

number

The new video width, in pixels.

height

number

The new video height, in pixels.

onFirstAudioPacketSend

Occurs when the first audio packet is sent.

onFirstAudioPacketSend : (func: OnFirstAudioPacketSendCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

audioTrack

AliRtcAudioTrack

The audio track.

timeCost

number

The duration from joining the channel until the SDK sends the first audio packet.

onFirstAudioPacketReceived

Occurs when the first audio packet is received.

onFirstAudioPacketReceived : (func: OnFirstAudioPacketReceivedCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

uid

string

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

audioTrack

AliRtcAudioTrack

The received audio track.

timeCost

number

The elapsed time, in milliseconds, from joining the channel to receiving the first audio packet.

onFirstRemoteAudioDecoded

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

onFirstRemoteAudioDecoded : (func: OnFirstRemoteAudioDecodedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The unique remote user ID assigned by your app server.

audioTrack

AliRtcAudioTrack

The remote user's audio track.

elapsed

number

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

onAudioVolumeCallback

Reports the volume of subscribed audio streams.

onAudioVolumeCallback : (func: OnAudioVolumeCallbackCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

volumeInfo

AliRtcUserVolumeInfo[]

An array of volume information for each speaker.

volumeInfoCount

number

The number of speakers in the volumeInfo array.

totalVolume

number

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

onTestAudioVolumeCallback

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

onTestAudioVolumeCallback : (func: OnTestAudioVolumeCallbackCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

volume

number

The captured audio volume.

onActiveSpeaker

Reports the user ID of the active speaker among subscribed users.

onActiveSpeaker : (func: OnActiveSpeakerCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The active speaker's user ID.

onAudioAccompanyStateChanged

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

onAudioAccompanyStateChanged : (func: OnAudioAccompanyStateChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

playState

AliRtcAudioAccompanyStateCode

The playback state.

errorCode

AliRtcAudioAccompanyErrorCode

The playback error code.

onAudioEffectFinished

Occurs when a local audio effect finishes playing.

onAudioEffectFinished : (func: OnAudioEffectFinishedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

soundId

number

The unique ID you assigned to the audio effect.

onNetworkQualityChanged

Occurs when the network quality changes.

onNetworkQualityChanged : (func: OnNetworkQualityChangedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The user ID. If this parameter is empty, the callback reports the local user's uplink and downlink network quality.

upQuality

AliRtcNetworkQuality

Uplink network quality.

downQuality

AliRtcNetworkQuality

Downlink network quality.

onLastmileDetectResultWithQuality

Callback for the network quality detection result.

onLastmileDetectResultWithQuality : (func: OnLastmileDetectResultWithQualityCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

networkQuality

AliRtcNetworkQuality

The detected network quality.

onLastmileDetectResultWithBandWidth

Reports the last-mile network detection result.

onLastmileDetectResultWithBandWidth : (func: OnLastmileDetectResultWithBandWidthCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

code

number

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

result

AliRtcNetworkProbeResult

Detailed network quality results.

onStats

Reports current session statistics.

onStats : (func: OnStatsCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

stats

AliRtcStats

Session statistics.

onLocalVideoStats

Reports local video statistics.

onLocalVideoStats : (func: OnLocalVideoStatsCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

localVideoStats

AliRtcLocalVideoStats

Local video statistics

onRemoteVideoStats

Reports the statistics of a remote video stream.

onRemoteVideoStats : (func: OnRemoteVideoStatsCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

remoteVideoStats

AliRtcRemoteVideoStats

Remote video stream statistics.

onLocalAudioStats

Reports statistics on the local audio stream.

onLocalAudioStats : (func: OnLocalAudioStatsCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

localAudioStats

AliRtcLocalAudioStats

Statistics for the local audio stream.

onRemoteAudioStats

Reports remote audio statistics.

onRemoteAudioStats : (func: OnRemoteAudioStatsCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

remoteAudioStats

AliRtcRemoteAudioStats

The remote audio statistics.

onPublishLiveStreamStateChanged

Triggered when the CDN live streaming state changes.

onPublishLiveStreamStateChanged : (func: OnPublishLiveStreamStateChangedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

streamUrl

string

The stream URL.

state

AliRtcLiveTranscodingState

The new publishing state.

errCode

AliRtcLiveTranscodingErrorCode

The error code that is reported when an error occurs during publishing.

onPublishLiveStreamStateChangedWithTaskId

Occurs when the publishing state of a live stream task changes, identified by its task ID.

onPublishLiveStreamStateChangedWithTaskId : (func: OnPublishLiveStreamStateChangedWithTaskIdCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

taskId

string

The ID of the task.

state

AliRtcLiveTranscodingState

The publishing state of the task.

errCode

AliRtcLiveTranscodingErrorCode

The error code for the state change.

onPublishLiveTaskStatusChanged

Occurs when the status of a publish live task changes.

onPublishLiveTaskStatusChanged : (func: OnPublishLiveTaskStatusChangedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

streamUrl

string

The URL of the stream.

status

AliRtcLiveTranscodingTaskStatus

The status of the publish live task.

onPublishLiveTaskStatusChangedWithTaskId

Occurs when the status changes for a live streaming task identified by a task id.

onPublishLiveTaskStatusChangedWithTaskId : (func: OnPublishLiveTaskStatusChangedWithTaskIdCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

taskId

string

The task id.

status

AliRtcLiveTranscodingTaskStatus

The task status.

onUserAudioMuted

Occurs when a remote user mutes or unmutes their audio.

onUserAudioMuted : (func: OnUserAudioMutedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The remote user ID.

isMute

boolean

Whether the remote user's audio is muted.

onUserVideoMuted

Occurs when a remote user starts or stops publishing a black frame.

onUserVideoMuted : (func: OnUserVideoMutedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The user ID of the remote user.

isMute

boolean

Indicates whether the remote user's video is muted. true: The video is muted. false: The video is unmuted.

onUserVideoEnabled

Occurs when a remote user enables or disables their camera.

onUserVideoEnabled : (func: OnUserVideoEnabledCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The user ID of the remote user.

isEnable

boolean

Whether the remote user's camera is enabled.

onUpdateRoleNotify

Triggered when a user's role changes.

onUpdateRoleNotify : (func: OnUpdateRoleNotifyCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

oldRole

AliRtcClientRole

The previous role.

newRole

AliRtcClientRole

The new role.

onRemoteAudioAccompanyStarted

Occurs when a remote user starts playing an accompaniment.

onRemoteAudioAccompanyStarted : (func: OnRemoteAudioAccompanyStartedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The unique identifier that your app server assigns to the remote user.

onRemoteAudioAccompanyFinished

Notifies you when a remote user's audio accompaniment finishes playing.

onRemoteAudioAccompanyFinished : (func: OnRemoteAudioAccompanyFinishedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

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

onMediaExtensionMsgReceived

Occurs when a media extension message is received.

onMediaExtensionMsgReceived : (func: OnMediaExtensionMsgReceivedCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The ID of the user who sent the message.

payloadType

number

The message type.

message

ArrayBuffer

The content of the extension message.

onLocalDeviceException

Triggered when a local device exception occurs.

onLocalDeviceException : (func: OnLocalDeviceExceptionCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

deviceType

AliRtcLocalDeviceType

The device type.

exceptionType

AliRtcLocalDeviceExceptionType

The device exception type.

msg

string

The exception message.

onDataChannelMessage

Occurs when a data channel message is received.

onDataChannelMessage : (func: OnDataChannelMessageCallback) => AliRtcEngineEventListener;
Note

The ARTC data channel relies on stream connectivity. To send messages, you must publish a stream. To receive messages, you must subscribe to a stream. Therefore, bidirectional communication requires active streams.

Callback parameters

Parameter

Type

Description

uid

string

The ID of the user who sent the message.

msg

AliRtcDataChannelMsg

The received message object.

onRemoteVideoChanged

Occurs when the state of a remote video stream changes.

onRemoteVideoChanged : (func: OnRemoteVideoChangedCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The ID of the user whose video state changed.

trackType

AliRtcVideoTrack

The video track that changed.

state

AliRtcVideoState

The new video state.

reason

AliRtcVideoReason

The reason for the state change.

onAuthInfoWillExpire

Notifies you that the user's authInfo is about to expire.

onAuthInfoWillExpire : (func: OnAuthInfoWillExpireCallback) => AliRtcEngineEventListener;

onAuthInfoExpired

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

onAuthInfoExpired : (func: OnAuthInfoExpiredCallback) => AliRtcEngineEventListener;

onAIAgentResult

Reports the processing result from the AI agent.

onAIAgentResult : (func: OnAIAgentResultCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

code

number

The return code for the operation.

action

string

The action associated with the result.

result

string

The processing result from the AI agent.

onRemoteUserSubscribedDataChannel

Fires when you can start sending messages through the data channel.

onRemoteUserSubscribedDataChannel : (func: OnRemoteUserSubscribedDataChannelCallback) => AliRtcEngineEventListener;

Callback parameters

Parameters

Type

Description

uid

string

The ID of the remote user.

onAudioDelayInfo

Reports audio delay information.

onAudioDelayInfo : (func: OnAudioDelayInfoCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

sentenceId

number

The sentence ID.

questionEndTime

number

The timestamp when the question ends.

answerStartTime

number

The timestamp when the answer starts.

onLocalAudioCaptureStateChanged

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

onLocalAudioCaptureStateChanged : (func: (state: AliRtcLocalAudioState, msg: string) => void) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

state

AliRtcLocalAudioState

The new device state.

msg

string

A message describing the state change.

onLocalVideoCaptureStateChanged

Triggered when the state of the local video capture device changes.

onLocalVideoCaptureStateChanged : (func: (state: AliRtcLocalVideoState, msg: string) => void) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

state

AliRtcLocalVideoState

The device state.

msg

string

Description of the device state change.

onRecordEvent

Reports events related to file recording.

onRecordEvent : (func: OnRecordEventCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

event

number

The type of recording event.

filePath

string

The recording file path.

onOccurWarning

Reports a warning.

onOccurWarning : (func: OnOccurWarningCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

warn

number

Warning type.

msg

string

Warning message.

onOccurError

Called when an error occurs.

onOccurError : (func: OnOccurErrorCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

error

number

The error code.

msg

string

The error message.

onPublishStreamByRtsUrlResult

Reports the result of publishing a stream to an RTS URL.

onPublishStreamByRtsUrlResult : (func: OnRtsUrlResultCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

rtsUrl

string

The publishing URL.

result

number

The publishing result, where a value of 0 indicates success and a non-zero value is the error code.

onStopPublishStreamByRtsUrlResult

Reports the result of stopping stream publishing to an RTS URL.

onStopPublishStreamByRtsUrlResult : (func: OnRtsUrlResultCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

rtsUrl

string

The stream publishing URL.

result

number

The stream publishing result. 0 indicates success; a non-zero value is an error code.

onSubscribeStreamByRtsUrlResult

Reports the result of subscribing to a stream using an RTS URL.

onSubscribeStreamByRtsUrlResult : (func: OnRtsUrlUidResultCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The subscribed user ID.

result

number

The subscription result, where 0 indicates success and a non-zero value is an error code.

onStopSubscribeStreamByRtsUrlResult

Reports the result of unsubscribing from a stream via an RTS URL.

onStopSubscribeStreamByRtsUrlResult : (func: OnRtsUrlUidResultCallback) => AliRtcEngineEventListener;

Parameters

Parameter

Type

Description

uid

string

The ID of the user who was unsubscribed.

result

number

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

onSubscribedRtsStreamBeyondLimit

Occurs when the number of RTS stream subscriptions exceeds the limit.

onSubscribedRtsStreamBeyondLimit : (func: OnSubscribedRtsStreamBeyondLimitCallback) => AliRtcEngineEventListener;

Callback function parameters

Parameter

Type

Description

uid

string

The ID of the remote user whose RTS stream subscription was terminated.

rtsUrl

string

The URL of the RTS stream whose subscription was terminated.

onPauseRtsStreamResult

Reports the result of pausing a subscription to an RTS stream by user ID.

onPauseRtsStreamResult : (func: OnRtsUrlUidResultCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The ID of the user whose subscription was paused.

result

number

The result of the pause operation. 0 indicates success. A non-zero value is an error code.

onResumeRtsStreamResult

Reports the result of resuming a stream subscription with an RTS UID.

onResumeRtsStreamResult : (func: OnRtsUrlUidResultCallback) => AliRtcEngineEventListener;

Callback parameters

Parameter

Type

Description

uid

string

The ID of the user whose subscription is resumed.

result

number

The result of the operation. A value of 0 indicates success. Any non-zero value is an error code.

onCapturedAudioFrame

The callback for captured raw audio data.

onCapturedAudioFrame : (func: OnAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Parameters

Parameter

Type

Description

audioFrame

AliRtcAudioFrame

The audio data frame.

onProcessCapturedAudioFrame

Invoked with the captured audio frame after 3A processing.

onProcessCapturedAudioFrame : (func: OnAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Callback Parameters

Parameter

Type

Description

audioFrame

AliRtcAudioFrame

The captured audio frame.

onPublishAudioFrame

Callback for published audio frames.

onPublishAudioFrame : (func: OnAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Parameters

Parameter

Type

Description

audioFrame

AliRtcAudioFrame

The audio frame.

onPlaybackAudioFrame

The callback for playback audio frames.

onPlaybackAudioFrame : (func: OnAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Parameters

Parameter

Type

Description

audioFrame

AliRtcAudioFrame

The audio frame.

onMixedAllAudioFrame

Provides the mixed audio data from all published and subscribed streams.

onMixedAllAudioFrame : (func: OnAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Parameters

Parameter

Type

Description

audioFrame

AliRtcAudioFrame

The audio frame object containing the mixed audio data.

onRemoteUserAudioFrame

Callback for receiving audio frames from a remote user.

onRemoteUserAudioFrame : (func: OnRemoteUserAudioFrameFunc) => AliRtcEngineAudioFrameListener;

Callback parameters

Parameter

Type

Description

uid

string

The user ID of the remote user who sent the audio frame.

audioFrame

AliRtcAudioFrame

An object containing the audio data.