AliRTCLinuxEngine API

更新时间:
复制 MD 格式

This topic describes the Python engine interfaces for the Real-Time Communication Linux SDK.

API reference

API

Description

CreateAliRTCEngine

Creates an AliRTCEngineInterface instance.

Release

Destroys the AliRTCEngineInterface instance.

GetEventHandler

Gets the event handler.

JoinChannel

Joins a channel using a simplified method without a nonce or timestamp, ensuring compatibility with other SDKs.

LeaveChannel

Leaves the channel.

IsLocalVideoStreamPublished

Checks whether publishing the camera track is enabled.

IsLocalScreenPublishEnabled

Checks whether publishing the screen track is enabled.

IsLocalAudioStreamPublished

Checks whether publishing the audio track is enabled.

IsDualStreamPublished

Checks if simulcast is enabled for the camera track.

SetExternalVideoSource

Enables an external video source.

PushExternalVideoFrame

Pushes an external video frame. Video input with a resolution of 2K or higher is not supported.

SetExternalAudioSource

Enables or disables publishing from an external audio source.

PushExternalAudioFrameRawData

Pushes external raw audio data for publishing.

SetAudioProfile

Sets the audio profile.

SetExternalAudioPublishVolume

Sets the publishing volume for the external audio source.

GetExternalAudioPublishVolume

Gets the publishing volume of the external audio source.

SendMediaExtensionMsg

Sends Supplemental Enhancement Information (SEI) messages up to 4 KB to transmit small amounts of application data.

PublishLocalDualStream

Enables or disables publishing the substream.

PublishLocalVideoStream

Enables or disables publishing the local camera stream.

PublishLocalAudioStream

Enables or disables publishing the local audio stream.

PublishScreenShareStream

Starts publishing the screen sharing stream.

SubscribeRemoteAudioStream

Subscribes to or unsubscribes from a specific remote user's audio stream. This method must be called after joining a channel.

SubscribeRemoteVideoStream

Subscribes to or unsubscribes from a remote user's video stream. This method must be called after joining a channel.

SetVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

SetScreenShareEncoderConfiguration

Sets the video encoder configuration for the screen sharing stream.

SetRemoteVideoStreamType

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

MuteLocalCamera

Stops or resumes sending local video data.

MuteLocalMic

Stops or resumes sending local audio data.

SetClientRole

Sets the client role.

SetRemoteDefaultVideoStreamType

Sets the default video stream type for remote subscriptions.

LeaveOnceNoStreamer

Configures the SDK to trigger the OnError callback with ERR_NO_PEOPLE for an audience member if the last broadcaster leaves the channel.

SetPeriodForCheckPeople

Sets a period after which the OnError callback is triggered with ERR_NO_PEOPLE if the user is alone in the channel.

SetParameter

Sets custom configurations by using a JSON-formatted string, such as enabling or disabling the data channel.

GenerateToken

Generates a token locally to join a channel, bypassing app server authentication.

SendDataChannelMessage

Sends a message through the data channel.

OnError

Triggered when an error occurs.

OnWarning

Triggered when a warning occurs.

OnJoinChannelResult

Reports the result of joining a channel.

OnDataChannelMsg

Triggered when a message is received from a remote user through the data channel.

OnLeaveChannelResult

Reports the result of leaving a channel.

OnRemoteUserOnLineNotify

Triggered when a remote user joins the channel in communication mode or as a broadcaster in interactive mode.

OnRemoteUserOffLineNotify

Triggered when a remote user leaves the channel in communication mode or as a broadcaster in interactive mode.

OnRemoteTrackAvailableNotify

Triggered when the state of a remote user's audio or video stream changes.

OnAudioSubscribeStateChanged

Triggered when the audio subscription state changes.

OnVideoSubscribeStateChanged

Triggered when the camera stream subscription state changes.

OnSubscribeStreamTypeChanged

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

OnScreenShareSubscribeStateChanged

