All Products
Search
Document Center

Intelligent Media Services:AliRtcEngine class

Last Updated:Jul 20, 2025

This topic describes the methods of the ApsaraVideo Real-time Communication (ARTC) SDK for Windows.

Contents

Basic methods

API

Description

Create

Creates an AliRtcEngine instance (singleton pattern).

Destroy

Destroys an AliRtcEngine instance.

QueryInterface

Queries a class instance.

SetH5CompatibleMode

Specifies whether to enable the HTML5 compatibility mode.

GetH5CompatibleMode

Queries whether the HTML5 compatibility mode is enabled.

SetEngineEventListener

Sets event listeners.

GetSDKVersion

Queries the current SDK version number.

Channel-related methods

API

Feature description

SetChannelProfile

Set the channel mode.

SetAudioProfile

Set the audio profile.

IsAudioOnlyMode

Queries whether the audio-only mode is enabled.

SetAudioOnlyMode

Enable the audio-only mode or the audio-video mode.

JoinChannel[1/3]

Join a channel.

JoinChannel[2/3]

Join a channel.

JoinChannel[3/3]

Joins a channel.

LeaveChannel

Leave a channel.

IsInCall

Checks whether the user is in a channel

SetClientRole

Specify the user role.

GetClientRole

Obtains the user role type.

RefreshAuthInfo[1/2]

Refresh the authentication information.

RefreshAuthInfo[2/2]

Refresh the authentication information.

Publish and subscribe APIs

API

Feature description

PublishLocalAudioStream

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

IsLocalAudioStreamPublished

Queries whether an audio stream is published.

SetDefaultSubscribeAllRemoteAudioStreams

Specifies whether to subscribe to the audio tracks of remote users. By default, all remote audio tracks are subscribed to.

We recommend that you call this method before users join the channel.

SubscribeAllRemoteAudioStreams

Stops or resumes receiving all remote audio streams.

SubscribeRemoteAudioStream

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

PublishLocalVideoStream

Specifies whether to publish a video stream.

IsLocalVideoStreamPublished

Queries whether a video stream is published.

SetDefaultSubscribeAllRemoteVideoStreams

Specifies whether to subscribe to the video streams. By default, all remote video streams are subscribed to.

We recommend that you call this method before users join the channel.

SubscribeAllRemoteVideoStreams

Stop or resume receiving all remote video streams.

SubscribeRemoteVideoStream

Subscribes to or stops subscribing to the video track of a remote user.

SubscribeRemoteMediaStream[1/2]

Subscribe to or stop subscribing to the media stream of a specific remote user.

We recommend that you call this method when both the audio and video tracks are available and need to be managed.

SubscribeRemoteMediaStream[2/2]

Subscribes to or stops subscribing to the media stream of a specific remote user.

We recommend that you call this method when both the audio and video tracks are available and need to be managed.

SubscribeRemoteDestChannelStream

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

SetRemoteAudioVolume

Sets the local playback volume for the audio track of a specific remote user.

Audio device management APIs

API

Feature description

MuteLocalMic

Specifies whether to stop publishing local audio.

MuteRemoteAudio

Specifies whether to stop the playback of the remote audio stream.

MuteAllRemoteAudio

Stops or resumes the playback of all remote audio.

StartAudioCapture[1/2]

Starts audio collection.

StartAudioCapture[2/2]

Starts audio collection.

StopAudioCapture

Stops audio collection.

EnableAudioVolumeIndication

Enables volume detection.

StartAudioPlayer

Starts the audio player.

StopAudioPlayer

Stops the audio player.

SetPlayoutVolume

Sets the playback volume.

SetRecordingVolume

Sets the recording volume.

PlayAudioFileTest

Plays an audio file.

StopAudioFileTest

Stops playing an audio file.

StartAudioCaptureTest

Starts audio capture testing before a call.

StopAudioCaptureTest

Stops audio capture testing.

EnableSystemAudioRecording

Enables/disables system audio collection and pushing.

IsSystemAudioRecording

Queries whether system audio collection and pushing are enabled.

SetSystemAudioRecordingVolume

Sets the volume of system audio that is collected and pushed.

GetSystemAudioRecordingVolume

Queries the current volume of system audio that is collected and pushed.

SetSystemAudioPlayoutVolume

Sets the system audio playback volume.

GetSystemAudioPlayoutVolume

Gets the current system audio playback volume.

GetAudioCaptureList

Gets the list of audio capture devices.

GetCurrentAudioCaptureName

Gets the name of the current audio capture device.

GetCurrentAudioCaptureID

Gets the ID of the current audio capture device.

SetCurrentAudioCaptureName

Sets the audio capture device with the specified name as the current device.

SetCurrentAudioCaptureID

Sets the current audio capture device ID.

GetAudioPlayerList

Gets the current list of audio playback devices.

GetSystemRecordAudioPlayerList

Gets the current list of system audio playback devices.

GetCurrentAudioPlayerName

Gets the name of the current audio playback device.

GetCurrentAudioPlayerID

Gets the ID of the current audio playback device.

SetCurrentAudioPlayerName

Sets the device with the specified name as the current playback device.

SetCurrentAudioPlayerID

Sets the device with the specified ID as the current playback device.

SetRecordingDeviceVolume

Sets the volume of the audio capture device.

GetRecordingDeviceVolume

Gets the volume of the audio capture device.

SetPlaybackDeviceVolume

Sets the volume of the audio playback device.

GetPlaybackDeviceVolume

Gets the volume of the audio playback device.

SetRecordingDeviceMute

Sets the mute state of the audio capture device.

GetRecordingDeviceMute

Gets the mute state of the audio capture device.

SetPlaybackDeviceMute

Sets the mute state of the audio playback device.

GetPlaybackDeviceMute

Gets the mute state of the audio playback device.

Audio voice change and reverberation

API

Feature description

SetAudioEffectVoiceChangerMode

Sets the voice change mode.

SetAudioEffectPitchValue

Sets the audio pitch parameter.

SetAudioEffectReverbMode

Sets the reverberation mode.

SetAudioEffectReverbParamType

Sets the reverberation type and specific parameters.

Custom audio input

API

Feature description

AddExternalAudioStream

Adds an external audio track.

PushExternalAudioStreamRawData

Imports external audio data.

SetExternalAudioStreamPublishVolume

Sets the volume of external audio for stream ingest.

GetExternalAudioStreamPublishVolume

Queries the volume of external audio for stream ingest.

SetExternalAudioStreamPlayoutVolume

Sets the playback volume of external audio.

GetExternalAudioStreamPlayoutVolume

Queries the playback volume of external audio.

RemoveExternalAudioStream

Removes an external audio track.

Audio accompaniment

API

Description

GetAudioFileInfo

Gets audio file information.

StartAudioAccompany

Starts accompaniment mixing.

StopAudioAccompany

Stops accompaniment mixing.

SetAudioAccompanyVolume

Sets the accompaniment volume.

SetAudioAccompanyPublishVolume

Sets the accompaniment volume for stream ingest.

GetAudioAccompanyPublishVolume

Gets the accompaniment volume for stream ingest.

SetAudioAccompanyPlayoutVolume

Sets the accompaniment volume for local playback.

GetAudioAccompanyPlayoutVolume

Gets the accompaniment volume for local playback.

PauseAudioAccompany

Pauses accompaniment mixing.

ResumeAudioAccompany

Resumes accompaniment mixing.

GetAudioAccompanyDuration

Gets the duration of the accompaniment file in milliseconds.

GetAudioAccompanyCurrentPosition

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

SetAudioAccompanyPosition

Sets the playback position of the accompaniment file.

Sound effect files

API

Feature description

PreloadAudioEffect

Preloads a sound effect file.

UnloadAudioEffect

Deletes a preloaded sound effect.

PlayAudioEffect

Starts the playback of a sound effect.

StopAudioEffect

Stops the playback of a sound effect.

StopAllAudioEffects

Stops the playback of all sound effects.

PauseAudioEffect

Pauses the sound effect.

PauseAllAudioEffects

Pauses all sound effects.

ResumeAudioEffect

Resumes the specified sound effect file.

ResumeAllAudioEffects

Resumes all sound effect files.

SetAudioEffectPublishVolume

Sets the volume of a sound effect for stream ingest.

GetAudioEffectPublishVolume

Queries the volume of a sound effect for stream ingest.

SetAllAudioEffectsPublishVolume

Sets the volume of all sound effects for stream ingest.

SetAudioEffectPlayoutVolume

Sets the volume of a sound effect for local playback.

GetAudioEffectPlayoutVolume

Queries the volume of a sound effect for local playback.

SetAllAudioEffectsPlayoutVolume

Sets the volume of all sound effects for local playback.

Methods related to video device management

API

Description

SetLocalViewConfig

Sets the rendering view and drawing parameters for local preview.

SetCameraCapturerConfiguration

Sets the collection preferences of the camera.

EnableLocalVideo

Disables or re-enables local video collection.

MuteLocalCamera

Specifies whether to stop publishing a local video track.

SetRemoteViewConfig

Sets the rendering view and drawing parameters for the video track of a remote user.

IsCameraOn

Queries whether the camera is enabled.

SetVideoEncoderConfiguration

Sets video encoding properties.

SetVideoDecoderConfiguration

Sets video decoding properties.

StartPreview

Starts a local preview.

StopPreview

Stops a local preview.

setVideoMirrorMode

Sets preview and stream ingest mirroring capabilities.

SetCapturePipelineScaleMode

Sets the capture scaling timing, whether video data is scaled immediately upon capture or only during encoding.

GetCameraList

Gets the list of available cameras.

GetCurrentCameraName

Gets the name of the current camera.

GetCurrentCameraID

Gets the ID of the current camera.

SetCurrentCameraName

Sets the camera with the specified name as the current camera.

SetCurrentCameraID

Sets the camera with the specified ID as the current camera.

GetCurrentCameraSupportedResolutionList

Gets the list of resolutions supported by the current camera.

Video data callback configuration

API

Description

RegisterVideoSampleObserver

Registers an object that is used to export video data.

UnRegisterVideoSampleObserver

Deregisters an object that is used to export video data.

SnapshotVideo

Enables snapshot capture for a video track.

Audio data callback configuration

API

Description

RegisterAudioFrameObserver

Registers an audio callback.

UnRegisterAudioFrameObserver

Unregisters audio data output.

EnableAudioFrameObserver

Configures audio callback parameters.

Custom video input

API

Feature description

SetExternalVideoSource

Enables an external video input source.

PushExternalVideoFrame

Imports video data.

Desktop sharing interface

API

Feature description

StartScreenShareByDesktopId

Starts sharing the screen stream corresponding to the specified desktop ID.

StartScreenShareByScreenRegion

Starts sharing the video stream of a specified screen area.

StartScreenShareByWindowId

Shares and pushes the video stream using the window specified by the user's window ID as the video source.

StopScreenShare

Stops screen sharing.

ResumeScreenShare

Resume screen sharing.

PauseScreenShare

Pause screen sharing.

IsScreenSharePublished

Queries whether screen sharing is set to push.

UpdateScreenShareConfig

Update screen sharing configuration.

CheckWindowSourceValid

Determines whether the window corresponding to the shared window ID is valid.

GetScreenShareConfig

Returns the configuration information of the current screen sharing.

GetScreenShareSourceInfo

Retrieves a list of objects from the specified source.

GetCurrentScreenShareSourceId

Get the screen sharing source ID of the current shared screen.

GetCurrentScreenShareSourceType

Get a list of objects from the specified source.

GetDesktopRegion

Gets the desktop sharing scope based on the specified source ID and source title.

SetScreenShareEncoderConfiguration

Sets the video encoding properties for the screen stream.

Live streaming bypass API

API

Feature description

StartPublishLiveStream

Start bypass live streaming.

UpdatePublishLiveStream

Updates the parameters for bypass live streaming.

StopPublishLiveStream

Stop bypass live streaming.

GetPublishLiveStreamState

Query the status of relayed live streaming.

StartLastmileDetect

Network quality detection before starting a call.

StopLastmileDetect

Stop network quality detection before ending the call.

Network quality detection methods

API

Description

StartLastmileDetect

Starts network quality detection before a call.

StopLastmileDetect

Stops network quality detection before a call.

SEI

API

Description

SendMediaExtensionMsg

Sends media extension information, implemented internally using SEI.

SendMediaExtensionMsgEx

Sends media extension information (extended), implemented internally using SEI.

Other interfaces

API

Feature description

SetParameter

Sets custom parameters.

GetParameter

Query custom parameters.

SetLogDirPath

Set the path for storing the log files of the SDK.

SetLogLevel

Set the log level.

GetNetworkTime

Gets the timeline time.

SendDataChannelMessage

Sends a data channel message.

Callback event

AliEngineEventListener

API

Description

OnConnectionStatusChange

The callback that is invoked when the network connection status changes. Pay attention to this callback.

OnLocalDeviceException

The callback that is invoked when a local device exception occurs. Pay attention to this callback.

OnAuthInfoWillExpire

The callback for authentication information that is about to expire. The authentication expires 30 seconds after you receive this callback. Pay attention to this callback.

OnAuthInfoExpired

The callback for expired authentication. The expiration information is returned by the server when users call a method that requires authentication.

OnJoinChannelResult

The callback that is invoked to return the result of joining a channel.

OnLeaveChannelResult

The callback that is invoked to return the result of leaving a channel.

OnRemoteUserOffLineNotify

The callback that is invoked when a remote user goes offline.

OnRemoteUserOnLineNotify

The callback that is invoked when a remote user goes online.

OnRemoteTrackAvailableNotify

The callback that is invoked when the stream of a remote user changes.

OnBye

A message is sent when you are removed from the channel by the server or when the meeting channel is closed.

OnAudioPublishStateChanged

The callback that is invoked when the status of stream ingest for an audio track changes.

OnAudioSubscribeStateChanged

The callback that is invoked when the status of the stream pulling for an audio track changes.

OnUserAudioMuted

Notification for remote user mute.

OnUserAudioInterruptedBegin

The callback that is invoked when the interruption of an audio device starts.

OnUserAudioInterruptedEnded

The callback that is invoked when the interruption of an audio device ends.

OnVideoPublishStateChanged

The callback that is invoked when the status of stream ingest for a video track changes.

OnVideoSubscribeStateChanged

The callback that is invoked when the status of subscription to a camera track changes.

OnUserVideoMuted

The callback that is invoked when a remote user sends black frames for the video track.

OnUserVideoEnabled

The callback that is invoked when a remote user disables data collection for the camera track.

OnUserWillResignActive

The callback that is invoked when a remote user switches the application to the background.

OnUserWillBecomeActive

The callback that is invoked when a remote user switches the application back to the foreground.

OnAudioEffectFinished

The callback that is invoked when the local playback of a sound effect ends.

OnAudioVolumeCallback

The callback for the subscribed audio volume, voice status, and UID.

OnActiveSpeaker

The callback that is invoked when an active user is detected speaking.

OnPublishLiveStreamStateChanged

The callback that is invoked when the status of relayed live streaming changes.

OnPublishTaskStateChanged

The callback that is invoked when the status of a relayed live streaming task changes.

OnNetworkQualityChanged

The callback that is invoked when the network quality changes.

OnLastmileDetectResultWithQuality

The callback for network quality detection before a call. This callback is provided approximately 3 seconds after the detection starts.

OnLastmileDetectResultWithBandWidth

The callback for the network quality detection result before a call. This callback is provided after approximately 30 seconds of detection.

OnOccurError

The callback that is invoked when an error occurs in the engine.

OnFirstAudioPacketSend

The callback that is invoked when the first audio packet is sent.

OnFirstAudioPacketReceived

The callback that is invoked when the first audio packet is received.

OnFirstVideoPacketSend

The callback that is invoked when the first video packet is sent.

OnFirstVideoPacketReceived

The callback that is invoked when the first video packet is received.

OnFirstRemoteAudioDecoded

The callback that is invoked when the first remote audio frame is decoded.

OnFirstRemoteVideoFrameDrawn

The callback that is invoked when the first video frame from a remote user is displayed.

OnFirstLocalVideoFrameDrawn

The callback that is invoked when the first video frame is displayed in the preview.

OnTestAudioVolumeCallback

The callback for the volume during audio capture testing before a call.

OnAudioAccompanyStateChanged

The callback for the local accompaniment playback status.

OnAudioFileInfo

The callback for audio file information.

OnRemoteAudioAccompanyStarted

The callback that is invoked when a remote user starts accompaniment playback.

OnRemoteAudioAccompanyFinished

The callback that is invoked when a remote user finishes accompaniment playback.

OnStats

The callback for real-time statistics. This callback is invoked every two seconds.

OnLocalVideoStats

The callback for local video statistics (invoked every 2 seconds).

OnRemoteVideoStats

The callback for remote video statistics (invoked every 2 seconds).

OnLocalAudioStats

The callback for local audio statistics (invoked every 2 seconds).

OnRemoteAudioStats

The callback for remote audio statistics (invoked every 2 seconds).

OnMediaExtensionMsgReceived

The callback that is invoked when an SEI message is received.

OnSnapshotComplete

The callback for snapshot results.

OnLocalAudioStateChange

The callback for local audio device state changes.

onLocalVideoStateChanged

The callback for local video device state changes.

OnRemoteUserSubscribedDataChannel

The callback that is invoked when data channel messages can be sent.

OnDataChannelMessage

The callback for data channel messages.

IAudioFrameObserver

API

Description

OnCapturedAudioFrame

The callback for captured raw audio data.

OnProcessCapturedAudioFrame

The callback for post-3A audio data.

OnPublishAudioFrame

The callback for stream ingest data.

OnPlaybackAudioFrame

The callback for playback data.

OnRemoteUserAudioFrame

The callback for remote stream pulling data.

IVideoFrameObserver

API

Description

OnCaptureVideoSample

The callback for local captured video data.

OnPreEncodeVideoSample

The callback for local pre-encoded video data.

OnRemoteVideoSample

The callback for remote video data.

GetVideoAlignment

The width alignment of the output video.

GetObservedFramePosition

The video data output content.

AliEngineDestroyCompletionCallback

API

Description

onDestroyCompletion

The callback for destruction completion.

Interface details

