AliRTCLinuxEngine API

更新时间:
复制 MD 格式

This reference details the C++ engine interface for the Linux real-time communication SDK.

API reference

API

Description

CreateAliRTCEngine

Creates an AliRTCEngineInterface instance.

Release

Destroys the AliRTCEngineInterface instance.

GetEventHandler

Gets the event callback handle.

JoinChannel[1/2]

Joins a channel.

JoinChannel[2/2]

Joins a channel.

LeaveChannel

Leaves the channel.

IsLocalVideoStreamPublished

Checks if the local video track (camera) is published.

IsLocalScreenPublishEnabled

Checks if publishing the local screen track is enabled.

IsLocalAudioStreamPublished

Checks if the local audio track is published.

IsDualStreamPublished

Checks if simulcast is enabled for the camera track.

SetExternalVideoSource

Enables or disables an external video source.

PushExternalVideoFrame

Pushes an external video frame. Input resolutions of 2K or higher are not supported.

SetExternalAudioSource

Enables or disables publishing from an external audio source.

PushExternalAudioFrameRawData

Pushes raw external audio data for publishing.

SetAudioProfile

Sets the audio profile.

SetExternalAudioPublishVolume

Sets the publishing volume for the external audio source.

GetExternalAudioPublishVolume

Gets the publishing volume for the external audio source.

SendMediaExtensionMsg

Sends a media extension message (SEI). The maximum message size is 4,096 bytes.

PublishLocalDualStream

Enables or disables publishing the secondary stream.

PublishLocalVideoStream

Enables or disables publishing the local video stream (camera).

PublishLocalAudioStream

Enables or disables publishing the local audio stream.

PublishScreenShareStream

Enables or disables publishing the screen stream.

SubscribeRemoteAudioStream

Subscribes to or unsubscribes from a specified remote user's audio stream. Must be called after joining a channel.

SubscribeRemoteVideoStream

Subscribes to or unsubscribes from a specified remote user's video stream. Must be called after joining a channel.

SetVideoEncoderConfiguration

Sets the video encoding configuration for the camera stream.

SetScreenShareEncoderConfiguration

Sets the video encoding configuration for the screen stream.

SetRemoteVideoStreamType

Sets the subscribed camera stream type to the main stream or substream.

MuteLocalCamera

Mutes or unmutes the local video stream.

MuteLocalMic

Mutes or unmutes the local audio stream.

SetClientRole

Sets the user role.

SetRemoteDefaultVideoStreamType

Sets the default video stream type for remote subscriptions.

LeaveOnceNoStreamer

When enabled, triggers the OnError callback with the ERR_NO_PEOPLE error code for an audience user when all hosts in the channel have stopped publishing.

SetPeriodForCheckPeople

When enabled, triggers the OnError callback with the ERR_NO_PEOPLE error code if the local user is still alone in the channel after a specified period.

SetParameter

Sets custom parameters using a JSON string, such as enabling or disabling the data channel.

GenerateToken

Generates a token on the client side for channel authentication. This bypasses the need for an AppServer.

SendDataChannelMessage

Sends a message through the data channel.

SetLogLevel

Sets the log level.

OnError

Occurs when the SDK engine reports an error.

OnWarning

Occurs when the SDK engine reports a warning.

OnJoinChannelResult

Occurs when the local user joins a channel.

OnDataChannelMsg

Occurs when the local user receives a data channel message from a remote user.

OnLeaveChannelResult

Occurs when the local user leaves a channel.

OnRemoteUserOnLineNotify

Occurs when a remote user joins the channel. In interactive mode, this callback is triggered only when a user with the host role joins.

OnRemoteUserOffLineNotify

Occurs when a remote user leaves the channel. In interactive mode, this callback is triggered only when a user with the host role leaves.

OnAudioSubscribeStateChanged

Occurs when the audio subscription state changes.

OnVideoSubscribeStateChanged

Occurs when the camera stream subscription state changes.