Triggered when the screen sharing stream subscription state changes.

OnScreenSharePublishStateChanged

Triggered when the screen sharing publishing state changes.

OnDualStreamPublishStateChanged

Triggered when the substream publishing state changes.

OnVideoPublishStateChanged

Triggered when the video publishing state changes.

OnAudioPublishStateChanged

Triggered when the audio publishing state changes.

OnSubscribeAudioFrame

Reports the audio data of each remote user before mixing.

OnSubscribeMixAudioFrame

Reports the mixed audio data of all subscribed remote users.

OnRemoteVideoSample

Reports the received remote video data frames.

OnRemoteVideoEncodedSample

Reports the received encoded remote video data before decoding.

OnMediaExtensionMsgReceived

Triggered when an SEI message is received.

OnUpdateRoleNotify

Triggered when the client role changes.

OnSubscribeAudioAac

Reports separate audio streams transcoded to the AAC format for custom audio archiving.

OnSubscribeMixedAudioAac

Reports the mixed audio stream transcoded to the AAC format for custom audio archiving.

OnPushAudioFrameBufferFull

Notifies the application that the SDK buffer is full due to rapid or uneven audio data input.

OnPushVideoFrameBufferFull

Notifies the application that the SDK buffer is full due to rapid or uneven video data input.

API

CreateAliRTCEngine

Creates and returns an AliRTCEngineInterface instance.

def CreateAliRTCEngine(eventHandler:EngineEventHandlerInterface, lowPort:int, highPort:int, \
                       logPath:str, coreServicePath:str, h5mode:bool, extra:str) -> AliRTCEngineInterface

Parameters

Parameter

Type

Description

eventHandler

EngineEventHandlerInterface *

The object that handles event callbacks.

lowPort

int

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

highPort

int

The upper bound of the port range.

logPath

str

The path to the SDK log files.

coreServicePath

str

The path to the AliRtcCoreService file.

h5mode

bool

A flag to enable h5 compatibility mode. In most cases, set this to false.

extra

str

A JSON-formatted string for additional SDK configurations.

Returns an AliRTCEngineInterface instance.

Release

Destroys the AliRTCEngineInterface instance.

def Release() -> None

GetEventHandler

Gets the event handler.

def GetEventHandler() -> EngineEventHandlerInterface

Return value: The event handler.

Join channel

Joins a channel without requiring a nonce or timestamp. This method simplifies integration and improves compatibility with SDKs from other vendors.

def JoinChannel(token:str, channelId:str, userId:str, userName:str, config:JoinChannelConfig) -> int
Note

This is an asynchronous method. To confirm if you have successfully joined the channel, listen for the OnJoinChannelResult callback.

Parameters

Parameter

Type

Description

token

str

The authentication token required to join the channel.

channelId

str

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

userId

str

The user ID of the client joining the channel. This value must match the user ID that was used to generate the token.

userName

str

The user's display name (not their user ID).

config

JoinChannelConfig

The configuration settings for joining the channel.

Returns 0 on success; a negative value on failure.

LeaveChannel

Leaves the channel.

def LeaveChannel() -> int

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

IsLocalVideoStreamPublished

Checks if the camera track is published.

def IsLocalVideoStreamPublished() -> bool

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

IsLocalScreenPublishEnabled

Checks whether publishing the screen track is enabled.

def IsLocalScreenPublishEnabled() -> bool

Returns
true if publishing is enabled; false otherwise.

IsLocalAudioStreamPublished

Checks if the local audio stream can be published.

def IsLocalAudioStreamPublished() -> bool

Returnstrue if publishing is allowed; false otherwise.

IsDualStreamPublished

Checks whether simulcast publishing for the camera track is enabled.

def IsDualStreamPublished() -> bool

Returns
Returns true if enabled, or false otherwise.

SetExternalVideoSource

Enables the external video source.

def SetExternalVideoSource(enable:bool, sourceType:VideoSource, renderMode:RenderMode) -> int

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