Create

Creates an AliRtcEngine instance.

static AliEngine *Create(const char *extras);

Call timing

Make sure to call this method to create an AliRtcEngine instance before calling other ARTC SDK APIs.

Call restrictions

For each App, the SDK only supports creating one AliRtcEngine instance.

Parameter description

Name

Type

Description

extras

const char *

Specifies the additional parameters delivered in canary releases. A JSON string is used to configure a special SDK feature. This parameter can be left empty.

Response description

Returns a singleton instance of the AliEngine class.

Destroy

Destroys an AliRtcEngine instance.

static void Destroy(AliEngineDestroyCompletionCallback *callback = nullptr);

Destroys the AliRtcEngine singleton object. After calling this method, all internally used resources will be released, and you will no longer be able to use other methods or any callbacks of AliRtcEngine. To use it again, you must call Create to create a new instance.

Note

This method is an asynchronous invocation. You can create the next instance only after you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#TUn2z" id="14c93d2e8bamj">onDestroyCompletion</a> callback. The destroy operation is not considered complete until this callback is returned.

Call timing

It is recommended to call this method to release the instance after completing audio and video communication.

Call restrictions

To avoid deadlocks, it is not recommended to call this method in any SDK callbacks.

Parameter description

Parameter

Type

Description

callback

AliEngineDestroyCompletionCallback

Destroy completion callback.

QueryInterface

Queries a class instance.

virtual int QueryInterface(AliEngineInterfaceIdType iid, void** pInterface) = 0;

This method is used to obtain a specific type of feature interface instance. When developing audio and video related applications on Windows platform, many advanced features (such as audio device management AliEngineInterfaceAudioDeviceManger, video device management AliEngineInterfaceVideoDeviceManger, and media engine AliEngineInterfaceMediaEngine) are provided through corresponding interface classes. However, before calling related methods, you must obtain instances of these interfaces through the QueryInterface method.

Note

After using the interface instance, if you no longer need it, you should release the resource by calling the Release method of the corresponding interface to avoid memory leaks.

Parameter description

Name

Type

Description

iid

AliEngineInterfaceIdType

Indicates the type of feature interface, telling the SDK what type of interface instance you want to obtain.

  • AliEngineInterfaceAudioDeviceManger: If pInterface is successfully obtained, the returned object is IAliEngineAudioDeviceManager

  • AliEngineInterfaceVideoDeviceManger: If pInterface is successfully obtained, the returned object is IAliEngineVideoDeviceManager

  • AliEngineInterfaceMediaEngine: If pInterface is successfully obtained, the returned object is IAliEngineMediaEngine

pInterface

void**

Returns an instance of the obtained interface type. Example parameter: AliEngineInterfaceMediaEngine* mediaEngine = nullptr;

Pass (void**)&mediaEngine.

Return description

  • 0: The query is successful.

  • <0: The query failed.

SetH5CompatibleMode

Specify whether to enable the HTML5 compatibility mode.

static void SetH5CompatibleMode(bool comp);

Parameter description

Name

Type

Description

comp

bool

  • A value of true enables the HTML5 compatibility mode.

  • A value of false disables the HTML5 compatibility mode. This is the default value.

Note

You cannot modify the HTML5 compatibility settings for the current version after you create an AliRtcEngine instance. You must call this method before you create an AliRtcEngine instance.

GetH5CompatibleMode

Queries whether the HTML5 compatibility mode is enabled.

static bool GetH5CompatibleMode();

Return description

A value of YES indicates that the HTML5 compatibility mode is enabled. A value of NO indicates that the HTML5 compatibility mode is disabled.

SetEngineEventListener

Sets the event listener.

virtual int SetEngineEventListener(AliEngineEventListener *listener) = 0;

This method sets an event listener for the SDK. By setting the listener, you can receive various notification events from the engine, such as when users join or leave a channel, the network status changes, or the audio and video stream status changes.

You must implement the `AliEngineEventListener` class to customize the event methods that you want to listen for. By default, all methods have empty implementations. You do not need to implement all methods. You can implement only the event methods that are relevant to your business.

Note
  • All callback methods are executed in the SDK's internal threads. You cannot perform UI operations directly in these callbacks. To perform UI-related operations, you must dispatch them to the main thread. Do not call this method from within a callback.

  • We recommend that you do not perform time-consuming operations in the callback methods, such as calling the `Destroy` method of the `AliEngine` instance. This may cause unnecessary blocking and affect the performance of the SDK.

Related callbacks

If an exception occurs during runtime, the SDK first attempts to automatically recover using its internal retry mechanism. For errors that the SDK cannot resolve on its own, the SDK notifies your application through predefined callback interfaces. The following table describes key callbacks for errors that the SDK cannot handle. Your application must listen for and respond to these callbacks.

Exception

Callback and parameters

Solution

Description

Authentication failed

The `result` parameter in the `OnJoinChannelResult` callback returns `AliRtcErrJoinBadToken`.

When this error occurs, your application must check whether the token is valid.

If authentication fails when you proactively call a method, the system returns an error message that indicates authentication failure in the callback for the method.

Network connection failure

The `OnConnectionStatusChange` callback returns `AliRtcConnectionStatusFailed`.

When this exception occurs, your application must rejoin the channel.

The SDK can automatically recover from a network disconnection within a specific period. However, if the disconnection duration exceeds the preset threshold, a timeout is triggered and the connection is lost. In this case, your application should check the network status and guide the user to rejoin the channel.

Local device exception

OnLocalDeviceException

When this exception occurs, your application must check the permissions and verify that the device hardware is working as expected.

The RTC service supports device detection and exception diagnosis. When a local device exception occurs that the SDK cannot handle, the SDK sends a callback to notify your application. In this case, your application must intervene to check whether the device is working correctly.

Kicked offline

OnBye

  • `AliRtcOnByeUserReplaced`: When this exception occurs, check whether another user with the same user ID has joined the channel.

  • `AliRtcOnByeBeKickedOut`: When this exception occurs, it indicates that the user was kicked out of the channel by the server. The user must rejoin the channel.

  • `AliRtcOnByeChannelTerminated`: When this exception occurs, it indicates that the channel was destroyed. The user must rejoin the channel.

The RTC service provides a feature that allows administrators to remove participants from a channel.

Authentication about to expire

OnWillAuthInfoExpire

When this exception occurs, your application must obtain the latest authentication information and then call `refreshAuthInfo` to refresh the authentication information.

An authentication expiration error can occur in two scenarios: when a user calls a method or during program execution. Therefore, the error is reported through the callback of the method or through a separate error callback.

Authentication expired

OnAuthInfoExpired

When this exception occurs, your application must rejoin the channel.

An authentication expiration error can occur in two scenarios: when a user calls a method or during program execution. Therefore, the error is reported through the callback of the method or through a separate error callback.

Parameters

Name

Type

Description

listener

AliEngineEventListener*

The event listener for the engine. You must implement the `AliEngineEventListener` class and override the event callbacks that you want to listen for. If you set this parameter to `nullptr`, all event listeners are deregistered.

Response Description

  • 0: Success.

  • A non-zero value: The method call failed. This may be because the `listener` parameter is invalid or the SDK is not correctly initialized.

GetSDKVersion

Query the current SDK version.

static const char *GetSDKVersion();

Return description

The current SDK version number in string format, for example: "2.5.0.x".

SetChannelProfile

Set the channel mode.

virtual int SetChannelProfile(const AliEngineChannelProfile channelProfile) = 0;

This method is used to set the channel mode. The following modes are available:

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

  • Interactive live streaming mode: In this mode, you need to call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#c99c2b257dd8o" id="4e50f781a01e1">SetClientRole</a> to set the user role. Users who publish streams in the channel are set to the streamer role (AliRTCSdkInteractive). Users who only need to subscribe to streams and do not need to publish streams are set to the viewer role (AliRTCSdkLive). We recommend that you use this mode for RTC scenarios.

Note
  • For RTC scenarios, we recommend that you use the interactive live streaming mode. To do this, call this method and set the mode to AliEngineInteractiveLive.

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

When to call

You can call this method only before you join a channel. You when you are in a channel. You can change the mode after you leave the channel.

Parameters

Name

Type

Description

profile

AliEngineChannelProfile

The channel mode. For RTC scenarios, we recommend that you set this parameter to AliEngineInteractiveLive, which specifies the interactive live streaming mode.

Response description

  • 0: The method is called successfully.

  • A value other than 0: The method call fails.

    • -1: The SDK is not initialized or has been destroyed.

SetAudioProfile

Sets the audio profile.

virtual int SetAudioProfile(int audioProfile, int audioScene) = 0;

This method is used to set the audio encoding mode and audio scenario mode. For more information, see Setting audio encoding and scenario modes. By default, the ARTC SDK uses high-quality mode (AliEngineHighQualityMode) and music scenario mode (AliEngineSceneMusicMode). If the default settings do not meet your requirements, you need to call this method to configure them.

Call timing

This method can only be called before joining a channel. You cannot reconfigure it after joining a channel, but you can reconfigure it after leaving the channel.

Parameter description

Name

Type

Description

audio_profile

AliEngineAudioProfile

Audio collection or encoding mode parameter. We recommend that you use high-quality mode (AliRtcEngineHighQualityMode).

Note

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

  • AliEngineLowQualityMode: Low audio quality mode with a default sample rate of 8000 Hz, mono channel, and maximum encoding bitrate of 12 kbps.

  • AliEngineBasicQualityMode: Standard audio quality mode with a default sample rate of 16000 Hz, mono channel, and maximum encoding bitrate of 24 kbps.

  • AliEngineHighQualityMode: Default sample rate of 48000 Hz, mono channel, and maximum encoding bitrate of 64 kbps.

  • AliEngineStereoHighQualityMode: Stereo high-quality mode with a default sample rate of 48000 Hz, dual channels, and maximum encoding bitrate of 80 kbps.

  • AliEngineSuperHighQualityMode: Super high-quality mode with a default sample rate of 48000 Hz, mono channel, and maximum encoding bitrate of 96 kbps.

  • AliEngineStereoSuperHighQualityMode: Stereo super high-quality mode with a default sample rate of 48000 Hz, dual channels, and maximum encoding bitrate of 128 kbps.

audio_scene

AliEngineAudioScenario

Audio scenario mode parameter, mainly including the following:

  • AliEngineSceneMusicMode (recommended): Music scenario that uses software 3A and collects audio from the mobile phone (higher audio quality).

  • AliEngineSceneDefaultMode: Uses hardware 3A and can collect audio from Bluetooth devices.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

IsAudioOnlyMode

Queries whether the audio-only mode is enabled.

virtual bool IsAudioOnlyMode() = 0;

Return description

A value of YES indicates that the audio-only mode is enabled. A value of NO indicates that the audio-video mode is enabled.

SetAudioOnlyMode

Enable the audio-only mode or the audio-video mode.

virtual int SetAudioOnlyMode(bool audioOnly) = 0;

Parameter description

Name

Type

Description

audioOnly

bool

  • A value of true enables the audio-only mode. In this mode, only audio tracks are ingested and pulled.

  • A value of false enables the audio-video mode. In this mode, both audio and video tracks are ingested and pulled. This is the default value.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

JoinChannel[1/3]

Join a channel.

virtual int JoinChannel(const char *token, const char *channelId, const char *userId, const char *userName) = 0;

This method is used to join a channel. ARTC organizes users through channels, and users need to join a channel to "publish" or "subscribe" to audio and video streams. This method, along with JoinChannel[2/3] and JoinChannel[3/3], can be used to join a channel. The difference lies in the authentication method and the user information passed, as follows:

  • This method is a single-parameter channel joining interface that requires only the Token generated by Token Authentication for single-parameter channel joining. This method is recommended for RTC scenarios.

  • JoinChannel[2/3] is a multi-parameter channel joining interface that requires the multi-parameter Token generated by Token Authentication, and the user information used to generate the Token.

  • JoinChannel[3/3] is used for AI real-time interaction scenarios, passing a single-parameter Token and setting the user attribute capabilityProfile according to the scenario.

Note

By default, when you join a channel, you subscribe to the audio and video streams of all other users in the channel and push your own audio and video streams to remote users. To disable this default subscription, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="00e50070ba5ck">SetDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="0b0bcff091gtk">SetDefaultSubscribeAllRemoteVideoStreams</a> before you call this method to disable the subscription to audio or video streams.

Call timing

You need to call this method after creating the engine.

Call restrictions

  • After successfully joining a channel, to join another channel, you must first call LeaveChannel to leave the current channel and ensure that you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="b2522e57e4vom">OnLeaveChannelResult</a> callback before calling this method again.

  • This method only supports joining one channel at a time.

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

  • If joining a channel fails, you do not need to call this method again when retrying.

Related callbacks

After successfully calling this method, the following callbacks will be triggered:

  • The result of the local client joining a channel is returned through the AliRtcEngineEventListener's <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#7cbf47a35bcel" id="cad6eb9b1bwx7">OnJoinChannelResult</a> callback.

  • After successfully joining the channel, remote users will trigger the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#3333f6e9d344q" id="fab4a94264m28">OnRemoteUserOnLineNotify</a> callback.

Parameter description

Parameter

Type

Description

token

const char *

The authentication information for single-parameter input.

channelId

const char *

The ID of the channel to join. The value must be the same as the channel ID that is used to generate the token.

userId

const char *

The ID of the user who wants to join the channel. The value must be the same as the user ID that is used to generate the token.

userName

const char *

The display name of the user. It is not the user ID.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

JoinChannel[2/3]

Join a channel.

virtual int JoinChannel(const AliEngineAuthInfo &authInfo,
                                 const char *userName) = 0;

This method is used to join a channel. In ARTC, users are organized by channels. A user must join a channel to publish or subscribe to audio and video streams. This method, JoinChannel[1/3], and JoinChannel[3/3] can all be used to join a channel. They differ in the authentication method and the user information that is passed, as described in the following list:

  • JoinChannel[1/3] is a single-parameter method. You can join a channel by passing a token that is generated for single-parameter authentication. For more information, see Token-based authentication. We recommend that you use this method to join a channel in RTC scenarios.

  • This method is a multi-parameter method. You must pass a token that is generated for multi-parameter authentication and the user information that is used to generate the token. For more information, see Token-based authentication.

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

Note
  • By default, after a user joins a channel, the SDK subscribes to the audio and video streams of all other users in the channel and publishes the local audio and video streams. If you want to change this default behavior, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="d4639ae922klp">SetDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="6d0a63e70bpiz">SetDefaultSubscribeAllRemoteVideoStreams</a> before you call this method to unsubscribe from audio or video streams.

  • This is a multi-parameter method. Before you call this method, see Token-based authentication to generate a token for multi-parameter authentication.

Usage limits

  • After you successfully join a channel, to join another channel, you must first call LeaveChannel to leave the current channel. You can join the new channel only after you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="fcd2fac6abf0y">OnLeaveChannelResult</a> callback.

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

  • Applications that use different App IDs cannot interoperate with each other.

Related callbacks

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

  • The result of the local client joining the channel is returned in the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#7cbf47a35bcel" id="b3db8c610ewua">OnJoinChannelResult</a> callback.

  • After a user successfully joins the channel, the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#3333f6e9d344q" id="a1297d33bcd92">OnRemoteUserOnLineNotify</a> callback is triggered on the remote client.

Parameters

Name

Type

Description

authInfo

AliEngineAuthInfo

The authentication information.

userName

const char *

The display name, instead of the ID, of the user.

JoinChannel[3/3]

Join a channel.

virtual int JoinChannel(const char *token, const char *channelId, const char *userId, const AliEngineChannelParam &userParam) = 0;

This method is used to join a channel. ARTC organizes users through channels, and users need to join a channel to "publish" or "subscribe" to audio and video streams. This method, along with JoinChannel[1/3] and JoinChannel[2/3], can be used to join a channel. The difference lies in the authentication method and the user information passed, as follows:

  • JoinChannel[1/3] is a single-parameter entry interface for RTC scenarios, which requires only the Token generated by Token Authentication for single-parameter entry. This interface is recommended for joining channels in RTC scenarios.

  • JoinChannel[2/3] is a multi-parameter entry interface, which requires the Token generated by Token Authentication for multi-parameter entry, along with the user information used to generate the Token.

  • This interface is used for AI real-time interaction scenarios, passing a single-parameter entry Token and setting the user attribute capabilityProfile according to the scenario. When communicating with an AI agent, set it to AliCapabilityProfileHuman.

Note

Without special configuration, when joining a channel, the system subscribes to all other users' audio and video streams in the channel by default and pushes audio and video streams to remote users by default. If you want to cancel the default subscription, call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="952a402dc4v73">SetDefaultSubscribeAllRemoteAudioStreams</a> and <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="4e977610713wy">SetDefaultSubscribeAllRemoteVideoStreams</a> before calling this method to disable subscription to audio or video streams.

Call restrictions

  • After successfully joining a channel, to join another channel, you must first call leaveChannel to leave the current channel and ensure that you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="15ec544e3985m">OnLeaveChannelResult</a> callback before calling join channel again.

  • This method only supports joining one channel at a time.

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

  • If joining a channel fails, there is no need to call this method again when retrying.

Related callbacks

After successfully calling this method, the following callbacks will be triggered:

  • The result of the local user joining the channel will be notified through the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#7cbf47a35bcel" id="5d109191c950l">OnJoinChannelResult</a> callback.

  • After successfully joining the channel, remote users will trigger the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#3333f6e9d344q" id="fa6f8d9357glx">OnRemoteUserOnLineNotify</a> callback.

Parameter description

Parameter

Type

Description

token

const char *

The authentication information for single-parameter input.

channelId

const char *

The channel to join, which must be the same as the one used when generating the token. This parameter can be omitted, in which case the channelId used to generate the token will be used by default.

userId

const char *

The user ID for joining the channel, which must be the same as the one used when generating the token. This parameter can be omitted, in which case the userId used to generate the token will be used by default.

userParam

AliEngineChannelParam

User attributes, such as user nickname, type, custom ID, etc.

Return description

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

LeaveChannel

Leave a channel.

virtual int LeaveChannel() = 0;

After calling this method, the SDK terminates audio and video interaction and leaves the current channel.