OnSubscribeStreamTypeChanged

Occurs when the subscribed stream type changes (main stream or substream).

OnScreenShareSubscribeStateChanged

Occurs when the screen stream subscription state changes.

OnScreenSharePublishStateChanged

Occurs when the screen stream publishing state changes.

OnDualStreamPublishStateChanged

Occurs when the secondary stream publishing state changes.

OnVideoPublishStateChanged

Occurs when the video publishing state changes.

OnAudioPublishStateChanged

Occurs when the audio publishing state changes.

OnSubscribeAudioFrame

Provides the audio data of each remote user before audio mixing.

OnSubscribeMixAudioFrame

Provides the mixed audio data of all subscribed remote users.

OnRemoteVideoSample

Provides the decoded video data of a subscribed remote user.

OnRemoteVideoEncodedSample

Provides the encoded video data of a subscribed remote user before decoding.

OnMediaExtensionMsgReceived

Occurs when the local user receives a media extension message.

OnSnapshotComplete

Occurs when a snapshot completes successfully.

OnPlaybackAudioFrameBeforeMixing

Provides the audio data of each remote user before audio mixing. (Deprecated. Use OnSubscribeAudioFrame instead.)

OnUpdateRoleNotify

Occurs when a user role changes.

OnSubscribeAudioAac

Provides the AAC-transcoded audio data of each individual subscribed stream, used for custom audio archiving.

OnSubscribeMixedAudioAac

Provides the mixed, AAC-transcoded audio data of all subscribed streams, used for custom audio archiving.

API

CreateAliRTCEngine

Creates an AliRTCEngineInterface instance.

AliRTCEngineInterface * CreateAliRTCEngine(EngineEventHandlerInterface * eventHandler, int lowPort, int highPort,  const char * logPath, const char * coreServicePath, bool h5mode=false, const char * extra="");

Parameters

Parameter

Type

Description

eventHandler

EngineEventHandlerInterface *

A callback object that handles events.

lowPort

int

The SDK randomly selects a port from the range between lowPort and highPort for inter-process communication.

highPort

int

The upper bound of the port number range.

logPath

const char *

The directory path for SDK log files.

coreServicePath

const char *

The absolute path to the AliRtcCoreService executable.

h5mode

bool

Specifies whether to enable h5 compatibility mode. For most use cases, set to false.

extra

const char *

A JSON format string for extra SDK configurations.

Returns A pointer to an AliRTCEngineInterface instance.

Release

Destroys the AliRTCEngineInterface instance.

virtual void Release() = 0;

GetEventHandler

Retrieves the event handler.

virtual EngineEventHandlerInterface * GetEventHandler() = 0;

Returns A pointer to the registered event handler.

JoinChannel[1/2]

Joins a channel.

virtual int JoinChannel(const AuthInfo &authInfo, const JoinChannelConfig &config) = 0;
Important

This is an asynchronous method. To determine if the join is successful, listen for the OnJoinChannelResult callback.

Parameters

Parameter

Type

Description

authInfo

AuthInfo

Authentication information from your application server.

config

const JoinChannelConfig

Configuration for joining the channel.

Returns A return value of 0 indicates success; a non-zero value indicates an error.

JoinChannel[2/2]

Joins a channel.

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

This is an asynchronous method. Listen for the OnJoinChannelResult callback to determine if you successfully joined the channel.

Parameters

Parameter

Type

Description

token

const char *

The token for authentication when joining the channel.

channelId

const char *

The ID of the channel to join. This value must match the channelId used to generate the token.

userId

const char *

The user ID. This value must match the userId used to generate the token.

userName

const char *

The user's display name, which is different from the user ID.

config

JoinChannelConfig

Configuration options for joining the channel.

Returns

LeaveChannel

Leaves the channel.

virtual int LeaveChannel() = 0;

Returns 0 if successful, and a non-zero value otherwise.

IsLocalVideoStreamPublished

Checks if the local camera track is published.