Parameters

Parameter

Type

Description

enable

bool

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

sourceType

VideoSource

Specifies the video source type.

renderMode

RenderMode

Specifies the render mode.

Returns

PushExternalVideoFrame

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

def PushExternalVideoFrame(frame:VideoDataSample, sourceType:VideoSource) -> int

The video frame supports various formats, such as YUV and RGB.

Parameters

Parameter

Type

Description

frame

VideoDataSample

Frame data.

sourceType

VideoSource

Stream type.

Returns Returns 0 on success, or a non-zero value on failure. If the return value is ERR_AUDIO_BUFFER_FULL, you can adjust the sending rate.

SetExternalAudioSource

Enables or disables publishing from an external audio source.

def SetExternalAudioSource(enable:bool, sampleRate:int, channelsPerFrame:int) -> int

Call SetExternalAudioPublishVolume to set the publishing volume for the external audio source.

Parameters

Parameter

Type

Description

enable

bool

true to enable the external audio source; false to disable it.

sampleRate

int

The sample rate in hertz (Hz), such as 16000 or 48000.

channelsPerFrame

int

The number of channels, such as 1 (mono) or 2 (stereo).

Returns

PushExternalAudioFrameRawData

Pushes raw external audio data to a stream.

def PushExternalAudioFrameRawData(audioSamples:bytes, sampleLength:int, timestamp:int) -> int

Parameters

Parameter

Type

Description

audioSamples

bytes

The raw audio data to be pushed.

sampleLength

int

The length of the audio data, in bytes.

timestamp

int

The timestamp of the audio data, in milliseconds (ms).

Returns
Returns 0 on success or a non-zero value on failure. A return value of ERR_AUDIO_BUFFER_FULL means the audio buffer is full; retry after the data sending interval.

SetAudioProfile

Sets the audio quality and scene.

def SetAudioProfile(audioProfile:AudioQualityMode, audioScene:AudioSceneMode) -> int

Parameters

Parameter

Type

Description

audioProfile

AudioQualityMode

Specifies the audio profile, which defines settings for audio capture and encoding.

audioScene

AudioSceneMode

Specifies the audio scene mode.

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

SetExternalAudioPublishVolume

Sets the volume of the external audio input for publishing.

def SetExternalAudioPublishVolume(volume:int) -> int

Parameters

Parameter

Type

Description

volume

int

The volume level, from 0 to 100.

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

GetExternalAudioPublishVolume

Gets the publishing volume of the mixed external audio.

def GetExternalAudioPublishVolume() -> int

Returns
The publishing volume.

SendMediaExtensionMsg

Sends a media extension message (SEI) to embed small amounts of application-specific data into the video stream. The maximum message size is 4,096 bytes.

def SendMediaExtensionMsg(message:bytes, length:int, repeatCount:int, delay:int, isKeyFrame:bool) -> int

Parameters

Parameter

Type

Description

message

bytes

The message payload, with a maximum size of 4,096 bytes.

length

int

The length of the message, in bytes.

repeatCount

int

The number of times to repeat the message. This helps prevent message loss due to packet loss.

delay

int

The delay before sending the message, in milliseconds.

isKeyFrame

bool

Specifies whether to embed the SEI message only in keyframes.

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

PublishLocalDualStream

Enables or disables publishing the secondary video stream.

def PublishLocalDualStream(enabled:bool) -> int

The secondary video stream is published only if the main video stream is published. Before enabling the secondary video stream, call the PublishLocalVideoStream method to publish the main video stream. By default, the SDK does not publish the secondary video stream. You can call this method before you join a channel to change the default setting. The setting takes effect when you publish the video stream.

Parameters

Parameter

Type

Description

enabled

bool

Whether to enable publishing the secondary video stream. true: Enables publishing. false: Disables publishing.

Returns

PublishLocalVideoStream

Publishes or unpublishes the local video stream.