Note
  • This method is an asynchronous operation. A successful call does not mean that you have actually left the channel until the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="2741d56c6eqau">OnLeaveChannelResult</a> callback is triggered.

  • After leaveChannel is completed, destroy the engine and set the engine to null.

    mAliRtcEngine->LeaveChannel();
    AliEngine::Destroy();
    mAliRtcEngine = nullptr;

Call timing

  • You should call this method when you need to leave a channel after joining it.

  • If you have already joined a channel and need to join another channel, you need to call this interface to leave the current channel first.

Related callbacks

  • Local: After calling this method, the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="9626ae24d89ue">OnLeaveChannelResult</a> callback will be triggered to notify the result of leaving the channel.

  • Remote: After successfully calling this interface, remote users will trigger the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#44ce12a0ecj52" id="0dfcab6a6fylt">OnRemoteUserOffLineNotify</a> callback.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

IsInCall

Checks whether you are in a channel.

virtual bool IsInCall() = 0;

Return description

A value of true indicates that you are in a channel. A value of false indicates that you are not in a channel.

SetClientRole

Specify the user role.

virtual int SetClientRole(const AliEngineClientRole clientRole) = 0;

This method is used to set the user role as a streamer or viewer.

In interactive mode, before joining a channel:

  • When setting the user role as a streamer: The SDK automatically pushes local audio and video streams by default, and receives audio and video streams from other streamers.

  • When setting the user role as a viewer: The SDK does not push local audio and video streams, but receives audio and video streams from other streamers.

Call timing

This method can be called both before and after joining a channel. You can set the user role before joining a meeting, or call it after joining to switch user roles.

Call restrictions

This method is only effective in interactive mode, which means it only works when the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#901e748242y3g" id="322c3da902jpt">SetChannelProfile</a> interface is set to AliEngineInteractiveLive.

In interactive mode, it is recommended to explicitly call this method to set the user role before joining a meeting.

Parameter description

Name

Type

Description

role

AliEngineClientRole

The role of the user. The default value is AliEngineClientRolelive, which indicates a viewer. This parameter takes effect only in non-communication mode.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetClientRole

Queries the current user role type (streamer or viewer).

virtual AliEngineClientRole GetClientRole() = 0;

Return description

After the method is called, an AliEngineClientRole object is returned. The object is an enumeration type that indicates the role type: streamer (0) or viewer (1).

RefreshAuthInfo[1/2]

Refresh the authentication information.

virtual int RefreshAuthInfo(const AliEngineAuthInfo &authInfo) = 0;

This method is used to update authentication information. The Token will expire after a certain period, at which point the SDK will not be able to establish a connection with the server.

Note

This interface and RefreshAuthInfo[2/2] both function to update authentication information, but this interface is used to update the Token for multi-parameter channel joining, while RefreshAuthInfo[2/2] is used to update the Token for single-parameter channel joining. For information about Token generation, see Token Authentication.

Call timing

In the following situations:

  • When you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#9f8ebe177degw" id="f52a19bb78yoi">OnAuthInfoWillExpire</a> callback reporting that the authentication information is about to expire, it is recommended that you regenerate the Token on your server and then call this method to pass in the new Token.

  • If the Token is not updated in time, the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#09c4ec9160eom" id="440c501877fxr">OnAuthInfoExpired</a> callback will be triggered to notify that the authentication has expired. In this case, you need to regenerate the Token and then call JoinChannel to rejoin the channel.

Parameter description

Name

Type

Description

authInfo

AliEngineAuthInfo

The authentication information.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

RefreshAuthInfo[2/2]

Refresh the authentication information.

virtual int RefreshAuthInfo(const char *token) = 0;

This method is used to update the Token. The Token will expire after a certain period, at which point the SDK will not be able to establish a connection with the server.

Note

This interface and RefreshAuthInfo[1/2] both function to update authentication information, but this interface is used to update the Token for single-parameter channel joining, while RefreshAuthInfo[1/2] is used to update the Token for multi-parameter channel joining. For information about Token generation, see Token Authentication.

Call timing

In the following situations, we recommend that you regenerate a Token on your server and then call this method to pass in the new Token:

  • When you receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#9f8ebe177degw" id="b21949148djrc">OnAuthInfoWillExpire</a> callback reporting that the authentication information is about to expire.

  • If the Token is not updated in time, the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#09c4ec9160eom" id="62df9bf63786v">OnAuthInfoExpired</a> callback will be triggered to notify that the authentication has expired. In this case, you need to call JoinChannel to rejoin the channel.

Parameter description

Name

Type

Description

token

const char *token

The authentication information for single-parameter input.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

PublishLocalAudioStream

Specifies whether to publish an audio track.

virtual int PublishLocalAudioStream(bool enabled) = 0;

This method is used to control whether to publish the locally captured audio stream. By default, the SDK publishes the audio stream. If you do not want to publish the audio stream by default, you can call PublishLocalAudioStream(false) before joining a channel to disable audio stream publishing.

Call timing

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

Related callbacks

When the local audio stream publishing status changes, the local device triggers the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#eb8fab7f5ak7v" id="c584949653jn5">OnAudioPublishStateChanged</a> callback to notify the latest audio publishing status, and the remote device triggers the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#ff1f7c8581r3r" id="75f2096b1efxy">OnRemoteTrackAvailableNotify</a> callback to notify that the audio and video streams of the remote user have changed.

Parameter description

Name

Type

Description

enable

bool

  • A value of true specifies that the local audio track is published.

  • A value of false specifies that the local audio track is not published. This is the default value.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

IsLocalAudioStreamPublished

Query whether an audio track is published.

virtual bool IsLocalAudioStreamPublished() = 0;

Return description

If set to true, pushing is allowed. If set to false, pushing is prevented.

SetDefaultSubscribeAllRemoteAudioStreams

Specify whether to subscribe to the audio tracks of remote users.

virtual int SetDefaultSubscribeAllRemoteAudioStreams(bool sub) = 0;

This method is used to configure whether the system subscribes to the audio tracks of remote users by default. This setting affects the audio track subscription behavior for users who join the channel later. We recommend that you set this parameter to true unless you have special requirements.

Call timing

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

  • Before joining a channel:

    • By default, the SDK subscribes to the audio tracks of remote users when joining a channel. If you want to modify this behavior, you can call this method before joining the channel.

  • After joining a channel:

    • If you want to stop the default subscription, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="e95a7e2d6fjwt">SetDefaultSubscribeAllRemoteAudioStreams</a>(false), which prevents subscribing to the audio tracks of users who join the channel later.

    • After stopping the default subscription, if you want to resume subscribing to the audio track of a specific user, call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#957e547813q56" id="1a391bcabc66e">SubscribeRemoteAudioStream</a> method. If you want to resume subscribing to multiple users, call this method multiple times.

    • After stopping the default subscription, calling <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="e79b5ad58awcw">SetDefaultSubscribeAllRemoteAudioStreams</a>(true) resumes the audio streams of users who join the channel afterward. However, it does not subscribe to the audio streams of remote users who joined while the subscription was stopped.

Call restrictions

If you have previously called <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f1e98cf7b446c" id="c9b658a17evjt">SubscribeAllRemoteAudioStreams</a>(false) to turn off the master switch for audio subscription, this method call will be ineffective.

Parameter description

Name

Type

Description

sub

bool

  • A value of true specifies that the audio tracks of remote users are subscribed to. This is the default value.

  • A value of false specifies that the audio tracks of remote users are not subscribed to.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeAllRemoteAudioStreams

Subscribe to or stop subscribing to the audio tracks of all remote users.

virtual int SubscribeAllRemoteAudioStreams(bool sub) = 0;

This interface serves as the master switch for subscribing to remote audio tracks, and we recommend setting it to true. If set to false, it will result in:

  • All remote audio in the current meeting will stop being subscribed to.

  • New users who join later will not be subscribed to.

  • You cannot individually control the audio stream of specific users through <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#957e547813q56" id="aface4ad3920l">SubscribeRemoteAudioStream</a>.

To resume subscribing, call this interface again and set it to true.

Note

By default, the SDK subscribes to the audio streams of all remote users when you join a meeting. To change this behavior, call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="3927721185m08">SetDefaultSubscribeAllRemoteAudioStreams</a>(false) before you join the meeting.

Parameter description

Name

Type

Description

sub

bool

  • A value of true specifies that the audio tracks of all remote users are subscribed to. This is the default value.

  • A value of false specifies that the audio tracks of all remote users are not subscribed to.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeRemoteAudioStream

Subscribe to or stop subscribing to the audio track of a specific remote user.

virtual int SubscribeRemoteAudioStream(const char* uid, bool sub) = 0;

This API lets you stop or resume a subscription to the audio stream of a specific remote user. <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f1e98cf7b446c" id="93db357f06pmq">SubscribeAllRemoteAudioStreams</a> provides global control, while SubscribeRemoteAudioStream provides fine-grained, individual control. We recommend that you set this parameter to true unless you have specific scenario requirements.

Note

By default, the SDK subscribes to the audio streams of all remote users when you join a conference. To change this behavior, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="5b0598b965tsv">SetDefaultSubscribeAllRemoteAudioStreams</a>(false) before joining the conference to disable this default configuration.

Call restrictions

If you have previously called <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f1e98cf7b446c" id="1595cb66e5ty2">SubscribeAllRemoteAudioStreams</a>(false) to stop subscribing to all remote audio tracks, this method call will be ineffective.

Parameter description

Name

Type

Description

uid

const char*

The ID of the remote user.

sub

bool

  • A value of true specifies that the audio track of the specified user is subscribed to. This is the default value.

  • A value of false specifies that the audio track of the specified user is not subscribed to.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

PublishLocalVideoStream

Publish/stop publishing camera stream.

virtual int PublishLocalVideoStream(bool enabled) = 0;

This method is used to control whether to publish the locally captured video stream.

Note

The SDK publishes video streams by default. To stop video stream publishing, call PublishLocalVideoStream(false) before joining the channel.

Call timing

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

Calling before joining a channel modifies the default configuration, which takes effect when joining the channel.

Related callbacks

When the local video stream publishing status changes, the local end will trigger the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#6bf4efbd1cadl" id="d37709b09147d">OnVideoPublishStateChanged</a> callback to notify the latest audio publishing status, and the remote end will trigger the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#ff1f7c8581r3r" id="f16e4b51bchqb">OnRemoteTrackAvailableNotify</a> callback to notify changes in the remote user's audio and video streams.

Parameter description

Name

Type

Description

enable

bool

  • A value of true specifies that the video track is published. This is the default value.

  • false means to stop sending. The default value is true.

Return description

  • 0: The method call is successful.

  • <0: The method call fails.

IsLocalVideoStreamPublished

Queries whether a video track is published.

virtual bool IsLocalVideoStreamPublished() = 0;

Return description

A value of true indicates that stream ingest is enabled for the video track. A value of false indicates that stream ingest is disabled for the video track.

SetDefaultSubscribeAllRemoteVideoStreams

Specifies whether to subscribe to the video tracks of remote users.

virtual int SetDefaultSubscribeAllRemoteVideoStreams(bool sub) = 0;

This method is used to specify whether to subscribe to video tracks. By default, the SDK subscribes to video tracks.

Note

By default, the SDK subscribes to the video tracks of remote users when joining a channel. If you want to modify this behavior, you can call this method before joining a channel.

Call timing

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

  • Before joining a channel:

    • You can use this method to cancel the default subscription setting.

  • After joining a channel:

    • If you want to stop the default subscription, you can call SetDefaultSubscribeAllRemoteVideoStreams(false), which will prevent subscribing to the audio tracks of users who subsequently join the channel.

    • After stopping the default subscription, if you want to resume subscribing to the audio track of a specific user, call the SubscribeRemoteVideoStream method. If you want to resume subscribing to multiple users, call this method multiple times.

    • After stopping the default subscription, calling SetDefaultSubscribeAllRemoteVideoStreams(false) only resumes subscribing to the audio tracks of users who subsequently join the channel.

Call restrictions

If you have previously called <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#4f427cc2d9cjf" id="b9cacc3b8an8e">SubscribeAllRemoteVideoStreams</a>(false) to turn off the master switch for video subscription, this method call will be ineffective.

Parameter description

Name

Type

Description

sub

bool

  • A value of true specifies that the video tracks of remote users are subscribed to. This is the default value.

  • A value of false specifies that the video tracks of remote users are not subscribed to.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeAllRemoteVideoStreams

Subscribe to or stop subscribing to the video tracks of all remote users.

virtual int SubscribeAllRemoteVideoStreams(bool sub) = 0;