virtual bool IsLocalVideoStreamPublished() = 0;

Returns true if the local camera track is published; false otherwise.

IsLocalScreenPublishEnabled

Checks whether publishing the screen track is enabled.

virtual bool IsLocalScreenPublishEnabled() = 0;

Returns true if publishing is enabled; false otherwise.

IsLocalAudioStreamPublished

Checks whether the local audio track is published.

virtual bool IsLocalAudioStreamPublished() = 0;

Returns

IsDualStreamPublished

Checks whether simulcast is enabled for publishing the camera track.

virtual bool IsDualStreamPublished() = 0;

Returns
true if enabled; false otherwise.

SetExternalVideoSource

Enables or disables the external video source.

virtual int SetExternalVideoSource(bool enable, VideoSource sourceType, RenderMode renderMode = RenderModeFill) = 0;

After enabling the external video source, call PushExternalVideoFrame to push video data.

Parameters

Parameter

Type

Description

enable

bool

Specifies whether to enable the external video source. true: Enable. false: Disable.

sourceType

VideoSource

Specifies the stream type.

renderMode

RenderMode

Specifies the rendering mode.

Returns Returns 0 on success, or an error code on failure.

PushExternalVideoFrame

Pushes an external video frame. This method does not support 2K or higher resolution video.

virtual int PushExternalVideoFrame(VideoDataSample *frame, VideoSource sourceType) = 0;

Parameters

Parameter

Type

Description

frame

VideoDataSample *

The frame data.

sourceType

VideoSource

The stream type. Currently, only the I420 format is supported as input.

Returns Returns 0 on success or an error code on failure. If this method returns ERR_AUDIO_BUFFER_FULL, adjust the send rate.

SetExternalAudioSource

Enables or disables stream publishing from an external audio source.

virtual int SetExternalAudioSource(bool enable, unsigned int sampleRate,  unsigned int channelsPerFrame) = 0;

Parameters

Parameter

Type

Description

enable

bool

true: Enables the external audio source. false: Disables the external audio source.

sampleRate

unsigned int

The sample rate (Hz) of the external audio source. Valid values include 16000 and 48000.

channelsPerFrame

unsigned int

The number of audio channels. Set this to 1 for mono or 2 for stereo.

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

PushExternalAudioFrameRawData

Pushes raw external audio data for streaming.

virtual int PushExternalAudioFrameRawData(const void* audioSamples, unsigned int sampleLength, long long timestamp) = 0;

Parameters

Parameter

Type

Description

audioSamples

const void*

A pointer to the raw audio data buffer.

sampleLength

unsigned int

The length of the audio data in bytes.

timestamp

long long

The timestamp of the audio data in milliseconds.

Returns Returns 0 on success, or a non-zero value on failure. If the return value is ERR_AUDIO_BUFFER_FULL, the audio buffer is full, and you should retry the operation after a delay equal to the duration of the audio data you tried to push.

SetAudioProfile

Sets the audio profile.

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

Parameters

Parameter

Type

Description

audioProfile

AudioQualityMode

Specifies the audio capture and encoding mode.

audioScene

AudioSceneMode

Specifies the audio scene mode.

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

SetExternalAudioPublishVolume

Sets the publishing volume of the external audio.

virtual int SetExternalAudioPublishVolume(int volume) = 0;

Parameters

Parameter

Type

Description

volume

int

The volume, ranging from 0 to 100.

Returns Returns 0 on success. Any other value indicates failure.

GetExternalAudioPublishVolume

Gets the mixing volume of the external audio for publishing.

virtual int GetExternalAudioPublishVolume() = 0;

Returns
The mixing volume.

SendMediaExtensionMsg

Sends Supplemental Enhancement Information (SEI) for small-scale data transfer, with the message limited to 4,096 bytes.

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

Parameters

Parameter

Type

Description

message

const char*

The content of the SEI message. The maximum length is 4,096 bytes.

length

size_t

