This topic describes the APIs of the ApsaraVideo Real-time Communication (ARTC) SDK for Windows.
Contents
Basic APIs
API | Description |
Creates an AliRtcEngine instance (singleton pattern). | |
Destroys the AliRtcEngine instance. | |
Gets an instance of a feature API. | |
Sets the H5 compatibility mode. | |
Checks whether the current mode is H5 compatible. | |
Sets the event listener callbacks. | |
Queries the current SDK version number. |
Channel-related APIs
API | Description |
Sets the channel profile. | |
Sets the audio profile. | |
Queries whether the current mode is audio-only. | |
Sets the mode to audio-only or audio and video. | |
Joins a channel. | |
Joins a channel. | |
Joins a channel. | |
Leaves a channel. | |
Checks whether the user is in a channel. | |
Sets the user role. | |
Gets the user role. | |
Refreshes the authentication information. | |
Refreshes the authentication information. |
Publishing and subscribing APIs
API | Description |
Sets whether to publish the local audio stream. By default, the audio stream is published. | |
Queries whether the local audio stream is being published. | |
Sets whether to subscribe to remote audio streams by default. By default, all remote audio streams are subscribed. Call this API before joining a channel. | |
Stops or resumes subscribing to the audio stream of a specific remote user. | |
Stops or resumes subscribing to all remote audio streams. | |
Sets whether to publish the local video stream. | |
Queries whether the local video stream is being published. | |
Sets whether to subscribe to remote video streams by default. By default, all remote video streams are subscribed. Call this API before joining a channel. | |
Stops or resumes subscribing to a remote user's video stream. | |
Stops or resumes subscribing to all remote video streams. | |
Stops or resumes subscribing to the media stream of a specific remote user. Use this API when both audio and video streams exist and need to be controlled. | |
Stops or resumes subscribing to the media stream of a specific remote user. Use this API when both audio and video streams exist and need to be controlled. | |
Stops or resumes subscribing to the media stream of a specific remote user across channels. | |
Adjusts the playback volume of a specified remote user on the local client. |
Audio device management APIs
API | Description |
Sets whether to stop publishing the local audio. | |
Sets whether to stop playing the remote audio stream. | |
Stops or resumes playing all remote audio. | |
Enables audio capture. | |
Enables audio capture. | |
Disables audio capture. | |
Enables the volume detection feature. | |
Enables the audio playback device. | |
Disables audio playback. | |
Sets the playback volume. | |
Sets the recording volume. | |
Plays an audio file. | |
Stops playing the audio file. | |
Starts an audio capture test before a call. | |
Stops the audio capture test. | |
Enables or disables system audio capture and publishing. | |
Queries whether system audio capture and publishing is enabled. | |
Sets the volume for system audio capture and publishing. | |
Gets the current volume for system audio capture and publishing. | |
Sets the system audio playback volume. | |
Gets the current system audio playback volume. | |
Gets the list of audio capture devices. | |
Gets the name of the current audio capture device. | |
Gets the ID of the current audio capture device. | |
Sets the audio capture device with the specified name as the current device. | |
Sets the ID of the current audio capture device. | |
Gets the list of current audio playback devices. | |
Gets the list of current system audio playback devices. | |
Gets the name of the current audio playback device. | |
Gets the ID of the current audio playback device. | |
Sets the device with the specified name as the current playback device. | |
Sets the device with the specified ID as the current playback device. | |
Sets the volume of the audio capture device. | |
Gets the volume of the audio capture device. | |
Sets the volume of the audio playback device. | |
Gets the volume of the audio playback device. | |
Sets the mute status of the audio capture device. | |
Gets the mute status of the audio capture device. | |
Sets the mute status of the audio playback device. | |
Gets the mute status of the audio playback device. |
Voice changing and reverberation
API | Description |
Sets the voice changer effect mode. | |
Sets the pitch shifting parameter. | |
Sets the reverberation effect mode. | |
Sets the reverberation effect type and specific parameters. | |
Sets the preset voice beautification effect mode. | |
Sets the audio equalizer (EQ) parameters to adjust the gain of a specified frequency band. |
Custom audio input
API | Description |
Adds an external audio stream. | |
Inputs external audio stream data. | |
Sets the publishing volume. | |
Gets the publishing volume. | |
Sets the playback volume of the external audio stream. | |
Gets the playback volume of the external audio stream. | |
Removes an external audio stream. |
Audio accompaniment
API | Description |
Gets audio file information. | |
Starts audio mixing for accompaniment. | |
Stops audio mixing for accompaniment. | |
Sets the accompaniment volume. | |
Sets the publishing volume for the accompaniment. | |
Gets the publishing volume for the accompaniment. | |
Sets the local playback volume for the accompaniment. | |
Gets the local playback volume for the accompaniment. | |
Pauses audio mixing for accompaniment. | |
Resumes audio mixing for accompaniment. | |
Gets the duration of the accompaniment file in milliseconds. | |
Gets the playback progress of the accompaniment file in milliseconds. | |
Sets the playback position of the accompaniment file. |
Sound effect files
API | Description |
Preloads a sound effect file. | |
Deletes a preloaded sound effect file. | |
Starts playing a sound effect. | |
Stops playing a sound effect. | |
Stops playing all sound effects. | |
Pauses a sound effect. | |
Pauses all sound effects. | |
Resumes a specified sound effect file. | |
Resumes all sound effect files. | |
Sets the mixing volume for publishing a sound effect. | |
Gets the mixing volume for publishing a sound effect. | |
Sets the mixing volume for publishing all sound effects. | |
Sets the local playback volume for a sound effect. | |
Gets the local playback volume for a sound effect. | |
Sets the local playback volume for all sound effects. |
Video device management APIs
API | Description |
Sets the rendering window and drawing parameters for the local preview. | |
Sets the camera capture preferences. | |
Disables or re-enables local video capture. | |
Sets whether to stop publishing the local video stream. | |
Sets the rendering window and drawing parameters for the remote video. | |
Checks if the camera is on. | |
Sets the video encoding properties. | |
Sets the video decoding properties. | |
Starts the local preview. | |
Stops the local preview. | |
Sets the mirroring capabilities for preview and publishing. | |
Sets the timing for capture scaling. Determines whether video data is scaled immediately upon capture or during encoding. | |
Gets the list of available cameras. | |
Gets the name of the currently used camera. | |
Gets the ID of the currently used camera. | |
Sets the camera with the specified name as the current camera. | |
Sets the camera with the specified ID as the current camera. | |
Gets the list of resolutions supported by the current camera. |
Configure video data callbacks
API | Description |
Registers a video data output object. | |
Unregisters a video data output object. | |
Video snapshot feature. |
Configure audio data callbacks
API | Description |
Registers an audio data callback. | |
Unsubscribes from audio data output. | |
Sets audio callback parameters. |
Custom video input
API | Description |
Enables an external video input source. | |
Inputs video data. |
Screen sharing APIs
API | Description |
Starts sharing the screen stream corresponding to the specified desktop ID. | |
Starts sharing the video stream of a specified region of the screen. | |
Shares and publishes the video stream from a window specified by its ID. | |
Stops screen sharing. | |
Resumes screen sharing. | |
Pauses screen sharing. | |
Queries whether screen sharing is set to be published. | |
Updates the screen sharing configuration. | |
Checks if the window corresponding to the shared window ID is valid. | |
Returns the current screen sharing configuration information. | |
Gets a list of objects based on the specified source. | |
Gets the ID of the current screen sharing source. | |
Gets a list of objects based on the specified source. | |
Gets the screen sharing region based on the specified source ID and source title. | |
Sets the video encoding properties for the screen stream. |
Bypass live streaming APIs
API | Description |
Starts bypass live streaming. | |
Updates bypass live streaming parameters. | |
Stops bypass live streaming. | |
Gets the bypass live streaming status. | |
Starts a pre-call network quality probe. | |
Stops the pre-call network quality probe. |
Network quality detection APIs
API | Description |
Starts a pre-call network quality probe. | |
Stops the pre-call network quality probe. |
SEI
API | Description |
Sends media extension information, implemented internally using SEI. | |
Sends media extension information (extended), implemented internally using SEI. |
Other APIs
API | Description |
Sets custom parameters. | |
Gets custom parameters. | |
Sets the path to save SDK log files. | |
Sets the log level. | |
Gets the timeline time. | |
Sends a data channel message. |
Callbacks
AliEngineEventListener
API | Description |
Callback for network connection status. Customers need to pay attention to this callback. | |
Callback for local device exceptions. Customers need to pay attention to this callback. | |
Notification that user authentication information is about to expire. Authentication will expire 30 seconds after this notification is received. Customers need to pay attention to this callback. | |
The server returns that the information has expired when the user calls an API that requires authentication. | |
Callback for the result of joining a channel. | |
Callback for the result of leaving a channel. | |
Notification that a remote user has gone offline. | |
Notification that a remote user has come online. | |
Notification of remote stream publishing information. | |
Message indicating that the user was kicked from the server or the channel has ended. | |
Notification of audio publishing state change. | |
Notification of audio subscription state change. | |
Notification that a remote user is muted. | |
Notification that audio device interruption has started. | |
Notification that audio device interruption has ended. | |
Callback for video publishing state change. | |
Callback for camera stream subscription state change. | |
Notification that the remote user is sending black video frames. | |
Notification that the remote user has disabled camera stream capture. | |
The remote user's application has moved to the background. | |
The remote user's application has returned to the foreground. | |
Callback for when local sound effect playback finishes. | |
The audio volume, voice status, and UID of the subscribed audio. | |
Voice activity detection. Callback for when an active user is detected. | |
Callback for bypass stream publishing state change. | |
Callback for bypass task state change. | |
Callback for network quality change. | |
Callback for the pre-call network quality probe. This callback is provided about 3 seconds after the probe starts. | |
Callback for the results of the pre-call network quality probe. This callback is provided about 30 seconds after the probe starts. | |
If an error occurs in the engine, this callback notifies the application. | |
Callback for the first audio packet sent. | |
Callback for the first audio packet received. | |
Callback for the first video packet sent. | |
Callback for the first video packet received. | |
Callback for the first decoded remote audio frame. | |
This message is triggered when the first video frame of a remote user is displayed. | |
This message is triggered when the first video frame is displayed in the preview. | |
Volume callback for the pre-call audio capture test. | |
Callback for local accompaniment playback state. | |
Callback for audio file information. | |
Callback for when a remote user's accompaniment starts playing. | |
Callback for when a remote user's accompaniment finishes playing. | |
Real-time data callback (triggered every 2 seconds). | |
Local video statistics (triggered every 2 seconds). | |
Remote video statistics (triggered every 2 seconds). | |
Local audio statistics (triggered every 2 seconds). | |
Remote audio statistics (triggered every 2 seconds). | |
Callback for receiving media extension information. | |
Callback for snapshot result. | |
Callback for local audio device state. | |
Callback for local video device state. | |
Callback indicating that you can start sending data channel messages. | |
Callback for data channel messages. |
IAudioFrameObserver
API | Description |
Callback for captured raw data. | |
Callback for data after 3A processing. | |
Callback for published stream data. | |
Callback for playback data. | |
Callback for remote stream data. |
IVideoFrameObserver
API | Description |
Callback for local captured video data. | |
Callback for local video data before encoding. | |
Callback for remote video data. | |
Video output width alignment. | |
Video data output content. |
AliEngineDestroyCompletionCallback
API | Description |
Callback for when destruction is complete. |
API details
Create
Creates an AliRtcEngine instance.
static AliEngine *Create(const char *extras);When to call
Call this method to create an AliRtcEngine instance before you call any other APIs of the ARTC SDK.
Limits
The SDK supports only one AliRtcEngine instance per application.
Metric descriptions
Name | Type | Description |
extras | const char * | Receives parameters for grayscale releases. Use JSON Configurations to set special SDK features. This parameter can be an empty string. |
Return value
Returns a singleton object of the AliEngine class.
Destroy
Destroys the AliRtcEngine instance.
static void Destroy(AliEngineDestroyCompletionCallback *callback = nullptr);This method destroys the AliRtcEngine singleton object and releases all its internal resources. After this method is called, you can no longer use other AliRtcEngine methods or any callbacks. To use them again, you must call Create to create a new instance.
This method is an asynchronous invocation. It provides a callback that lets you track the completion of the destroy operation. You can create a new 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, which indicates that the destroy operation is complete.
When to call
Call this method to release the instance after you finish using Real-Time Communication.
Limits
To avoid deadlocks, do not call this method in any SDK callbacks.
Parameters
Parameter | Type | Description |
callback | AliEngineDestroyCompletionCallback | The callback for when the destroy operation is complete. |
QueryInterface
Retrieves a feature interface instance.
virtual int QueryInterface(AliEngineInterfaceIdType iid, void** pInterface) = 0;This method retrieves an instance of a specific feature interface. When you develop applications for Real-Time Communication on the Windows platform, many advanced features are provided through corresponding interface classes, such as audio device management (AliEngineInterfaceAudioDeviceManager), video device management (AliEngineInterfaceVideoDeviceManager), and the media engine (AliEngineInterfaceMediaEngine). Before you call the related methods, you must use the QueryInterface method to obtain instances of these interfaces.
After you finish using an interface instance, call the `Release` method of the corresponding interface to release resources and prevent memory leaks.
Parameters
Name | Type | Description |
iid | The type of the feature interface. It tells the SDK which type of interface instance to get.
| |
pInterface | void** | Returns an instance of the specified interface type. Example:
Pass |
Return value
0: The call was successful.
<0: The call failed.
SetH5CompatibleMode
Enables or disables H5 compatibility mode.
static void SetH5CompatibleMode(bool comp);Parameters
Name | Type | Description |
comp | bool |
|
The current version does not support changing the H5 compatibility mode after an AliRtcEngine instance is created. You must call this method before you create the instance.
GetH5CompatibleMode
Checks whether H5 compatibility mode is enabled.
static bool GetH5CompatibleMode();Return value
true: H5 compatibility is enabled. false: H5 compatibility is disabled.
SetEngineEventListener
Sets the event listener callbacks.
virtual int SetEngineEventListener(AliEngineEventListener *listener) = 0;This method sets a callback listener for the SDK. By setting this listener, you can receive various notification events from the engine, such as users joining or leaving a channel, network status changes, and audio and video stream status.
You need to implement the AliEngineEventListener class to customize the event methods that you want to listen for. By default, all methods have empty implementations, so you do not need to implement all of them. You can implement only the event methods that you need.
All callbacks are executed in internal SDK threads. Do not perform UI operations in these callbacks. If UI operations are needed, run them on the main thread. Do not call this method within a callback.
Do not perform time-consuming operations in callbacks, such as calling the Destroy method of AliEngine. This can cause unnecessary blocking and affect SDK performance.
Related callbacks
If an exception occurs during an operation, the SDK first attempts to recover automatically using its internal retry mechanism. For errors that cannot be resolved automatically, the SDK notifies your application through predefined callback interfaces. The following are key callbacks for issues that the SDK cannot handle and that require your application to listen for and respond to:
Cause of exception | Callback and parameters | Solution | Description |
Authentication failed | The result parameter in the OnJoinChannelResult callback returns AliRtcErrJoinBadToken | If this error occurs, check whether the token is correct. | When a user calls an API, if authentication fails, the system returns an authentication failure error message in the API's callback. |
Network connectivity abnormal | The OnConnectionStatusChange callback returns AliRtcConnectionStatusFailed. | If this exception occurs, the application needs to rejoin the channel. | The SDK can automatically recover from network disconnections for a certain period. However, if the disconnection time exceeds the preset threshold, a timeout is triggered, and the connection is lost. In this case, the application should check the network status and guide the user to rejoin the channel. |
On-premises device abnormal | OnLocalDeviceException | If this exception occurs, check whether the permissions and device hardware are normal. | The RTC service supports device detection and exception diagnosis. When an on-premises device exception occurs, the RTC service notifies the customer through a callback. If the SDK cannot resolve the issue, the application must intervene to check if the device is normal. |
Kicked offline | OnBye |
| The RTC service provides a feature for administrators to actively remove participants. |
Authentication is about to expire | OnWillAuthInfoExpire | If this exception occurs, get the latest authentication information and then call refreshAuthInfo to refresh it. | Authentication expiration errors occur in two situations: when a user calls an API or during program execution. Therefore, the error feedback is sent through an API callback or a separate error callback. |
Authentication expired | OnAuthInfoExpired | If this exception occurs, the application needs to rejoin the channel. | Authentication expiration errors occur in two situations: when a user calls an API or during program execution. Therefore, the error feedback is sent through an API callback or a separate error callback. |
Parameters
Name | Type | Description |
listener | AliEngineEventListener* | The engine event listener. You need to implement the AliEngineEventListener class and override the event callbacks you want to listen for. If you set this to nullptr, all event listeners are canceled. |
Return value
0: Success.
A non-zero value: Failure. This may be because the listener parameter is invalid or the SDK is not initialized correctly.
GetSDKVersion
Queries the current SDK version.
static const char *GetSDKVersion();Return value
The current SDK version number in a string format. Example: "2.5.0.x".
SetChannelProfile
Sets the channel profile.
virtual int SetChannelProfile(const AliEngineChannelProfile channelProfile) = 0;This method sets the channel profile. It currently provides profiles for video call scenarios and interactive stream scenarios:
Video call profile: All users have the streamer role and can publish and subscribe to streams.
Interactive stream mode: You must call the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#c99c2b257dd8o" id="4e50f781a01e1">SetClientRole</a>method to set the user role. Set the role of users who ingest streams in the channel to streamer (AliRTCSdkInteractive). If a user only needs to pull streams and does not ingest streams, set their role to viewer (AliRTCSdkLive). This mode is recommended for RTC scenarios.
We recommend that you use the interactive stream profile for all RTC scenarios. To do this, call this method and set the profile to
AliEngineInteractiveLive.Users in the same channel must use the same channel profile.
When to call
You can call this method only before you join a channel. You cannot reset it while in the channel. You can reset it after you leave the channel.
Parameters
Name | Type | Description |
profile | The channel profile. For RTC scenarios, we recommend setting this to AliEngineInteractiveLive, which is the interactive stream profile. |
Return value
0: The method call was successful.
Other values: The method call failed.
-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 sets the audio encoding profile and the audio scenario. For more information, see Common audio operations and configurations. The ARTC SDK uses the high-quality mode (AliEngineHighQualityMode) and the music scenario mode (AliEngineSceneMusicMode) by default. If the default settings do not meet your needs, you can call this method to configure them.
When to call
You can call this method only before you join a channel. You cannot reset it after you join the channel. You can reset it after you leave the channel.
Parameters
Name | Type | Description |
audio_profile | The audio collection or encoding profile parameter. We recommend using the high-quality mode (AliRtcEngineHighQualityMode). Note To interoperate with the web, set the sample rate to 48 kHz.
| |
audio_scene | The audio scenario parameter. It mainly includes:
|
Return value
0: The method call was successful. Other values: The method call failed.
IsAudioOnlyMode
Checks whether the current mode is audio-only.
virtual bool IsAudioOnlyMode() = 0;Return value
true: The current mode is audio-only. false: The current mode is audio and video.
SetAudioOnlyMode
Sets the mode to audio-only or audio and video.
virtual int SetAudioOnlyMode(bool audioOnly) = 0;Parameters
Name | Type | Description |
audioOnly | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
JoinChannel[1/3]
Joins a channel.
virtual int JoinChannel(const char *token, const char *channelId, const char *userId, const char *userName) = 0;This method joins a channel. In ARTC, users are organized by channels. Users must join a channel to publish or subscribe to audio and video streams. This method, JoinChannel[2/3], and JoinChannel[3/3] can all be used to join a channel. They differ in their authentication methods and the user information they pass, as follows:
This method is for joining a channel with a single parameter. You must pass a token generated for single-parameter joining using Token-based authentication. We recommend that you use this method to join a channel in RTC scenarios.
JoinChannel[2/3]is for joining a channel with multiple parameters. You need to pass a multi-parameter token generated using Token-based authentication and the user information that was used to generate the token.JoinChannel[3/3]is for AI real-time interaction scenarios. You must pass a single-parameter token and set the user propertycapabilityProfilebased on the scenario.
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. If you want to cancel 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 API to disable the subscription to audio or video streams.
When to call
Call this method after you create the engine.
Limits
After you successfully join a channel, to join another channel, you must first call
LeaveChannelto leave the current channel. You can call to join another 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="b2522e57e4vom">OnLeaveChannelResult</a>callback.This method supports joining only one channel at a time.
Applications with different App IDs cannot communicate with each other.
Do not call this method when you retry after a failed attempt to join a channel.
Related callbacks
A successful call to this method triggers the following callbacks:
The result of the local client joining a channel is returned through the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#7cbf47a35bcel" id="cad6eb9b1bwx7">OnJoinChannelResult</a>callback ofAliRtcEngineEventListener.After you successfully join the channel, the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#3333f6e9d344q" id="fab4a94264m28">OnRemoteUserOnLineNotify</a>callback is triggered on remote clients.
Parameters
Parameter | Type | Description |
token | const char * | The authentication information for single-parameter joining. |
channelId | const char * | The channel to join. This must be the same as the value used to generate the token. |
userId | const char * | The user ID for joining. This must be the same as the value used to generate the token. |
userName | const char * | The user's display name (not the user ID). |
Return value
0: The method call was successful. A non-zero value: The method call failed.
JoinChannel[2/3]
Joins a channel.
virtual int JoinChannel(const AliEngineAuthInfo &authInfo,
const char *userName) = 0;This method joins a channel. In ARTC, users are organized by channels. Users 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 their authentication methods and the user information they pass, as follows:
JoinChannel[1/3]is for joining a channel with a single parameter. You must pass a token generated for single-parameter joining using Token-based authentication. We recommend that you use this method to join a channel in RTC scenarios.This method is for joining a channel with multiple parameters. You need to pass a multi-parameter token generated using Token-based authentication and the user information that was used to generate the token.
JoinChannel[3/3]is for AI real-time interaction scenarios. You must pass a single-parameter token and set the user propertycapabilityProfilebased on the scenario.
By default, when you join a channel, you subscribe to the audio and video streams of all other users and push your own streams to remote users. To cancel 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="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 operation to disable the subscription to audio or video streams.This is a multi-parameter method for joining a channel. Before you call it, you must generate a multi-parameter token. For more information, see Token-based authentication.
Limits
After you successfully join a channel, to join another channel, you must first call
LeaveChannelto leave the current channel. You can call to join another 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.This method supports joining only one channel at a time.
Applications with different App IDs cannot communicate with each other.
Related callbacks
A successful call to this method triggers the following callbacks:
The local client is notified of the result of joining a channel through 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 you successfully join a 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 remote clients.
Parameters
Name | Type | Description |
authInfo | Authentication information. | |
userName | const char * | The user's display name (not the user ID). |
JoinChannel[3/3]
Joins a channel.
virtual int JoinChannel(const char *token, const char *channelId, const char *userId, const AliEngineChannelParam &userParam) = 0;This method joins a channel. In ARTC, users are organized by channels. Users must join a channel to publish or subscribe to audio and video streams. This method, JoinChannel[1/3], and JoinChannel[2/3] can all be used to join a channel. They differ in their authentication methods and the user information they pass, as follows:
JoinChannel[1/3]is a single-parameter method for joining a channel in RTC scenarios. You must pass a token generated for single-parameter joining using Token-based authentication. We recommend that you use this method to join a channel in RTC scenarios.JoinChannel[2/3]is for joining a channel with multiple parameters. You need to pass a multi-parameter token generated using Token-based authentication and the user information that was used to generate the token.This method is for AI real-time interaction scenarios. You must pass a single-parameter token and set the user property
capabilityProfilebased on the scenario. To communicate with an AI agent, set it toAliCapabilityProfileHuman.
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 cancel 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="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 you call this API to disable the subscription to audio or video streams.
Limits
After you successfully join a channel, to join another channel, you must first call
leaveChannelto leave the current channel. You can join a channel again only after 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.This method supports joining only one channel at a time.
Applications with different App IDs cannot communicate with each other.
Do not call this method when you retry after a failed attempt to join a channel.
Related callbacks
A successful call to this method triggers the following callbacks:
The result of the local user joining a channel is provided 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 you successfully join the channel, the remote client triggers the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#3333f6e9d344q" id="fa6f8d9357glx">OnRemoteUserOnLineNotify</a>callback.
Parameters
Parameter | Type | Description |
token | const char * | The authentication information for single-parameter joining. |
channelId | const char * | The channel to join. This must be the same as the value used to generate the token. You can leave this empty. If empty, the channelId used to generate the token is used by default. |
userId | const char * | The user ID for joining. This must be the same as the value used to generate the token. You can leave this empty. If empty, the userId used to generate the token is used by default. |
userParam | User properties, such as nickname, type, and custom ID. |
Return value
0: The method call was successful. A non-zero value: The method call failed.
LeaveChannel
You can leave the channel.
virtual int LeaveChannel() = 0;After you call this method, the SDK terminates the audio and video call and leaves the current channel.
This method is an asynchronous operation. A successful call to this method does not mean that you have left the channel. You have not 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 returned.After you leave the channel, you must destroy the engine and set it to null.
mAliRtcEngine->LeaveChannel(); AliEngine::Destroy(); mAliRtcEngine = nullptr;
When to call
Call this method to leave a channel.
You must call this method to leave the current channel before joining a new one.
Related callbacks
Calling this method triggers the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#b70203f9ea0mz" id="9626ae24d89ue">OnLeaveChannelResult</a>callback on the local client, which reports whether the client successfully left the channel.Remote users: A successful call to this API triggers the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#44ce12a0ecj52" id="0dfcab6a6fylt">OnRemoteUserOffLineNotify</a>callback.
Response Description
A value of 0 indicates that the method call succeeded. Any other value indicates that the method call failed.
IsInCall
Checks whether the user is currently in a channel.
virtual bool IsInCall() = 0;Return value
true: The user is in a channel. false: The user is not in a channel.
SetClientRole
Sets the user role.
virtual int SetClientRole(const AliEngineClientRole clientRole) = 0;This method sets the user role to streamer or viewer.
In interactive stream mode, before you join a channel:
If you set the user role to streamer, the SDK automatically publishes the local audio and video streams and receives the audio and video streams of other streamers by default.
If you set the user role to viewer, the SDK does not publish the local audio and video streams but receives the audio and video streams of other streamers.
When to call
This method can be called before or after you join a channel. You can call it before you join to set the user role, or after you join to switch the user role.
Limits
This method is effective only in interactive stream mode. This means you must call the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#901e748242y3g" id="322c3da902jpt">SetChannelProfile</a> method and set the channel profile to AliEngineInteractiveLive.
In interactive stream mode, we recommend that you explicitly call this method to set the user role before you join a channel.
Parameters
Name | Type | Description |
role | The user role type. The default value is AliEngineClientRolelive (viewer). The role type is only valid in non-communication mode. |
Return value
0: The method call was successful. Other values: The method call failed.
GetClientRole
Retrieves the current user role type (streamer or viewer).
virtual AliEngineClientRole GetClientRole() = 0;Return value
If the method call is successful, it returns an AliEngineClientRole object. This is an enumeration type that indicates the role is either streamer (0) or viewer (1).
RefreshAuthInfo[1/2]
Refreshes the authentication information.
virtual int RefreshAuthInfo(const AliEngineAuthInfo &authInfo) = 0;This method updates the authentication information. The token expires after a certain period. When the token expires, the SDK cannot connect to the server.
Both this method and RefreshAuthInfo[2/2] update the authentication information. This method is used to update a multi-parameter token, while RefreshAuthInfo[2/2] is used to update a single-parameter token. For more information about token generation, see Token-based authentication.
When to call
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, which indicates that the authentication information is about to expire, we recommend that you regenerate a token on your server and then call this method with the new token.If you do not update the token 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 is triggered to notify you that the authentication has expired. You must then regenerate the token and callJoinChannelto rejoin the channel.
Parameters
Name | Type | Description |
authInfo | Authentication information. |
Return value
0: The method call was successful. Other values: The method call failed.
RefreshAuthInfo[2/2]
Refreshes the authentication information.
virtual int RefreshAuthInfo(const char *token) = 0;This method updates the token. The token expires after a certain period. When the token expires, the SDK cannot connect to the server.
Both this method and RefreshAuthInfo[1/2] update the authentication information. This method is used to update a single-parameter token, while RefreshAuthInfo[1/2] is used to update a multi-parameter token. For more information about token generation, see Token-based authentication.
When to call
In the following situations, we recommend that you regenerate the 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, which indicates 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 is triggered to indicate that the authentication has expired. In this case, you need to callJoinChannelto rejoin the channel.
Parameters
Name | Type | Description |
token | const char *token | The authentication information for single-parameter joining. |
Return value
0: The method call was successful. Other values: The method call failed.
PublishLocalAudioStream
Enables or disables publishing of the local audio stream.
virtual int PublishLocalAudioStream(bool enabled) = 0;This method controls whether to publish the locally collected audio stream. The SDK publishes the audio stream by default. If you do not want to publish the audio stream by default, you can call PublishLocalAudioStream(false) before you join the channel to disable audio stream publishing.
When to call
You can call this method before or after you join a channel. Calling it before you join a channel modifies the default configuration, which takes effect when you join the channel.
Related callbacks
When the state of the local audio stream ingest changes, the local client 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 report the latest state of the audio stream ingest. The remote client 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 report changes to the remote user's audio and video streams.
Parameters
Name | Type | Description |
enable | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
IsLocalAudioStreamPublished
Queries whether publishing the audio stream is currently allowed.
virtual bool IsLocalAudioStreamPublished() = 0;Return value
true: Publishing is allowed. false: Publishing is not allowed.
SetDefaultSubscribeAllRemoteAudioStreams
Sets whether to subscribe to remote audio streams by default.
virtual int SetDefaultSubscribeAllRemoteAudioStreams(bool sub) = 0;This method configures whether to subscribe to remote users' audio streams by default. This setting affects the audio stream subscription behavior for new users who join the channel. We recommend that you set this to true unless you have special requirements.
When to call
You can call this method before or after you join a channel.
Before you join a channel:
The SDK subscribes to remote users' audio streams by default when you join a channel. If you want to change this behavior, call this method before you join.
After you join a channel:
If you want to stop the default subscription, call
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="e95a7e2d6fjwt">SetDefaultSubscribeAllRemoteAudioStreams</a>(false). Then, you will not subscribe to the audio streams of users who join the channel later.After you stop the default subscription, you can call
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#957e547813q56" id="1a391bcabc66e">SubscribeRemoteAudioStream</a>to resume subscribing to a specific user's audio stream. If you want to resume subscribing to multiple users, you must call this method multiple times.After you stop 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 subscription only for the audio streams of users who subsequently join the channel. It does not subscribe to the streams of remote users who joined while the subscription was stopped.
Parameters
Name | Type | Description |
sub | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
SubscribeRemoteAudioStream
Stops or resumes subscribing to a specific remote user's audio stream.
virtual int SubscribeRemoteAudioStream(const char* uid, bool sub) = 0;This method stops or resumes subscribing to a specific remote user's audio stream. We recommend that you set this to true unless you have special requirements.
By default, the SDK subscribes to the audio streams of all remote users when you join a channel. If you want to change this behavior, you can call <a baseurl="t2713962_v4_1_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e51a461de2k9t" id="bf2d59f02d9tq">SetDefaultSubscribeAllRemoteAudioStreams</a>(false) before you join the channel to cancel this default configuration.
Parameters
Name | Type | Description |
uid | const char* | The remote user ID. |
sub | bool |
|
Response description
0: The method call was successful. Other values: The method call failed.
SubscribeAllRemoteAudioStreams
Stops or resumes receiving all remote audio streams.
virtual int SubscribeAllRemoteAudioStreams(bool sub) = 0;This method is the master switch for subscribing to remote audio streams. We recommend that you set it to true. If you set it to false, the following occurs:
Subscription to all remote audio streams in the current channel stops.
Users who join later will also not be subscribed.
You cannot use
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#957e547813q56" id="aface4ad3920l">SubscribeRemoteAudioStream</a>to control the audio stream of a specific user.
To resubscribe, call this method again and set it to true to resume the subscription.
By default, the SDK subscribes to the audio streams of all remote users when you join a channel. 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="3927721185m08">SetDefaultSubscribeAllRemoteAudioStreams</a>(false) before you join the channel to cancel this default configuration.
Parameters
Name | Type | Description |
sub | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
PublishLocalVideoStream[1/2]
Publishes or stops publishing the camera stream.
virtual int PublishLocalVideoStream(bool enabled) = 0;This method controls whether to publish the locally collected video stream.
The SDK publishes the video stream by default. To disable video stream publishing, you can call PublishLocalVideoStream(false) before you join the channel.
When to call
You can call this method before or after you join a channel.
Calling it before you join a channel modifies the default configuration, which takes effect when you join the channel.
Related callbacks
When the local audio stream ingest state changes, the local client triggers 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 report the new audio stream ingest status, and the remote client triggers 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 report changes to the remote user's audio and video stream.
Parameters
Name | Type | Description |
enable | bool |
|
Return value
0: The method call was successful.
<0: The method call failed.
PublishLocalVideoStream[2/2]
Enables or disables sending the video stream.
virtual int PublishLocalVideoStream(bool enabled, AliEngineVideoTrack track) = 0;This method controls whether to publish the locally collected video stream.
The SDK publishes the video stream by default. To disable video stream publishing, you can call PublishLocalVideoStream(false) before you join the channel.
When to call
You can call this method before or after you join a channel.
Calling it before you join a channel modifies the default configuration, which takes effect when you join the channel.
Related callbacks
When the state of the local video stream ingest changes, the local client triggers the <a baseurl="t2713962_v5_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#6bf4efbd1cadl" id="18a9d4b47ezcc">OnVideoPublishStateChanged</a> callback to report the latest state of the video stream ingest. The remote client triggers the <a baseurl="t2713962_v5_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#ff1f7c8581r3r" id="d01e7a574f92o">OnRemoteTrackAvailableNotify</a> callback to notify that the remote user's audio and video streams have changed.
Parameters
Name | Type | Description |
enable | bool |
|
track | The video stream type, such as camera stream or screen sharing stream. |
Returns
0: The method call was successful.
<0: The method call failed.
IsLocalVideoStreamPublished
Queries whether publishing the video stream is currently allowed.
virtual bool IsLocalVideoStreamPublished() = 0;Return value
true: The camera stream is published. false: The camera stream is not published.
SetDefaultSubscribeAllRemoteVideoStreams
Sets whether to receive video streams by default.
virtual int SetDefaultSubscribeAllRemoteVideoStreams(bool sub) = 0;This method sets whether to subscribe to video streams by default. The SDK subscribes by default.
By default, the SDK subscribes to remote users' video streams when you join a channel. If you want to change this behavior, you can call this method before you join the channel.
When to call
You can call this method before or after you join a channel.
Before you join a channel:
You can use this method to cancel the default subscription setting.
After you join a channel:
To stop the default subscription, call
SetDefaultSubscribeAllRemoteVideoStreams(false). This will prevent subscription to the video streams of users who join the channel subsequently.After you stop the default subscription, if you want to resume subscribing to a specific user's video stream, call the SubscribeRemoteVideoStream method. To resume subscribing to multiple users, you must call it multiple times.
After the default subscription is stopped, a call to
SetDefaultSubscribeAllRemoteVideoStreams(false)only resumes the audio streams of users who join the channel later.
Parameters
Name | Type | Description |
sub | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
SubscribeRemoteVideoStream
Stops or resumes subscribing to a remote user's video stream.
virtual int SubscribeRemoteVideoStream(const char* uid, AliEngineVideoTrack track, bool sub) = 0;This method subscribes to or unsubscribes from a specific user's video stream.
By default, the SDK subscribes to the video streams of all remote users when you join a channel. You can call <a baseurl="t2713962_v4_1_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="f71e02d13ap2b">SetDefaultSubscribeAllRemoteVideoStreams</a>(false) before you join the channel to cancel this default configuration.
When to call
You can call this method before or after you join a channel.
Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
track | The video stream type. | |
sub | bool | Whether to subscribe to the remote user's video stream. This controls subscription or unsubscription. |
Return value
true: The setting was successful.
false: The setting failed.
SubscribeAllRemoteVideoStreams
Stops or resumes receiving all remote video streams.
virtual int SubscribeAllRemoteVideoStreams(bool sub) = 0;This method is the master switch for subscribing to remote video streams. If you set it to false, the following occurs:
Subscription to all remote video streams in the current channel stops.
Video streams from new users who join the channel later will also not be subscribed to, even if you have called
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#2cbc54790brn3" id="b7b0080f3cnoq">SetDefaultSubscribeAllRemoteVideoStreams</a>(true)to subscribe by default.You cannot use
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#jyGTp" id="0e2edf97aa1g6">SubscribeRemoteVideoStream</a>to independently control the audio stream of a specified user.
To resubscribe, call this method again and set it to true to resume the subscription.
By default, the SDK subscribes to the video streams of all remote users when you join a channel. To change 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 you join the channel to cancel this default configuration.
Parameters
Name | Type | Description |
sub | bool |
|
Response description
0: The method call was successful. Other values: The method call failed.
SubscribeRemoteMediaStream[1/2]
Stops or resumes a specific remote user's media stream.
virtual int SubscribeRemoteMediaStream(const char* uid, AliEngineVideoTrack videoTrack, bool subVideo, bool subAudio) = 0;This method subscribes to remote audio and video streams together.
In this method, AliRtcVideoTrackNo of AliRtcVideoTrack is invalid and has no effect.
Related methods
Compared with SubscribeRemoteMediaStream[2/2], this method uses two Boolean parameters, subVideo and subAudio, to determine whether to subscribe to the remote audio and video streams. The videoTrack parameter controls which video stream to pull.
Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
videoTrack | The video stream type. | |
subVideo | boo | Stops or resumes pulling a specific remote user's video stream. Values:
|
subAudio | boo | Stops or resumes pulling a specific remote user's audio stream. Values:
|
Return value
0: The method call was successful. Other values: The method call failed.
SubscribeRemoteMediaStream[2/2]
Stops or resumes a specific remote user's media stream.
virtual int SubscribeRemoteMediaStream(const char* uid, AliEngineVideoTrack videoTrack, AliEngineAudioTrack audioTrack) = 0;This method subscribes to remote audio and video streams together.
Related methods
Compared with SubscribeRemoteMediaStream[1/2], this method uses the videoTrack and audioTrack parameters to inform the SDK of the desired subscription state in a single call. For example:
To subscribe to the camera stream and microphone stream, set videoTrack and audioTrack to
AliRtcVideoTrackCameraandAliRtcAudioTrackMicrespectively when you call the method.To unsubscribe from the camera stream but keep the microphone stream, call the method again and set videoTrack and audioTrack to
AliRtcVideoTrackNoandAliRtcAudioTrackMicrespectively.To cancel both subscriptions, call the method again and set videoTrack and audioTrack to
AliRtcVideoTrackNoandAliRtcAudioTrackNorespectively.To subscribe to both the camera stream and the screen sharing stream simultaneously, set videoTrack to
AliRtcVideoTrackBoth. The same applies to audio.
Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
videoTrack | The video stream type. | |
audioTrack | The audio stream type. |
Return value
0: The method call was successful. Other values: The method call failed.
SubscribeRemoteDestChannelStream
Subscribes to a specified user's stream across channels.
virtual int SubscribeRemoteDestChannelStream(const char* channelId, const char* uid, AliEngineVideoTrack track, bool sub_audio, bool sub) = 0;Parameters
Parameter | Type | Description |
channelId | const char* | The remote channel ID. |
uid | const char* | The remote user ID. |
track | The video stream to subscribe to. | |
sub_audio | bool | Stops or resumes pulling a specific remote user's audio stream. Values:
|
sub | bool | Stops or resumes cross-channel subscription to the specified user's stream. |
Return value
0: The method call was successful. Other values: The method call failed.
SetRemoteAudioVolume
Adjusts the playback volume of a specified remote user.
virtual int SetRemoteAudioVolume(const char *uid, int volume) = 0;Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
volume | int | The playback volume. The range is [0,100]. 0: Mute. 100: Original volume. |
Return value
0: Success.
A non-zero value: Failure.
MuteLocalMic
Stops or resumes sending local audio data.
virtual int MuteLocalMic(bool mute, AliEngineMuteLocalAudioMode mode = AliEngineMuteLocalAudioModeDefault) = 0;Muting means sending silent audio frames. The collection and encoding modules continue to work.
When to call
You can call this method before or after you join a channel.
Related callbacks
After the call succeeds, the <a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#a15f0a6cf6id7" id="f4ae88f094vqy">OnUserAudioMuted</a> callback is triggered on remote clients to indicate whether the user is muted.
Parameters
Name | Type | Description |
mute | bool |
|
mode | The mute mode. The default is to mute all.
|
Return value
0: The method call was successful. Other values: The method call failed.
MuteRemoteAudio
Stops or resumes playback of remote audio.
virtual int MuteRemoteAudio(const char *uid,
bool mute) = 0;This API is used only to stop or resume audio playback for a specified remote user. It does not affect stream pulling or decoding of the remote audio. To unsubscribe from a user's 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>.
When to call
You can call this method before or after you join a channel.
Parameters
Name | Type | Description |
uid | const char * | The user ID. |
mute | bool |
|
Return value
0: The method call was successful. Other values: The method call failed.
MuteAllRemoteAudio
Stops or resumes the playback of the audio tracks of all remote users.
virtual int MuteAllRemoteAudio(bool mute) = 0;Use this method to stop or resume all remote audio playback.
This operation stops only playback. Stream pulling and decoding are not affected.
You can call this method before or after you call JoinChannel.
When to call
You can call this method before or after you join a channel.
Parameters
Name | Type | Description |
mute | bool |
|
Return value
0: The method call was successful. A non-zero value: The method call failed.
StartAudioCapture[1/2]
Starts audio collection.
virtual int StartAudioCapture() = 0;This method starts audio collection. You can also call it before you join a channel to start audio collection in advance. If it is not set, the SDK automatically controls the audio collection device. To start audio collection after it has been stopped by calling stopAudioCapture, call this method.
When to call
You can call this method before or after you join a channel.
Related methods
The
StartAudioCapture[2/2]method can control whether the audio collection device remains on after you leave the channel using a parameter.
Related callbacks
After you call this method to change the local audio collection state, you can retrieve the state change through the OnLocalAudioStateChange callback.
Return value
0: The method call was successful. Other values: The method call failed.
StartAudioCapture[2/2]
Starts audio collection.
virtual int StartAudioCapture(bool keepAlive) = 0;Stops microphone audio capture after muting.
This method starts audio collection. You can also call it before you join a channel to start audio collection in advance. If it is not set, the SDK automatically controls the audio collection device.
When to call
You can call this method before or after you join a channel.
Related methods
Compared with StartAudioCapture[1/2], this method lets you control whether the collection device remains on after you leave the channel using the keepAlive parameter.
Related callbacks
After you call this method to change the local audio collection state, you can retrieve the state change through the OnLocalAudioStateChange callback.
Parameters
Parameter | Type | Description |
keepAlive | bool | The state of the collection device after leaving the channel. Values:
|
Return value
0: The method call was successful. Other values: The method call failed.
StopAudioCapture
Stops audio collection.
virtual int StopAudioCapture() = 0;After you start audio device collection with StartAudioCapture, you can call this method to stop it.
Related callbacks
After you call this method to change the local audio collection state, you can retrieve the state change through the OnLocalAudioStateChange callback.
Return value
0: The method call was successful. Other values: The method call failed.
EnableAudioVolumeIndication
Sets the volume callback frequency and smoothing coefficient.
virtual int EnableAudioVolumeIndication(int interval, int smooth, int reportVad) = 0;This method allows the SDK to periodically report volume-related information about local publishing users and the remote user with the highest instantaneous volume to the application.
When to call
You can call this method before or after you join a channel.
Related callbacks
After a successful call to this method, if there are publishing users in the channel, the SDK triggers the following two callbacks at the set time interval:
The speaker's audio volume is reported through the OnAudioVolumeCallback callback. The callback frequency is determined by the `interval` parameter.
Voice activity detection. When an active user is detected, the speaker's UID is reported through the OnActiveSpeaker callback.
When to call
You can call this method before or after you join a channel.
Parameters
Name | Type | Description |
interval | int | The time interval in milliseconds. The minimum value must not be less than 10 ms. We recommend setting it to 300-500 ms. A value less than or equal to 0 disables the volume and speaker indication functions. |
smooth | int | The smoothing coefficient. The range is [0,9]. The larger the value, the higher the smoothing degree, and vice versa, the better the real-time performance. We recommend setting it to 3. |
reportVad | int | The speaker detection switch. Values:
|
Response Description
0: The method call was successful. Other values: The method call failed.
StartAudioPlayer
Starts the audio playback device.
virtual int StartAudioPlayer() = 0;This method can start audio playback in advance. If it is not set, the SDK automatically starts audio playback after subscribing to an audio stream.
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
StopAudioPlayer
Stops audio playback.
virtual int StopAudioPlayer() = 0;This method can stop audio playback. It corresponds to AliEngine::StartAudioPlayer.
Parameters
None.
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
SetPlayoutVolume
Sets the playback volume.
virtual int SetPlayoutVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The playback volume. The range is [0,400]. 0: Mute. >100: Increases the volume. <100: Decreases the volume. |
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
SetRecordingVolume
virtual int SetRecordingVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The playback volume. The range is [0,400]. 0: Mute. >100: Increases the volume. <100: Decreases the volume. |
Response description
0: Success.
A non-zero value: Failure. An error code is returned.
PlayAudioFileTest
Plays an audio file.
virtual int PlayAudioFileTest(const char* filePath) = 0;Parameters
Name | Type | Description |
filePath | const char* | The path of the audio file to play. |
Return value
0: Success.
<0: Failure.
StopAudioFileTest
Stops playing the audio file.
virtual int StopAudioFileTest() = 0;Return value
0: Success.
<0: Failure.
StartAudioCaptureTest
Starts an audio collection test before a call.
virtual int StartAudioCaptureTest() = 0;This method can start an audio collection test. You can use the result of the AliEngineEventListener::OnTestAudioVolumeCallback callback to determine if audio collection is normal.
You can call this method only before you join a channel (JoinChannel).
Return value
0: Success.
<0: Failure.
StopAudioCaptureTest
Stops the audio collection test.
virtual int StopAudioCaptureTest() = 0;You can call this method only before you join a channel (JoinChannel).
Return value
0: Success.
<0: Failure.
EnableSystemAudioRecording
Enables or disables system audio collection and publishing.
virtual int EnableSystemAudioRecording(bool enable, const char *path = nullptr, const char *device_id = nullptr) = 0;This method enables or disables system audio collection, such as sounds played by browsers and applications.
This method is supported only on Windows and macOS.
Parameters
Name | Type | Description |
enable | bool | Enables or disables system audio collection and publishing.
|
path | const char* | If path is empty, the sound of the entire system is collected. If path is the path of an .exe program, this program is started and its sound is collected. |
device_id | const char* | If path is empty, the sound of the default sound card device is collected. Otherwise, the sound played by the device with this device_id is collected. Use the ID returned by GetSystemRecordAudioPlayerList. |
Return value
0: The method call was successful.
<0: The method call failed.
IsSystemAudioRecording
Checks if system audio collection and publishing is currently enabled.
virtual bool IsSystemAudioRecording() = 0;To enable or disable system audio collection, call EnableSystemAudioRecording. This method is valid only on Windows and macOS platforms.
Return value
true: Enabled.
false: Disabled.
SetSystemAudioRecordingVolume
Sets the system audio collection and publishing volume.
virtual int SetSystemAudioRecordingVolume(int volume) = 0;This method is valid only on Windows and macOS platforms.
This method can be set only after system audio collection and publishing is enabled. Otherwise, the setting is invalid.
Parameters
Name | Type | Description |
volume | int | The publishing volume of the system collection. The range is [0-400]. |
Return value
0: Success.
<0: Failure.
GetSystemAudioRecordingVolume
Retrieves the current system audio collection and publishing volume.
virtual int GetSystemAudioRecordingVolume() = 0;This method is valid only on Windows and macOS platforms.
Return value
The system collection publishing volume.
SetSystemAudioPlayoutVolume
Sets the system audio playback volume.
virtual int SetSystemAudioPlayoutVolume(int volume) = 0;This method is valid only on Windows and macOS platforms.
This method can be set only after system audio collection and publishing is enabled. Otherwise, the setting is invalid.
Parameters
Name | Type | Description |
volume | int | The playback volume of the system collection. The range is [0-400]. |
Return value
0: Success.
<0: Failure.
GetSystemAudioPlayoutVolume
Retrieves the current system audio playback volume.
virtual int GetSystemAudioPlayoutVolume() = 0;This method is valid only on Windows and macOS platforms.
Return value
The system tracks the playback volume.
GetAudioCaptureList
Retrieves the list of recording devices in the system.
virtual AliEngineDeviceInfoList* GetAudioCaptureList() = 0;Return value
A pointer to the list of recording devices, AliEngineDeviceInfoList *.
GetCurrentAudioCaptureName
Retrieves the name of the recording device in use.
virtual String GetCurrentAudioCaptureName() = 0;Return value
The name of the current audio collection device.
GetCurrentAudioCaptureID
Retrieves the ID of the recording device in use.
virtual String GetCurrentAudioCaptureID() = 0;Return value
The ID of the recording device currently in use.
SetCurrentAudioCaptureName
Selects a recording device by name.
virtual int SetCurrentAudioCaptureName(const char* captureName) = 0;Parameters
Name | Type | Description |
captureName | const char * | The recording device name. |
Return value
0 for success, other values for failure.
SetCurrentAudioCaptureID
Selects a recording device by ID.
virtual int SetCurrentAudioCaptureID(const char* captureID) = 0;Parameters
Name | Type | Description |
captureID | const char * | The recording device ID. |
Return value
0 for success, other values for failure.
GetAudioPlayerList
Retrieves 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
Retrieves the list of recordable speakers in the system (for in-system recording).
virtual AliEngineDeviceInfoList* GetSystemRecordAudioPlayerList() = 0;Return value
The audio playback device list is mainly used as the last parameter for EnableSystemAudioRecording to collect system playback audio.
GetCurrentAudioPlayerName
Retrieves the name of the speaker currently in use.
virtual String GetCurrentAudioPlayerName() = 0;Return value
The name of the current audio playback device.
GetCurrentAudioPlayerID
Retrieves the ID of the speaker currently in use.
virtual String GetCurrentAudioPlayerID() = 0;Return value
The ID of the current audio playback device.
SetCurrentAudioPlayerName
Selects a speaker by name.
virtual int SetCurrentAudioPlayerName(const char* playerName) = 0;Return value
The audio playback device name.
SetCurrentAudioPlayerID
Selects a speaker by ID.
virtual int SetCurrentAudioPlayerID(const char* playerID) = 0;Parameters
Name | Type | Description |
playerID | const char * | The playback device ID. |
Return value
0 for success, other values for failure.
SetRecordingDeviceVolume
Sets the audio collection device volume. The volume range is [0, 100].
virtual int SetRecordingDeviceVolume(int volume) = 0;Parameter list
Name | Type | Description |
volume | int | Volume [0..100]. |
Return value
0 for success, other values for failure.
GetRecordingDeviceVolume
Retrieves the audio collection device volume.
virtual int GetRecordingDeviceVolume() = 0;Return value
>=0 returns the volume. Other values indicate failure.
SetPlaybackDeviceVolume
Sets the audio playback device volume. The volume range is [0, 100].
virtual int SetPlaybackDeviceVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | Volume [0..100] |
Return value
0 for success, other values for failure.
GetPlaybackDeviceVolume
Retrieves the audio playback device volume.
virtual int GetPlaybackDeviceVolume() = 0;Return value
>=0 for system volume. Other values for failure.
SetRecordingDeviceMute
Mutes the audio collection device.
virtual int SetRecordingDeviceMute(bool mute) = 0;Parameters
Name | Type | Description |
mute | bool | Whether to mute recording. |
Return value
0 for success, other values for failure.
GetRecordingDeviceMute
Retrieves the mute status of the audio collection device.
virtual bool GetRecordingDeviceMute() = 0;Return value
Whether recording is muted.
SetPlaybackDeviceMute
Mutes the audio playback device.
virtual int SetPlaybackDeviceMute(bool mute) = 0;Parameters
Name | Type | Description |
mute | bool | Whether to mute recording. |
Return value
0 for success, other values for failure.
GetPlaybackDeviceMute
Retrieves the mute status of the audio playback device.
virtual bool GetPlaybackDeviceMute() = 0;Return value
Whether the playback device is muted.
SetAudioEffectVoiceChangerMode
Sets the voice changer effect mode.
virtual int SetAudioEffectVoiceChangerMode(const AliEngineAudioEffectVoiceChangerMode &mode) = 0;Parameters
Name | Type | Description |
mode | The mode value. The default value is AliEngineAudioEffectVoiceChangerOff. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAudioEffectPitchValue
Sets the pitch parameter.
virtual int SetAudioEffectPitchValue(double value) = 0;Parameters
Name | Type | Description |
value | double | The range is [0.5, 2.0]. The default is 1.0, which means the pitch is unchanged. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAudioEffectReverbMode
Sets the reverb effect mode.
virtual int SetAudioEffectReverbMode(const AliEngineAudioEffectReverbMode& mode) = 0;Parameters
Name | Type | Description |
mode | The sound effect mode. The default value is AliEngineAudioEffectReverbOff. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAudioEffectReverbParamType
Sets the reverb effect type and specific parameters.
virtual int SetAudioEffectReverbParamType(const AliEngineAudioEffectReverbParamType& type,
float value) = 0;Parameters
Name | Type | Description |
type | The sound effect reverb mode. | |
value | float | The specific parameter value. |
Return value
0: The method call was successful. Other values: The method call failed.
setAudioEffectBeautifyMode
Sets the preset beautification sound effect mode.
virtual int SetAudioEffectBeautifyMode(const AliEngineAudioEffectBeautifyMode& mode) = 0;This method sets preset beautification modes within the SDK. It is suitable for scenarios that require beautification of human voice quality, such as voice live streaming, karaoke, and voice social networking. By selecting different beautification modes, you can change the auditory effect of the human voice, such as enhancing magnetism or improving clarity. This improves the listening experience for remote users.
When to call
You can call this method before or after you join a channel.
Parameters
Parameter | Type | Description |
mode | The beautification sound effect mode. See the enumeration definition for details. |
Return value
0: The setting was successful.
A non-zero value: The setting failed.
setAudioEffectEqualizationParam
Sets the audio equalizer (EQ) parameters to adjust the gain of a specified frequency band.
virtual int SetAudioEffectEqualizationParam(const AliEngineAudioEffectEqualizationBandFrequency &bandIndex, float gain) = 0;This method adjusts the locally collected human voice or audio signal using a Graphic Equalizer. By adjusting the gain (in dB) of one of the 10 fixed frequency bands, you can customize the timbre. It is suitable for scenarios such as voice clarity optimization, human voice enhancement, and noise reduction assistance.
The equalizer supports adjustment of the full audio spectrum from 31 Hz to 16 kHz, with a total of 10 standard frequency bands. The gain value for each band can be set independently, ranging from [-15, 15] dB, with a default of 0 dB (no enhancement or attenuation).
Limits
The equalizer cannot be used alone before the beautification mode is enabled. You must call this method after you call
setAudioEffectBeautifyMode.
Parameters
Parameter | Type | Description |
bandIndex | The index of the frequency band to be adjusted, corresponding to a segment of the center frequency (31Hz ~ 16kHz). | |
gain | float | The gain value in dB, ranging from [-15, 15]. |
Response description
0: The setting was successful.
A non-zero value: The setting failed.
AddExternalAudioStream
Adds an external audio stream.
virtual int AddExternalAudioStream(const AliEngineExternalAudioStreamConfig& config) = 0;This method adds a new external audio stream. The steps are as follows:
Call
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#991b862eb353w" id="08ee3d1ed35jj">AddExternalAudioStream</a>to add an external audio stream and obtain the external audio stream ID.Call
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#e6cf3f7cef0g6" id="fae817d0f00p3">PushExternalAudioStreamRawData</a>to push audio data to the created audio stream.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 stream.
For more information about how to publish custom collected audio in a channel, see Custom audio collection.
Parameters
Name | Type | Description |
config | AliEngineExternalAudioStreamConfig | External audio stream configuration. |
Return value
A value greater than 0 indicates a successful method call and returns the external audio stream ID. Other values indicate a failed method call.
PushExternalAudioStreamRawData
Inputs external audio stream data.
virtual int PushExternalAudioStreamRawData(int streamId, AliEngineAudioRawData& data) = 0;This method passes data into the specified audio stream. The steps are as follows:
Call the
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#991b862eb353w" id="3836ac109732c">AddExternalAudioStream</a>API to add an external audio stream and obtain the external audio stream ID.Call
PushExternalAudioStreamRawDatato pass audio data into the created audio stream.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="398ea88d61fn0">RemoveExternalAudioStream</a>to remove the external audio stream.
For more information about how to publish custom collected audio in a channel, see Custom audio collection.
Parameters
Name | Type | Description |
streamId | int | The external audio stream ID. |
data | The audio data. |
Return value
0: The method call was successful. Other values: The method call failed.
SetExternalAudioStreamPublishVolume
Sets the publishing volume of the external audio stream.
virtual int SetExternalAudioStreamPublishVolume(int streamId, int vol) = 0;Parameters
Name | Type | Description |
streamId | int | The external audio stream ID. |
vol | int | The publishing volume. |
Return value
0: The method call was successful. Other values: The method call failed.
SetExternalAudioStreamPlayoutVolume
Sets the publishing volume of the external audio stream.
virtual int SetExternalAudioStreamPlayoutVolume(int streamId, int vol) = 0;Parameters
Name | Type | Description |
streamId | int | The external audio stream ID. |
vol | int | The publishing volume. |
Return value
0: The method call was successful. Other values: The method call failed.
GetExternalAudioStreamPublishVolume
Retrieves the publishing volume of the external audio stream.
virtual int GetExternalAudioStreamPublishVolume(int streamId) = 0;Parameters
Name | Type | Description |
streamId | int | The external audio stream ID. |
Returns
[0, 100]: The publishing volume. A value less than 0 indicates failure.
GetExternalAudioStreamPlayoutVolume
Retrieves the playback volume of the external audio stream.
virtual int GetExternalAudioStreamPlayoutVolume(int streamId) = 0;Parameters
Name | Type | Description |
streamId | int | The external audio stream ID. |
Return value
[0, 100]: The playback volume. A value less than 0 indicates failure.
RemoveExternalAudioStream
Removes an external audio stream.
virtual int RemoveExternalAudioStream(int streamId) = 0;This method removes the corresponding external audio stream based on the passed streamId. It corresponds to the AddExternalAudioStream method.
When to call
If you want to use the custom audio input feature, you need to call the AddExternalAudioStream method to add an audio stream and obtain the external audio stream ID. You can 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> interface to input your audio data to the SDK. When you want to stop the custom audio input, call this interface to remove the corresponding external audio stream and clean up resources.
Parameters
Name | Type | Description |
streamId | int | The audio stream ID. |
Return value
0 for success, other values for failure.
GetAudioFileInfo
Retrieves audio file information.
virtual int GetAudioFileInfo(const char *filePath) = 0;This is an asynchronous method. You can retrieve the audio file information through AliEngineEventListener::OnAudioFileInfo.
Parameters
Name | Type | Description |
filePath | const char * | The audio file path. |
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
StartAudioAccompany
Starts audio mixing for accompaniment.
virtual int StartAudioAccompany(const char *filePath, const AliEngineAudioAccompanyConfig& config) = 0;This is an asynchronous method. You can listen to the audio accompaniment player status through AliEngineEventListener::OnAudioAccompanyStateChanged.
Parameters
Name | Type | Description |
filePath | const char * | The audio file path. |
config | The accompaniment playback configuration. |
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
StopAudioAccompany
Stops audio mixing for accompaniment.
virtual int StopAudioAccompany() = 0;Return value
0: Success.
A non-zero value: Failure. An error code is returned.
SetAudioAccompanyVolume
Sets the accompaniment volume.
virtual int SetAudioAccompanyVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The accompaniment volume. The range is [0,100].
|
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
SetAudioAccompanyPublishVolume
Sets the accompaniment publishing volume.
virtual int SetAudioAccompanyPublishVolume(int volume) = 0;The volume can be set only after AliEngine::StartAudioAccompany takes effect.
Parameters
Name | Type | Description |
volume | int | The accompaniment publishing volume. The range is [0,100].
|
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
GetAudioAccompanyPublishVolume
Retrieves the accompaniment publishing volume.
virtual int GetAudioAccompanyPublishVolume() = 0;Return value
The accompaniment publishing volume. The range is [0-100].
SetAudioAccompanyPlayoutVolume
Sets the local playback volume for accompaniment.
virtual int SetAudioAccompanyPlayoutVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The accompaniment playback volume. The range is [0,100].
|
Return value
0: Success.
A non-zero value: Failure. An error code is returned.
GetAudioAccompanyPlayoutVolume
Retrieves the local playback volume for accompaniment.
virtual int GetAudioAccompanyPlayoutVolume() = 0;Return value
The local playback volume for accompaniment. The range is [0-100].
PauseAudioAccompany
Pauses audio mixing for accompaniment.
virtual int PauseAudioAccompany() = 0;Response description
0: Success.
A non-zero value: Failure. An error code is returned.
ResumeAudioAccompany
Resumes audio mixing for accompaniment.
virtual int ResumeAudioAccompany() = 0;Response description
0: Success.
A non-zero value: Failure. An error code is returned.
GetAudioAccompanyDuration
Retrieves the duration of the accompaniment file in milliseconds.
virtual int GetAudioAccompanyDuration() = 0;Response description
The duration of the audio accompaniment file in milliseconds.
GetAudioAccompanyCurrentPosition
Retrieves the playback progress of the accompaniment file in milliseconds.
virtual int GetAudioAccompanyCurrentPosition() = 0;Return value
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;Response Description
0: Success.
A non-zero value: Failure. An error code is returned.
PreloadAudioEffect
Preloads a sound effect file.
virtual int PreloadAudioEffect(unsigned int soundId,
const char *filePath) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
filePath | const char * | The sound effect file path. |
Return value
0: The method call was successful. Other values: The method call failed.
UnloadAudioEffect
Deletes a preloaded sound effect file.
virtual int UnloadAudioEffect(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | NSInteger | The ID assigned to the sound effect file by the user. |
Return value
0: The method call was successful. Other values: The method call failed.
PlayAudioEffect
Starts playing a sound effect.
virtual int PlayAudioEffect(unsigned int soundId, const char *filePath, const AliEngineAudioEffectConfig& config) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
filePath | const char * | The sound effect file path. |
config | AliEngineAudioEffectConfig | The sound effect configuration. |
Returns
0: The method call was successful. Other values: The method call failed.
StopAudioEffect
Stops playing a sound effect.
virtual int StopAudioEffect(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
Return value
0: The method call was successful. Other values: The method call failed.
StopAllAudioEffects
Stops playing all sound effects.
- (int)StopAllAudioEffects;Return value
0: The method call was successful. Other values: The method call failed.
PauseAudioEffect
Pauses a sound effect.
virtual int PauseAudioEffect(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
Response Description
0: The method call was successful. Other values: The method call failed.
PauseAllAudioEffects
Pauses all sound effects.
virtual int PauseAllAudioEffects() = 0;Response description
0: The method call was successful. Other values: The method call failed.
ResumeAudioEffect
Resumes playing a sound effect.
virtual int ResumeAudioEffect(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
Response description
0: The method call was successful. Other values: The method call failed.
ResumeAllAudioEffects
Resumes playing all sound effects.
virtual int ResumeAllAudioEffects() = 0;Return value
0: The method call was successful. Other values: The method call failed.
SetAudioEffectPublishVolume
Sets the publishing volume for a sound effect.
virtual int SetAudioEffectPublishVolume(unsigned int soundId, int volume) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
volume | int | The mixing volume. The range is [0,100]. The default value is 50. |
Returns
0: The method call was successful. Other values: The method call failed.
GetAudioEffectPublishVolume
Retrieves the publishing volume of a sound effect.
virtual int GetAudioEffectPublishVolume(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAllAudioEffectsPublishVolume
Sets the local playback volume for all sound effects.
virtual int SetAllAudioEffectsPublishVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The mixing volume. The range is [0,100]. The default value is 50. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAudioEffectPlayoutVolume
Sets the local playback volume for a sound effect.
virtual int SetAudioEffectPlayoutVolume(unsigned int soundId, int volume) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
volume | int | The mixing volume. The range is [0,100]. The default value is 50. |
Return value
0: The method call was successful. Other values: The method call failed.
GetAudioEffectPlayoutVolume
Retrieves the local playback volume of a sound effect.
virtual int GetAudioEffectPlayoutVolume(unsigned int soundId) = 0;Parameters
Name | Type | Description |
soundId | unsigned int | The ID assigned to the sound effect file by the user. |
Response description
0: The method call was successful. Other values: The method call failed.
SetAllAudioEffectsPlayoutVolume
Sets the playback volume for all sound effects.
virtual int SetAllAudioEffectsPlayoutVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The mixing volume. The range is [0,100]. The default value is 50. |
Return value
0: The method call was successful. Other values: The method call failed.
SetAllAudioEffectsPublishVolume
Sets the publishing volume for all sound effects.
virtual int SetAllAudioEffectsPublishVolume(int volume) = 0;Parameters
Name | Type | Description |
volume | int | The mixing volume. The range is [0,100]. The default value is 50. |
Return value
0: The method call was successful. Other values: The method call failed.
SetLocalViewConfig
Sets the rendering window and drawing parameters for the local preview.
virtual int SetLocalViewConfig(AliEngineVideoCanvas renderConfig,
AliEngineVideoTrack track) = 0;This method sets the local preview view. It binds the display view of the local video stream and sets the rendering mode, mirror mode, and rotation angle of the local user's view. It affects only the local user's preview and not the published video. To set the view for a remote user, call SetRemoteViewConfig.
If the view parameter in AliEngineVideoCanvas is empty, rendering stops.
To reset the renderMode parameter of AliEngineVideoCanvas during playback, keep the other parameters unchanged and only modify renderMode.
To reset the mirrorMode parameter of AliEngineVideoCanvas during playback, keep the other parameters unchanged and only modify mirrorMode.
We recommend that you explicitly call StartPreview() to start the local preview.
When to call
This method can be called before or after you join a channel.
Parameters
Name | Type | Description |
renderConfig | Rendering parameters, including the rendering window and rendering method. | |
track | The type of video track. |
Return value
0: The method call was successful. Other values: The method call failed.
SetCameraCapturerConfiguration
Sets the camera collection preferences.
virtual int SetCameraCapturerConfiguration(const AliEngineCameraCapturerConfiguration& config) = 0;This method configures camera collection preferences, such as camera direction and collection frame rate.
When to call
You must set this before you open the camera. For example, call it before the following operations:
StartPreview (starts preview)
JoinChannel (joins a channel)
Parameters
Name | Type | Description |
config | Camera collection preferences, including camera direction and frame rate. Default values:
A value of -1 for the above indicates using the SDK's internal default settings. |
Return value
0: The method call was successful. Other values: The method call failed.
EnableLocalVideo
Disables or re-enables local video collection.
virtual int EnableLocalVideo(bool enabled) = 0;This method controls the enabling and disabling of local video collection. When local video collection is disabled, both the local preview and the published stream have no video data, but this does not affect receiving remote video. If you call this method to disable local camera collection, both the local preview and the remote published stream will remain on the last frame.
Local video collection is enabled by default in the SDK.
When to call
This method can be called before or after you join a channel.
Related callbacks
After a successful call to this method, the OnUserVideoEnabled callback notifies remote users.
Parameters
Name | Type | Description |
enable | bool | true: Resumes normal operation. false: Stops video collection. The default is true. |
Return value
0: The method call was successful. Other values: The method call failed.
MuteLocalCamera
Stops or resumes sending local video data.
virtual int MuteLocalCamera(bool mute, AliEngineVideoTrack track) = 0;When you publish a stream, you can call this method to publish all-black video frames. The local preview remains normal, and the collection, encoding, and sending modules continue to work, but the video content consists of black frames.
This method controls only whether to send black frames on the specified video stream. Collection and data sending will not stop. To disable collection, use the EnableLocalVideo method. To stop sending video data, use the PublishLocalVideoStream method.
Parameters
Name | Type | Description |
mute | bool | true: Sends black frames for video data. false: Resumes normal operation. The default value is false. |
track | The type of video track whose publishing state needs to be changed. |
Return value
0: The method call was successful. Other values: The method call failed.
SetRemoteViewConfig
Sets the rendering window and drawing parameters for a remote video.
virtual int SetRemoteViewConfig(AliEngineVideoCanvas renderConfig,
const char *uid,
AliEngineVideoTrack track) = 0;This method attaches the display view for a specified video stream from a remote user and sets properties for the local display of the remote view, such as the rendering mode, mirror mode, and rotation angle. This action affects only the video image that the local user sees. To set the 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 the other parameters unchanged and only modify renderMode.
To reset the mirrorMode parameter of AliEngineVideoCanvas during playback, keep the other parameters unchanged and only modify mirrorMode.
When to call
We recommend that you call this when you receive the OnRemoteTrackAvailableNotify callback, which is when the remote user's video is available.
Parameters
Name | Type | Description |
canvas | Rendering parameters, including the rendering window and rendering method. | |
uid | const char * | The user ID. |
track | The type of video track to set. |
Return value
0: The method call was successful. Other values: The method call failed.
IsCameraOn
Checks whether the camera is on.
virtual bool IsCameraOn() = 0;Return value
true: The camera is on. false: The camera is not on.
SetVideoEncoderConfiguration
Sets the video encoding properties.
virtual void SetVideoEncoderConfiguration(const AliEngineVideoEncoderConfiguration& config) = 0;This method sets the video parameters for the video stream encoding properties, such as resolution, frame rate, bitrate, and video orientation. We recommend that you call this method for all video scenarios.
All set parameters have corresponding range limits. If a set parameter is outside the valid range, the SDK automatically adjusts it.
When to call
This method can be called before or after you join a channel. If you only need to set the camera stream video encoding properties once per session, we recommend that you call it before you join the channel.
Limits
The `mirrorMode` of this method and setVideoMirrorMode can both set the video publishing mirror. We recommend that you use only one of them. Using multiple methods at the same time can cause the mirror effects to stack, which leads to failed or incorrect mirror settings.
Parameters
Name | Type | Description |
config | Predefined encoding properties. Default values:
|
SetVideoDecoderConfiguration
Sets the video decoding properties. This method sets the camera stream video decoding properties, including software and hardware decoding settings and whether to enable B-frames.
virtual void SetVideoDecoderConfiguration(const AliEngineVideoDecoderConfiguration& config) = 0;When to call
We recommend that you call this before you join a channel and pull a stream.
Parameters
Parameter | Type | Description |
config | A struct that describes the video decoding properties, main properties, and default values. |
StartPreview
Starts the local preview and automatically turns on the camera.
virtual int StartPreview(int width = 0, int height = 0) = 0;This method starts the local video preview and automatically turns on the camera. To stop the local preview, call the StopPreview method.
Leaving a channel using LeaveChannel automatically stops the local preview. If the camera stream is not being published, the camera is automatically turned off.
When to call
Before you call this method, you need to set a view for the local preview through SetLocalViewConfig. Otherwise, you cannot preview the video, but this does not affect publishing.
If needed, you can call this method before you join a channel with JoinChannel to start the preview, which will automatically turn on the camera.
Response description
0: The method call was successful. Other values: The method call failed.
StopPreview
Stops the local preview.
virtual int StopPreview() = 0;This method closes the local video preview and turns off the camera. After you stop the preview, the local end will remain on the last frame, which does not affect publishing.
Leaving a channel using LeaveChannel automatically stops the local preview. If the camera stream is not being published, the camera is automatically turned off.
When to call
To stop the preview after you have started it, you can call this method.
Return value
0: The method call was successful. Other values: The method call failed.
setVideoMirrorMode
Sets the preview and publishing mirror capabilities.
virtual int setVideoMirrorMode(AliEngineVideoPipelineMirrorMode mirrorMode) = 0;This method sets whether to enable mirror mode for the local preview video and the published video stream.
This method has a higher priority than SetLocalViewConfig and SetVideoEncoderConfiguration. To set the video mirror mode, we recommend that you call this method.
When to call
This method can be dynamically set before and after you join a channel. The SDK records the state and operates on the video when the preview and encoding (publishing) can be operated.
Limits
This method overlaps with the mirrorMode parameter in SetLocalViewConfig and SetVideoEncoderConfiguration. We recommend that you use only this method.
Parameters
Name | Type | Description |
mirrorMode | Sets the mirror mode. |
Return value
0: The setting was successful.
<0: The setting failed.
AliRtcErrInner: An internal SDK state error. Check if the SDK instance was created successfully.
SetCapturePipelineScaleMode
Sets the collection scaling timing. Video data is scaled either immediately upon collection or during encoding.
virtual void SetCapturePipelineScaleMode(const AliEngineCapturePipelineScaleMode mode) = 0;This method sets whether video data collection scaling occurs immediately upon collection or during encoding. For example, when the collection resolution is inconsistent with the encoding resolution, you can set the scaling timing to determine whether the preview data and the published data are consistent.
When to call
This method needs to be set before you open the camera, for example, before you start the preview with StartPreview or join a channel with JoinChannel.
Parameters
Name | Type | Description |
mode | The mode that controls the timing of collection scaling. The default is to scale immediately upon collection. |
GetCameraList
Retrieves the camera list.
virtual AliEngineDeviceInfoList* GetCameraList() = 0;Return value
A pointer to the camera list object, AliEngineDeviceInfoList*.
GetCurrentCameraName
Retrieves the name of the camera currently in use.
virtual String GetCurrentCameraName() = 0;Return value
The name of the camera device currently in use.
GetCurrentCameraID
Retrieves the ID of the camera currently in use.
virtual String GetCurrentCameraID() = 0;Return value
The ID of the camera currently in use.
SetCurrentCameraName
Selects a camera by name.
virtual int SetCurrentCameraName(const char* cameraName) = 0;Parameters
Name | Type | Description |
cameraName | const char * | The device name. |
Return value
0 for success, other values for failure.
SetCurrentCameraID
Selects a camera by ID.
virtual int SetCurrentCameraID(const char* cameraID) = 0;Parameters
Name | Type | Description |
cameraID | const char * | The device ID. |
Return value
0 for success, other values for failure.
GetCurrentCameraSupportedResolutionList
Retrieves the supported resolutions.
virtual AliEngineVideoResolutionList * GetCurrentCameraSupportedResolutionList(int source) = 0 ;Parameters
Name | Type | Description |
source | int | The device type. |
Return value
If the value is not NULL, it retrieves the list of supported resolutions. NULL indicates failure.
SetExternalVideoSource
Enables an external video input source.
virtual int SetExternalVideoSource(bool enable,
AliEngineVideoTrack type,
AliEngineRenderMode renderMode) = 0;Parameters
Name | Type | Description |
enable | bool | true: Enable. false: Disable. |
type | The stream type. | |
renderMode | The rendering mode. |
PushExternalVideoFrame
Inputs video data.
virtual int PushExternalVideoFrame(const AliEngineVideoRawData &frame,
AliEngineVideoTrack type) = 0;Parameters
Name | Type | Description |
frame | The frame data. | |
type | The stream type. |
Return value
0: The method call was successful. Other values: The method call failed.
StartPublishLiveStream
Starts a bypass live stream.
virtual int StartPublishLiveStream(const String& streamURL, const AliEngineLiveTranscodingParam &transcoding) = 0;Parameters
Name | Type | Description |
streamUrl | const String | The ingest URL. |
transcoding | The parameters required for stream ingest. |
Return value
0: The method call was successful. Other values: The method call failed.
UpdatePublishLiveStream
Updates bypass live stream parameters.
virtual int UpdatePublishLiveStream(const String& streamURL, const AliEngineLiveTranscodingParam &transcoding) = 0;Parameters
Name | Type | Description |
streamUrl | const String | The ingest URL. |
transcoding | The parameters required for stream ingest. |
Return value
0: The method call was successful. Other values: The method call failed.
StopPublishLiveStream
Stops the bypass live stream.
virtual int StopPublishLiveStream(const String& streamURL) = 0;Parameters
Name | Type | Description |
streamURL | const String | The ingest URL. |
Response description
0: The method call was successful. Other values: The method call failed.
GetPublishLiveStreamState
Retrieves the bypass live stream status.
virtual AliEngineLiveTranscodingState GetPublishLiveStreamState(const String& streamURL) = 0;Parameters
Parameter | Type | Description |
streamURL | const String | The ingest URL. |
Response description
Returns the bypass live stream status.
StartLastmileDetect
Starts network quality detection. Some on-premises network problems may cause audio and video calls to fail. By calling this method, you can obtain information such as upstream and downstream network bandwidth, packet loss rate, jitter, and link RTT to help locate and solve related network problems.
virtual int StartLastmileDetect(bool uplink, bool downlink, int uplinkBandWidth, int downlinkBandWidth) = 0;When to call
This method needs to be called before JoinChannel. The detection results will be provided through a callback. A network detection may take a long time. You can call StopLastmileDetect to stop the network detection as needed.
Limits
The SDK can perform only one network detection at a time. Repeated calls before the previous detection is complete will be invalid.
Related callbacks
After a successful call to this method, two callbacks will be triggered:
OnLastmileDetectResultWithQuality: This callback is triggered in about 3s to roughly determine the network quality level.
OnLastmileDetectResultWithBandWidth: This callback is triggered in about 30s to provide detailed detection results.
Parameters
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 value
0: The method call was successful.
<0: The method call failed. For example, this can occur if you have already joined a channel.
StopLastmileDetect
Stops network quality detection. Call this method to stop network quality detection.
virtual int StopLastmileDetect() = 0;When to call
You can call this method after you create the engine and before you join a channel.
Return value
0: This method was called successfully.
<0: This method call failed.
SendMediaExtensionMsg
Sends media extension information, which is 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 the function of sending and receiving media extension information. The receiving end refers to AliEngineEventListener::OnMediaExtensionMsgReceived. When you use media extension information, it is necessary to reuse the audio and video data channel, so the sending frequency and data length of custom messages must be controlled. The usage limits are as follows:
Send a maximum of fps messages per second as set by the profile.
To avoid affecting the transmission quality of media data, the custom message body length is limited to 4 KB, which can be used to transmit a small amount of data.
The repeatCount parameter in the sendMediaExtensionMsg function is the redundancy of the custom message. If it is greater than 1, it will be sent multiple times to prevent message loss due to network packet loss. In this case, other people in the room will also receive the same message multiple times, and duplicates need to be removed.
When the custom message is sent, subscribers in the room will also receive it during bypass live streaming. Setting it to -1 means sending the data permanently, unless sendMediaExtensionMsg is called again.
Only one sendMediaExtensionMsg will be sent at a time. This means that calling sendMediaExtensionMsg will overwrite the previous call to sendMediaExtensionMsg if the previous call was not sent or not completed.
Parameters
Name | Type | Description |
message | const int8_t * | The extension information content, with a maximum length of 4 KB. |
length | uint32_t | The extension information length, with a maximum length of 4 KB (4 × 1024 bytes). |
repeatCount | int32_t | The number of repetitions, which represents the message redundancy, used to prevent message loss due to network packet loss. -1 means infinite resending, unless SendMediaExtensionMsg is called again. |
delay | uint32_t | The delay in milliseconds before sending the SEI. Since the 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 is added only to keyframes. |
Return value
0: Success.
<0: Failure. An error code is returned.
ERR_INNER(-1): An internal SDK error. This may occur if the SDK is not initialized or is called after being destroyed.
SendMediaExtensionMsgEx
Sends media extension information, which is 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 the function of sending and receiving media extension information. The receiving end refers to AliEngineEventListener::OnMediaExtensionMsgReceived. When you use media extension information, it is necessary to reuse the audio and video data channel, so the sending frequency and data length of custom messages must be controlled. The usage limits are as follows:
Send a maximum of fps messages per second as set by the profile.
To avoid affecting the transmission quality of media data, the custom message body length is limited to 4 KB, which can be used to transmit a small amount of data.
The repeatCount parameter in the sendMediaExtensionMsg function is the redundancy of the custom message. If it is greater than 1, it will be sent multiple times to prevent message loss due to network packet loss. In this case, other people in the room will also receive the same message multiple times, and duplicates need to be removed.
When the custom message is sent, subscribers in the room will also receive it during bypass live streaming. Setting it to -1 means sending the data permanently, unless sendMediaExtensionMsg is called again.
Only one sendMediaExtensionMsg will be sent at a time. This means that calling sendMediaExtensionMsg will overwrite the previous call to sendMediaExtensionMsg if the previous call was not sent or not completed.
Parameters
Name | Type | Description |
message | const int8_t * | The extension information content, with a maximum length of 4 KB. |
length | uint32_t | The extension information length, with a maximum length of 4 KB (4 × 1024 bytes). |
repeatCount | int32_t | The number of repetitions, which represents the message redundancy, used to prevent message loss due to network packet loss. -1 means infinite resending, unless SendMediaExtensionMsg is called again. |
delay | uint32_t | The delay in milliseconds before sending the SEI. Since the 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 is added only to keyframes. |
payloadType | int32_t | The data type field. payload=5 payload=[100..254]. |
Return value
0: Success.
<0: Failure. An error code is returned.
ERR_INNER(-1): An internal SDK error. This may occur if the SDK is not initialized or is called after being destroyed.
OnConnectionStatusChange
Callback for network connection status changes.
virtual void OnConnectionStatusChange(int status, int reason) {};Parameters
Parameter | Type | Description |
status | The current status value. | |
reason | The specific reason for the status change. |
OnLocalDeviceException
Callback for on-premises device exceptions. Customers need to pay attention to this callback.
virtual void OnLocalDeviceException(AliEngineLocalDeviceType deviceType, AliEngineLocalDeviceExceptionType exceptionType, const char* msg){};Parameters
Parameter | Type | Description |
deviceType | AliEngineLocalDeviceType | The device type. |
exceptionType | AliEngineLocalDeviceExceptionType | The device exception type. |
msg | const char* | The information carried with the exception. |
OnAuthInfoWillExpire
Notification that user authentication information is about to expire. Authentication will expire 30 seconds after this notification is received. Customers need to pay attention to this callback.
virtual void OnAuthInfoWillExpire() {};This callback indicates that the user's authentication information is about to expire. Authentication will expire 30 seconds after this callback is received. You need to obtain a new token and then update the authentication information in one of the following ways:
Call the
RefreshAuthInfomethod to update the authentication information.Call
LeaveChannelto leave the current channel, and then callJoinChannelto rejoin the channel.
When triggered
The SDK triggers this callback 30 seconds before the user's authentication information expires. You should update the authentication information promptly after you receive this callback.
OnAuthInfoExpired
The user calls an interface that requires authentication, and the server returns that the information has expired.
virtual void OnAuthInfoExpired() {};This callback indicates that the user's authentication information has expired. If you want to continue the session, you need to generate a new token on the server and then update the authentication information using the following method:
Call
LeaveChannelto leave the current channel, and then callJoinChannelto rejoin the channel.
When triggered
This callback is triggered when the user's authentication information expires.
OnJoinChannelResult
Callback for the result of joining a channel. This callback is equivalent to the block operation of calling the JoinChannel method, which handles events after joining the channel. Choose one of them.
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 joining and the time it took to join.
Parameters
Parameter | Type | Description |
result | int | The result of joining the channel. 0 is returned for success. An error code is returned for failure. For more information, see Error code list. The following are some common error codes:
|
channel | const char * | The ID of the channel joined. |
userId | const char * | The ID of the user who joined. |
elapsed | int | The time it took to join the channel. |
OnLeaveChannelResult
Callback for the result of leaving a channel. This is returned after you call the LeaveChannel method. If you call Destroy immediately after you call this, 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 and the statistics of this channel session.
If you call Destroy to destroy the engine immediately after LeaveChannel, this callback will not be triggered.
Parameters
Parameter | Type | Description |
result | int | The result of leaving the channel. 0 is returned for success, and an error code is returned for failure. |
stats | A summary of the data statistics for this channel session. |
OnRemoteUserOffLineNotify
Callback for 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. When a remote user goes offline, this method is triggered.
Trigger conditions
The callback is triggered when a remote user actively leaves the channel.
A 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 their role to a viewer (set to AliEngineClientRoleLive).The callback is triggered when no data is received from the remote streamer for a long time and they are considered to have dropped.
Parameters
Parameter | Type | Description |
uid | const char * | The unique identifier assigned to the user ID from the App server. |
reason | The reason the user went offline. |
OnRemoteUserOnLineNotify
Callback for when a remote user comes online.
virtual void OnRemoteUserOnLineNotify(const char *uid, int elapsed) {}This method notifies 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 a join callback for users already in the channel. This is used to display previously joined users.
Parameters
Parameter | Type | Description |
uid | const char * | The unique identifier assigned to the user ID from the App server. |
elapsed | int | The time it took for the user to join the channel. |
OnRemoteTrackAvailableNotify
Callback for when a remote user's stream changes.
virtual void OnRemoteTrackAvailableNotify(const char *uid,
AliEngineAudioTrack audioTrack,
AliEngineVideoTrack videoTrack) {}This callback is triggered when a remote user's publishing state changes. Through this callback, you can know in real time whether a remote user is publishing audio and video streams. You can then display or hide the remote user's audio and video information on the UI accordingly.
Trigger conditions
This callback is triggered in the following scenarios:
When a remote user changes from not publishing to publishing (including audio and video).
When a remote user changes from publishing to not publishing (including audio and video).
In interactive stream mode, when a remote user calls SetClientRole to switch from viewer to streamer and also sets publishing, this callback is triggered.
Taking video as an example, suppose a remote user is set not to publish. This callback will not be triggered in that case.
When the remote user starts publishing the camera stream (publishing state: no video stream -> only camera stream), the local callback returns
AliEngineVideoTrackCamera, which indicates that the remote user's camera stream is available.When the remote user also publishes the screen sharing stream (publishing state: only camera stream -> camera stream and screen sharing stream), the local callback returns
AliEngineVideoTrackBoth, which indicates 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 (publishing state: camera stream and screen sharing stream -> only screen sharing stream), the local callback returns
AliEngineVideoTrackScreen, which indicates that only the screen sharing stream is currently available.When the remote user stops publishing the screen sharing stream (publishing state: only screen sharing stream -> no video stream), the local callback returns
AliEngineVideoTrackNo, which indicates that no video stream is currently available.
This callback returns the remote user's publishing status. To know which stream went offline in this change, you must record the state changes before and after the callback.
Parameters
Parameter | Type | Description |
uid | const char * | The unique identifier assigned to the user ID from the App server. |
audioTrack | The audio stream of the remote user after the change. | |
videoTrack | The video stream of the remote user after the change. |
OnBye
Callback for when the user is kicked out by the server or the channel is closed.
virtual void OnBye(int code) {}When a user is disconnected for some reason or the channel is closed, this callback is triggered. You can use the callback parameter code to identify the reason for the disconnection and handle it accordingly.
Trigger conditions
The current user is kicked out by the server.
The channel is closed (the server actively removes the channel).
Passive leaving, which requires the client to try to restore the session or reconnect.
Parameters
Parameter | Type | Description |
code | int | The message type. Values:
|
OnAudioPublishStateChanged
Callback for audio publishing changes.
virtual void OnAudioPublishStateChanged(AliEnginePublishState oldState, AliEnginePublishState newState, int elapseSinceLastState, const char *channel) {};This callback listens for changes in the local user's audio stream publishing state.
Trigger conditions
When the user's audio publishing state changes, for example:
Stops publishing.
Calls
<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 a viewer.
Parameters
Parameter | Type | Description |
oldState | The previous publishing state. | |
newStat | The current publishing state. | |
elapseSinceLastState | int | The time interval since the state change, in milliseconds. |
channel | const char * | The current channel ID. |
OnAudioSubscribeStateChanged
Callback for audio subscription changes.
virtual void OnAudioSubscribeStateChanged(const char *uid,
AliEngineSubscribeState oldState,
AliEngineSubscribeState newState,
int elapseSinceLastState,
const char *channel) {};This callback notifies the local user of changes in the remote user's audio stream subscription state. Through this callback, you can know the subscription state change of a remote user's camera stream and the time interval from the previous state to the current state.
Parameters
Parameter | Type | Description |
uid | NSString *_Nonnull | The user ID whose subscription has changed. |
oldState | The previous subscription state. | |
newState | The current subscription state. | |
elapseSinceLastState | int | The time interval since the state change, in milliseconds. |
channel | const char * | The current channel ID. |
OnUserAudioMuted
Notification that a user has muted their audio.
virtual void OnUserAudioMuted(const char* uid, bool isMute) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user who executed MuteAudio. |
isMute | bool | true: Muted. false: Not muted. |
OnUserAudioInterruptedBegin
Notification that a user's audio has been interrupted. This usually occurs in scenarios where audio is preempted, such as by a phone call.
virtual void OnUserAudioInterruptedBegin(const char* uid) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user whose audio was interrupted. |
OnUserAudioInterruptedEnded
Notification that a user's audio interruption has ended. This corresponds to OnUserAudioInterruptedBegin.
virtual void OnUserAudioInterruptedEnded(const char* uid) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user whose audio interruption has ended. |
OnVideoPublishStateChanged
Callback for video publishing changes.
virtual void OnVideoPublishStateChanged(AliEnginePublishState oldState, AliEnginePublishState newState, int elapseSinceLastState, const char *channel) {};This callback listens for changes in the local user's video publishing state.
Parameters
Parameter | Type | Description |
oldState | The previous publishing state. | |
newState | The current publishing state. | |
elapseSinceLastState | int | The time interval since the state change, in milliseconds. |
channel | const char * | The current 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 of changes in the remote user's camera stream subscription state. Through this callback, you can know the subscription state change of a remote user's camera stream and the time interval from the previous state to the current state.
Related callbacks
Video streams mainly include camera streams and screen sharing streams. This method is for camera stream subscription state changes. The related callback method for screen sharing streams is OnScreenShareSubscribeStateChanged.
Parameters
Parameter | Type | Description |
uid | const char * | The user ID whose subscription has changed. |
oldState | The previous subscription state. | |
newState | The current subscription state. | |
elapseSinceLastState | int | The time interval since the state change, in milliseconds. |
channel | const char * | The current channel ID. |
OnUserVideoMuted
Notification that a user has muted their video.
virtual void OnUserVideoMuted(const char* uid, bool isMute) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user who executed muteVideo. |
isMute | bool | true: Publishing black frames. false: Normal publishing. |
OnUserVideoEnabled
Notification that local video collection has been disabled or re-enabled.
virtual void OnUserVideoEnabled(const char* uid, bool isEnable) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user who executed EnableLocalVideo. |
isMute | bool | true: Camera stream collection is on. false: Camera stream collection is off. |
OnUserWillResignActive
Callback for when a remote user's application moves to the background.
virtual void OnUserWillResignActive(const char* uid) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user whose application has moved to the background. |
OnUserWillBecomeActive
Callback for when a remote user's application returns to the foreground.
virtual void OnUserWillBecomeActive(const char* uid) {}Parameters
Parameter | Type | Description |
uid | const char* | The user ID of the user whose application has returned to the foreground. |
OnStats
Real-time data callback. This is triggered every 2 seconds.
virtual void OnStats(const AliEngineStats& stats) {}Parameters
Parameter | Type | Description |
stats | The data callback. |
OnLocalVideoStats
Local video statistics. This is triggered every 2 seconds.
virtual void OnLocalVideoStats(const AliEngineLocalVideoStats& localVideoStats);Parameter information
Parameter | Type | Description |
localVideoStats | const AliEngineLocalVideoStats& | Local video statistics, including bitrate, frame rate, and other information. |
OnRemoteVideoStats
Remote video statistics. This is triggered every 2 seconds.
virtual void OnRemoteVideoStats(const AliEngineRemoteVideoStats& remoteVideoStats);Parameter information
Parameter | Type | Description |
remoteVideoStats | const AliEngineRemoteVideoStats& | Remote video statistics, including remote user ID, frame rate, stuttering, and other information. |
OnLocalAudioStats
Local audio statistics. This is triggered every 2 seconds.
virtual void OnLocalAudioStats(const AliEngineLocalAudioStats& localAudioStats);Parameter information
Parameter | Type | Description |
localAudioStats | const AliEngineLocalAudioStats& | Local audio statistics, including sample rate, number of sound channels, and so on. |
OnRemoteAudioStats
Remote audio statistics. This is triggered every 2 seconds.
virtual void OnRemoteAudioStats(const AliEngineRemoteAudioStats& remoteAudioStats);Parameter information
Parameter | Type | Description |
remoteAudioStats | const AliEngineRemoteAudioStats& | Remote audio statistics, including packet loss rate, stuttering rate, and so on. |
OnMediaExtensionMsgReceived
Callback for receiving media extension information. When one end sends information through SendMediaExtensionMsg, the other end receives data through this callback.
virtual void OnMediaExtensionMsgReceived(const char* uid, const uint8_t payloadType, const int8_t * message, uint32_t size);When one end sends information through sendMediaExtensionMsg, the other end receives data through this callback.
Parameters
Parameter | Type | Description |
uid | const char* | The sending user's userId. |
payloadType | const uint8_t | The payload type. sendMediaExtensionMsg returns 5. sendMediaExtensionMsgEx will return the specific type. |
message | const int8_t * | The extension information content. |
size | uint32_t | The extension information length. |
OnSnapshotComplete
Callback for the screenshot result. When a user successfully calls SnapshotVideo, the screenshot result is returned through this callback.
virtual void OnSnapshotComplete(const char* userId, AliEngineVideoTrack videoTrack, void* buffer, int width, int height, bool success);Parameters
Parameter | Type | Description |
userId | const char* | The user ID, indicating which user's video stream was captured. |
videoTrack | The type of video captured, such as camera stream or screen sharing stream. | |
buffer | void* | If successful, returns the image data of the screenshot. The image format is RGBA. If it fails, it returns nullptr. |
width | int | The screenshot width. |
height | int | The screenshot height. |
success | bool | Whether the screenshot was successful.
|
OnLocalAudioStateChange
Callback for local audio device status.
virtual void OnLocalAudioStateChange(AliEngineLocalAudioStateType state, const char* msg);Parameters
Parameter | Type | Description |
state | The current audio device status, such as starting or started. | |
msg | const char* | Description of the device status change. |
onLocalVideoStateChanged
Callback for local video device status.
virtual void onLocalVideoStateChanged(AliEngineLocalVideoStateType state, const char* msg);Parameters
Parameter | Type | Description |
state | The current video device status, such as starting or started. | |
msg | const char* | Description of the device status change. |
OnRemoteUserSubscribedDataChannel
Callback that you can start sending data channel messages.
virtual void OnRemoteUserSubscribedDataChannel(const char* uid);This method is a callback that 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. You can then safely call SendDataChannelMessage to send data to them. This callback is a key mechanism for ensuring reliable message delivery and preventing packet loss or failure when you send messages to a target user who has not subscribed to the Data Channel.
This callback is triggered only in AI scenarios.
Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
OnDataChannelMessage
Callback for data channel messages.
virtual void OnDataChannelMessage(const char* uid, const AliEngineDataChannelMsg& msg);The ARTC SDK provides the ability to send and receive custom messages. This lets you send custom real-time message data while transmitting audio and video data. For example, you can call this method to transmit real-time control instructions, status synchronization data, or other business messages along with audio and video. For more information, see Send and receive custom messages.
In interactive scenarios, the streamer role can send and receive messages, while the viewer role only supports receiving messages.
This feature is disabled by default. To enable this feature, after you create the engine, call
<a baseurl="t2713962_v4_0_0.xdita" data-node="4904760" data-root="16090" data-tag="xref" href="#d78a13ea0e6hy" id="327b69c0ee1wh">SetParameter</a>to set{\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}.
When triggered
After the sender calls SendDataChannelMessage to send a custom message, if the receiver has enabled the data channel feature, this callback is triggered on the receiver's end.
Parameters
Parameter | Type | Description |
uid | const char* | The sending user ID. |
msg | const AliEngineDataChannelMsg& | The data channel message. |
OnCapturedAudioFrame
Callback for raw audio collection data.
virtual bool OnCapturedAudioFrame(AliEngineAudioRawData audioRawData) = 0;This callback retrieves the raw audio data collected by the current device. It is disabled by default. To retrieve this audio data:
Enable this callback through audioSource in EnableAudioFrameObserver(true,audioSource,config). The config parameter can also set the sample rate, number of sound channels, and read/write mode for the audio data.
Call RegisterAudioFrameObserver to register the audio data receiving object.
This method supports setting the sample rate, number of sound channels, and read/write mode.
Parameters
Parameter | Type | Description |
audioRawData | The audio data. |
Return value
true: Success.
false: Failure.
OnProcessCapturedAudioFrame
Callback for data after 3A processing.
virtual bool OnProcessCapturedAudioFrame(AliEngineAudioRawData audioRawData) = 0;This callback retrieves the audio data after it has been processed by 3A. It is disabled by default. To retrieve this audio data:
Enable this callback through audioSource in EnableAudioFrameObserver(true,audioSource,config). The config parameter can also set the sample rate, number of sound channels, and read/write mode for the audio data.
Call RegisterAudioFrameObserver to register the audio data receiving object.
This method supports setting the sample rate, number of sound channels, and read/write mode.
Parameters
Parameter | Type | Description |
audioRawData | The audio data. |
Return value
true: Success.
false: Failure.
OnPublishAudioFrame
Callback for published data.
virtual bool OnPublishAudioFrame(AliEngineAudioRawData audioRawData) = 0;This callback retrieves the published audio data. It is disabled by default. To retrieve this audio data:
Enable this callback through audioSource in EnableAudioFrameObserver(true,audioSource,config). The config parameter can also set the sample rate, number of sound channels, and read/write mode for the audio data.
Call RegisterAudioFrameObserver to register the audio data receiving object.
This method supports setting the sample rate and number of sound channels, but can be set only to read-only mode.
Parameters
Parameter | Type | Description |
audioRawData | The audio data. |
Return value
true: Success.
false: Failure.
OnPlaybackAudioFrame
Callback for playback data.
virtual bool OnPlaybackAudioFrame(AliEngineAudioRawData audioRawData) = 0;This callback retrieves the playback audio data. It is disabled by default. To retrieve this audio data:
Enable this callback through audioSource in EnableAudioFrameObserver(true,audioSource,config). The config parameter can also set the sample rate, number of sound channels, and read/write mode for the audio data.
Call RegisterAudioFrameObserver to register the audio data receiving object.
This method supports setting the sample rate, number of sound channels, and read/write mode.
Limits
Do not perform any time-consuming operations in this callback function. Otherwise, it may cause sound abnormalities.
Parameters
Parameter | Type | Description |
audioRawData | The audio data. |
Return value
true: Success.
false: Failure.
OnRemoteUserAudioFrame
Callback for remote pulled stream data.
virtual bool OnRemoteUserAudioFrame(const char *uid, AliEngineAudioRawData audioRawData) = 0; This callback retrieves the remote audio data of a specified user that is being pulled. It is disabled by default. To retrieve this audio data:
Enable this callback through audioSource in EnableAudioFrameObserver(true,audioSource,config). The config parameter can also set the sample rate, number of sound channels, and read/write mode for the audio data.
Call RegisterAudioFrameObserver to register the audio data receiving object.
This method does not support setting the sample rate or number of sound channels, but you can set the read/write mode.
Limits
Do not perform any time-consuming operations in this callback function. Otherwise, it may cause sound abnormalities.
Parameters
Parameter | Type | Description |
uid | const char * | The remote user ID. |
audioRawData | The audio data. |
Return value
true: Success.
false: Failure.
OnCaptureVideoSample
Callback for local collected video data.
virtual bool OnCaptureVideoSample(AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;This method is a callback for retrieving local video collection data. It is used to retrieve the raw video frames (such as YUV data) collected by the local camera. You can use this callback to implement custom video processing logic (such as adding filters, watermarks, or transcoding) 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.
When triggered
After you successfully call <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, the SDK captures the corresponding video frame.
Parameters
Parameter | Type | Description |
videoSource | The video data source. | |
videoRawData | The raw video data. |
Response description
true: Needs to be written back to the SDK (valid only for I420 and native (iOS/macOS)).
false: Does not need to be written back to the SDK.
OnPreEncodeVideoSample
Callback for local video data before encoding.
virtual bool OnPreEncodeVideoSample(AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;This method is a callback for retrieving local video data before encoding. It is used to retrieve the raw video data (such as YUV format) before the SDK encodes the video frame. You can use this callback to implement custom processing logic (such as adding watermarks, adjusting colors, or transcoding) and decide whether to return the processed data to the SDK for subsequent encoding.
Parameters
Parameter | Type | Description |
videoSource | The video data source. | |
videoRawData | The video data. |
Return value
true: Needs to be written back to the SDK (valid only for I420 and native (iOS/macOS)).
false: Does not need to be written back to the SDK.
OnRemoteVideoSample
Callback for subscribed remote video data.
virtual bool OnRemoteVideoSample(const char *uid, AliEngineVideoSource videoSource, AliEngineVideoRawData &videoRawData) = 0;This method is a callback for retrieving subscribed remote video data. It is used to retrieve the raw video frame data (such as YUV format) of a remote user. You can use this callback to implement custom processing logic (such as adding filters, watermarks, or transcoding) and decide whether to return the processed data to the SDK for subsequent rendering.
Parameters
Parameter | Type | Description |
uid | const char * | The remote user ID. |
videoSource | The video data source. | |
videoRawData | The raw video data. |
Return value
true: Needs to be written back to the SDK.
false: Does not need to be written back to the SDK.
GetVideoAlignment
Video output width alignment.
virtual AliEngineVideoObserAlignment GetVideoAlignment();Return value
The expected video output width alignment. See AliEngineVideoObserAlignment.
GetObservedFramePosition
Video data output content.
virtual uint32_t GetObservedFramePosition();Return value
The expected video output content. See AliEngineVideoObserPosition.
onDestroyCompletion
Callback for when the destroy operation is complete.
virtual void onDestroyCompletion();This callback indicates that the SDK engine instance has been destroyed and a new one can be created.
When triggered
This callback is triggered after the engine is destroyed when the user calls Destroy.
Wait for the onDestroyCompletion callback before you execute other methods to avoid blocking the main thread.
OnAudioEffectFinished
Callback for when a local sound effect has finished playing.
virtual void OnAudioEffectFinished(int soundId) {}Parameter | Type | Description |
soundId | int | The ID of the sound effect that has finished playing. |
OnAudioVolumeCallback
Callback for the 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 it is enabled, the SDK triggers this callback at the 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 a channel with active stream ingest. The callback result contains volume information for both local and remote speakers.
Parameters
Parameter | Type | Description |
volumeInfo | An array of user volume information, including user UID, voice status, and volume.
| |
volumeInfoCount | int | The number of pieces of information in the user volume information array. |
totalVolume | int | The total volume after mixing. The range is [0,255]. In the local user's callback, totalVolume is the volume of the local user after mixing. In the remote user's callback, totalVolume is the total volume of all speakers after mixing. |
OnActiveSpeaker
Callback for the active speaker.
virtual void OnActiveSpeaker(const char *uid) {}After you successfully call <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 for the remote user with the highest volume. The remote user who is identified as the loudest for the most number of times within the current time period is the active speaker.
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 is always the same user, the SDK does not trigger the
OnActiveSpeakercallback again.If the most active remote user changes, the SDK triggers this callback again and reports the UID of the new most active remote user.
Parameters
Parameter | Type | Description |
uid | const char * | The ID of the person currently speaking. |
OnPublishLiveStreamStateChanged
Callback for bypass publishing state changes.
virtual void OnPublishLiveStreamStateChanged(const char* streamUrl ,AliEngineLiveTranscodingState state ,AliEngineLiveTranscodingErrorCode errCode){};Parameters
Parameter | Type | Description |
streamURL | const char* | The stream URL. |
state | The state. | |
errCode | The error code. |
OnPublishTaskStateChanged
Callback for bypass task state changes.
virtual void OnPublishTaskStateChanged(const char* streamUrl, AliEngineTrascodingPublishTaskStatus state){};Parameters
Parameter | Type | Description |
streamURL | const char* | The stream URL. |
state | The state. |
OnNetworkQualityChanged
Callback for network quality changes. This is triggered when the network quality changes.
virtual void OnNetworkQualityChanged(const char *uid, AliEngineNetworkQuality upQuality, AliEngineNetworkQuality downQuality);Parameters
Parameter | Type | Description |
uid | char* | The UID of the user whose network quality has changed. Note An empty UID indicates that the user's own network quality has changed. |
upQuality | The upstream network quality level. | |
downQuality | The downstream network quality level. |
OnLastmileDetectResultWithQuality
Callback for the pre-call network quality detection, which is provided about 3s after the detection starts.
virtual void OnLastmileDetectResultWithQuality(AliEngineNetworkQuality networkQuality);This callback describes the network detection result of the local user before joining the channel, which is used to roughly judge the network quality level. After you call StartLastmileDetect, the SDK returns this callback in about 3s.
Parameters
Parameter | Type | Description |
networkQuality | The network quality level. |
OnLastmileDetectResultWithBandWidth
Callback for the result of the pre-call network quality detection, which is provided about 30s after the detection.
virtual void OnLastmileDetectResultWithBandWidth(int code, AliRTCSdk::AliEngineNetworkProbeResult networkQuality);After you call StartLastmileDetect, the SDK returns this callback in about 30s, which provides a detailed result of the network quality.
Parameters
Parameter | Type | Description |
code | int | Return value:
|
networkQuality | AliRTCSdk::AliEngineNetworkProbeResult | The network detection result, including link RTT and the packet loss rate, jitter, and bandwidth of the upstream and downstream networks. |
OnOccurError
If an error occurs in the engine, this callback notifies the app.
virtual void OnOccurError(int error, const char *msg);Parameters
Parameter | Type | Description |
error | int | The error type. See AliEngineErrorCode. |
msg | const char * | The error message. |
OnFirstAudioPacketSend
Callback for the first audio packet sent. This callback is triggered when the first audio data packet is sent.
virtual void OnFirstAudioPacketSend(AliEngineAudioTrack audioTrack, int timeCost);Parameters
Parameter | Type | Description |
audioTrack | The audio type, indicating which audio stream's first packet was sent. | |
timeCost | int | The time taken to send, from joining the channel to the first audio packet being sent (in milliseconds). |
OnFirstAudioPacketReceived
Callback for the first audio packet received. This callback is triggered when the first remote audio data packet is received.
virtual void OnFirstAudioPacketReceived(const char* uid, AliEngineAudioTrack audioTrack, int timeCost) Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
audioTrack | The audio type, indicating which audio stream's first packet was received. | |
timeCost | int | The time taken to receive, from joining the channel to the first audio packet being received (in milliseconds). |
OnFirstVideoPacketSend
Callback for the first video packet sent.
virtual void OnFirstVideoPacketSend(AliEngineVideoTrack videoTrack, int timeCost);Parameters
Parameter | Type | Description |
videoTrack | The video type, indicating which video stream's first packet was sent, such as camera stream or screen sharing stream. | |
timeCost | int | The time taken to send, from joining the channel to the first video packet being sent (in milliseconds). |
OnFirstVideoPacketReceived
Callback for the first video packet received.
virtual void OnFirstVideoPacketReceived(const char* uid, AliEngineVideoTrack videoTrack, int timeCost);Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
videoTrack | The video type, indicating which video stream's first packet was received, such as camera stream or screen sharing stream. | |
timeCost | int | The time taken to receive, from joining the channel to the first video packet being received (in milliseconds). |
OnFirstRemoteAudioDecoded
Callback for the first decoded remote audio frame.
virtual void OnFirstRemoteAudioDecoded(const char* uid, AliEngineAudioTrack audioTrack, int elapsed);Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
audioTrack | The audio type, indicating which audio stream's first frame was decoded. | |
elapsed | int | The delay 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);Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
videoTrack | The video type, indicating which video stream, such as camera stream or screen sharing stream. | |
width | int | The video width. |
height | int | The video height. |
elapsed | int | The total delay from when the local user joins the channel until this callback is triggered (in milliseconds). |
OnFirstLocalVideoFrameDrawn
This message is triggered when the preview starts displaying the first video frame.
virtual void OnFirstLocalVideoFrameDrawn(int width, int height, int elapsed);Parameters
Parameter | Type | Description |
width | int | The video width. |
height | int | The video height. |
elapsed | int | The total delay from when the local user joins the channel until this callback is triggered (in milliseconds). |
OnTestAudioVolumeCallback
Callback for the volume of the pre-call audio collection test.
virtual void OnTestAudioVolumeCallback(int volumn);After you successfully call StartAudioCaptureTest before a call, this callback is triggered. If a normal volume can be returned, it indicates that the audio collection is normal.
Parameters
Parameter | Type | Description |
volumn | int | Returns the volume information. |
OnAudioAccompanyStateChanged
Callback for the local accompaniment playback state.
virtual void OnAudioAccompanyStateChanged(AliEngineAudioAccompanyStateCode playState, AliEngineAudioAccompanyErrorCode errorCode);This callback is triggered when the accompaniment playback state changes, and it notifies the current playback state and error code.
Parameters
Parameter | Type | Description |
playState | The current playback state. | |
errorCode | The playback error code. |
OnAudioFileInfo
Callback for audio file information.
virtual void OnAudioFileInfo(AliEngineAudioFileInfo info, AliEngineAudioAccompanyErrorCode errorCode);This callback is triggered after you call GetAudioFileInfo, and it returns the current audio file information and an error code.
Parameters
Parameter | Type | Description |
info | The audio file information. | |
errorCode | The error code. |
OnRemoteAudioAccompanyStarted
Callback for when a remote user's accompaniment starts playing.
virtual void OnRemoteAudioAccompanyStarted(const char* uid);Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
OnRemoteAudioAccompanyFinished
Callback for when a remote user's accompaniment finishes playing.
virtual void OnRemoteAudioAccompanyFinished(const char* uid);Parameters
Parameter | Type | Description |
uid | const char* | The remote user ID. |
SetParameter
Sets custom parameters.
virtual int SetParameter(const char* parameter) = 0;Parameters
Parameter | Type | Description |
parameter | const char* | Custom parameters. |
GetParameter
Retrieves custom parameters.
virtual String GetParameter(const char* parameter) = 0;Parameters
Parameter | Type | Description |
parameter | const char* | Custom parameters. |
EnableAudioFrameObserver
Enables or disables subscription to audio data.
virtual int EnableAudioFrameObserver(bool enabled, AliEngineAudioSource audioSource, AliEngineAudioFrameObserverConfig config) = 0;This method enables or disables the callback for a specified type of audio data, which lets you retrieve various types of raw and encoded audio data. It is disabled by default. To enable it, call this method.
When you call this method to enable the audio data callback for the corresponding AliEngineAudioSource, you need to use it with the RegisterAudioFrameObserver method to pass in the audio data receiving object.
When to call
When you need to retrieve audio data, you can call this method to enable it.
Parameters
Parameter | Type | Description |
enable | bool | Whether to allow data callbacks. |
audioSource | The callback data source type, including collected (0), post-3A (1), published (2), playback (3), and pulled audio data (5). Note:
| |
config | AliEngineAudioFrameObserverConfig | Audio callback parameter settings, including sample rate, number of channels, and callback read/write mode (read-only, write-only, read-write). If the parameter is null, the default is (48000, 1, ReadOnly). |
RegisterAudioFrameObserver
Registers an audio data callback.
virtual int RegisterAudioFrameObserver(IAudioFrameObserver* observer) = 0;This method registers the receiving object for audio callback data.
When to call
When you need the SDK to trigger the OnCapturedAudioFrame, OnProcessCapturedAudioFrame, OnPublishAudioFrame, OnPlaybackAudioFrame, or OnRemoteUserAudioFrame callbacks to retrieve various types of audio data, you need to call this method to provide an audio data receiving object. To unregister, call this method again and pass null.
Limits
You need to call EnableAudioFrameObserver to enable the callback for the specific AliEngineAudioSource. Otherwise, the passed observer cannot retrieve data.
Parameters
Parameter | Type | Description |
observer | IAudioFrameObserver* | A pointer to the callback object. |
Return value
0 for success, other values for failure.
UnRegisterAudioFrameObserver
Unsubscribes from audio data output (IAliEngineMediaEngine method).
virtual void UnRegisterAudioFrameObserver(IAudioFrameObserver* observer) = 0;Parameters
Name | Type | Description |
observer | A pointer to the callback object. |
RegisterVideoSampleObserver
Subscribes to video data output.
virtual void RegisterVideoSampleObserver(IVideoFrameObserver* observer) = 0;This method registers the output object for video data. To unregister, call the UnRegisterVideoSampleObserver method.
The output data will be returned through the {@link IVideoFrameObserver} callback.
When to call
To retrieve raw video data (such as YUV or RGBA format), you can call this method to register a video data observer to retrieve video data at various stages.
Related callbacks
After you successfully register a video data output observer, the SDK triggers the callbacks you implement when it captures each video frame. Implement the corresponding callbacks as needed:
OnCaptureVideoSample: Callback for local collected video data.
OnRemoteVideoSample: Callback for remote video data.
OnPreEncodeVideoSample: Callback for local video data before encoding.
Parameters
Name | Type | Description |
observer | IVideoFrameObserver | A pointer to the callback object. |
UnRegisterVideoSampleObserver
Unregisters video data output.
virtual void UnRegisterVideoSampleObserver(IVideoFrameObserver* observer) = 0;This method corresponds to the RegisterVideoSampleObserver method and is responsible for unregistering the video data output object.
Parameters
Name | Type | Description |
observer | IVideoFrameObserver | A pointer to the callback object. |
SnapshotVideo
Video snapshot feature.
virtual int SnapshotVideo(const String& userId, const AliEngineVideoTrack &trackType) = 0;The video snapshot feature is an asynchronous method. You can listen for the AliEngineEventListener::OnSnapshotComplete callback to retrieve the current screenshot.
Parameters
Parameter | Type | Description |
userId | const String& | The user ID. An empty string for userId represents the local user. |
trackType | const AliEngineVideoTrack& | The video stream type. Only AliEngineVideoTrackCamera and AliEngineVideoTrackScreen are supported. |
Return value
0: The method call was successful. The screenshot is obtained through the callback.
<0: The method call failed.
SetLogDirPath
Sets the SDK log file save path.
static int SetLogDirPath(const char *logDirPath);Parameters
Name | Type | Description |
logDirPath | const char * | The absolute path to save the log file. |
Returns
0: The method call was successful. Other values: The method call failed.
Call this method before you call any other SDK methods to avoid log loss. The application must ensure that the specified directory exists and is writable.
SetLogLevel
Sets the log level.
static void SetLogLevel(AliEngineLogLevel logLevel);Parameters
Name | Type | Description |
logLevel | The log level. The default value is AliEngineLogInfo. |
GetNetworkTime
Retrieves the current network time.
virtual long long GetNetworkTime() = 0;Return value
Retrieves the current network time adjusted for offset (NTP time), in milliseconds.
SendDataChannelMessage
Sends a data channel message.
virtual int SendDataChannelMessage(const AliEngineDataChannelMsg& msg) = 0;The ARTC SDK provides the ability to send and receive custom messages. This lets you send custom real-time message data while transmitting audio and video data. For example, you can call this method to transmit real-time control instructions, status synchronization data, or other business messages along with audio and video. For more information, see Send and receive custom messages.
The custom message channel is disabled by default. To enable 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>API and set the parameter to `"{\"data\":{\"enablePubDataChannel\":true" + ",\"enableSubDataChannel\":true}}"`. You can do this either before or after you join a channel.The message can be any data, such as text or images.
Related callbacks
After the sender successfully enables the custom message channel, they can call this method to send custom messages. The receiver triggers this callback by listening for the
OnDataChannelMessagecallback to receive the custom messages.
Limits
The streamer role can send and receive messages. The viewer role only supports receiving messages.
You need to call SetParameter to enable the custom message channel.
The data sending is limited to:
A bitrate limit of 30 KB/s.
The data channel can send a maximum of 60 data packets per second, with each packet up to 1 KB.
Parameters
Name | Type | Description |
msg | const AliEngineDataChannelMsg& | The message to be sent. |
Return value description
0: Success.
A non-zero value: Failure.
StartScreenShareByDesktopId
Starts sharing the screen stream corresponding to the specified desktop ID.
virtual int StartScreenShareByDesktopId(unsignedint desktopId, const AliEngineScreenShareConfig& config) = 0;Parameters
Name | Type | Description |
desktopId | unsignedint | The desktop ID. |
config | The configuration for sharing the desktop. |
Return value
0: Success.
Other: Failure.
StartScreenShareByScreenRegion
Starts sharing the video stream of a specified screen region.
This method is only for desktop sharing. To set up window sharing, use the StartScreenShareByWindowId method.
When you configure a specified region for sharing, the minimum resolution of the shared region is 16 × 16. If the set region is smaller than the minimum resolution, it is reset to the minimum resolution.
When you configure a specified region for sharing, if the set shared region exceeds the actual desktop resolution, the entire desktop is shared.
For more information about virtual screen coordinates, see The Virtual Screen.
virtual int StartScreenShareByScreenRegion(
const AliEngineScreenShareRegion & screenRegion,
const AliEngineScreenShareConfig & config) = 0;Parameters
Name | Type | Description |
screenRegion | Specifies the position of the screen to be shared relative to the virtual screen. | |
config | The screen sharing configuration. |
Return value
0: Success.
Other: Failure.
StartScreenShareByWindowId
Shares and publishes the video stream from a video source using the user-specified window ID.
virtual int StartScreenShareByWindowId(unsigned int windowId,
const AliEngineScreenShareConfig & config) = 0;Parameters
Name | Type | Description |
windowId | int | The window ID. |
config | The screen sharing configuration. |
Return value
0: Success.
Other: Failure.
StopScreenShare
Stops screen sharing.
virtual int StopScreenShare() = 0 ;Return value
0: Success.
Other: Failure.
ResumeScreenShare
Resumes screen sharing.
virtual int ResumeScreenShare() = 0;Return value
0: Success.
Other: Failure.
PauseScreenShare
Pauses screen sharing.
virtual int PauseScreenShare() = 0;Return value
0: Success.
Other: Failure.
IsScreenSharePublished
Queries whether screen sharing is published.
Call this method to check if the screen sharing stream is currently published. The SDK does not publish the screen sharing stream by default. To publish the screen sharing stream, you can call the StartScreenShareByDesktopId, StartScreenShareByScreenRegion, or StartScreenShareByWindowId method.
virtual bool IsScreenSharePublished() = 0;Return value
true: Publishing is set.
false: Publishing is not set.
UpdateScreenShareConfig
Updates the screen sharing configuration.
virtual int UpdateScreenShareConfig(const AliEngineScreenShareConfig & config) = 0;Parameters
Parameter | Type | Description |
config | The updated screen sharing configuration. |
Return value
0: Success.
Other: Failure.
CheckWindowSourceVaild
Determines whether the window corresponding to the shared window ID is valid.
virtual bool CheckWindowSourceVaild(unsigned int windowId) = 0;Parameters
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 information.
virtual AliEngineScreenShareConfig GetScreenShareConfig() = 0;Parameters
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
Retrieves a list of objects based on the specified source.
virtual AliEngineScreenSourceList* GetScreenShareSourceInfo(AliEngineScreenShareType sourceType) = 0;Parameters
Parameter | Type | Description |
sourceType | The sharing source type. |
Return value
A non-empty
AliEngineScreenSourceListobject is the list of sharing source types obtained.NULL indicates failure.
GetCurrentScreenShareSourceId
Retrieves the ID of the current shared screen source.
virtual unsigned int GetCurrentScreenShareSourceId() = 0;Return value
>=0 indicates the ID of the current shared screen source.
<0 indicates failure.
GetCurrentScreenShareSourceType
Retrieves a list of objects from the specified source.
virtual AliEngineScreenShareType GetCurrentScreenShareSourceType() = 0;Parameters
Parameter | Type | Description |
sourceType | The type of the shared source. |
Return value
A non-empty
AliEngineScreenSourceListobject that contains the list of shared source types.NULL indicates that the operation failed.
GetDesktopRegion
Retrieves the desktop sharing range based on the specified source ID and source title.
virtual int GetDesktopRegion(const String& sourceId, const String& sourceTitle, AliEngineScreenShareRegion & region) = 0;Parameters
Parameter | Type | Description |
sourceId | String | The sharing source ID. |
sourceTitle | String | The source title. |
region | The sharing range. |
Return value
0: Success.
Other: Failure.
SetScreenShareEncoderConfiguration
Sets the screen stream video encoding properties.
virtual void SetScreenShareEncoderConfiguration(const AliEngineScreenShareEncoderConfiguration& config) = 0;This method sets the video parameters for the screen stream video encoding properties, such as resolution, frame rate, bitrate, and video orientation. All set parameters have corresponding range limits. If a set parameter is outside the valid range, the SDK automatically adjusts it.
This method can be called before or after you join a channel. If you only need to set the screen stream video encoding properties once per session, we recommend that you call it before you join the channel.
Parameters
Parameter | Type | Description |
config | Predefined screen sharing encoding properties. |
Belongs to interface
IAliEngineMediaEngine