This interface serves as a master switch for subscribing to remote video streams. If set to false, it will result in:

  • All remote video streams in the current meeting will stop being subscribed to.

  • New users who join later will not be subscribed to (even if you have set <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="b7b0080f3cnoq">SetDefaultSubscribeAllRemoteVideoStreams</a>(true) for default subscription.

  • You cannot control the audio stream of a specific user individually through <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#jyGTp" id="0e2edf97aa1g6">SubscribeRemoteVideoStream</a>.

To resume subscription, call this interface again and set it to true.

Note

By default, the SDK subscribes to the video streams of all remote users when joining a channel. If you want to modify this behavior, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="629f58d5304mf">SetDefaultSubscribeAllRemoteVideoStreams</a>(false) before joining the channel to cancel this default configuration.

Parameter description

Name

Type

Description

sub

bool

  • A value of true specifies that the video tracks of all remote users are subscribed to. This is the default value.

  • A value of false specifies that the video tracks of all remote users are not subscribed to.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeRemoteMediaStream[1/2]

Subscribes to or stops subscribing to the media stream of a specific remote user.

virtual int SubscribeRemoteMediaStream(const char* uid, AliEngineVideoTrack videoTrack, bool subVideo,  bool subAudio) = 0;

This interface is used to combine subscription to remote audio and video streams.

Note

In this interface, AliRtcVideoTrackNo in AliRtcVideoTrack is invalid and setting it will not have any effect.

Related interfaces

Compared to SubscribeRemoteMediaStream[2/2], this interface uses two boolean parameters subVideo and subAudio to determine whether to subscribe to remote audio and video streams, while videoTrack is used to control which video stream to pull.

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

videoTrack

AliEngineVideoTrack

The type of the video track.

subVideo

boo

Specifies whether to subscribe to the video track of the remote user. Valid values:

  • true (default): Resume.

  • false: Stop.

subAudio

boo

Specifies whether to subscribe to the audio track of the remote user. Valid values:

  • true (default value): resume.

  • false: Stop.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeRemoteMediaStream[2/2]

Subscribe to or stop subscribing to the media stream of a specific remote user.

virtual int SubscribeRemoteMediaStream(const char* uid, AliEngineVideoTrack videoTrack, AliEngineAudioTrack audioTrack) = 0;

This interface is used to combine subscription to remote audio and video streams.

Related interfaces

Compared to SubscribeRemoteMediaStream[1/2], this interface uses two parameters, videoTrack and audioTrack, to inform the SDK about the subscription status in a single call, for example:

  • To subscribe to both camera stream and microphone stream, set videoTrack to AliRtcVideoTrackCamera and audioTrack to AliRtcAudioTrackMic when calling.

  • To unsubscribe from the camera stream but keep the microphone stream, set videoTrack to AliRtcVideoTrackNo and audioTrack to AliRtcAudioTrackMic when calling again.

  • To unsubscribe from both streams, set videoTrack to AliRtcVideoTrackNo and audioTrack to AliRtcAudioTrackNo when calling again.

  • To subscribe to both camera stream and screen sharing stream simultaneously, set videoTrack to AliRtcVideoTrackBoth. The same applies to audio.

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

videoTrack

AliEngineVideoTrack

The type of the video track.

audioTrack

AliEngineAudioTrack

The type of the audio track.

Return description

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

SubscribeRemoteDestChannelStream

Subscribe to or stop subscribing to the media stream of a specific remote user across channels.

virtual int SubscribeRemoteDestChannelStream(const char* channelId, const char* uid, AliEngineVideoTrack track, bool sub_audio, bool sub) = 0;

Parameter description

Parameter

Type

Description

channelId

const char*

The ID of the remote channel.

uid

const char*

The ID of the remote user.

track

AliEngineVideoTrack

The video track to which you want to subscribe.

sub_audio

bool

Specifies whether to subscribe to the audio track of the specific remote user. Valid values:

  • true (default value): Resume.

  • false: Stop.

sub

bool

Specifies whether to subscribe to or stop subscribing to the stream of the specified user across channels.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SubscribeRemoteVideoStream

Stop or resume subscribing to the video stream of a remote user.

virtual int SubscribeRemoteVideoStream(const char* uid, AliEngineVideoTrack track, bool sub) = 0;

Subscribe to or unsubscribe from the video stream of a specified user.

Note

By default, the SDK subscribes to the video streams of all remote users when joining a channel. If you want to modify this behavior, you can call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="370d1caf608ya">SetDefaultSubscribeAllRemoteVideoStreams</a>(false) before joining the channel to cancel this default configuration.

Call timing

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

Call restrictions

The subscription behavior is controlled by the master switch SubscribeAllRemoteVideoStreams. If you have previously called SubscribeAllRemoteVideoStreams(false) to disable subscription to all remote videos, the subscription function will be turned off, and all other enabling behaviors will not take effect. Before calling this API, make sure you have called SubscribeAllRemoteVideoStreams(true) to re-enable the subscription function.

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

track

AliEngineVideoTrack

The type of the video track.

sub

bool

Specifies whether to subscribe to the video stream of the remote user, controlling subscription or unsubscription.

Return description

  • true: The setting is successful.

  • false: The setting failed.

SetRemoteAudioVolume

Sets the local playback volume for the audio track of a specific remote user.

virtual int SetRemoteAudioVolume(const char *uid, int volume) = 0;

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

volume

int

The playback volume. Valid values: [0,100].

0: Mute.

100: Original volume.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed.

MuteLocalMic

Specify whether to mute the local audio.

virtual int MuteLocalMic(bool mute, AliEngineMuteLocalAudioMode mode = AliEngineMuteLocalAudioModeDefault) = 0;
Note

Muting means that the audio stream sends silent frames, while the collection and encoding modules are still working.

Call timing

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

Related callbacks

After a successful call, remote users will receive the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#a15f0a6cf6id7" id="f4ae88f094vqy">OnUserAudioMuted</a> notification indicating whether the user is muted.

Parameter description

Name

Type

Description

mute

bool

  • A value of true mutes the local audio.

  • A value of false indicates that the service has recovered. The default value is false.

mode

AliEngineMuteLocalAudioMode

The mute mode. By default, all audio is muted.

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

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

  • AliEngineMuteLocalAudioModeMuteOnlyMic: Mutes only the microphone.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

MuteRemoteAudio

Specify whether to stop the playback of the audio track of a specific remote user.

virtual int MuteRemoteAudio(const char *uid,
                                    bool mute) = 0;

This interface is only used to stop or resume audio playback for a specified remote user. It does not affect the pulling or decoding of the remote audio stream. To unsubscribe from an audio stream, call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#957e547813q56" id="89841a0989t7y">SubscribeRemoteAudioStream</a> for a specific user, or call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f1e98cf7b446c" id="37ccd4be636nf">SubscribeAllRemoteAudioStreams</a> for all users.

Call timing

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

Parameter description

Name

Type

Description

uid

const char *

The user ID.

mute

bool

  • A value of true specifies that the playback is stopped.

  • A value of false specifies that the playback is not stopped. This is the default value.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

MuteAllRemoteAudio

Specifies whether to stop the playback of the audio tracks of all remote users.

virtual int MuteAllRemoteAudio(bool mute) = 0;

This method is used to stop or resume the playback of all remote audio tracks.

Note
  • This method only stops playback; stream pulling and decoding are not affected.

  • You can call this method before or after JoinChannel.

Call timing

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

Parameter description

Name

Type

Description

mute

bool

  • A value of true specifies that the playback is stopped.

  • A value of false specifies that the playback is not stopped. This is the default value.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StartAudioCapture[1/2]

Start audio collection.

virtual int StartAudioCapture() = 0;

This interface is used to control the start of audio collection. When called before joining a channel, you can control the audio collection device to open in advance. If not set, the SDK will automatically control the audio collection device. After calling stopAudioCapture to close audio collection, call this interface if you want to open it again.

Call timing

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

Related interfaces

  • The StartAudioCapture[2/2] interface lets you control whether the audio collection device remains on after leaving a channel through parameters.

Related callbacks

After calling this interface to modify the local audio collection status, you can get status changes through the OnLocalAudioStateChange callback.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StartAudioCapture[2/2]

Start audio collection.

virtual int StartAudioCapture(bool keepAlive) = 0;

Close microphone collection after muting.

This interface is used to control audio collection. When called before joining a channel, it can control audio collection in advance. If not set, the SDK will automatically control the audio collection device.

Call timing

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

Related interfaces

Compared to StartAudioCapture[1/2], this interface lets you control whether the collection device remains on after leaving a channel through the keepAlive parameter.

Related callbacks

After calling this interface to modify the local audio collection status, you can obtain status changes through the OnLocalAudioStateChange callback.

Parameter description

Parameter

Type

Description

keepAlive

bool

The status of the audio collection device after you leave a channel. Valid values:

  • true: The audio collection device remains on after you leave a channel.

  • false (default): The audio collection device is turned off after you leave a channel.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StopAudioCapture

Stop audio collection.

virtual int StopAudioCapture() = 0;

After calling StartAudioCapture to start audio device collection, you can call this method to stop collection.

Related callbacks

After calling this method to modify the local audio collection status, you can obtain the status change through the OnLocalAudioStateChange callback.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

EnableAudioVolumeIndication

Set the volume callback interval and smoothing factor.

virtual int EnableAudioVolumeIndication(int interval, int smooth, int reportVad) = 0;

This method allows the SDK to regularly report volume-related information to the App about the local streaming user and the remote user with the highest instantaneous volume.

Call timing

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

Related callbacks

After successfully calling this method, if there are users streaming in the channel, the SDK will trigger the following two callbacks according to the set time interval:

  • The audio volume of the speaker will be notified through the OnAudioVolumeCallback callback, with the frequency determined by the interval parameter.

  • For voice activation, when an active user is detected, the speaker's uid will be reported through the OnActiveSpeaker callback.

Call timing

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

Parameter description

Name

Type

Description

interval

int

The interval at which volume detection is performed. Unit: milliseconds. The value must be equal to or greater than 10. We recommend that you set this parameter to a value from 300 to 500. If the value is less than or equal to 0, the indicators for indicating the volume and the person who speaks are disabled.

smooth

int

The smoothing factor. Valid values: 0 to 9. A larger value indicates a higher smoothing degree. A smaller value indicates a lower smoothing degree but better real-time performance. We recommend that you set the value to 3.

reportVad

int

The switch used to detect the person who speaks. Valid values:

  • 1: turns on the switch. You can invoke the onAudioVolumeCallback callback to obtain the status of each person who speaks.

  • 0: disabled

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StartAudioPlayer

Starts the audio player.

virtual int StartAudioPlayer() = 0;

This interface can control opening the audio player in advance. If not set, the SDK will automatically open the audio player after subscribing to an audio stream.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, returning an error code.

StopAudioPlayer

Stops the audio player.

virtual int StopAudioPlayer() = 0;

This interface can be used to control the shutdown of audio playback, corresponding to AliEngine::StartAudioPlayer.

Parameter description

None.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, returning an error code.

SetPlayoutVolume

Sets the playback volume.

virtual int SetPlayoutVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The playback volume. Valid values: [0,400]. 0: Mute; >100: Increase volume; <100: Decrease volume.

Return description

  • 0: The operation is successful.

  • Other values: The operation failed and an error code is returned.

SetRecordingVolume

virtual int SetRecordingVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

Playback volume, valid values [0,400]. 0: mute; >100: increase volume; <100: decrease volume.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, and an error code is returned.

PlayAudioFileTest

Play an audio file.

virtual int PlayAudioFileTest(const char* filePath) = 0;

Parameter description

Name

Type

Description

filePath

const char*

The path of the audio file to be played.

Return description

  • 0: The operation is successful.

  • <0: The operation failed.

StopAudioFileTest

Stop playing the audio file.

virtual int StopAudioFileTest() = 0;

Return description

  • 0: The operation is successful.

  • <0: The operation failed.

StartAudioCaptureTest

Start audio capture test before a call.

virtual int StartAudioCaptureTest() = 0;

This interface can control the opening of audio capture testing. You can determine whether audio capture is working properly through the AliEngineEventListener::OnTestAudioVolumeCallback callback result.

Note

This interface can only be called before joining a channel (JoinChannel).

Return description

  • 0: The operation is successful.

  • <0: The operation failed.

StopAudioCaptureTest

Stops the audio capture test.

virtual int StopAudioCaptureTest() = 0;
Note

This interface can only be called before joining a channel (JoinChannel).

Return description

  • 0: The operation is successful.

  • <0: The operation failed.

EnableSystemAudioRecording

Enable/disable system audio recording and streaming.

virtual int EnableSystemAudioRecording(bool enable, const char *path = nullptr, const char *device_id = nullptr) = 0;

This interface is used to enable or disable system audio recording, such as sounds played by browsers, applications, etc.

Note

This interface is only supported on Windows and macOS.

Parameter description

Name

Type

Description

enable

bool

Enable/disable system audio recording and streaming.

  • true: enables.

  • false: disables.

path

const char*

If path is empty, the entire system's audio is recorded; if path is an exe program path, this program will be launched and its audio will be recorded.

device_id

const char*

If path is empty, the audio from the default sound card device is recorded; otherwise, the audio played by the device with this device_id is recorded, using the id returned by GetSystemRecordAudioPlayerList.

Return description

  • 0: The method call is successful.

  • <0: The method call fails.

IsSystemAudioRecording

Queries whether system audio collection and pushing are enabled.

virtual bool IsSystemAudioRecording() = 0;
Note

To enable or disable system audio collection, call EnableSystemAudioRecording. This interface is only available on Windows and macOS platforms.

Return description

  • true: enabling status.

  • false: shutdown status.

SetSystemAudioRecordingVolume

Sets the volume of system audio that is collected and pushed.

virtual int SetSystemAudioRecordingVolume(int volume) = 0;

This interface is only available on Windows and macOS platforms.

This interface requires system audio collection and pushing to be enabled before it can be set, otherwise the setting will be ineffective.

Parameter description

Name

Type

Description

volume

int

The volume of system audio for stream ingest. Valid values: [0-400].

Return description

  • 0: The operation is successful.

  • <0: The operation failed.

GetSystemAudioRecordingVolume

Queries the current volume of system audio that is collected and pushed.

virtual int GetSystemAudioRecordingVolume() = 0;

This interface is available only on Windows and macOS platforms.

Response description

The playback volume.

SetSystemAudioPlayoutVolume

Sets the system audio playback volume.

virtual int SetSystemAudioPlayoutVolume(int volume) = 0;

This interface is only available on Windows and macOS platforms.

This interface requires system audio capture and pushing to be enabled before it can be set, otherwise the setting will not take effect.

Parameter description

Name

Type

Description

volume

int

The playback volume of the system audio capture. Range: [0-400].

Return description

  • 0: The operation is successful.

  • <0: The operation fails.

GetSystemAudioPlayoutVolume

Gets the current system audio playback volume.

virtual int GetSystemAudioPlayoutVolume() = 0;

This interface is only available on Windows and macOS platforms.

Return description

The system audio playback volume.

GetAudioCaptureList

Gets the list of audio capture devices in the system.

virtual AliEngineDeviceInfoList* GetAudioCaptureList() = 0;

Return value

AliEngineDeviceInfoList * Pointer to the list of audio capture devices.

GetCurrentAudioCaptureName

Gets the name of the audio capture device in use.

virtual String GetCurrentAudioCaptureName() = 0;

Return value

String: The name of the current audio capture device.

GetCurrentAudioCaptureID

Gets the ID of the audio capture device in use.

virtual String GetCurrentAudioCaptureID() = 0;

Return value

The ID of the audio capture device currently in use.

SetCurrentAudioCaptureName

Select the audio capture device name.

virtual int SetCurrentAudioCaptureName(const char* captureName) = 0;

Parameter description

Name

Type

Description

captureName

const char *

Audio capture device name

Return value

0 indicates success, other values indicate failure.

SetCurrentAudioCaptureID

Select the audio recording device ID.

virtual int SetCurrentAudioCaptureID(const char* captureID) = 0;

Parameter description

Name

Type

Description

captureID

const char *

Audio recording device ID

Return value

0 indicates success, other values indicate failure.

GetAudioPlayerList

Gets the list of speakers in the system.

virtual AliEngineDeviceInfoList* GetAudioPlayerList() = 0;

Return value

A pointer to the list of speakers in the system AliEngineDeviceInfoList *

GetSystemRecordAudioPlayerList

Get the list of recordable speakers in the system (for system audio recording).

virtual AliEngineDeviceInfoList* GetSystemRecordAudioPlayerList() = 0;

Return value

The audio playback device list is mainly provided for EnableSystemAudioRecording to use as the last parameter, for capturing system audio playback.

GetCurrentAudioPlayerName

Gets the name of the currently used speaker.

virtual String GetCurrentAudioPlayerName() = 0;

Return value

The name of the current audio playback device

GetCurrentAudioPlayerID

Gets the ID of the currently used speaker.

virtual String GetCurrentAudioPlayerID() = 0;

Return value

The ID of the current audio playback device.

SetCurrentAudioPlayerName

Select the speaker name.

virtual int SetCurrentAudioPlayerName(const char* playerName) = 0;

Return value

The name of the audio playback device.

SetCurrentAudioPlayerID

Select speaker ID

virtual int SetCurrentAudioPlayerID(const char* playerID) = 0;

Parameter description

Name

Type

Description

playerID

const char *

Playback device ID

Return value

0 indicates success, other values indicate failure.

SetRecordingDeviceVolume

Sets the volume of the audio capture device. The volume range is [0, 100].

virtual int SetRecordingDeviceVolume(int volume) = 0;

Parameter list

Name

Type

Description

volume

int

Volume range [0..100].

Return value

0 indicates success, other values indicate failure.

GetRecordingDeviceVolume

Gets the volume of the audio recording device.

virtual int GetRecordingDeviceVolume() = 0;

Return value

>=0 returns the volume, other values indicate failure.

SetPlaybackDeviceVolume

Sets the volume of the audio playback device. The volume range is [0, 100].

virtual int SetPlaybackDeviceVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

Volume [0..100]

Return value

0 indicates success, other values indicate failure.

GetPlaybackDeviceVolume

Gets the volume of the audio playback device.

virtual int GetPlaybackDeviceVolume() = 0;

Return value

>=0 indicates the system volume, other values indicate failure.

SetRecordingDeviceMute

Specifies whether to mute an audio collection device.

virtual int SetRecordingDeviceMute(bool mute) = 0;

Parameter description

Name

Type

Description

mute

bool

Specifies whether to mute the recording

Return value

0 indicates success, other values indicate failure.

GetRecordingDeviceMute

Gets the mute status of the audio recording device

virtual bool GetRecordingDeviceMute() = 0;

Return value

Whether the recording is muted.

SetPlaybackDeviceMute

Mute the audio playback device

virtual int SetPlaybackDeviceMute(bool mute) = 0;

Parameter description

Name

Type

Description

mute

bool

Whether to mute the audio playback

Return value

0 indicates success, other values indicate failure.

GetPlaybackDeviceMute

Queries whether an audio player is muted.

virtual bool GetPlaybackDeviceMute() = 0;

Return description

Indicates whether the playback device is muted.

SetAudioEffectVoiceChangerMode

Set the voice change mode.

virtual int SetAudioEffectVoiceChangerMode(const AliEngineAudioEffectVoiceChangerMode &mode) = 0;

Parameter description

Name

Type

Description

mode

AliEngineAudioEffectVoiceChangerMode

The voice change mode. Default value: AliEngineAudioEffectVoiceChangerOff.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAudioEffectPitchValue

Set the audio pitch.

virtual int SetAudioEffectPitchValue(double value) = 0;

Parameter description

Name

Type

Description

value

double

The pitch value. Valid values: 0.5 to 2.0. The default value is 1.0, which indicates that the pitch remains the same.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAudioEffectReverbMode

Set the reverberation mode.

virtual int SetAudioEffectReverbMode(const AliEngineAudioEffectReverbMode& mode) = 0;

Parameter description

Name

Type

Description

mode

AliEngineAudioEffectReverbMode

The reverberation mode. Default value: AliEngineAudioEffectReverbOff.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAudioEffectReverbParamType

Set the parameters of the reverberation mode.

virtual int SetAudioEffectReverbParamType(const AliEngineAudioEffectReverbParamType& type,
                                                  float value) = 0;

Parameter description

Name

Type

Description

type

AliEngineAudioEffectReverbParamType

The reverberation mode.

value

float

The value of the sound effect parameter.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

AddExternalAudioStream

Add an external audio track.

virtual int AddExternalAudioStream(const AliEngineExternalAudioStreamConfig& config) = 0;

This method is used to add a new external audio track. The following are the related steps:

  1. Call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#991b862eb353w" id="08ee3d1ed35jj">AddExternalAudioStream</a> method to add an external audio track and obtain the external audio track ID.

  2. Call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e6cf3f7cef0g6" id="fae817d0f00p3">PushExternalAudioStreamRawData</a> method to input audio data into the created audio track.

  3. When the call ends, you need to call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#u27oe" id="3b9a3eb119umh">RemoveExternalAudioStream</a> to remove the external audio track.

To publish custom captured audio in a channel, you can refer to the document Custom Audio Capture.

Parameter description

Name

Type

Description

config

AliEngineExternalAudioStreamConfig

The configuration of the external audio track.

Return description

A value greater than 0 indicates that the call is successful and is the ID of the external audio track. A value less than or equal to 0 indicates that the call fails.

PushExternalAudioStreamRawData

Import external audio data.

virtual int PushExternalAudioStreamRawData(int streamId, AliEngineAudioRawData& data) = 0;

This interface is used to input data into a specified audio stream. The following are the related steps:

  1. Call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#991b862eb353w" id="3836ac109732c">AddExternalAudioStream</a> interface to add an external audio stream and obtain the external audio stream ID.

  2. Call PushExternalAudioStreamRawData to input audio data into the created audio stream.

  3. When ending the call, you need to call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#u27oe" id="398ea88d61fn0">RemoveExternalAudioStream</a> to remove the external audio stream.

To publish custom captured audio in a channel, you can refer to the document Custom audio capture.

Parameter description

Name

Type

Description

streamId

int

The ID of the external audio track.

data

AliEngineAudioRawData

The audio data.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetExternalAudioStreamPublishVolume

Set the volume of external audio for stream ingest.

virtual int SetExternalAudioStreamPublishVolume(int streamId, int vol) = 0;

Parameter description

Name

Type

Description

streamId

int

The ID of the external audio track.

vol

int

The volume of the external audio for stream ingest.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetExternalAudioStreamPlayoutVolume

Set the volume of external audio for stream ingest.

virtual int SetExternalAudioStreamPlayoutVolume(int streamId, int vol) = 0;

Parameter description

Name

Type

Description

streamId

int

The ID of the external audio track.

vol

int

The volume of the external audio for stream ingest.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetExternalAudioStreamPublishVolume

Queries the volume of external audio for stream ingest.

virtual int GetExternalAudioStreamPublishVolume(int streamId) = 0;

Parameter description

Name

Type

Description

streamId

int

The ID of the external audio track.

Return description

The valid values of the volume range from 0 to 100. A value less than 0 indicates that the call fails.

GetExternalAudioStreamPlayoutVolume

Query the playback volume of external audio.

virtual int GetExternalAudioStreamPlayoutVolume(int streamId) = 0;

Parameter description

Name

Type

Description

streamId

int

The ID of the external audio track.

Return description

The valid values of the volume range from 0 to 100. A value less than 0 indicates that the call fails.

RemoveExternalAudioStream

Removes an external audio stream.

virtual int RemoveExternalAudioStream(int streamId) = 0;

This method removes the external audio stream that corresponds to the specified streamId. This method is paired with the AddExternalAudioStream method.

When to call

If you want to use the custom audio input feature, you must call the AddExternalAudioStream method to add an audio stream and obtain the external audio stream ID. Then, call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e6cf3f7cef0g6" id="bdab74f108i1p">PushExternalAudioStreamRawData</a> method to push your audio data to the SDK. When you want to stop using custom audio input, call this method to remove the corresponding external audio stream and release the resources.

Parameters

Name

Type

Description

streamId

int

The ID of the audio stream.

Return value

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetAudioFileInfo

Gets audio file information.

virtual int GetAudioFileInfo(const char *filePath) = 0;

This is an asynchronous interface. You can obtain audio file information through AliEngineEventListener::OnAudioFileInfo.

Parameter description

Name

Type

Description

filePath

const char *

The path of the audio file.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, and an error code is returned.

StartAudioAccompany

Starts accompaniment mixing.

virtual int StartAudioAccompany(const char *filePath, const AliEngineAudioAccompanyConfig& config) = 0;

This is an asynchronous interface. You can monitor the audio accompaniment player status through AliEngineEventListener::OnAudioAccompanyStateChanged.

Parameter description

Name

Type

Description

filePath

const char *

The path of the audio file.

config

const AliEngineAudioAccompanyConfig

The accompaniment playback configuration.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed and returned an error code.

StopAudioAccompany

Stops accompaniment mixing.

virtual int StopAudioAccompany() = 0;

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, returning an error code.

SetAudioAccompanyVolume

Sets the accompaniment volume.

 virtual int SetAudioAccompanyVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The accompaniment volume. Valid values: [0,100].

  • 0: mute.

  • 100: original volume.

Return description

  • 0: The operation is successful.

  • Other values: The operation failed and an error code is returned.

SetAudioAccompanyPublishVolume

Sets the volume of audio accompaniment for stream ingest.

virtual int SetAudioAccompanyPublishVolume(int volume) = 0;
Note

The volume setting takes effect only after calling AliEngine::StartAudioAccompany.

Parameter description

Name

Type

Description

volume

int

The volume of audio accompaniment for stream ingest. Valid values: [0,100].

  • 0: mute.

  • 100: The original volume.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed and returned an error code.

GetAudioAccompanyPublishVolume

Queries the volume of audio accompaniment for stream ingest.

virtual int GetAudioAccompanyPublishVolume() = 0;

Return description

The volume of audio accompaniment for stream ingest. Valid values: [0-100].

SetAudioAccompanyPlayoutVolume

Sets the local playback volume of the audio accompaniment.

virtual int SetAudioAccompanyPlayoutVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The playback volume of the accompaniment. Valid values: [0,100].

  • 0: Mute.

  • 100: Original volume.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed and an error code is returned.

GetAudioAccompanyPlayoutVolume

Queries the local playback volume of the accompaniment.

virtual int GetAudioAccompanyPlayoutVolume() = 0;

Return description

The local playback volume of the accompaniment. Valid values: [0-100].

PauseAudioAccompany

Pauses accompaniment mixing.

virtual int PauseAudioAccompany() = 0;

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed and returns an error code.

ResumeAudioAccompany

Resumes accompaniment mixing.

virtual int ResumeAudioAccompany() = 0;

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed, and an error code is returned.

GetAudioAccompanyDuration

Gets the duration of the accompaniment file in milliseconds.

virtual int GetAudioAccompanyDuration() = 0;

Return description

The duration of the audio accompaniment file in milliseconds.

GetAudioAccompanyCurrentPosition

Gets the playback progress of the accompaniment file in milliseconds.

virtual int GetAudioAccompanyCurrentPosition() = 0;

Return description

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

SetAudioAccompanyPosition

Sets the playback position of the accompaniment file.

virtual int SetAudioAccompanyPosition(int pos) = 0;

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed and an error code is returned.

PreloadAudioEffect

Preload a sound effect.

virtual int PreloadAudioEffect(unsigned int soundId,
                                       const char *filePath) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

filePath

const char *

The path of the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

UnloadAudioEffect

Delete a preloaded sound effect.

virtual int UnloadAudioEffect(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

NSInteger

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

PlayAudioEffect

Start the playback of a sound effect.

virtual int PlayAudioEffect(unsigned int soundId, const char *filePath, const AliEngineAudioEffectConfig& config) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

filePath

const char *

The path of the sound effect.

config

AliEngineAudioEffectConfig

The configuration of the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StopAudioEffect

Stop the playback of a sound effect.

virtual int StopAudioEffect(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StopAllAudioEffects

Stop the playback of all sound effects.

- (int)StopAllAudioEffects;

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

PauseAudioEffect

Pause the playback of a sound effect.

virtual int PauseAudioEffect(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

PauseAllAudioEffects

Pause the playback of all sound effects.

virtual int PauseAllAudioEffects() = 0;

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

ResumeAudioEffect

Resume the playback of a sound effect.

virtual int ResumeAudioEffect(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

ResumeAllAudioEffects

Resume the playback of all sound effects.

virtual int ResumeAllAudioEffects() = 0;

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAudioEffectPublishVolume

Set the volume of a sound effect for stream ingest.

virtual int SetAudioEffectPublishVolume(unsigned int soundId, int volume) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

volume

int

The volume of the mixed audio. Valid values: 0 to 100. Default value: 50.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetAudioEffectPublishVolume

Queries the volume of a sound effect for stream ingest.

virtual int GetAudioEffectPublishVolume(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAllAudioEffectsPublishVolume

Set the volume of all sound effects for local playback.

virtual int SetAllAudioEffectsPublishVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The volume of the mixed audio. Valid values: 0 to 100. Default value: 50.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAudioEffectPlayoutVolume

Set the volume of a sound effect for local playback.

virtual int SetAudioEffectPlayoutVolume(unsigned int soundId, int volume) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

volume

int

The volume of the mixed audio. Valid values: 0 to 100. Default value: 50.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetAudioEffectPlayoutVolume

Query the volume of a sound effect for local playback.

virtual int GetAudioEffectPlayoutVolume(unsigned int soundId) = 0;

Parameter description

Name

Type

Description

soundId

unsigned int

The ID that is assigned by the user to the sound effect.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAllAudioEffectsPlayoutVolume

Set the volume of all sound effects for local playback.

virtual int SetAllAudioEffectsPlayoutVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The volume of the mixed audio. Valid values: 0 to 100. Default value: 50.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetAllAudioEffectsPublishVolume

Set the volume of all sound effects for stream ingest.

virtual int SetAllAudioEffectsPublishVolume(int volume) = 0;

Parameter description

Name

Type

Description

volume

int

The volume of the mixed audio. Valid values: 0 to 100. Default value: 50.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetLocalViewConfig

Set the rendering view and drawing parameters for local preview.

virtual int SetLocalViewConfig(AliEngineVideoCanvas renderConfig,
                                         AliEngineVideoTrack track) = 0;

This method is used to set up the local preview view. Calling this method binds the display window (view) of the local video stream and sets the rendering mode, mirror mode, rotation angle, and other parameters for the local user's view. It only affects the local user's preview and does not affect the streamed video. To set up the view for a remote user, call SetRemoteViewConfig.

Note
  • If the view parameter in AliEngineVideoCanvas is empty, rendering will stop.

  • To reset the renderMode parameter of AliEngineVideoCanvas during playback, keep other parameters unchanged and only modify renderMode.

  • To reset the mirrorMode parameter of AliEngineVideoCanvas during playback, keep other parameters unchanged and only modify mirrorMode.

  • We recommend explicitly calling StartPreview() to start the local preview.

Call timing

This method can be called both before and after joining a channel.

Parameter description

Name

Type

Description

renderConfig

AliEngineVideoCanvas

The rendering configuration, including the rendering view and rendering mode.

track

AliEngineVideoTrack

The source of the video track.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetCameraCapturerConfiguration

Set the capture preferences of the camera.

virtual int SetCameraCapturerConfiguration(const AliEngineCameraCapturerConfiguration& config) = 0;

This interface is used to configure camera capture preferences, such as camera orientation, capture frame rate, etc.

Call timing

Must be set before turning on the camera, for example, call before the following operations:

  • StartPreview (start preview)

  • JoinChannel (join channel)

Parameter description

Name

Type

Description

config

AliEngineCameraCapturerConfiguration

Camera capture preferences, including camera orientation, frame rate, etc. Default values:

  • preference:

    • AliEngineCaptureOutputPreferenceAuto, SDK automatically adjusts capture parameters.

    • AliEngineCaptureOutputPreferencePerformance: High-definition preview, capture prioritizes video preview quality.

    • AliEngineCaptureOutputPreferencePerformance: Capture selects the resolution closest to streaming, prioritizing device performance.

  • fps: -1 indicates using the frame rate settings inside the encoder, default is 15

  • cameraCaptureProfile: 0, specifies a specific resolution for video capture.

  • disableVideoCaptureReverse: Do not flip captured video frames based on aspect ratio, -1: default, 0: not effective, 1: effective.

  • captureObserverOriginal: Whether to callback the original videoframe data, -1: default, 0: off, 1: on.

"-1" indicates using the default settings of the SDK.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

EnableLocalVideo

Disable or re-enable local video collection.

virtual int EnableLocalVideo(bool enabled) = 0;

This method is used to control the enabling and disabling of local video collection. When local video collection is disabled, there is no video data for local preview and streaming, but it does not affect receiving remote video. If you call this interface to turn off local camera collection, both local preview and remote streaming will remain on the last frame.

Note

Local video collection is enabled by default in the SDK.

Call timing

This method can be called both before and after joining a channel.

Related callbacks

After successfully calling this interface, remote users will be notified through the OnUserVideoEnabled callback.

Parameter description

Name

Type

Description

enable

bool

A value of true re-enables local video collection. A value of false disables local video collection. Default value: true.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

MuteLocalCamera

Specify whether to stop publishing a local video track.

virtual int MuteLocalCamera(bool mute, AliEngineVideoTrack track) = 0;

When streaming, you can call this interface to push black video frames while maintaining normal local preview. The collection, encoding, and sending modules continue to work, but the video content consists of black frames.

Note

This interface only controls whether black frames are sent on the specified video stream. The collection and data sending processes are not stopped. If you want to stop video collection, use the EnableLocalVideo interface. If you want to stop sending video data, use the PublishLocalVideoStream interface.

Parameter description

Name

Type

Description

mute

bool

A value of true specifies that the publishing of the video track is stopped by sending black frames. A value of false specifies that the video track is published. Default value: false.

track

AliEngineVideoTrack

The source of the video track for which you want to change the publishing status.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

SetRemoteViewConfig

Set the rendering view and drawing parameters for the video track of a remote user.

virtual int SetRemoteViewConfig(AliEngineVideoCanvas renderConfig,
                                          const char *uid,
                                          AliEngineVideoTrack track) = 0;

This method binds the display view for a specified video stream of a remote user and sets the rendering mode, mirror mode, rotation angle, and other parameters for displaying the remote user's view locally. It only affects the video image seen by the local user. To set up a local preview view, call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#fbc8ab10f5e03" id="c0f59b8c26y7o">SetLocalViewConfig</a>.

  • If the view parameter in AliEngineVideoCanvas is empty, rendering stops.

  • To reset the renderMode parameter of AliEngineVideoCanvas during playback, keep other parameters unchanged and only modify renderMode.

  • To reset the mirrorMode parameter of AliEngineVideoCanvas during playback, keep other parameters unchanged and only modify mirrorMode.

Call timing

We recommend that you call this method when you receive the OnRemoteTrackAvailableNotify callback, which indicates that the remote user's video is available.

Parameter description

Name

Type

Description

canvas

AliEngineVideoCanvas

The rendering configuration, including the rendering view and rendering mode.

uid

const char *

The user ID.

track

AliEngineVideoTrack

The source of the video track.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

IsCameraOn

Queries whether the camera is turned on.

virtual bool IsCameraOn() = 0;

Return description

A value of YES indicates that the camera is turned on. A value of NO indicates that the camera is turned off.

SetVideoEncoderConfiguration

Set video encoding properties.

virtual void SetVideoEncoderConfiguration(const AliEngineVideoEncoderConfiguration& config) = 0;

This method is used to set video parameters corresponding to video stream encoding properties, such as resolution, frame rate, bitrate, video orientation, etc. It is recommended to call this interface for all video scenarios.

Note

All parameters have corresponding range limitations. If the set parameters are not within the valid range, the SDK will automatically adjust them.

Call timing

This method can be called both before and after joining a channel. If you only need to set the camera stream video encoding properties once per channel entry, it is recommended to call this before joining the channel.

Call restrictions

Both the mirrorMode parameter in this method and setVideoMirrorMode can set video stream mirroring. It is recommended to use only one method, as using multiple methods simultaneously may cause mirroring effects to stack, resulting in mirror setting failures or errors.

Parameter description

Name

Type

Description

config

AliEngineVideoEncoderConfiguration

The predefined encoding properties. Default values:

  • dimensions: [640,480]

  • frameRate: 15

  • bitrate: 0

  • keyFrameInterval: Group of Pictures (GOP) interval in milliseconds. Default is 0, indicating that it is controlled internally by the SDK.

  • forceStrictKeyFrameInterval: Whether to force the encoder to strictly generate keyframes according to the set keyframe interval. Default value is false.

  • mirrorMode: Stream mirroring, default is AliEngineVideoMirrorModeDisabled, see details in

  • orientationMode: 0

  • rotation: 0

SetVideoDecoderConfiguration

Sets video decoding properties. This method is used to set camera stream video decoding properties, including hardware/software decoding settings, whether to enable B frames, etc.

virtual void SetVideoDecoderConfiguration(const AliEngineVideoDecoderConfiguration& config) = 0;

Call timing

It is recommended to call this method before joining a channel and pulling streams.

Parameter description

Parameter

Type

Description

config

AliEngineVideoDecoderConfiguration

A struct that describes video decoding properties and their default values

StartPreview

Start a local preview. The camera is automatically turned on.

virtual int StartPreview(int width = 0, int height = 0) = 0;

This method is used to start a local video preview and automatically turn on the camera. To stop the local preview, you can call the StopPreview method.

Note

LeaveChannel will automatically stop the local preview; if you are not publishing a camera stream, the camera will be automatically turned off.

Call timing

  • Before calling this method, you need to set a view for local preview through SetLocalViewConfig, otherwise you cannot preview, but stream ingest is not affected.

  • If needed, you can call this method before JoinChannel to start the preview, which will automatically turn on the camera.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StopPreview

Stop a local preview.

virtual int StopPreview() = 0;

This method is used to close the local video preview and shut down the camera. After stopping the preview, the local end will remain on the last frame without affecting the stream ingest.

Note

LeaveChannel automatically stops the local preview; if you are not publishing a camera stream, the camera will be automatically turned off.

Call timing

You can call this method to stop the preview after it has been started.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

setVideoMirrorMode

Sets the preview and stream ingest mirroring capability.

virtual int setVideoMirrorMode(AliEngineVideoPipelineMirrorMode mirrorMode) = 0;

Sets whether to enable mirror mode for local preview video and pushed video streams.

Note

The priority of this interface is higher than SetLocalViewConfig&SetVideoEncoderConfiguration. To set video mirror mode, we recommend that you call this interface.

Call timing

This interface can be dynamically set both before and after joining a channel. The SDK internally records the state and operates on the video when it can handle preview and encoding (stream ingest).

Call restrictions

This interface overlaps with the mirrorMode parameter in SetLocalViewConfig&SetVideoEncoderConfiguration. We recommend that you only use this method.

Parameter description

Name

Type

Description

mirrorMode

AliEngineVideoPipelineMirrorMode

Sets the mirror mode

Return description

  • 0: The setting is successful.

  • <0: The setting failed.

    • AliRtcErrInner: SDK internal state error. Check whether the SDK instance was created successfully.

SetCapturePipelineScaleMode

Sets the capture scaling timing, determining whether video data is scaled immediately during capture or only during encoding.

virtual void SetCapturePipelineScaleMode(const AliEngineCapturePipelineScaleMode mode) = 0;

Sets the timing for video data capture scaling, determining whether to scale immediately during capture or only during encoding. For example, when the capture resolution differs from the encoding resolution, you can decide whether preview data and streaming data are consistent by setting the scaling timing.

Call timing

This method needs to be set before opening the camera, for example, before calling StartPreview to start preview or JoinChannel to join a channel.

Parameter description

Name

Type

Description

mode

AliEngineCapturePipelineScaleMode

The mode that controls the capture scaling timing. By default, scaling occurs immediately during capture.

GetCameraList

Gets the camera list.

virtual AliEngineDeviceInfoList* GetCameraList() = 0;

Return value

A pointer to the camera list object AliEngineDeviceInfoList*.

GetCurrentCameraName

Gets the name of the currently used camera.

virtual String GetCurrentCameraName() = 0;

Return value

The name of the currently used camera device.

GetCurrentCameraID

Gets the ID of the current camera

virtual String GetCurrentCameraID() = 0;

Return value

The ID of the current camera.

SetCurrentCameraName

Select camera name.

virtual int SetCurrentCameraName(const char* cameraName) = 0;

Parameter description

Name

Type

Description

cameraName

const char *

device name

Return value

0 indicates success, other values indicate failure.

SetCurrentCameraID

Select a camera ID.

virtual int SetCurrentCameraID(const char* cameraID) = 0;

Parameter description

Name

Type

Description

cameraID

const char *

The device ID.

Return value

0 indicates success, other values indicate failure.

GetCurrentCameraSupportedResolutionList

Gets the supported resolutions.

virtual AliEngineVideoResolutionList * GetCurrentCameraSupportedResolutionList(int source) = 0 ;

Parameter description

Name

Type

Description

source

int

The device type.

Return value

!=NULL indicates that the list of supported resolutions is obtained successfully. NULL indicates that the operation fails.

SetExternalVideoSource

Specifies whether to enable an external video source.

virtual int SetExternalVideoSource(bool enable,
        AliEngineVideoTrack type,
        AliEngineRenderMode renderMode) = 0;

Parameter description

Name

Type

Description

enable

bool

A value of true enables the external video source. A value of false disables the external video source.

type

AliEngineVideoTrack

Stream type.

renderMode

AliEngineRenderMode

The rendering mode.

PushExternalVideoFrame

Import external video data.

virtual int PushExternalVideoFrame(const AliEngineVideoRawData &frame,
        AliEngineVideoTrack type) = 0;

Parameter description

Name

Type

Description

frame

AliEngineVideoRawData

The video data.

type

AliEngineVideoTrack

Stream type.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StartPublishLiveStream

Starts relayed live streaming.

virtual int StartPublishLiveStream(const String& streamURL, const AliEngineLiveTranscodingParam &transcoding) = 0;

Parameter description

Name

Type

Description

streamUrl

const String

The ingest URL.

transcoding

AliEngineLiveTranscodingParam

The parameters for relayed live streaming.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

UpdatePublishLiveStream

Update the parameters for relayed live streaming.

virtual int UpdatePublishLiveStream(const String& streamURL, const AliEngineLiveTranscodingParam &transcoding) = 0;

Parameter description

Name

Type

Description

streamUrl

const String

The ingest URL.

transcoding

AliEngineLiveTranscodingParam

The parameters for relayed live streaming.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

StopPublishLiveStream

Stop relayed live streaming.

virtual int StopPublishLiveStream(const String& streamURL) = 0;

Parameter description

Name

Type

Description

streamURL

const String

The ingest URL.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

GetPublishLiveStreamState

Query the status of relayed live streaming.

virtual AliEngineLiveTranscodingState GetPublishLiveStreamState(const String& streamURL) = 0;

Parameter description

Parameter

Type

Description

streamURL

const String

The ingest URL.

Return description

The status of relayed live streaming is returned.

StartLastmileDetect

Starts network quality monitoring. Some local network issues may cause audio and video calls to fail. By calling this method, you can obtain information about the uplink and downlink networks, such as bandwidth, packet loss rate, jitter, and link RTT, which helps locate and resolve related network issues.

 virtual int StartLastmileDetect(bool uplink, bool downlink, int uplinkBandWidth, int downlinkBandWidth) = 0;

Call timing

You must call this method before you call JoinChannel. The detection results are returned in callbacks. A network detection process may take a long time. You can call StopLastmileDetect to stop the network detection process as required.

Call restrictions

The SDK can only execute one network detection at a time. Repeated calls before the previous detection ends will be ineffective.

Related callbacks

After successfully calling this method, two callbacks will be triggered:

Parameter description

Parameter

Type

Description

uplink

bool

Whether to detect the uplink.

downlink

bool

Whether to detect the downlink.

uplinkBandWidth

int

The maximum bandwidth for uplink detection.

downlinkBandWidth

int

The maximum bandwidth for downlink detection.

Return description

  • 0: The method call is successful.

  • <0: The method call fails, for example, if you have already joined a channel.

StopLastmileDetect

Stops network quality testing. You can call this method to stop network quality testing.

virtual int StopLastmileDetect() = 0;

Call timing

You need to call this method after creating the engine and before joining a channel.

Return description

  • 0: The call to this method is successful.

  • <0: The call to this method fails.

SendMediaExtensionMsg

Sends media extension information, implemented internally using SEI.

virtual int SendMediaExtensionMsg(const int8_t * message, uint32_t length, int32_t repeatCount, uint32_t delay, bool isKeyFrame) = 0;

The SDK provides functionality to send and receive media extension information. For the receiver side, refer to AliEngineEventListener::OnMediaExtensionMsgReceived. You need to reuse audio and video data tunnels when you use SEI. Therefore, you must control the frequency at which custom messages are sent and the length of the messages. Take note of the following points:

  • You can send a maximum of fps (set in the profile) messages per second.

  • To avoid affecting the transmission quality of media data, the custom message body is limited to 4K bytes, which can be used to transmit small amounts of data.

  • The repeatCount parameter in the sendMediaExtensionMsg function represents the redundancy of custom messages. If it is greater than 1, the message will be sent multiple times to prevent message loss due to network packet loss. In this case, others in the channel will also receive the same message multiple times and need to remove duplicates.

  • For custom messages that are sent, subscribers in the channel will also receive them during bypass live streaming. Setting to -1 will permanently send the data until sendMediaExtensionMsg is set again.

  • Only one sendMediaExtensionMsg will be sent at a time, meaning that calling sendMediaExtensionMsg will overwrite the previous call to sendMediaExtensionMsg if the previous call has not been sent or completed.

Parameter description

Name

Type

Description

message

const int8_t *

Extension information content, with a maximum length of 4K bytes

length

uint32_t

Extension information length, limited to a maximum of 4K (4*1024) bytes.

repeatCount

int32_t

Repeat count, representing message redundancy to prevent message loss due to network packet loss. A value of -1 indicates infinite retransmission until SendMediaExtensionMsg is called again.

delay

uint32_t

Delay in milliseconds before sending SEI. Because SEI is attached to the encoded h264/h265 stream, the actual delay will be slightly longer than the set delay.

isKeyFrame

bool

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

Return description

  • 0: The operation is successful.

  • <0: The operation failed, and an error code is returned.

    • ERR_INNER(-1): Internal SDK error, which may occur if the SDK is not initialized or if the method is called after the SDK is destroyed.

SendMediaExtensionMsgEx

Sends media extension information, implemented internally using SEI.

virtual int SendMediaExtensionMsgEx(const int8_t * message, uint32_t length, int32_t repeatCount, uint32_t delay, bool isKeyFrame, int32_t payloadType) = 0;

The SDK provides functionality for sending and receiving media extension information. For the receiver side, refer to AliEngineEventListener::OnMediaExtensionMsgReceived. You need to reuse audio and video data tunnels when you use SEI. Therefore, you must control the frequency at which custom messages are sent and the length of the messages. Take note of the following points:

  • You can send a maximum of fps (set in the profile) messages per second.

  • To avoid affecting the transmission quality of media data, the custom message body is limited to 4K bytes, which can be used to transmit small amounts of data.

  • The repeatCount parameter in the sendMediaExtensionMsg function represents the redundancy of custom messages. If the value is greater than 1, the message will be sent multiple times to prevent message loss due to network packet loss. In this case, other users in the channel will also receive the same message multiple times, requiring deduplication.

  • For custom messages that are sent, subscribers in the channel will also receive them during bypass live streaming. Setting to -1 means permanently sending data until sendMediaExtensionMsg is set again.

  • Only one sendMediaExtensionMsg will be sent at a time, meaning that calling sendMediaExtensionMsg will overwrite the previous call if the previous call has not been sent or completed.

Parameter description

Name

Type

Description

message

const int8_t *

Extension information content, limited to a maximum of 4K bytes

length

uint32_t

Extension information length, limited to a maximum of 4K (4*1024) bytes.

repeatCount

int32_t

Repeat count, representing message redundancy to prevent message loss due to network packet loss. A value of -1 indicates infinite retransmission until SendMediaExtensionMsg is called again.

delay

uint32_t

Delay in milliseconds before sending SEI. Because SEI is attached to the encoded h264/h265 stream, the actual delay will be slightly longer than the set delay.

isKeyFrame

bool

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

payloadType

int32_t

Data type field, payload=5 or payload=[100..254].

Return description

  • 0: The operation is successful.

  • <0: The operation failed, and an error code is returned.

    • ERR_INNER(-1): Internal SDK error, possibly because the SDK is not initialized or the method is called after the SDK is destroyed.

OnConnectionStatusChange

The callback that is invoked when the network connection status changes.

virtual void OnConnectionStatusChange(int status, int reason) {};

Parameter description

Parameter

Type

Description

status

AliEngineConnectionStatus

The current status.

reason

AliEngineConnectionStatusChangeReason

The specific reason for the status change.

OnLocalDeviceException

The callback that is invoked when a local device exception occurs. Pay attention to this callback.

virtual void OnLocalDeviceException(AliEngineLocalDeviceType deviceType, AliEngineLocalDeviceExceptionType exceptionType, const char* msg){};

Parameter description

Parameter

Type

Description

deviceType

AliEngineLocalDeviceType

The type of the device.

exceptionType

AliEngineLocalDeviceExceptionType

The type of the device exception.

msg

const char*

The information carried in the exception.

OnAuthInfoWillExpire

The callback for authentication information that is about to expire. The authentication expires 30 seconds after you receive this callback. Pay attention to this callback.

virtual void OnAuthInfoWillExpire() {};

This callback indicates that the user's authentication information is about to expire. The authentication expires 30 seconds after you receive this callback. You need to obtain a new Token and update the authentication information using one of the following methods:

  • Call the RefreshAuthInfo method to update the authentication information.

  • Call the LeaveChannel method to leave the current channel, and then call the JoinChannel method to rejoin the channel.

Call timing

The SDK triggers this callback 30 seconds before the user authentication information expires. You should update the authentication information promptly after receiving this callback.

OnAuthInfoExpired

The callback for expired authentication. The expiration information is returned by the server when users call a method that requires authentication.

virtual void OnAuthInfoExpired() {};

This callback indicates that the user's authentication information has expired. If you want to continue in the meeting, you need to generate a new Token on the server side and then update the authentication information using one of the following methods:

  • Call LeaveChannel to leave the current channel, and then call JoinChannel to rejoin the channel.

Trigger timing

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

OnJoinChannelResult

The callback that is invoked to return the result of joining a channel (this callback is equivalent to the block operation of calling the JoinChannel method, which handles events after joining a channel, and you can choose either one).

virtual void OnJoinChannelResult(int result, const char *channel, const char *userId, int elapsed) {}

Trigger conditions

When the application calls the JoinChannel method, this callback indicates whether the channel was successfully joined and returns information about the channel and the time taken to join the channel.

Parameter description

Parameter

Type

Description

result

int

The result of joining the channel. A value of 0 indicates success. Other values indicate error codes. For more information, see Error code list. The following are some common error codes:

  • ERR_JOIN_BAD_APPID: The AppId does not exist

  • ERR_JOIN_INVALID_APPID: The AppId has expired

  • ERR_JOIN_BAD_CHANNEL: The channel does not exist

  • ERR_JOIN_INVALID_CHANNEL: The channel has expired

  • ERR_JOIN_BAD_TOKEN: The token does not exist

  • ERR_JOIN_TIMEOUT: Joining the channel timed out

  • ERR_JOIN_BAD_PARAM: The parameters for joining the channel are incorrect

  • ERR_JOIN_FAILED: Failed to join the channel

  • ERR_JOIN_CONFIG_INVALID: The meeting parameters are invalid, such as an empty token

channel

const char *

The ID of the channel.

userId

const char *

The ID of the user.

elapsed

int

The amount of time consumed for joining the channel.

OnLeaveChannelResult

The callback that is invoked to return the result of leaving a channel. This callback is returned after you call the LeaveChannel method. If you call Destroy immediately after calling LeaveChannel, you will not receive this callback.

virtual void OnLeaveChannelResult(int result, AliEngineStats stats) {}

Trigger conditions

When the application successfully calls LeaveChannel to leave the channel, this callback is triggered to return the result of leaving the channel and the statistics for the channel session.

Note

If you call Destroy immediately after calling LeaveChannel, this callback is not triggered.

Parameters

Parameter

Type

Description

result

int

The result of the request to leave the channel. A value of 0 indicates that the request is successful. A value other than 0 indicates the error code that is returned if the request fails.

stats

AliEngineStats

The statistics on the session in the channel.

OnRemoteUserOffLineNotify

The callback that is invoked when a remote user goes offline.

virtual void OnRemoteUserOffLineNotify(const char *uid, AliEngineUserOfflineReason reason) {}

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

Trigger conditions

  • When a remote user actively leaves the channel, this callback is triggered.

  • When a remote streamer calls <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#c99c2b257dd8o" id="03e45f655fcxx">SetClientRole</a> to switch to the viewer role (set to AliEngineClientRoleLive), this callback is triggered.

  • When no data is received from a remote streamer for a long time and they are considered disconnected, this callback is triggered.

Parameter description

Parameter

Type

Description

uid

const char *

The user ID that is uniquely assigned by the AppServer.

reason

AliEngineUserOfflineReason

The reason why the remote user goes offline.

OnRemoteUserOnLineNotify

The callback that is invoked when a remote user goes online.

virtual void OnRemoteUserOnLineNotify(const char *uid, int elapsed) {}

This interface is used to notify the local client that a remote user has joined the channel.

Trigger conditions

  • A remote user successfully joins the channel.

  • After the current user joins the channel, they will receive join callbacks for users who are already in the channel, to display previously joined users.

Parameter description

Parameter

Type

Description

uid

const char *

The user ID that is uniquely assigned by the AppServer.

elapsed

int

The amount of time consumed for the remote user to join the channel.

OnRemoteTrackAvailableNotify

The callback that is invoked when the stream of a remote user changes.

virtual void OnRemoteTrackAvailableNotify(const char *uid,
                                                  AliEngineAudioTrack audioTrack,
                                                  AliEngineVideoTrack videoTrack) {}

This callback is triggered when the streaming status of a remote user changes. Through this callback, developers can monitor in real-time whether remote users are publishing audio and video streams, and display or hide remote users' audio and video information on the interface accordingly.

Trigger conditions

This callback is triggered in the following scenarios:

  • When a remote user changes from not streaming to streaming (including audio and video)

  • When a remote user changes from streaming to not streaming (including audio and video)

  • In interactive mode, when a remote user calls SetClientRole to switch from viewer to streamer role, and sets up streaming, this callback will be triggered

Taking video as an example, if a remote user sets not to stream, this callback will not be triggered:

  • When a remote user starts publishing a camera stream (streaming status: no video stream -> camera stream only), the callback returns AliEngineVideoTrackCamera indicating that the remote user's camera stream is available.

  • When the remote user also publishes a screen sharing stream (streaming status: camera stream only -> both camera stream and screen sharing stream), the callback returns AliEngineVideoTrackBoth indicating that both the remote user's camera stream and screen sharing stream are available.

  • When the remote user stops publishing the camera stream and only keeps the screen sharing stream (streaming status: both camera stream and screen sharing stream -> screen sharing stream only), the callback returns AliEngineVideoTrackScreen indicating that only the screen sharing stream is currently available.

  • When the remote user also stops publishing the screen sharing stream (streaming status: screen sharing stream only -> no video stream), the callback returns AliEngineVideoTrackNo indicating that no video stream is currently available.

Note

This callback returns the streaming status of remote users. To know which stream went offline in this change, please record the status changes before and after the callback.

Parameter description

Parameter

Type

Description

uid

const char *

The user ID that is uniquely assigned by the AppServer.

audioTrack

AliEngineAudioTrack

The source of the audio track after the change.

videoTrack

AliEngineVideoTrack

The source of the video track after the change.

OnBye

The callback that is invoked when a user is forced to leave a channel.

virtual void OnBye(int code) {}

This callback is triggered when a user is disconnected for some reason or when the meeting ends. Developers can determine the reason for disconnection based on the callback parameter code and take appropriate action.

Trigger conditions

  • The current user is kicked out by the server.

  • The meeting ends (the server actively removes the channel).

  • Passive departure, requiring the client to attempt to recover the session or reconnect.

Parameter description

Parameter

Type

Description

code

int

The message type. Valid values:

  • 1: The user is kicked out from the channel by the server.

  • 2: The channel is closed.

  • 3: The user is removed from the channel by the server because the same user ID is used to join the channel from another device.

OnAudioPublishStateChanged

The callback that is invoked when the status of stream ingest for an audio track changes.

virtual void OnAudioPublishStateChanged(AliEnginePublishState oldState, AliEnginePublishState newState, int elapseSinceLastState, const char *channel) {};

This callback is used to monitor changes in the stream ingest state of the local user's audio stream.

Trigger conditions

When the audio stream ingest state of the user changes, for example:

  • Stop stream ingest.

  • Call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#c99c2b257dd8o" id="904fc4e83a35n">SetClientRole</a> to switch to viewer role.

Parameter description

Parameter

Type

Description

oldState

AliEnginePublishState

The previous stream ingest state.

newStat

AliEnginePublishState

The current stream ingest state.

elapseSinceLastState

int

The time elapsed for the change. Unit: milliseconds.

channel

const char *

The ID of the current channel.

OnAudioSubscribeStateChanged

The callback that is invoked when the status of subscription to an audio track changes.

virtual void OnAudioSubscribeStateChanged(const char *uid,
                                                  AliEngineSubscribeState oldState, 
                                                  AliEngineSubscribeState newState,
                                                  int elapseSinceLastState,
                                                  const char *channel) {};

This callback notifies the local user that the subscription status of a remote user's audio stream has changed. Through this callback, you can learn about the changes in the subscription status of a remote user's audio stream, along with the time interval from the previous state to the current state.

Parameter description

Parameter

Type

Description

uid

NSString *_Nonnull

The ID of the user for whom the subscription status changes.

oldState

AliEngineSubscribeState

The previous subscription state.

newState

AliEngineSubscribeState

The current subscription status.

elapseSinceLastState

int

The time elapsed since the last status change. Unit: milliseconds.

channel

const char *

The channel ID.

OnUserAudioMuted

Notification when a user mutes their audio.

virtual void OnUserAudioMuted(const char* uid, bool isMute) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who executes MuteAudio.

isMute

bool

A value of true indicates that the audio track is muted. A value of false indicates that the audio track is not muted.

OnUserAudioInterruptedBegin

A notification that the user's audio was interrupted. This typically occurs when another application, such as a phone call app, takes control of the audio.

virtual void OnUserAudioInterruptedBegin(const char* uid) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user whose audio track is interrupted.

OnUserAudioInterruptedEnded

Notification that a user's audio interruption has ended (corresponds to OnUserAudioInterruptedBegin).

virtual void OnUserAudioInterruptedEnded(const char* uid) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user whose audio interruption has ended.

OnVideoPublishStateChanged

The callback that is invoked when the first video frame from a remote user is displayed.

virtual void OnVideoPublishStateChanged(AliEnginePublishState oldState, AliEnginePublishState newState, int elapseSinceLastState, const char *channel) {};

This callback is used to monitor changes in the video stream ingest status of the local user.

Parameter description

Parameter

Type

Description

oldState

AliEnginePublishState

The previous stream ingest state.

newState

AliEnginePublishState

The current stream ingest state.

elapseSinceLastState

int

The time elapsed since the last state change. Unit: milliseconds.

channel

const char *

The channel ID.

OnVideoSubscribeStateChanged

Callback for camera stream subscription changes.

virtual void OnVideoSubscribeStateChanged(const char *uid, 
                                                  AliEngineSubscribeState oldState, 
                                                  AliEngineSubscribeState newState,
                                                  int elapseSinceLastState,
                                                  const char *channel) {};

This callback notifies the local user that the subscription status of a remote user's camera track has changed. Through this callback, you can learn about the subscription status change of a specific remote user's camera track, along with the time interval from the previous state to the current state.

Related callbacks

Video streams mainly include camera tracks and screen sharing tracks. This interface is for the subscription status change of camera tracks, while the related callback interface for screen sharing tracks is OnScreenShareSubscribeStateChanged.

Parameter description

Parameter

Type

Description

uid

const char *

The ID of the user for whom the subscription status changes.

oldState

AliEngineSubscribeState

The previous subscription status.

newState

AliEngineSubscribeState

The current subscription status.

elapseSinceLastState

int

The time elapsed since the last state change. Unit: milliseconds.

channel

const char *

The current channel ID.

OnUserVideoMuted

User MuteVideo notification.

virtual void OnUserVideoMuted(const char* uid, bool isMute) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who stops the video track.

isMute

bool

A value of true indicates that black frames are sent for stream ingest. A value of false indicates that the stream is normally ingested.

OnUserVideoEnabled

Notification for disabling or re-enabling local video capture.

virtual void OnUserVideoEnabled(const char* uid, bool isEnable) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who executes EnableLocalVideo.

isMute

bool

A value of true indicates that camera stream capturing is enabled. A value of false indicates that camera stream capturing is disabled.

OnUserWillResignActive

The callback that is triggered when a remote user's application moves to the background.

virtual void OnUserWillResignActive(const char* uid) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who switches the application to the background.

OnUserWillBecomeActive

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

virtual void OnUserWillBecomeActive(const char* uid) {}

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who switches the application back to the foreground.

OnStats

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

virtual void OnStats(const AliEngineStats& stats) {}

Parameter description

Parameter

Type

Description

stats

AliEngineStats

Data callback.

OnLocalVideoStats

Local video statistics information (triggered every 2 seconds).

virtual void OnLocalVideoStats(const AliEngineLocalVideoStats& localVideoStats);

Parameter information

Parameter

Type

Description

localVideoStats

const AliEngineLocalVideoStats&

Local video statistics information, including bitrate, frame rate, and other information.

OnRemoteVideoStats

Remote video statistics information (triggered every 2 seconds).

virtual void OnRemoteVideoStats(const AliEngineRemoteVideoStats& remoteVideoStats);

Parameter information

Parameter

Type

Description

remoteVideoStats

const AliEngineRemoteVideoStats&

Remote video statistics information, including remote user ID, frame rate, stuttering, and other information.

OnLocalAudioStats

Local audio statistics information (triggered every 2 seconds).

virtual void OnLocalAudioStats(const AliEngineLocalAudioStats& localAudioStats);

Parameter information

Parameter

Type

Description

localAudioStats

const AliEngineLocalAudioStats&

Local audio statistics information, including sample rate, the number of sound channels, etc.

OnRemoteAudioStats

Remote audio statistics information (triggered once every 2 seconds).

virtual void OnRemoteAudioStats(const AliEngineRemoteAudioStats& remoteAudioStats);

Parameter information

Parameter

Type

Description

remoteAudioStats

const AliEngineRemoteAudioStats&

Remote audio statistics information, including packet loss rate, stuttering rate, etc.

OnMediaExtensionMsgReceived

The callback that is invoked when an SEI message is received. When one user sends a message through SendMediaExtensionMsg, other users receive the data through this callback.

virtual void OnMediaExtensionMsgReceived(const char* uid, const uint8_t payloadType, const int8_t * message, uint32_t size);

When one user sends a message through sendMediaExtensionMsg, other users receive the data through this callback.

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the user who sends the message.

payloadType

const uint8_t

The payload type. sendMediaExtensionMsg returns 5, while sendMediaExtensionMsgEx returns the specific type.

message

const int8_t *

The content of the message.

size

uint32_t

The length of the message.

OnSnapshotComplete

The callback for snapshot results, which returns the snapshot result after a user successfully calls SnapshotVideo.

virtual void OnSnapshotComplete(const char* userId, AliEngineVideoTrack videoTrack, void* buffer, int width, int height, bool success);

Parameter description

Parameter

Type

Description

userId

const char*

The user ID, indicating which user's video stream was captured.

videoTrack

AliEngineVideoTrack

The type of video being captured, such as camera stream or screen sharing stream.

buffer

void*

If successful, returns the image data of the snapshot in RGBA format; if failed, returns nullptr.

width

int

The width of the snapshot.

height

int

The height of the snapshot.

success

bool

Indicates whether the snapshot is taken.

  • true: The snapshot is taken successfully.

  • false: The snapshot failed.

OnLocalAudioStateChange

Local audio device status callback.

virtual void OnLocalAudioStateChange(AliEngineLocalAudioStateType state, const char* msg);

Parameter description

Parameter

Type

Description

state

AliEngineLocalAudioStateType

The current status of the audio device, such as starting, started, etc.

msg

const char*

Description information about the device status change.

onLocalVideoStateChanged

Local video device status callback.

virtual void onLocalVideoStateChanged(AliEngineLocalVideoStateType state, const char* msg);

Parameter description

Parameter

Type

Description

state

AliEngineLocalVideoStateType

The current status of the video device, such as starting, started, etc.

msg

const char*

Description information about the device status change.

OnRemoteUserSubscribedDataChannel

Callback indicating that you can start sending data channel messages.

virtual void OnRemoteUserSubscribedDataChannel(const char* uid);

This interface is triggered when a remote user subscribes to the Data Channel. This callback notifies the local user that the specified remote user is ready to receive custom messages, allowing developers to safely call SendDataChannelMessage to send data to them. This callback is a key mechanism for ensuring reliable message delivery, preventing packet loss or failures that might occur when sending messages to users who have not subscribed to the Data Channel.

Parameter description

Parameter

Type

Description

uid

const char*

Remote user ID.

OnDataChannelMessage

Data channel message callback.

virtual void OnDataChannelMessage(const char* uid, const AliEngineDataChannelMsg& msg);

ARTC SDK provides the ability to send and receive custom messages, allowing you to send custom real-time message data while transmitting audio and video data. This callback is used to receive data channel custom messages. For specific usage, please refer to Custom message sending and receiving.

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

  • This feature is disabled by default. To enable it, call <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#d78a13ea0e6hy" id="327b69c0ee1wh">SetParameter</a> after creating the engine and set {\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}.

Trigger timing

After the sender calls SendDataChannelMessage to send a custom message, if the receiver has enabled the data channel feature, this callback will be triggered on the receiver's side.

Parameter description

Parameter

Type

Description

uid

const char*

Sender user ID.

msg

const AliEngineDataChannelMsg&

Data channel message.

OnCapturedAudioFrame

Audio capture raw data callback.

virtual bool OnCapturedAudioFrame(AliEngineAudioRawData audioRawData) = 0;

This callback is used to obtain the original audio data captured by the current device. It is disabled by default. To obtain this audio data:

  • Enable this callback through the audioSource parameter in EnableAudioFrameObserver(true,audioSource,config). Additionally, the config parameter can be used to set the sample rate, the number of sound channels, read/write mode, and other parameters for obtaining audio data.

  • Call RegisterAudioFrameObserver to register an audio data receiver object.

Note

This interface supports setting the sample rate, the number of sound channels, and read/write mode.

Parameter description

Parameter

Type

Description

audioRawData

AliEngineAudioRawData

The audio data.

Return description

  • true: Success.

  • false: Failure.

OnProcessCapturedAudioFrame

3A processed data callback.

virtual bool OnProcessCapturedAudioFrame(AliEngineAudioRawData audioRawData) = 0;

This callback is used to obtain audio data after 3A processing. It is disabled by default. To obtain this audio data:

  • Enable this callback through the audioSource parameter in EnableAudioFrameObserver(true,audioSource,config). Additionally, the config parameter can be used to set the sample rate and the number of sound channels, read/write mode, etc.

  • Call RegisterAudioFrameObserver to register an audio data receiver object.

Note

This interface supports setting the sample rate, the number of sound channels, and read/write mode.

Parameter description

Parameter

Type

Description

audioRawData

AliEngineAudioRawData

The audio data.

Return description

  • true: Success.

  • false: Failure.

OnPublishAudioFrame

The callback for data statistics during stream ingest.

virtual bool OnPublishAudioFrame(AliEngineAudioRawData audioRawData) = 0;

This callback is used to obtain audio data during stream ingest. It is disabled by default. To obtain this audio data:

  • Enable this callback through the audioSource parameter in EnableAudioFrameObserver(true,audioSource,config). Additionally, the config parameter can be used to set the sample rate, the number of sound channels, read/write mode, and other parameters for obtaining audio data.

  • Call RegisterAudioFrameObserver to register an audio data receiver object.

Note

This interface supports setting the sample rate and the number of sound channels, but can only be set to read-only mode.

Parameter description

Parameter

Type

Description

audioRawData

AliEngineAudioRawData

The audio data.

Return description

  • true: successful.

  • false: failed.

OnPlaybackAudioFrame

Playback data callback.

virtual bool OnPlaybackAudioFrame(AliEngineAudioRawData audioRawData) = 0;

This callback is used to obtain the audio data being played. It is disabled by default. To obtain this audio data:

  • Enable this callback through the audioSource parameter in EnableAudioFrameObserver(true,audioSource,config). Additionally, the config parameter can be used to set the sample rate and the number of sound channels, read/write mode, and other parameters for obtaining audio data.

  • Call RegisterAudioFrameObserver to register an audio data receiver object.

Note

This interface supports setting the sample rate, the number of sound channels, and the read/write mode.

Call restrictions

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

Parameter description

Parameter

Type

Description

audioRawData

AliEngineAudioRawData

The audio data.

Return description

  • true: Success.

  • false: Failure.

OnRemoteUserAudioFrame

Remote audio stream data callback.

virtual bool OnRemoteUserAudioFrame(const char *uid, AliEngineAudioRawData audioRawData) = 0; 

This callback is used to obtain the remote audio data of a specified user. It is disabled by default. To obtain this audio data:

  • Enable this callback through the audioSource parameter in EnableAudioFrameObserver(true, audioSource, config). Additionally, you can use the config parameter to set the sample rate, the number of sound channels, read/write mode, and other parameters for obtaining audio data.

  • Call RegisterAudioFrameObserver to register an audio data receiver object.

Note

This interface does not support setting the sample rate or the number of sound channels, but it can set the read/write mode.

Call restrictions

Do not perform any time-consuming operations in this callback function, as this may cause audio abnormalities.

Parameter description

Parameter

Type

Description

uid

const char *

Remote user ID.

audioRawData

AliEngineAudioRawData

The audio data.

Return description

  • true: Success.

  • false: Failed.

OnCaptureVideoSample

Local video data capture callback.

virtual bool OnCaptureVideoSample(AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;

This interface is a callback for obtaining local video capture data, used to acquire raw video frames (such as YUV data) captured by the local camera. You can implement custom video processing logic (such as adding filters, watermarks, transcoding, etc.) through this callback, and decide whether to return the processed data to the SDK for subsequent encoding or rendering. To send the processed video to the SDK, return true.

Call timing

After successfully calling <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#0873ceb145h0t" id="c9469a35210sg">RegisterVideoSampleObserver</a> to register the video data observer, when the SDK captures the corresponding video frame.

Parameter description

Parameter

Type

Description

videoSource

AliEngineVideoSource

Video data source.

videoRawData

AliEngineVideoRawData

The raw video data.

Return description

  • true: Needs to be written back to SDK (only effective for I420 and native(ios/mac)).

  • false: No need to write back to SDK.

OnPreEncodeVideoSample

Local pre-encode video data callback.

virtual bool OnPreEncodeVideoSample(AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;

This interface is a callback for obtaining local video data before encoding. It is used to retrieve the original video data (such as YUV format) before the SDK encodes the video frame. Developers can implement custom processing logic (such as adding watermarks, adjusting colors, transcoding, etc.) through this callback and decide whether to return the processed data to the SDK for subsequent encoding.

Parameter description

Parameter

Type

Description

videoSource

AliEngineVideoSource

Video data source.

videoRawData

AliEngineVideoRawData

Video data.

Return description

  • true: The data needs to be written back to the SDK (only effective for I420 and native(ios/mac)).

  • false: The data does not need to be written back to the SDK.

OnRemoteVideoSample

The callback that is invoked to return the remote video data being subscribed to.

virtual bool OnRemoteVideoSample(const char *uid, AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;

This interface is a callback for obtaining the subscribed remote video data, used to get the original video frame data (such as YUV format) of remote users. You can implement custom processing logic (such as adding filters, watermarks, transcoding) through this callback, and decide whether to return the processed data to the SDK for subsequent rendering.

Parameter description

Parameter

Type

Description

uid

const char *

The ID of the remote user.

videoSource

AliEngineVideoSource

The video data source.

videoRawData

AliEngineVideoRawData

The raw video data.

Return description

  • true: The data needs to be written back to the SDK.

  • false: The data does not need to be written back to the SDK.

GetVideoAlignment

The width alignment of the output video.

virtual AliEngineVideoObserAlignment GetVideoAlignment();

Return value

The expected width alignment of the output video. For more information, see AliEngineVideoObserAlignment.

GetObservedFramePosition

Video data output content.

virtual uint32_t GetObservedFramePosition();

Return description

Expected video output content. For more information, see AliEngineVideoObserPosition.

onDestroyCompletion

Destroy completion callback.

virtual void onDestroyCompletion();

This callback indicates that the SDK engine instance has been destroyed completely, and a new instance can be created.

Trigger timing

This callback is triggered after the engine is completely destroyed when the user calls Destroy.

Note

Wait for the onDestroyCompletion callback before executing other methods to avoid blocking the main thread.

OnAudioEffectFinished

Callback for when local sound effect playback ends.

virtual void OnAudioEffectFinished(int soundId) {}

Parameter

Type

Description

soundId

int

The ID of the sound effect that has finished playing.

OnAudioVolumeCallback

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

virtual void OnAudioVolumeCallback(const AliEngineUserVolumeInfo* volumeInfo, int volumeInfoCount, int totalVolume) {}

This callback is disabled by default. You can enable it by calling the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f69f93ca70pa6" id="9e5f7dfbe43ze">EnableAudioVolumeIndication</a> method. After this callback is enabled, if users are publishing streams in the channel, the SDK triggers this callback at the time interval specified in <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f69f93ca70pa6" id="ebd7f2147ar4d">EnableAudioVolumeIndication</a> after you join the channel. The callback result includes volume information for both local and remote speakers.

Parameter description

Parameter

Type

Description

volumeInfo

AliEngineUserVolumeInfo*

The array that contains the volume information of each user, including the UID, speech status, and volume. A value of 0 for the UID indicates a local user.

volumeInfoCount

int

Indicates the number of items in the callback user volume information array

totalVolume

int

The total volume after the audio is mixed. Valid values: 0 to 255. If this callback is returned to a local user, the value of totalVolume indicates the volume after the audio of the local user is mixed. If this callback is returned to a remote user, the value of totalVolume indicates the total volume after the audio from all speakers is mixed.

OnActiveSpeaker

The callback for the active speaker.

virtual void OnActiveSpeaker(const char *uid) {}

After successfully calling <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#f69f93ca70pa6" id="b5e0ba1248tmp">EnableAudioVolumeIndication</a>, the SDK continuously monitors the remote user with the highest volume and tracks how many times this user is determined to be the loudest. During the current time period, the remote user with the highest accumulated count is identified as the most active user.

Trigger conditions

When the number of users in the channel is greater than or equal to 2 and there is an active remote user, the SDK triggers this callback and reports the uid of the most active remote user.

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

  • If the most active remote user changes, the SDK will trigger this callback again and report the uid of the new most active remote user.

Parameter description

Parameter

Type

Description

uid

const char *

The ID of the user who is speaking.

OnPublishLiveStreamStateChanged

The callback that is invoked when the status of a relayed live streaming task changes.

virtual void OnPublishLiveStreamStateChanged(const char* streamUrl ,AliEngineLiveTranscodingState state ,AliEngineLiveTranscodingErrorCode errCode){};

Parameter description

Parameter

Type

Description

streamURL

const char*

Stream URL.

state

AliEngineLiveTranscodingState

Status.

errCode

AliEngineLiveTranscodingErrorCode

Fault code.

OnPublishTaskStateChanged

Bypass task status change callback.

virtual void OnPublishTaskStateChanged(const char* streamUrl, AliEngineTrascodingPublishTaskStatus state){};

Parameter description

Parameter

Type

Description

streamURL

const char*

Stream URL.

state

AliEngineTrascodingPublishTaskStatus

Status.

OnNetworkQualityChanged

Network quality change callback. This callback is triggered when the network quality changes.

virtual void OnNetworkQualityChanged(const char *uid, AliEngineNetworkQuality upQuality, AliEngineNetworkQuality downQuality);

Parameter description

Parameter

Type

Description

uid

char*

The user UID whose network quality has changed.

Note

When the UID is empty, it indicates that the user's own network quality has changed.

upQuality

AliEngineNetworkQuality

Uplink network quality level.

downQuality

AliEngineNetworkQuality

Downlink network quality level.

OnLastmileDetectResultWithQuality

The callback that is invoked when the network quality is poor.

virtual void OnLastmileDetectResultWithQuality(AliEngineNetworkQuality networkQuality);

This callback describes the network probe results before the local user joins the channel, which is used to roughly determine the network quality level. After calling StartLastmileDetect, the SDK returns this callback in approximately 3 seconds.

Parameter description

Parameter

Type

Description

networkQuality

AliEngineNetworkQuality

Network quality level.

OnLastmileDetectResultWithBandWidth

The callback result for the pre-call network quality probe. This callback is triggered after the probe runs for approximately 30 seconds.

virtual void OnLastmileDetectResultWithBandWidth(int code, AliRTCSdk::AliEngineNetworkProbeResult networkQuality);

After calling StartLastmileDetect, the SDK will return this callback in about 30 seconds, providing detailed network quality results.

Parameter description

Parameter

Type

Description

code

int

Return value:

  • 0: The detection is successful.

  • -1: The detection fails.

networkQuality

AliRTCSdk::AliEngineNetworkProbeResult

The network detection result, including link RTT and packet loss rate, jitter, and bandwidth for uplink and downlink networks.

OnOccurError

When an error occurs in the engine, the app receives notification through this callback.

virtual void OnOccurError(int error, const char *msg);

Parameter description

Parameter

Type

Description

error

int

The error type, refer to AliEngineErrorCode.

msg

const char *

The error message.

OnFirstAudioPacketSend

Callback triggered when the first audio data packet is sent.

virtual void OnFirstAudioPacketSend(AliEngineAudioTrack audioTrack, int timeCost);

Parameter description

Parameter

Type

Description

audioTrack

AliEngineAudioTrack

Audio type, indicating which audio stream's first packet is being sent.

timeCost

int

Sending time cost, the time elapsed from joining the channel to sending the first audio packet (unit: milliseconds).

OnFirstAudioPacketReceived

The callback that is triggered when the first audio data packet from a remote user is received.

virtual void OnFirstAudioPacketReceived(const char* uid, AliEngineAudioTrack audioTrack, int timeCost) 

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

audioTrack

AliEngineAudioTrack

The audio track type, indicating which audio stream's first packet was received.

timeCost

int

The time elapsed from joining the channel to receiving the first audio packet (unit: milliseconds).

OnFirstVideoPacketSend

Callback triggered when the first video packet is sent.

virtual void OnFirstVideoPacketSend(AliEngineVideoTrack videoTrack, int timeCost);

Parameter description

Parameter

Type

Description

videoTrack

AliEngineVideoTrack

The video track type, indicating which video stream's first packet was sent, such as camera stream or screen sharing stream.

timeCost

int

The time cost in milliseconds, from joining the channel to sending the first video packet.

OnFirstVideoPacketReceived

Callback triggered when the first video packet is received.

virtual void OnFirstVideoPacketReceived(const char* uid, AliEngineVideoTrack videoTrack, int timeCost);

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

videoTrack

AliEngineVideoTrack

The video track type, indicating which video stream's first packet was received, such as camera stream or screen sharing stream.

timeCost

int

The time elapsed from joining the channel to receiving the first video packet (in milliseconds).

OnFirstRemoteAudioDecoded

The callback that is invoked when the first remote audio frame is decoded.

virtual void OnFirstRemoteAudioDecoded(const char* uid, AliEngineAudioTrack audioTrack, int elapsed);

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

audioTrack

AliEngineAudioTrack

The audio track type, indicating which audio stream has completed decoding of the first frame.

elapsed

int

The time elapsed from when the local user joins the channel until this callback is triggered, in milliseconds.

OnFirstRemoteVideoFrameDrawn

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

virtual void OnFirstRemoteVideoFrameDrawn(const char *uid, AliEngineVideoTrack videoTrack,
                                                  int width, int height, int elapsed);

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

videoTrack

AliEngineVideoTrack

The video type, indicating which video stream, such as camera stream or screen sharing stream.

width

int

The width of the video.

height

int

The height of the video.

elapsed

int

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

OnFirstLocalVideoFrameDrawn

This message is triggered when the first video frame is displayed in the preview.

virtual void OnFirstLocalVideoFrameDrawn(int width, int height, int elapsed);

Parameter description

Parameter

Type

Description

width

int

The width of the video.

height

int

The height of the video.

elapsed

int

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

OnTestAudioVolumeCallback

Audio volume callback for pre-call audio capture testing.

virtual void OnTestAudioVolumeCallback(int volumn);

This callback is triggered after you successfully call StartAudioCaptureTest. A normal volume return indicates that the audio capture is functioning properly.

Parameter description

Parameter

Type

Description

volumn

int

Returns volume information.

OnAudioAccompanyStateChanged

Local accompaniment playback status callback.

virtual void OnAudioAccompanyStateChanged(AliEngineAudioAccompanyStateCode playState, AliEngineAudioAccompanyErrorCode errorCode);

This callback is triggered when the accompaniment playback status changes and notifies you of the current playback status and error code.

Parameter description

Parameter

Type

Description

playState

AliEngineAudioAccompanyStateCode

Current playback status.

errorCode

AliEngineAudioAccompanyErrorCode

Playback error code.

OnAudioFileInfo

Audio file information callback.

virtual void OnAudioFileInfo(AliEngineAudioFileInfo info, AliEngineAudioAccompanyErrorCode errorCode);

This callback is triggered after calling GetAudioFileInfo, returning the current audio file information and error code.

Parameter description

Parameter

Type

Description

info

AliEngineAudioFileInfo

Audio file information.

errorCode

AliEngineAudioAccompanyErrorCode

Error code.

OnRemoteAudioAccompanyStarted

The callback that is invoked when a remote user begins audio accompaniment playback.

virtual void OnRemoteAudioAccompanyStarted(const char* uid);

Parameter description

Parameter

Type

Description

uid

const char*

The ID of the remote user.

OnRemoteAudioAccompanyFinished

The callback that is invoked when the playback of a remote user's audio accompaniment ends.

virtual void OnRemoteAudioAccompanyFinished(const char* uid);

Parameter description

Parameter

Type

Description

uid

const char*

The remote user ID.

SetParameter

Set custom parameters.

virtual int SetParameter(const char* parameter) = 0;

Parameter description

Parameter

Type

Description

param

const char*

Custom parameters.

GetParameter

Retrieve custom parameters.

virtual String GetParameter(const char* parameter) = 0;

Parameter description

Parameter

Type

Description

parameter

const char*

Custom parameters.

EnableAudioFrameObserver

Enables or disables audio data callbacks.

virtual int EnableAudioFrameObserver(bool enabled, AliEngineAudioSource audioSource, AliEngineAudioFrameObserverConfig config) = 0;

This method enables or disables callbacks for specific types of audio data. This lets you obtain various types of raw and encoded audio data. By default, this feature is disabled. To enable it, call this method.

Note

When you call this method to enable audio data callbacks for a specific AliEngineAudioSource, you must also call the RegisterAudioFrameObserver method to register a receiver object for the audio data.

When to call

You can call this method when you need to obtain audio data.

Parameters

Parameter

Type

Description

enable

bool

Specifies whether to allow callbacks.

audioSource

AliEngineAudioSource

The type of the data source for the callback. The sources include post-collection (0), post-3A processing (1), stream ingest (2), playback (3), and pulled stream (5) audio data.

Note:

  • Audio data for stream ingest and mixed audio data for stream ingest and playback support only the read-only (ReadOnly) mode.

  • You cannot modify parameters such as the sample rate and the number of sound channels for audio data from pulled streams.

config

AliEngineAudioFrameObserverConfig

The audio callback settings, which include the sample rate, number of sound channels, and callback read/write mode (read-only, write-only, or read/write). If this parameter is set to null, the default settings are used: a sample rate of 48,000, one sound channel, and ReadOnly mode.

RegisterAudioFrameObserver

Registers an audio callback.

virtual int RegisterAudioFrameObserver(IAudioFrameObserver* observer) = 0;

This method registers an object that receives audio callback data.

Call timing

When you need the SDK to trigger callbacks such as OnCapturedAudioFrame, OnProcessCapturedAudioFrame, OnPublishAudioFrame, OnPlaybackAudioFrame, OnRemoteUserAudioFrame to obtain various types of audio data, you can call this method to provide an object that receives audio data. To cancel the registration, call this method again and pass null.

Call restrictions

You need to call EnableAudioFrameObserver to enable specific AliEngineAudioSource callbacks. Otherwise, the current observer will not receive data.

Parameter description

Parameter

Type

Description

observer

IAudioFrameObserver*

Pointer to the callback object

Return value

0 indicates success. Other values indicate failure.

UnRegisterAudioFrameObserver

Unsubscribe from audio data output (IAliEngineMediaEngine interface).

virtual void UnRegisterAudioFrameObserver(IAudioFrameObserver* observer) = 0;

Parameter description

Name

Type

Description

observer

IAudioFrameObserver

Callback object pointer

RegisterVideoSampleObserver

Subscribe to video data output.

virtual void RegisterVideoSampleObserver(IVideoFrameObserver* observer) = 0;

This interface is used to register a video data output object. Use the UnRegisterVideoSampleObserver interface to unregister.

Note

Output data will be returned through the @link IVideoFrameObserver callback

Call timing

To obtain raw video data (such as YUV or RGBA format), you can call this interface to register a video data monitor to obtain video data at various stages.

Related callbacks

After successfully registering a video data output monitor, the SDK will trigger the callbacks you implement when each video frame is captured. You can implement the corresponding callbacks according to your business needs:

Parameter description

Name

Type

Description

observer

IVideoFrameObserver

Callback object pointer

UnRegisterVideoSampleObserver

Deregister the video data output.

virtual void UnRegisterVideoSampleObserver(IVideoFrameObserver* observer) = 0;

This interface corresponds to the RegisterVideoSampleObserver interface and is responsible for deregistering the video data output object.

Parameter description

Name

Type

Description

observer

IVideoFrameObserver

Callback object pointer

SnapshotVideo

Enables snapshot capture for a video track.

virtual int SnapshotVideo(const String& userId, const AliEngineVideoTrack &trackType) = 0;

The video snapshot feature is an asynchronous interface. You can obtain the current snapshot image by listening to the AliEngineEventListener::OnSnapshotComplete callback.

Parameter description

Parameter

Type

Description

userId

const String&

The user ID. An empty userId ("") represents the local user.

trackType

const AliEngineVideoTrack&

The video track type. Only AliEngineVideoTrackCamera and AliEngineVideoTrackScreen are supported.

Return description

  • 0: The method call is successful. The snapshot image is obtained through the callback.

  • <0: The method call fails.

SetLogDirPath

Set the save path for the SDK log file.

static int SetLogDirPath(const char *logDirPath);

Parameter description

Name

Type

Description

logDirPath

const char *

The absolute path for storing the log files of the SDK.

Return description

A value of 0 indicates that the call is successful. A value other than 0 indicates that the call fails.

Note

We recommend that you call this method before all other methods to prevent log loss. Before calling this method, ensure that the path specified by the logDirPath parameter exists and that log files can be written to this path.

SetLogLevel

Set the log level.

static void SetLogLevel(AliEngineLogLevel logLevel);

Parameter description

Name

Type

Description

logLevel

AliEngineLogLevel

The log level. Default value: AliEngineLogInfo.

GetNetworkTime

Gets the current network time.

virtual long long GetNetworkTime() = 0;

Return description

Returns the current network time (NTP time) adjusted by offset, in milliseconds.

SendDataChannelMessage

Send data channel message.

virtual int SendDataChannelMessage(const AliEngineDataChannelMsg& msg) = 0;

The ARTC SDK provides the ability to send and receive custom messages, allowing you to send custom real-time message data while transmitting audio and video data. For example, you can call this interface to transmit real-time control instructions, state synchronization data, or other business messages while transmitting audio and video. For more information, see Custom message sending and receiving.

Note
  • The custom message channel is disabled by default. To use this feature, call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#d78a13ea0e6hy" id="fe71661227b31">SetParameter</a> interface to set ("{\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}") to enable the custom message channel. You can enable this either before or after joining the channel.

  • Messages can be any data (such as text, images, etc.).

Related callbacks

  • When a remote user enables subscription to data channel data, the OnRemoteUserSubscribedDataChannel callback is triggered. Once you receive this callback, you can send data channel messages to that user.

  • After you successfully enable the custom message channel, you can call this interface to send custom messages. The receiver can receive custom messages by listening to the OnDataChannelMessage callback.

Call timing

You can call this method after receiving the OnRemoteUserSubscribedDataChannel callback when a remote user has called SetParameter to enable EnableSubDataChannel to receive data channel messages.

Call restrictions

  • Streamers can send and receive messages. Viewers can only receive messages.

  • You need to call SetParameter to enable the custom message channel.

Parameter description

Name

Type

Description

msg

const AliEngineDataChannelMsg&

The message to be sent.

Return description

  • 0: The operation is successful.

  • Non-0: The operation failed.

StartScreenShareByDesktopId

Starts sharing the screen stream for the specified desktop ID.

virtual int StartScreenShareByDesktopId(unsignedint desktopId, const AliEngineScreenShareConfig& config) = 0;

Parameter description

Name

Type

Description

desktopId

unsignedint

The desktop ID.

config

AliEngineScreenShareConfig

The configuration for desktop sharing.

Return value

  • 0: Success

  • Other values: Failure

StartScreenShareByScreenRegion

Starts sharing the video stream of the specified screen area.

  • This method is only applicable for desktop sharing. For window sharing, use the StartScreenShareByWindowId interface.

  • When configuring a specific region for sharing, the minimum resolution of the shared region is 16 × 16. If the set region is smaller than the minimum resolution, it will be reset to the minimum resolution.

  • When configuring a specific region for sharing, if the set sharing region exceeds the actual desktop resolution, the entire desktop will be shared.

  • For more information about virtual screen coordinates, see virtual screen coordinates.

virtual int StartScreenShareByScreenRegion(
const AliEngineScreenShareRegion & screenRegion, 
const AliEngineScreenShareConfig & config) = 0;

Parameter description

Name

Type

Description

screenRegion

AliEngineScreenShareRegion

The position of the screen to be shared relative to the virtual screen.

config

AliEngineScreenShareConfig

The screen sharing configuration.

Return value

  • 0: Success

  • Other: Failure

StartScreenShareByWindowId

Shares and pushes a video stream using a window as the video source, identified by a user-provided ID.

virtual int StartScreenShareByWindowId(unsigned int windowId, 
  const AliEngineScreenShareConfig & config) = 0;

Parameter description

Name

Type

Description

windowId

int

The window ID.

config

AliEngineScreenShareConfig

The screen sharing configuration.

Return value

  • 0: Success

  • Other values: Failure

StopScreenShare

Stop screen sharing.

virtual int StopScreenShare() = 0 ;

Return value

  • 0: Success

  • Other: Failure

ResumeScreenShare

Restart screen sharing.

virtual int ResumeScreenShare() = 0;

Return value

  • 0: Success

  • Other values: Failure

PauseScreenShare

Pause screen sharing.

virtual int PauseScreenShare() = 0;

Return value

  • 0: Success

  • Other values: Failure

IsScreenSharePublished

Query whether the screen sharing push is set.

Note

You can call this method to check whether screen sharing is currently set to push. By default, the SDK does not push screen sharing. To push screen sharing, you can actively enable it through the StartScreenShareByDesktopId, StartScreenShareByScreenRegion, or StartScreenShareByWindowId interfaces.

virtual bool IsScreenSharePublished() = 0;

Return Description

  • true: Push is configured.

  • false: Push is not set.

UpdateScreenShareConfig

Update the screen sharing configuration.

virtual int UpdateScreenShareConfig(const AliEngineScreenShareConfig & config) = 0;

Parameter description

Parameter

Type

Description

config

AliEngineScreenShareConfig

The updated screen sharing configuration.

Return value

  • 0: Success

  • Other values: Failure

CheckWindowSourceVaild

Determine whether the window that corresponds to the shared window ID is valid.

virtual bool CheckWindowSourceVaild(unsigned int windowId) = 0;

Parameter description

Parameter

Type

Description

int

unsigned int

The window ID.

Return value

  • true: The corresponding window ID is valid.

  • false: The corresponding window ID is invalid.

GetScreenShareConfig

Returns the current screen sharing configuration.

virtual AliEngineScreenShareConfig GetScreenShareConfig() = 0;

Parameter description

Parameter

Type

Description

int

unsigned int

The window ID.

Return value

  • true: The corresponding window ID is valid.

  • false: The corresponding window ID is invalid.

GetScreenShareSourceInfo

You can retrieve the list of objects from the specified source.

virtual AliEngineScreenSourceList* GetScreenShareSourceInfo(AliEngineScreenShareType sourceType) = 0;

Parameter description

Parameter

Type

Description

sourceType

AliEngineScreenShareType

The sharing source type.

Return value

  • A non-null AliEngineScreenSourceList object representing the list of sharing source types obtained.

  • NULL indicates that the operation failed.

GetCurrentScreenShareSourceId

Retrieves the ID of the current screen sharing source.

virtual unsigned int GetCurrentScreenShareSourceId() = 0;

Return value

  • >=0 indicates the ID of the currently shared screen source.

  • <0 indicates failure.

GetCurrentScreenShareSourceType

Retrieves the list of objects from the specified source.

virtual AliEngineScreenShareType GetCurrentScreenShareSourceType() = 0;

Parameter description

Parameter

Type

Description

sourceType

AliEngineScreenShareType

The sharing source type.

Return value

  • A non-null AliEngineScreenSourceList object representing the list of obtained sharing source types.

  • NULL indicates failure.

GetDesktopRegion

Retrieves the desktop sharing scope based on the specified source ID and source title.

virtual int GetDesktopRegion(const String& sourceId, const String& sourceTitle, AliEngineScreenShareRegion & region) = 0;

Parameter description

Parameter

Type

Description

sourceId

String

The sharing source ID.

sourceTitle

String

The source title.

region

AliEngineScreenShareRegion

The sharing region.

Return value

  • 0: Success

  • Other values: Failure

SetScreenShareEncoderConfiguration

Configures the video encoding settings for a screen track.

virtual void SetScreenShareEncoderConfiguration(const AliEngineScreenShareEncoderConfiguration& config) = 0;

This method configures video parameters for screen sharing video encoding, such as resolution, frame rate, bitrate, and video orientation. All parameters have valid range limitations. If the parameters you set exceed these ranges, the SDK automatically adjusts them.

You can call this method before or after you join a channel. We recommend calling this method before joining a channel so you only need to configure the video encoding properties once.

Parameter description

Parameter

Type

Description

config

AliEngineScreenShareEncoderConfiguration

Predefined screen sharing encoding properties.

Interface

IAliEngineMediaEngine