The length of the message, in bytes.

repeatCount

int

Specifies how many times to repeat the message to compensate for potential network packet loss.

delay

uint32_t

The delay before sending the message, in milliseconds.

isKeyFrame

bool

Specifies whether to attach the SEI message exclusively to keyframes.

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

PublishLocalDualStream

Enables or disables publishing the dual stream.

virtual int PublishLocalDualStream(bool enabled) = 0;

The dual stream is published only if the main video stream is also published. Before enabling the dual stream, you must first enable video stream publishing by calling the PublishLocalVideoStream method. By default, the SDK does not publish the dual stream. You can call this method before joining a channel to change the default setting. This setting takes effect when you start publishing the video stream.

Parameters

Parameter

Type

Description

enabled

bool

true: Enable publishing the dual stream. false: Disable publishing the dual stream.

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

PublishLocalVideoStream

Sets whether to publish the local video stream from the camera.

virtual int PublishLocalVideoStream(bool enabled) = 0;

By default, the SDK publishes the local video stream. You can call this API before joining a channel to change the default setting. The new setting applies after you join the channel.

Parameters

Parameter

Type

Description

enabled

bool

Whether to publish the local video stream. true: Enables publishing. false: Disables publishing.

Return value 0 indicates success; any other value indicates failure.

PublishLocalAudioStream

Enables or disables publishing the local audio stream.

virtual int PublishLocalAudioStream(bool enabled) = 0;

By default, the SDK publishes the audio stream. To change this setting, call this method before joining a channel. The change takes effect when you join the channel.

Parameters

Parameter

Type

Description

enabled

bool

Specifies whether to publish the local audio stream. true: Enables publishing the local audio stream (default). false: Disables publishing the local audio stream.

Returns 0 indicates success. Any other value indicates failure.

PublishScreenShareStream

Starts or stops publishing the screen share stream.

virtual int PublishScreenShareStream(bool enabled) = 0;

Parameters

Parameter

Type

Description

enabled

bool

Set to true to publish the screen share stream, or false to stop.

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

SubscribeRemoteAudioStream

Subscribes to or unsubscribes from the audio stream of a specified remote user. You must call this method after joining a channel.

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

Parameters

Parameter

Type

Description

uid

const char*

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

sub

bool

Whether to subscribe to the remote user's audio stream. true: Subscribe. false: Unsubscribe.

Returns Returns 0 if the method call succeeds; otherwise, it returns an error code.

SubscribeRemoteVideoStream

Subscribes to or unsubscribes from the video stream of a remote user. Call this method only after joining a channel.

virtual int SubscribeRemoteVideoStream(const char* uid, VideoTrack videoTrack, bool sub) = 0;

Parameters

Parameter

Type

Description

uid

const char*

The unique user ID of the remote user, assigned by your application server.

videoTrack

VideoTrack

The video track.
- AliEngineVideoTrackNo: Invalid parameter. This setting has no effect.
- AliEngineVideoTrackCamera: The camera track.
- AliEngineVideoTrackScreen: The screen track.
- AliEngineVideoTrackBoth: Both the camera and screen tracks.



sub

bool

Sets whether to subscribe to the remote video stream. true to subscribe, false to unsubscribe.

Returns
Returns 0 on success, or an error code on failure.

SetVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

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

This method sets the encoding parameters for the camera stream, such as resolution, frame rate, bitrate, and video orientation. If you specify a parameter outside its valid range, the SDK automatically adjusts it to the nearest valid value. You can call this method before or after joining a channel. If you only need to set the video encoder configuration once per session, call this method before joining the channel.

Parameters

Parameter

Type

Description

config

AliEngineVideoEncoderConfiguration

The predefined encoding properties. For details, see AliEngineVideoEncoderConfiguration.

SetScreenShareEncoderConfiguration

Sets the video encoding properties for the screen stream.

virtual int SetScreenShareEncoderConfiguration(const AliEngineScreenShareEncoderConfiguration& config) = 0;