def PublishLocalVideoStream(enabled:bool) -> int

By default, the SDK publishes the video stream. You can call this method before joining a channel to change the default setting. The change takes effect when you join the channel.

Parameters

Parameter

Type

Description

enabled

bool

Specifies whether to publish or unpublish the local video stream. Set to true to publish; set to false to unpublish.

Return value

PublishLocalAudioStream

Enables or disables publishing the local audio stream.

def PublishLocalAudioStream(enabled:bool) -> int

By default, the SDK publishes the local audio stream. You can call this method before joining a channel to change the default setting. This setting takes effect after you join the channel.

Parameters

Parameter

Type

Description

enabled

bool

Specifies whether to publish the local audio stream.

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

PublishScreenShareStream

Starts publishing the screen share stream.

def PublishScreenShareStream(enabled:bool) -> int

Parameters

Parameter

Type

Description

enabled

bool

Whether to enable (true) or disable (false) publishing the screen share stream.

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

SubscribeRemoteAudioStream

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

def SubscribeRemoteAudioStream(uid:str, sub:bool) -> int

Parameters

Parameter

Type

Description

uid

str

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

sub

bool

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

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

SubscribeRemoteVideoStream

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

def SubscribeRemoteVideoStream(uid:str, videoTrack:VideoTrack, sub:bool) -> int:

Parameters

Parameter

Type

Description

uid

str

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

videoTrack

VideoTrack

The video stream type. Valid values are:
- AliEngineVideoTrackNo: Invalid. This setting has no effect.
- AliEngineVideoTrackCamera: The camera stream.
- AliEngineVideoTrackScreen: The screen sharing stream.
- AliEngineVideoTrackBoth: Both the camera stream and screen sharing stream.



sub

bool

Specifies whether to subscribe to the remote user's video stream. Set this parameter to true to subscribe or false to unsubscribe.

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

SetVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

def SetVideoEncoderConfiguration(config:AliEngineVideoEncoderConfiguration) -> int

This method sets the video parameters for the camera stream, such as resolution, frame rate, bitrate, and video orientation. All parameters have valid ranges. If you specify values outside these ranges, the SDK automatically adjusts them. You can call this method either before or after joining a channel. If you only need to set the video encoder configuration once per session, it is recommended to call this method before joining.

Parameters

Parameter

Type

Description

config

AliEngineVideoEncoderConfiguration

The video encoder configuration. For details, see AliEngineVideoEncoderConfiguration.

SetScreenShareEncoderConfiguration

Sets the video encoder configuration for the screen sharing stream.

def SetScreenShareEncoderConfiguration(config:AliEngineScreenShareEncoderConfiguration) -> int

This method sets the video encoder configuration for the screen sharing stream, including resolution, frame rate, bitrate, and video orientation. All parameters have valid ranges. If you set a parameter outside its valid range, the SDK automatically adjusts it. You can call this method either before or after you join a meeting. If you only need to configure screen sharing once per session, call this method before joining.

Parameters

Parameter

Type

Description

config

AliEngineScreenShareEncoderConfiguration

The screen sharing encoder configuration. For details, see AliEngineScreenShareEncoderConfiguration.

SetRemoteVideoStreamType

Sets the video stream type to subscribe to for a remote user, either the high stream or the low stream.

def SetRemoteVideoStreamType(uid:str, streamType:AliEngineVideoStreamType) -> int

By default, the publisher does not publish the low stream. The subscriber can choose to subscribe to the high stream or low stream only after the publisher enables dual-stream mode by calling PublishLocalDualStream(true). Otherwise, the subscriber can subscribe only to the high stream.

Parameters

Parameter

Type

Description

uid

str

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

streamType

AliEngineVideoStreamType

The video stream type to subscribe to. Values include:
- AliEngineVideoStreamTypeNone: Invalid value. This setting has no effect.
- AliEngineVideoStreamTypeHigh: The high stream.
- AliEngineVideoStreamTypeLow: The low stream.