This method sets the video parameters for the screen stream, including resolution, frame rate, bitrate, and video orientation. All parameters have valid ranges. If a parameter is outside its valid range, the SDK automatically adjusts it to a compliant value. You can call this method before or after joining a conference. If you only need to set these properties once per conference, we recommend calling this method before joining.

Parameters

Parameter

Type

Description

config

const AliEngineScreenShareEncoderConfiguration

The predefined encoding properties for screen sharing. See AliEngineScreenShareEncoderConfiguration: Screen stream encoding properties.

SetRemoteVideoStreamType

Specifies whether to subscribe to the high or low video stream from a remote user.

virtual int SetRemoteVideoStreamType(const char* uid, AliEngineVideoStreamType streamType) = 0;

By default, a publisher does not send a low stream. Subscribers can choose between the high and low streams only after the publisher enables dual-stream mode by calling PublishLocalDualStream(true). Otherwise, the subscriber can only receive the high stream.

Parameters

Parameter

Type

Description

uid

const char*

The unique ID of the remote user, assigned by your application server.

streamType

AliEngineVideoStreamType

The stream type. - AliEngineVideoStreamTypeNone: Invalid parameter. This setting has no effect. - AliEngineVideoStreamTypeHigh: The high stream. - AliEngineVideoStreamTypeLow: The low stream.

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

MuteLocalCamera

Stops or resumes sending local video data.

virtual int MuteLocalCamera(bool mute) = 0;

Parameters

Parameter

Type

Description

mute

bool

Set to true to stop sending local video data, or false to resume.

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

MuteLocalMic

Stops or resumes sending local audio data.

virtual int MuteLocalMic(bool mute) = 0;

Parameters

Parameter

Type

Description

mute

bool

Whether to stop (true) or resume (false) sending local audio data.

Returns 0 if the method call succeeds, or an error code if it fails.

SetClientRole

Sets the user role.

virtual int SetClientRole(const AliEngineClientRole clientRole) = 0;

You can call this method only when the channel profile is AliRtcChannelProfileCommunication. This method can be called either before or after joining a channel. A successful call to this method triggers the OnUpdateRoleNotify callback. To switch the user role from Interactive to Live, you must first stop publishing the stream. Otherwise, the method call fails. When the channel profile is AliRtcChannelProfileInteractiveLive, the user role defaults to AliRtcClientRoleLive.

Parameters

Parameter

Type

Description

clientRole

AliEngineClientRole

The user role to set.

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

SetRemoteDefaultVideoStreamType

Sets the default video stream type to subscribe to.

virtual int SetRemoteDefaultVideoStreamType(const AliEngineVideoStreamType streamType) = 0;

Parameters

Parameter

Type

Description

streamType

const AliEngineVideoStreamType

The stream type: high stream or low stream.

Returns 0 on success; any other value indicates failure.

LeaveOnceNoStreamer

In audience mode, if all streamers in a room stop publishing their streams, the OnError callback is immediately triggered with the ERR_NO_PEOPLE error code.

virtual int LeaveOnceNoStreamer(bool enable) = 0;

This feature is designed for moderation scenarios.

Parameters

Parameter

Type

Description

enable

bool

Set to true to enable this feature, or false to disable it.

Returns Returns 0 on success; any other value indicates failure.

SetPeriodForCheckPeople

Sets a waiting period after a user joins a meeting. If no other users are online during this period, the SDK triggers the OnError callback with the ERR_NO_PEOPLE error code.

virtual int SetPeriodForCheckPeople(int seconds) = 0;

Parameters

Parameter

Type

Description

seconds

int

The waiting period in seconds after joining a meeting. A value of 0 or less disables this check.

Returns A return value of 0 indicates that the method call succeeded. Any other value indicates failure.

SetParameter

Sets custom configuration using a JSON-formatted string. For example, this method lets you enable or disable the dataChannel.