Returns

MuteLocalCamera

Stops or resumes sending the local video stream.

def MuteLocalCamera(mute:bool) -> int

Parameters

Parameter

Type

Description

mute

bool

Whether to stop or resume sending the local video stream.

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

MuteLocalMic

Stops or resumes sending local audio data.

def MuteLocalMic(mute:bool) -> int

Parameters

Parameter

Type

Description

mute

bool

Specifies whether to mute the local microphone. true: Mutes the microphone. false: Unmutes the microphone.

Returns

SetClientRole

Sets the user role.

def SetClientRole(clientRole:AliEngineClientRole) -> int

You can call this method before or after joining a channel, but only in the AliRtcChannelProfileCommunication channel mode. If the call is successful, the SDK triggers the OnUpdateRoleNotify callback. To switch from an interactive role to a live role, you must first stop publishing your stream. Otherwise, the call fails. In the AliRtcChannelProfileInteractiveLive channel mode, the default user role is AliRtcClientRoleLive.

Parameters

Parameter

Type

Description

clientRole

AliEngineClientRole

The user's role.

Return value

SetRemoteDefaultVideoStreamType

Sets the default video stream type for remote subscriptions.

def SetRemoteDefaultVideoStreamType(streamType:AliEngineVideoStreamType) -> int

Parameters

Parameter

Type

Description

streamType

AliEngineVideoStreamType

Specifies the stream type: main stream or sub-stream.

Returns

LeaveOnceNoStreamer

For users in audience mode, when all streamers in the room stop streaming, the SDK immediately triggers the OnError callback with the error code ERR_NO_PEOPLE.

def LeaveOnceNoStreamer(enable:bool) -> None

This feature is designed for content moderation scenarios.

Parameters

Parameter

Type

Description

enable

bool

A boolean to enable (true) or disable (false) this feature.

SetPeriodForCheckPeople

After joining a channel, if no one else joins within the specified period, the SDK triggers the OnError callback with the ERR_NO_PEOPLE error code.

def SetPeriodForCheckPeople(seconds:int) -> None

If a timeout occurs, the attempt to join the channel fails, and the OnJoinChannelResult callback returns -1. This feature is for moderation scenarios. By default, the maximum duration for this check is 5 seconds.

Parameters

Parameter

Type

Description

seconds

int

The maximum time, in seconds, to wait for another user to join before a timeout. Set to 0 or a negative value to disable this check.

SetParameter

Applies a custom configuration using a JSON string, such as enabling or disabling the dataChannel.

def SetParameter(params:str) -> int

Parameters

Parameter

Type

Description

params

str

The custom configuration as a JSON string.

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

GenerateToken

Generates a token locally for channel authentication. This token is required to call the JoinChannel method, enabling you to bypass an appserver.

def GenerateToken(authInfo:AuthInfo, appkey:str) -> None

The generated token is used as a parameter for joining a channel.

Parameters

Parameter

Type

Description

authInfo

AuthInfo

The authentication information object. You must set its appid, nonce, and timestamp values before generating a token.

appkey

str

The key corresponding to the appid, required to generate a token.

SendDataChannelMessage

Sends data through the data channel.

def SendDataChannelMessage(ctrlMsg:AliEngineDataChannelMsg) -> int
Note

The data channel feature depends on a publisher sending an audio and video stream. Ensure you are actively publishing an audio and video stream.

Usage limits

  • Anchors can send and receive messages, while the audience can only receive messages.

  • Call the setParameter method to enable the custom message channel.

  • The following limits apply to sending data:

    • Maximum bitrate: 30 Kbps.

    • The data channel supports a maximum of 60 data packets per second, with each packet limited to 1 KB.

Parameters

Parameter

Type

Description

ctrlMsg

AliEngineDataChannelMsg

Contains the data to send and control commands.

Returns

OnError

Notifies the application layer when the engine encounters an error.