virtual int SetParameter(const char* params) = 0;

Parameters

Parameter

Type

Description

params

const char*

The custom configuration, specified as a JSON-formatted string.

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

Generate token

Generates the token required to join a channel locally, bypassing application server authentication.

virtual void GenerateToken(AuthInfo& authInfo, const char* appkey) {}

This method automatically determines which token type to generate. If the length of authInfo.token is less than 64, it generates a multi-parameter token. If the length is 64, it generates a single-parameter token.

Parameters

Parameter

Type

Description

authInfo

AuthInfo

A custom configuration object. This object must be populated with the application ID, nonce, and timestamp.

appkey

const char*

The application key corresponding to the application ID. This key is required for token calculation.

SendDataChannelMessage

Sends data through the data channel.

virtual int SendDataChannelMessage(AliEngineDataChannelMsg ctrlMsg) = 0;
Note

The ARTC data channel feature depends on an active audio or video stream from the publisher. Ensure you are publishing an audio or video stream.

Limitations

  • Hosts can send and receive messages, while viewers can only receive messages.

  • You must call setParameter to enable the custom message channel.

  • Data transmission has the following limits:

    • The maximum bitrate is 30 KB/s.

    • The data channel is limited to 60 data packets per second, with each packet up to 1 KB in size.

Parameters

Parameter

Type

Description

ctrlMsg

AliEngineDataChannelMsg

Contains the data payload and control commands.

Returns A return value of 0 indicates a successful method call; other values indicate a failure.

SetLogLevel

Sets the log level.

int SetLogLevel(const LogLevel logLevel, bool upload);

Parameters

Parameter

Type

Description

logLevel

LogLevel

The log level. For details, see LogLevel.

upload

bool

Whether to upload the logs.

Return value 0 indicates the method call was successful; any other value indicates failure.

OnError

Notifies the business layer when an error occurs in the engine.

virtual void OnError(ERROR_CODE error_code) {}

Parameter

Parameter

Type

Description

error_code

ERROR_CODE

Specifies the error type.

OnWarning

Notifies the business layer when the engine reports a warning.

virtual void OnWarning(WARNING_CODE warning_code) {}

Parameters

Parameter

Type

Description

warning_code

WARNING_CODE

Warning type.

OnJoinChannelResult

Reports the result of a user's attempt to join a channel.

virtual void OnJoinChannelResult(int result, const char *channel, const char *userId) {
        fprintf(stdout, "[Client] On join channel result: %d\n", result);
    }

After the application calls JoinChannel, this callback reports whether the user successfully joined the channel.

Parameters

Parameter

Type

Description

result

int

0 indicates a successful join; any other value is an error code.

channel

const char *

The channel name.

userId

const char *

The user ID.

OnDataChannelMsg

Called when the data channel receives a remote message.

virtual void OnDataChannelMsg(const char* uid, AliEngineDataChannelMsg& msg) {}
Note

The ARTC data channel depends on the audio and video stream: sending messages requires stream publishing, and receiving them requires stream pulling. All bidirectional communication requires an active audio and video stream.

Parameters

Parameter

Type

Description

uid

const char *

The user ID of the message sender.

msg

AliEngineDataChannelMsg

The remote message.

OnLeaveChannelResult

Reports the result of leaving a channel.

virtual void OnLeaveChannelResult(int result) {}

When your application calls the LeaveChannel method, this callback is triggered to report the result of leaving the channel. This callback is not triggered if you call LeaveChannel and then immediately call Release on the SDK.

Parameters

Parameter

Type

Description

result

int

The result of leaving the channel. 0 indicates success, while any other value is an error code.

OnRemoteUserOnLineNotify

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

virtual void OnRemoteUserOnLineNotify(const char * uid) {}

The SDK triggers this callback in the following scenarios:

Communication mode

  • A remote user joins the channel. When the local user joins a channel, the SDK also triggers this callback for each user already present.

Interactive mode

  • A remote user with the host role joins the channel. When the local user joins a channel, the SDK also triggers this callback for each host already present.

  • A remote audience member calls SetClientRole to switch their role to host (AliEngineClientRoleInteractive).

Callback behavior in interactive mode: 1. Hosts receive this callback when other hosts join the channel. 2. Audience members receive this callback when a host joins the channel. 3. Hosts do not receive this callback when an audience member joins the channel.

Parameters

Parameter

Type

Description

uid

const char *

The ID of the remote user who joined the channel.

OnRemoteUserOffLineNotify

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

virtual void OnRemoteUserOffLineNotify(const char * uid) {}

The SDK triggers this callback in the following scenarios.

Communication mode

A remote user leaves the channel.

Interactive mode

This callback also triggers when a remote user in communication mode or a broadcaster in interactive mode disconnects due to a timeout, for instance, when their data is not received for an extended period.

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

OnAudioSubscribeStateChanged

Occurs when the audio subscription state changes.

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

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

oldState

AliEngineSubscribeState

The previous subscription state. See AliEngineSubscribeState: subscription state. for details.

newState

AliEngineSubscribeState

The current subscription state. See AliEngineSubscribeState: subscription state. for details.

elapseSinceLastState

int

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

channel

const char *

The channel ID.

OnVideoSubscribeStateChanged

Triggered when the subscription state of a camera stream changes.

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

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

oldState

AliEngineSubscribeState

The previous subscription state. See AliEngineSubscribeState for details.

newState

AliEngineSubscribeState

The current subscription state. See AliEngineSubscribeState for details.

elapseSinceLastState

int

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

channel

const char *

The current channel ID.

OnSubscribeStreamTypeChanged

Triggered when the subscribed stream type changes.

virtual void OnSubscribeStreamTypeChanged(const char *uid, AliEngineVideoStreamType oldStreamType, AliEngineVideoStreamType newStreamType, int elapseSinceLastState, const char *channel) {}

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

oldStreamType

AliEngineVideoStreamType

The previous high/low-quality stream type. See AliEngineVideoStreamType.

newStreamType

AliEngineVideoStreamType

The current high/low-quality stream type. See AliEngineVideoStreamType.

elapseSinceLastState

int

The time interval, in milliseconds, between stream type changes.

channel

const char *

The channel ID.

OnScreenShareSubscribeStateChanged

Triggered when the subscription state of the screen sharing stream changes.

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

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

oldState

AliEngineSubscribeState

The previous subscription state. See AliEngineSubscribeState: subscription state.

newState

AliEngineSubscribeState

The current subscription state. See AliEngineSubscribeState: subscription state.

elapseSinceLastState

int

Elapsed time since the last state change, in milliseconds.

channel

const char *

The current channel ID.

OnScreenSharePublishStateChanged

Triggered when the screen sharing publishing state changes.

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

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publishing state.

newState

AliEnginePublishState

The current publishing state.

elapseSinceLastState

int

Time elapsed since the last state change.

channel

const char *

The current channel ID.

OnDualStreamPublishStateChanged

Occurs when the dual stream publish state changes.

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

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publish state.

newState

AliEnginePublishState

The current publish state.

elapseSinceLastState

int

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

channel

const char *

The channel ID.

OnVideoPublishStateChanged

Occurs when the video publishing state changes.

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

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publishing state.

newState

AliEnginePublishState

The current publishing state.

elapseSinceLastState

int

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

channel

const char *

The current channel ID.

OnAudioPublishStateChanged

Triggered when the audio publishing state changes.

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

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publishing state.

newState

AliEnginePublishState

The current publishing state.

elapseSinceLastState

int

Time since the last state change, in milliseconds.

channel

const char *

The channel ID.

OnSubscribeAudioFrame

Provides the audio data of a single remote user before audio mixing.

virtual void OnSubscribeAudioFrame(const char* uid, const AudioFrame * frame) {}