def OnError(self, error_code:ERROR_CODE) -> None

Parameters

Parameter

Type

Description

error_code

ERROR_CODE

The type of error encountered.

OnWarning

Notifies the business layer when the engine reports a warning.

def OnWarning(self, warning_code:WARNING_CODE) -> None

Parameters

Parameter

Type

Description

warning_code

WARNING_CODE

The warning code.

OnJoinChannelResult

Reports the result of joining a channel.

def OnJoinChannelResult(self, result:int, channel:str, userId:str) -> None

This callback is triggered when the application calls the JoinChannel method. It indicates whether the user successfully joined the channel.

Parameters

Parameter

Type

Description

result

int

The result of joining the channel. A value of 0 indicates success, and any other value is an error code.

channel

str

The channel ID.

userId

str

The user ID.

OnDataChannelMsg

Triggered when you receive a message from a remote user through the data channel.

def OnDataChannelMsg(self, uid:str, msg:AliEngineDataChannelMsg) -> None
Note

The Alibaba Cloud Real-Time Communication (ARTC) data channel requires an active audio/video stream. To send messages, you must be publishing a stream. To receive messages, you must be subscribing to a stream.

Parameters

Parameter

Type

Description

uid

str

The user ID.

msg

AliEngineDataChannelMsg

The message from the remote user.

OnLeaveChannelResult

Reports the result of leaving a channel.

def OnLeaveChannelResult(self, result:int) -> None

When your application calls the LeaveChannel method, the SDK triggers this callback to report the result. If you destroy the SDK instance immediately after calling LeaveChannel, you will not receive this callback.

Parameters

Parameter

Type

Description

result

int

The result of leaving the channel. A value of 0 indicates success, and any non-zero value indicates an error.

OnRemoteUserOnLineNotify

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

def OnRemoteUserOnLineNotify(self, uid:str) -> None

The SDK triggers this callback in the following scenarios:

Communication mode

  • The current user receives this callback when a remote user joins the channel. When the current user joins a channel, they also receive this callback for each user already present.

Interactive mode

  • The current user receives this callback when a remote host joins the channel. When the current user joins a channel, they also receive this callback for each host already present.

  • The current user also receives this callback when a remote user in the audience role calls SetClientRole to switch to the host role (AliEngineClientRoleInteractive).

In interactive mode, this callback behaves as follows:

  1. Hosts receive this callback when other hosts join the channel.

  2. Audience members receive this callback when hosts join the channel.

  3. Hosts do not receive this callback when audience members join the channel.

Parameters

Parameter

Type

Description

uid

str

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

OnRemoteUserOffLineNotify

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

def OnRemoteUserOffLineNotify(self, uid:str) -> None

This callback occurs in the following scenarios:

Communication mode

  • A remote user leaves the channel.

Interactive mode

  • A host (a remote user with the host role) leaves the channel.

  • A host calls SetClientRole to switch to the audience role.

The SDK also triggers this callback when a user in communication mode or a host in interactive mode times out. A user times out if the SDK does not receive their data packets for an extended period.

Parameters

Parameter

Type

Description

uid

str

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

OnRemoteTrackAvailableNotify

This callback notifies you when the state of a remote user's audio or video stream changes.

def OnRemoteTrackAvailableNotify(self, uid:str, audioTrack:AudioTrack, videoTrack:VideoTrack) -> None

The SDK triggers this callback in the following scenarios:

  1. A remote user starts publishing an audio or video stream.

  2. A remote user stops publishing an audio or video stream.

  3. In interactive mode, an audience member calls SetClientRole to switch to the broadcaster role (AliEngineClientRoleInteractive) and starts publishing a stream.

The SDK triggers this callback only for users in communication mode and broadcasters in interactive mode.

Parameters

Parameter

Type

Description

uid

str

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

audioTrack

AudioTrack

The remote user's audio track. For details, see AudioTrack.

videoTrack

VideoTrack

The remote user's video track. For details, see VideoTrack.

OnAudioSubscribeStateChanged

Fires when the audio subscription state changes.

def OnAudioSubscribeStateChanged(self, uid:str, oldState:AliEngineSubscribeState, newState:AliEngineSubscribeState,
                                     elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

uid

str

The user ID, a unique identifier from your application server.

oldState

AliEngineSubscribeState

The previous subscription state. See AliEngineSubscribeState.

newState

AliEngineSubscribeState

The current subscription state. See AliEngineSubscribeState.

elapseSinceLastState

int

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

channel

str

The channel ID.

OnVideoSubscribeStateChanged

Triggered when the camera stream subscription state changes.

def OnVideoSubscribeStateChanged(self, uid:str, oldState:AliEngineSubscribeState, newState:AliEngineSubscribeState,
                                     elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

uid

str

The user ID, a unique identifier assigned by the application server.

oldState

AliEngineSubscribeState

The previous subscription state. For details, see AliEngineSubscribeState: Subscription states.

newState

AliEngineSubscribeState

The current subscription state. For details, see AliEngineSubscribeState: Subscription states.

elapseSinceLastState

int

Time elapsed (in milliseconds) since the last state change.

channel

str

The current channel ID.

OnSubscribeStreamTypeChanged

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

def OnSubscribeStreamTypeChanged(self, uid:str, oldStreamType:AliEngineVideoStreamType, newStreamType:AliEngineVideoStreamType,
                                     elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

uid

str

The user ID, a unique identifier assigned by the application server.

oldStreamType

AliEngineVideoStreamType

The previous subscribed stream type. For details, see AliEngineVideoStreamType: video stream type.

newStreamType

AliEngineVideoStreamType

The current subscribed stream type. For details, see AliEngineVideoStreamType: video stream type.

elapseSinceLastState

int

The time interval (in milliseconds) since the last state change.

channel

str

The current channel ID.

OnScreenShareSubscribeStateChanged

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

def OnScreenShareSubscribeStateChanged(self, uid:str, oldState:AliEngineSubscribeState, newState:AliEngineSubscribeState,
                                           elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

uid

str

The user ID assigned by the application server.

oldState

AliEngineSubscribeState

The previous subscription state. For more information, see AliEngineSubscribeState.

newState

AliEngineSubscribeState

The current subscription state. For more information, see AliEngineSubscribeState.

elapseSinceLastState

int

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

channel

str

The channel ID.

OnScreenSharePublishStateChanged

Triggered when the screen share publishing state changes.

def OnScreenSharePublishStateChanged(self, oldState:AliEnginePublishState, newState:AliEnginePublishState,
                                         elapseSinceLastState:int, channel:str) -> None

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

str

The current channel ID.

OnDualStreamPublishStateChanged

Triggers when the dual stream publish state changes.

def OnDualStreamPublishStateChanged(self, oldState:AliEnginePublishState, newState:AliEnginePublishState,
                                        elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publish state.

newState

AliEnginePublishState

The current publish state.

elapseSinceLastState

int

Time elapsed since the last state change, in milliseconds.

channel

str

The channel ID.

OnVideoPublishStateChanged

Called when the video publishing state changes.

def OnVideoPublishStateChanged(self, oldState:AliEnginePublishState, newState:AliEnginePublishState,
                                   elapseSinceLastState:int, channel:str) -> None

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.

channel

str

The current channel ID.

OnAudioPublishStateChanged

Triggers when the audio stream's publishing state changes.

def OnAudioPublishStateChanged(self, oldState:AliEnginePublishState, newState:AliEnginePublishState,
                                   elapseSinceLastState:int, channel:str) -> None

Parameters

Parameter

Type

Description

oldState

AliEnginePublishState

The previous publishing state.

newState

AliEnginePublishState

The current publishing state.

elapseSinceLastState

int

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

channel

str

The current channel ID.

OnSubscribeAudioFrame

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

def OnSubscribeAudioFrame(self, uid:str, frame:AudioFrame) -> None

This callback is triggered for each audio frame. For more information, see AliRTCSdk::Linux::AudioFormatPcmBeforMixing.

Parameters

Parameter

Type

Description

uid

str

The remote user ID.

frame

AudioFrame

The audio frame object. For details, see the AudioFrame class.

OnSubscribeMixAudioFrame

Provides the mixed audio data from all subscribed remote users.

def OnSubscribeMixAudioFrame(self, frame:AudioFrame) -> None

This audio data is ready for local playback. For details, see AudioFrame: The audio frame class.

Parameters

Parameter

Type

Description

frame

AudioFrame

The mixed audio frame. For details, see AudioFrame: The audio frame class.

OnRemoteVideoSample

Occurs when the SDK receives the raw video data of a subscribed remote user.

def OnRemoteVideoSample(self, uid:str, frame:VideoFrame) -> None

Parameters

Parameter

Type

Description

uid

str

The remote user ID.

frame

VideoFrame

Contains the raw video data.

OnRemoteVideoEncodedSample

Reports the encoded data from a subscribed remote video stream before decoding.

def OnRemoteVideoEncodedSample(self, uid:str, frame:VideoFrame) -> None

Parameters

Parameter

Type

Description

uid

str

User ID of the remote user.

frame

VideoFrame

Contains the encoded video data in Network Abstraction Layer Unit (NALU) format.

OnMediaExtensionMsgReceived

Occurs when a media extension message is received.

def OnMediaExtensionMsgReceived(self, userid:str, message:bytes, size:int) -> None

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

Parameters

Parameter

Type

Description

userid

str

The user ID of the sender.

message

bytes

The content of the media extension message.

size

int

The length of the media extension message, in bytes.

OnUpdateRoleNotify

Occurs when the user role changes.

def OnUpdateRoleNotify(self, oldRole:AliEngineClientRole, newRole:AliEngineClientRole) -> None

The SDK triggers this callback after the role is successfully changed by calling SetClientRole.

Parameters

Parameter

Type

Description

oldRole

AliEngineClientRole

The user's previous role. For more information, see AliEngineClientRole: user role types.

newRole

AliEngineClientRole

The user's new role. For more information, see AliEngineClientRole: user role types.

OnSubscribeAudioAac

The SDK triggers this callback upon receiving an AAC-encoded audio frame from a subscribed remote user. You can use this callback to transcode individual audio streams to the AAC format for use cases such as custom audio archiving.

def OnSubscribeAudioAac(self, uid:str, frame:AudioFrame) -> None

Parameters

Parameter

Type

Description

uid

str

The remote user ID.

frame

AudioFrame

The received AAC-encoded audio frame. See AudioFrame for details.

OnSubscribeMixedAudioAac

Occurs when an AAC-encoded mixed audio frame is received. This callback enables custom audio archiving by transcoding the mixed audio stream to the AAC format.

def OnSubscribeMixedAudioAac(self, frame:AudioFrame) -> None

Parameters

Parameter

Type

Description

frame

AudioFrame

The AAC-encoded mixed audio stream. For details, see AudioFrame: The audio frame class.

OnPushAudioFrameBufferFull

Called when the SDK audio buffer is full because audio data is being pushed too quickly or unevenly.

def OnPushAudioFrameBufferFull(self, isFull:bool) -> None

Parameters

Parameter

Type

Description

isFull

boolean

Whether the SDK audio buffer is full. If true, temporarily stop pushing audio data.

OnPushVideoFrameBufferFull

This callback is triggered when the SDK's internal video buffer is full, which occurs when video data is pushed too quickly or unevenly.

def OnPushVideoFrameBufferFull(self, isFull:bool) -> None

Parameters

Parameter

Type

Description

isFull

bool

Indicates whether the SDK's internal video buffer is full. If true, pause pushing video data.