This callback corresponds to the AliRTCSdk::Linux::AudioFormatPcmBeforMixing audio format.

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

frame

const AudioFrame *

A pointer to the audio frame. For details, see AudioFrame: audio frame structure.

OnSubscribeMixAudioFrame

This callback is triggered for subscribed audio data.

virtual void OnSubscribeMixAudioFrame(const AudioFrame * frame) {}

Provides the mixed audio data from all remote users, ready for playback. The data format is AudioFormatMixedPcm.

Parameters

Parameter

Type

Description

frame

const AudioFrame *

The audio frame. See AudioFrame: audio frame struct. for the struct's definition.

OnRemoteVideoSample

This callback provides the raw video data from a subscribed remote user.

virtual void OnRemoteVideoSample(const char* uid, const VideoFrame * frame) {}

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

frame

const VideoFrame *

The video frame containing the raw video data.

OnRemoteVideoEncodedSample

Reports the encoded video data received from a remote user before decoding.

virtual void OnRemoteVideoEncodedSample(const char* uid, const VideoFrame * frame) {}

Parameters

Parameter

Type

Description

uid

const char *

User ID.

frame

const VideoFrame *

Encoded video frame data.

OnMediaExtensionMsgReceived

Occurs when a media extension message is received.

virtual void OnMediaExtensionMsgReceived(const char* userid, const char* message, size_t size) {}

When a user calls SendMediaExtensionMsg, other users in the channel receive the message through this callback.

Parameters

Parameter

Type

Description

userid

const char *

The user ID of the sender.

message

const char *

The content of the media extension message.

size

size_t

The length of the message in bytes.

OnSnapshotComplete

Reports the result of a snapshot operation.

virtual void OnSnapshotComplete(const char* userId, VideoTrack videoSource, void* buffer, int width, int height, bool success) {}

The SDK triggers this callback when a snapshot operation is complete.

Parameters

Parameter

Type

Description

userId

const char *

The user ID.

videoSource

VideoTrack

The video track from which the snapshot was taken. For details, see VideoTrack: video track.

buffer

void *

The snapshot data in RGBA format on success; NULL on failure.

width

int

The width of the snapshot in pixels.

height

int

The height of the snapshot in pixels.

success

bool

Indicates whether the snapshot succeeded.

OnPlaybackAudioFrameBeforeMixing

Reports the audio data of each remote user before mixing.

virtual void OnPlaybackAudioFrameBeforeMixing(const char *uid, AudioFrame *frame) {}
Warning

This method is deprecated. Use OnSubscribeAudioFrame instead.

The SDK triggers this callback when the audio format for the subscription is set to AudioFormatPcmBeforeMixing.

Parameters

Parameter

Type

Description

uid

const char *

The remote user ID.

frame

AudioFrame *

A pointer to the AudioFrame struct.

OnUpdateRoleNotify

Occurs when the user role changes.

virtual void OnUpdateRoleNotify(const AliEngineClientRole oldRole, const AliEngineClientRole newRole) {}

This callback is triggered after a successful call to SetClientRole.

Parameters

Parameter

Type

Description

oldRole

const AliEngineClientRole

The previous user role. For details, see AliEngineClientRole.

newRole

const AliEngineClientRole

The current user role. For details, see AliEngineClientRole.

OnSubscribeAudioAac

Provides the AAC-transcoded audio data from each subscribed stream for custom audio archiving.

virtual void OnSubscribeAudioAac(const char* uid, const AudioFrame * frame) {}

Parameters

Parameter

Type

Description

uid

const char *

The user ID.

frame

const AudioFrame *

The audio data. For details, see the AudioFrame struct.

OnSubscribeMixedAudioAac

Outputs the mixed audio, transcoded to AAC, for custom audio archiving.

virtual void OnSubscribeMixedAudioAac(const AudioFrame * frame) {}

Parameters

Parameter

Type

Description

frame

const AudioFrame *

The audio frame. For details, see AudioFrame: audio frame struct.