AliRTCLinuxEngine API

更新时间:
复制 MD 格式

This document provides the engine interface reference for the Real-Time Communication SDK for Java on Linux.

Contents

API

Description

createInstance

Creates an AliRTCLinuxEngine instance.

destroy

Destroys the AliRTCLinuxEngine instance.

generateToken

Simulates an app server to generate a local token with one or more parameters.

generateTokenV2

Simulates an app server to generate a local token with a single parameter. This API is deprecated. We recommend using generateToken().

setVideoCallbackPeriod

For content moderation scenarios, sets the callback interval for video frames. The default interval is one frame per second.

joinChannel[1/2]

Joins a channel.

joinChannel[2/2]

Joins a channel.

leaveChannel

Leaves the channel.

isLocalCameraPublishEnabled

Checks whether publishing the camera stream is enabled.

isLocalScreenPublishEnabled

Checks whether publishing the screen share stream is enabled.

isLocalAudioPublishEnabled

Checks whether publishing the audio stream is enabled.

isLocalSimulcastEnabled

Checks whether publishing simulcast streams for the camera is enabled.

setExternalVideoSource

Enables an external video source.

pushExternalVideoFrame

Pushes an external video frame.

setExternalAudioSource

Enables or disables publishing from an external audio source.

pushExternalAudioFrameRawData

Pushes raw external audio data for publishing.

setExternalAudioPublishVolume

Sets the publishing volume of the external audio source.

getExternalAudioPublishVolume

Gets the publishing volume of the external audio source.

sendMediaExtensionMsg

Sends Real-Time Transport Protocol (RTP) media extension messages.

publishLocalDualStream

Enables or disables publishing the secondary video stream.

publishLocalVideoStream

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

publishLocalAudioStream

Enables or disables publishing the local audio stream.

publishScreenShareStream

Starts publishing the screen share stream.

subscribeRemoteAudioStream

Stops or resumes subscribing to a specified remote user's audio stream. Call this method after joining a channel.

subscribeRemoteVideoStream

Stops or resumes subscribing to a specified remote user's video stream. Call this method after joining a channel.

setVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

setScreenShareEncoderConfiguration

Sets the video encoder configuration for the screen share stream.

setRemoteVideoStreamType

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

muteLocalCamera

Stops or resumes sending local video data.

muteLocalMic

Stops or resumes sending local audio data.

setClientRole

Sets the user role.

setParameter

Configures custom settings using a JSON-formatted string, such as enabling or disabling the dataChannel.

sendDataChannelMsg

Sends data through the dataChannel.

setAudioProfile

Sets the audio profile.

setRemoteDefaultVideoStreamType

Sets the default video stream type for subscriptions.

setPeriodForCheckPeople

After joining a channel, waits for a specified period. If no other users join, the onError callback is triggered with the ERR_NO_PEOPLE error code.

leaveOnceNoStreamer

After joining a channel as an audience member, if all broadcasters leave the channel, the engine immediately triggers the onError callback with the ERR_NO_PEOPLE error code.

getProcess

Gets the current process.

getIpcInput

Gets the data input stream for inter-process communication (IPC).

getSocket

Gets the socket endpoint for creating an inter-process communication connection.

getIpcOutput

Gets the data output stream for IPC.

onError

Occurs when an engine error occurs.

onWarning

Occurs when an engine warning occurs.

onJoinChannelResult

Occurs when the join channel operation completes.

onLeaveChannelResult

Occurs when the leave channel operation completes.

onRemoteUserOnLineNotify

Occurs when a remote user (in communication mode) or a broadcaster (in interactive mode) joins the channel.

onRemoteUserOffLineNotify

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

onRemoteTrackAvailableNotify

Occurs when a remote user's media stream becomes available or unavailable.

onVideoSubscribeStateChanged

Occurs when the subscription state of a camera stream changes.

onSubscribeStreamTypeChanged

Occurs when the subscribed stream type (high-quality or low-quality) changes.

onScreenShareSubscribeStateChanged

Occurs when the subscription state of a screen share stream changes.

onScreenSharePublishStateChanged

Occurs when the publishing state of a screen share stream changes.

onDualStreamPublishStateChanged

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

onVideoPublishStateChanged

Occurs when the video publishing state changes.

onAudioPublishStateChanged

Occurs when the audio publishing state changes.

onSubscribeAudioFrame

Occurs when an audio frame is received from a subscribed remote user.

onSubscribeMixedAudioFrame

Occurs when the mixed audio frame from all subscribed remote users is received.

onSubscribeAudioAac

For custom audio archiving, this callback reports individual audio streams after they are transcoded to the Advanced Audio Coding (AAC) format.

onSubscribeMixedAudioAac

For custom audio archiving, this callback reports the mixed audio stream after it is transcoded to the AAC format.

onRemoteVideoSample

Occurs when a decoded video frame is received from a remote user.

onRemoteVideoEncodedSample

Occurs when raw, encoded data is received from a subscribed remote video stream.

onMediaExtensionMsgReceived

Occurs when a media extension message is received.

onSnapshotComplete

Occurs when a snapshot operation completes.

onPlaybackAudioFrameBeforeMixing

Occurs when the audio data of each remote user is received before audio mixing.

onUpdateRoleNotify

Occurs when a user role changes.

onDataChannelMsg

Occurs when a message is received through the dataChannel.

API

createInstance

Creates an AliRTCLinuxEngine instance.

public static synchronized AliRTCLinuxEngine createInstance(AliRTCLinuxEngineListener listener, int lowPort, int highPort, String logPath, String coreServicePath, boolean h5mode, String extra) throws Exception{};

Parameters

Parameter

Type

Description

listener

AliRTCLinuxEngineListener

The object that receives 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

String

The path to the SDK's runtime log directory.

coreServicePath

String

The absolute path to AliRtcCoreService.

h5mode

boolean

Controls whether to enable H5 compatibility mode. You can usually set this to false.

extra

String

A JSON string with additional configuration options for the SDK.

Returns The created AliRTCLinuxEngine instance.

destroy

Destroys the AliRTCLinuxEngine instance.

public abstract void destroy();

Generate token

Simulates app server behavior to locally generate a token using one or more parameters.

public abstract String generateToken(AuthInfo authInfo, String appkey);

Parameters

Parameter

Type

Description

authInfo

AuthInfo

The custom configuration information. Populate its appid, nonce, and timestamp fields before computing the token.

appkey

String

The key that corresponds to appid. It is required to compute the token.

Returns The locally generated token.

generateTokenV2

Deprecated. Use generateToken() instead. This method simulates app server behavior to locally generate a single-parameter token.

public abstract String generateTokenV2(AuthInfo authInfo);

Parameters

Parameter

Type

Description

authInfo

AuthInfo

The custom configuration. You must populate the appid, nonce, and timestamp fields before generating the token.

Returns The locally generated token.

setVideoCallbackPeriod

Sets the callback period for video frames in moderation scenarios. If you do not call this method, the default callback rate is one frame per second.

public abstract boolean setVideoCallbackPeriod(int period);

Parameters

Parameter

Type

Description

period

int

The callback period for video frames.

Returns

joinChannel[1/2]

Joins a channel.

public abstract int joinChannel(AuthInfo authInfo, JoinChannelConfig config) throws Exception;
Note

This is an asynchronous method. The onJoinChannelResult callback returns the result of joining the channel.

Parameters

Parameter

Type

Description

authInfo

AuthInfo

Authentication information from your application server.

config

JoinChannelConfig

Configuration options for joining the channel.

Returns A return value of 0 indicates that the method call was successful; a non-zero value indicates failure.

joinChannel[2/2]

Joins a channel.

public abstract int joinChannel(String token, String channelId, String userId, String userName, JoinChannelConfig config);
Note

This is an asynchronous method. Check the onJoinChannelResult callback to determine if the join was successful.

Parameters

Parameter

Type

Description

token

String

The authentication information used to join the channel.

channelId

String

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

userId

String

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

userName

String

The display name of the user (not the user ID).

config

JoinChannelConfig

Configuration for joining the channel.

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

leaveChannel

Leaves the channel.

public abstract int leaveChannel();

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

isLocalCameraPublishEnabled

Checks whether publishing the camera track is enabled.

public abstract boolean isLocalCameraPublishEnabled();

Returns: true if enabled; false otherwise.

isLocalScreenPublishEnabled

Checks whether publishing the screen track is enabled.

public abstract boolean isLocalScreenPublishEnabled();

Returns true if enabled; false if disabled.

isLocalAudioPublishEnabled

Indicates whether publishing the local audio track is enabled.

public abstract boolean isLocalAudioPublishEnabled();

Returns true if enabled; false otherwise.

isLocalSimulcastEnabled

Checks if simulcast is enabled for the camera track.

public abstract boolean isLocalSimulcastEnabled();

Returns true if simulcast is enabled; false otherwise.

setExternalVideoSource

Enables an external video source.

public abstract int setExternalVideoSource(boolean enable, VideoSource source, RenderMode renderMode);
Note

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

Parameters

Parameter

Type

Description

enable

boolean

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

source

VideoSource

The stream type.

renderMode

RenderMode

The rendering mode.

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

pushExternalVideoFrame

Pushes an external video frame.

public abstract int pushExternalVideoFrame(VideoDataSample frame, VideoSource source);

Parameters

Parameter

Type

Description

frame

VideoDataSample

The video frame.

source

VideoSource

The video source type. Only the I420 format is supported for external video.

Returns

setExternalAudioSource

Enables or disables publishing from an external audio source.

public abstract int setExternalAudioSource(boolean enable, int sampleRate, int channelsPerFrame);
Note

You can call setExternalAudioPublishVolume to set the publishing volume for the external audio source.

Parameters

Parameter

Type

Description

enable

boolean

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

sampleRate

int

The sample rate, in Hz. For example, 16000 or 48000.

channelsPerFrame

int

The number of audio channels. For example, 1 for mono or 2 for stereo.

Return value

pushExternalAudioFrameRawData

Pushes raw external audio data for stream publishing.

public abstract int pushExternalAudioFrameRawData(byte[] audioSamples, int sampleLength, long timestamp);

Parameters

Parameter

Type

Description

audioSamples

byte[]

The audio data buffer.

sampleLength

int

The length of the audio data in bytes.

timestamp

long

Timestamp of the audio data.

Returns A return value of 0 indicates a successful method call; a non-zero value indicates failure. If the method returns ERR_AUDIO_BUFFER_FULL, wait for at least the duration of the audio data before retrying the call.

setExternalAudioPublishVolume

Sets the mixing volume of the external audio source for publishing.

public abstract int setExternalAudioPublishVolume(int volume);

Parameters

Parameter

Type

Description

volume

int

The valid range is 0 to 100.

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

getExternalAudioPublishVolume

Retrieves the mixing volume of the external audio input for publishing.

public abstract int getExternalAudioPublishVolume();

Returns The volume level.

sendMediaExtensionMsg

Sends RTP media extension information.

public abstract int sendMediaExtensionMsg(byte[] message, int repeatCount, int delay, boolean isKeyFrame);

Parameters

Parameter

Type

Description

message

byte[]

The extension information payload. Maximum size: 4 KB.

repeatCount

int

Specifies how many times to repeat the message. This helps reduce message loss caused by packet loss.

delay

int

The send delay in milliseconds.

isKeyFrame

boolean

Specifies whether to add SEI only to keyframes.

Returns 0 on success; any other value indicates failure.

publishLocalDualStream

Enables or disables publishing the secondary video stream.

public abstract int publishLocalDualStream(boolean enabled);
Note
  • The SDK publishes the secondary video stream only when the primary video stream is published. Before enabling the secondary video stream, enable video stream publishing by calling publishLocalVideoStream.

  • By default, the SDK does not publish the secondary video stream. You can call this method before joining a channel to change the default. The setting takes effect when you publish the video stream.

Parameters

Parameter

Type

Description

enabled

boolean

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

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

publishLocalVideoStream

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

public abstract int publishLocalVideoStream(boolean enabled);
Note

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

Parameters

Parameter

Type

Description

enabled

boolean

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

Returns
0 indicates success; any other value indicates failure.

publishLocalAudioStream

Enables or disables publishing the local audio stream.

public abstract int publishLocalAudioStream(boolean enabled);
Note

By default, the SDK publishes the local audio stream. Call this method before joining a channel to change this default. The setting takes effect once you join the channel.

Parameters

Parameter

Type

Description

enabled

boolean

true to publish the local audio stream; false to unpublish it.

Returns 0 indicates success; any other value indicates failure.

publishScreenShareStream

Publishes the screen share stream.

public abstract int publishScreenShareStream(boolean enabled);

Parameters

Parameter

Type

Description

enabled

boolean

Whether to publish the screen share stream. true: Publishes the screen share stream. false: Stops publishing the screen share stream.

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

subscribeRemoteAudioStream

Stops or resumes subscribing to the audio stream of a specified remote user. You must call this method after joining a channel. Calling it before joining a channel has no effect.

public abstract int subscribeRemoteAudioStream(String uid, boolean sub);

Parameters

Parameter

Type

Description

uid

String

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

sub

boolean

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

Returns 0 to indicate that the method call is successful. Any other value indicates failure.

subscribeRemoteVideoStream

Stops or resumes subscribing to a remote user's video stream. This method is only effective when called in-call; calling it pre-call has no effect.

public abstract int subscribeRemoteVideoStream(String uid, VideoTrack videoTrack, boolean sub);

Parameters

Parameter

Type

Description

uid

String

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

videoTrack

VideoTrack

The video stream type. Valid values include: - AliEngineVideoTrackCamera: The camera stream. - AliEngineVideoTrackScreen: The screen sharing stream. - AliEngineVideoTrackBoth: Both the camera stream and the screen sharing stream. - AliEngineVideoTrackNo: An invalid parameter. This value has no effect.

sub

boolean

Specifies whether to subscribe to the remote user's video stream. true: Subscribes to the video stream. false: Unsubscribes from the video stream.

Return Value

setVideoEncoderConfiguration

Sets the video encoder configuration for the camera stream.

public abstract void setVideoEncoderConfiguration(AliEngineVideoEncoderConfiguration config);
Note
  • This method sets video parameters for the camera stream, such as resolution, frame rate, bitrate, and video orientation. If a parameter is set outside its valid range, the SDK automatically adjusts it to a value within the range.

  • You can call this method before or after joining a meeting. If you only need to set the configuration once per session, call this method before joining the meeting.

Parameters

Parameter

Type

Description

config

AliEngineVideoEncoderConfiguration

The video encoder configuration for the camera stream. See AliEngineVideoEncoderConfiguration for details.

setScreenShareEncoderConfiguration

Sets the video encoder configuration for the screen share stream.

public abstract void setScreenShareEncoderConfiguration(AliEngineScreenShareEncoderConfiguration config);
Note
  • This method sets video parameters for the screen share stream, such as resolution, frame rate, bitrate, and video orientation. Each parameter has a valid range. The SDK automatically adjusts any value set outside this range.

  • You can call this method before or after you join a meeting. As a best practice, if you only need to set the configuration once, do so before you join.

Parameters

Parameter

Type

Description

config

AliEngineScreenShareEncoderConfiguration

The video encoder configuration for the screen share stream. See AliEngineScreenShareEncoderConfiguration for details.

setRemoteVideoStreamType

Sets the video stream type to subscribe to, which can be either the high-quality stream or the low-quality stream.

public abstract int setRemoteVideoStreamType(String uid, AliEngineVideoStreamType streamType);
Note

By default, a publisher does not send the low-quality stream. A subscriber can receive the low-quality stream only after the publisher enables dual-stream mode by calling publishLocalDualStream(true). If dual-stream mode is disabled, a subscriber can only receive the high-quality stream, regardless of the stream type specified in this method.

Parameters

Parameter

Type

Description

uid

String

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

streamType

AliEngineVideoStreamType

The video stream type. Valid values are:

Returns

muteLocalCamera

Stops or resumes sending the local video stream.

public abstract int muteLocalCamera(boolean mute);

Parameters

Parameter

Type

Description

mute

boolean

Whether to stop sending the local video stream.

Returns

muteLocalMic

Mutes or unmutes the local microphone.

public abstract int muteLocalMic(boolean mute);

Parameters

Parameter

Type

Description

mute

boolean

Whether to mute the local microphone. Set to true to mute or false to unmute.

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

setClientRole

Sets the user role.

public abstract int setClientRole(AliEngineClientRole clientRole);
Note
  • You can call this method only when the channel profile is AliRtcChannelProfileCommunication, either before or after joining the channel. A successful call triggers the onUpdateRoleNotify callback. To switch from the Interactive role to the Live role, you must first stop publishing streams; otherwise, the method call fails.

  • When the channel profile is set to AliRtcChannelProfileInteractiveLive, the user role defaults to AliRtcClientRoleLive.

Parameters

Parameter

Type

Description

clientRole

AliEngineClientRole

The user's role.

Returns A return value of 0 indicates that the method call was successful, while any other value indicates a failure.

setParameter

Uses a JSON-formatted string to set custom configurations, such as enabling or disabling the dataChannel.

public abstract int setParameter(String param);

Parameters

Parameter

Type

Description

param

String

A JSON-formatted string containing the custom configuration.

Returns 0 indicates the method call succeeded; any other value indicates failure.

sendDataChannelMsg

Sends data over the data channel.

public abstract int sendDataChannelMsg(AliRtcDataChannelMsg controlMsg);
Note

The ARTC data channel feature depends on a publisher sending an audio or video stream. Ensure that an audio or video stream is active in your session.

Limitations

  • Hosts can send and receive messages. The audience can only receive messages.

  • Call setParameter to enable the custom message channel.

  • Data sending is subject to the following limits:

    • Maximum bitrate: 30 KB/s.

    • The data channel can send up to 60 data packets per second, with a maximum packet size of 1 KB.

Parameters

Parameter

Type

Description

controlMsg

AliRtcDataChannelMsg

The message to send.

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

setAudioProfile

Sets the audio profile and audio scene mode.

public abstract int setAudioProfile(AliEngineAudioQualityMode audioProfile, AliEngineAudioSceneMode audioScene);

Parameters

Parameter

Type

Description

audioProfile

AliEngineAudioQualityMode

Specifies the audio capture and encoding settings.

audioScene

AliEngineAudioSceneMode

Optimizes audio processing for specific use cases.

Returns

setRemoteDefaultVideoStreamType

Sets the default video stream type for remote subscriptions.

public abstract int setRemoteDefaultVideoStreamType(AliEngineVideoStreamType streamType);

Parameters

Parameter

Type

Description

streamType

AliEngineVideoStreamType

The video stream type: high-quality stream or low-quality stream.

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

setPeriodForCheckPeople

Sets a timer after the local user joins a channel. If no remote users join before the timer expires, the SDK triggers the onError callback with the ERR_NO_PEOPLE error code.

public abstract void setPeriodForCheckPeople(int seconds);
Note

This is a custom feature for moderation scenarios.

Parameters

Parameter

Type

Description

seconds

int

The timeout in seconds after joining the channel. Set to 0 or less to disable this feature.

Return value Returns 0 if the method call is successful. Any other value indicates an error.

leaveOnceNoStreamer

When this feature is enabled, if a user joins a room in audience mode and all streamers leave, the SDK immediately triggers the onError callback with the ERR_NO_PEOPLE error code.

public abstract void leaveOnceNoStreamer(boolean enable);
Note

This feature is designed for moderation scenarios.

Parameters

Parameter

Type

Description

enable

boolean

Specifies whether to enable this feature. Set to true to enable, false to disable.

Returns

getProcess

Gets the current process.

public abstract Process getProcess();

Returns: The current process.

getIpcInput

Returns the data input stream for inter-process communication.

public abstract DataInputStream getIpcInput();

Returns A data input stream for inter-process communication.

getSocket

Returns the socket for inter-process communication.

public abstract Socket getSocket();

Returns
The inter-process communication socket.

getIpcOutput

Gets the data output stream for inter-process communication.

public abstract DataOutputStream getIpcOutput();

Returns
The data output stream.

onError

Notifies the application layer when the engine encounters an error.

void onError(int error_code);

Parameters

Parameter

Type

Description

error_code

int

The error code.

onWarning

Called when the engine reports a warning.

void onWarning(int warning_code);

Parameters

Parameter

Type

Description

warning_code

int

The warning code.

onJoinChannelResult

Occurs when the SDK completes a request to join a channel.

void onJoinChannelResult(int result, String channel, String userId);
Note

When your application calls the joinChannel method, this callback reports whether the attempt to join the channel was successful.

Parameters

Parameter

Type

Description

result

int

The result of the joinChannel operation. 0 indicates success, while a non-zero value indicates an error code.

channel

String

The channel name.

userId

String

The user ID.

onLeaveChannelResult

Reports the result of leaving a channel.

void onLeaveChannelResult(int result);
Note

When an application calls the leaveChannel method, the SDK triggers this callback to report the result. If you call destroy immediately after leaveChannel, the SDK does not trigger this callback.

Parameters

Parameter

Type

Description

result

int

The result of leaving the channel. A value of 0 indicates success, while a non-zero value is an error code.

onRemoteUserOnLineNotify

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

void onRemoteUserOnLineNotify(String uid);

The SDK triggers this callback in the following scenarios:

  1. In communication mode: The SDK triggers this callback when a remote user joins the channel. If other users are already in the channel when the local user joins, the SDK also triggers this callback for each existing user.

  2. In interactive mode:

  1. The SDK triggers this callback when a remote host joins the channel. If other hosts are already present when the local user joins, the SDK also triggers this callback for each existing host.

  2. This callback is triggered when a remote user in the audience role calls setClientRole to switch to the broadcaster role, AliEngineClientRoleInteractive.

Note

Callback behavior in interactive mode:

  • Hosts receive callbacks when other hosts join the channel.

  • The audience receives callbacks when hosts join the channel.

  • Hosts do not receive callbacks when audience members join the channel.

Parameters

Parameter

Type

Description

uid

String

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

onRemoteUserOffLineNotify

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

void onRemoteUserOffLineNotify(String uid);

The SDK triggers this callback in the following scenarios:

Note

This callback also triggers when a user in communication mode or a broadcaster in interactive mode disconnects due to a network timeout.

Parameters

Parameter

Type

Description

uid

String

The unique user ID assigned by the app server.

onRemoteTrackAvailableNotify

Triggered when a remote user's audio or video track becomes available or unavailable.

void onRemoteTrackAvailableNotify(String uid, AliRTCLinuxEngine.AudioTrack audioTrack, AliRTCLinuxEngine.VideoTrack videoTrack);

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, a user calls setClientRole to switch to the AliEngineClientRoleInteractive broadcaster role and starts publishing a stream.

Note

This callback is triggered only for users in communication mode or users with the broadcaster role in interactive mode.

Parameters

Parameter

Type

Description

uid

String

The user's unique identifier, assigned by your app server.

audioTrack

AliRTCLinuxEngine.AudioTrack

The audio track type. For details, see AudioTrack: Audio track type enumeration.

videoTrack

AliRTCLinuxEngine.VideoTrack

The video track type. For details, see VideoTrack: Video track type enumeration.

onVideoSubscribeStateChanged

Occurs when the subscription state of a camera stream changes.

void onVideoSubscribeStateChanged(String uid, AliRTCLinuxEngine.AliEngineSubscribeState oldState, AliRTCLinuxEngine.AliEngineSubscribeState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

uid

String

The user's unique identifier, assigned by the app server.

oldState

AliRTCLinuxEngine.AliEngineSubscribeState

The previous subscription state.

newState

AliRTCLinuxEngine.AliEngineSubscribeState

The current subscription state.

elapseSinceLastState

int

Elapsed time in milliseconds since the last state change.

channel

String

The channel ID.

onSubscribeStreamTypeChanged

Occurs when the subscribed stream type changes from the high-quality stream to the low-quality stream, or vice versa.

void onSubscribeStreamTypeChanged(String uid, AliRTCLinuxEngine.AliEngineVideoStreamType oldStreamType, AliRTCLinuxEngine.AliEngineVideoStreamType newStreamType, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

uid

String

The user's unique identifier, assigned by the app server.

oldStreamType

AliRTCLinuxEngine.AliEngineVideoStreamType

The previous subscribed stream type.

newStreamType

AliRTCLinuxEngine.AliEngineVideoStreamType

The current subscribed stream type.

elapseSinceLastState

int

The duration in milliseconds since the last state change.

channel

String

The current channel ID.

onScreenShareSubscribeStateChanged

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

void onScreenShareSubscribeStateChanged(String uid, AliRTCLinuxEngine.AliEngineSubscribeState oldState, AliRTCLinuxEngine.AliEngineSubscribeState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

uid

String

The user ID, assigned by the application server.

oldState

AliRTCLinuxEngine.AliEngineSubscribeState

The previous subscription state.

newState

AliRTCLinuxEngine.AliEngineSubscribeState

The current subscription state.

elapseSinceLastState

int

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

channel

String

The channel ID.

onScreenSharePublishStateChanged

Triggered when the screen sharing publish state changes.

void onScreenSharePublishStateChanged(AliRTCLinuxEngine.AliEnginePublishState oldState, AliRTCLinuxEngine.AliEnginePublishState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

oldState

AliRTCLinuxEngine.AliEnginePublishState

The previous publish state.

newState

AliRTCLinuxEngine.AliEnginePublishState

The current publish state.

elapseSinceLastState

int

The time elapsed in milliseconds since the last state change.

channel

String

The current channel ID.

onDualStreamPublishStateChanged

Occurs when the secondary stream publish state changes.

void onDualStreamPublishStateChanged(AliRTCLinuxEngine.AliEnginePublishState oldState, AliRTCLinuxEngine.AliEnginePublishState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

oldState

AliRTCLinuxEngine.AliEnginePublishState

The previous publish state.

newState

AliRTCLinuxEngine.AliEnginePublishState

The current publish state.

elapseSinceLastState

int

Time in milliseconds since the last state change.

channel

String

The current channel ID.

onVideoPublishStateChanged

Triggered when the video publishing state changes.

void onVideoPublishStateChanged(AliRTCLinuxEngine.AliEnginePublishState oldState, AliRTCLinuxEngine.AliEnginePublishState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

oldState

AliRTCLinuxEngine.AliEnginePublishState

The previous publish state.

newState

AliRTCLinuxEngine.AliEnginePublishState

The current publish state.

elapseSinceLastState

int

The elapsed time in milliseconds since the last state change.

channel

String

The channel ID.

onAudioPublishStateChanged

Occurs when the audio publishing state changes.

void onAudioPublishStateChanged(AliRTCLinuxEngine.AliEnginePublishState oldState, AliRTCLinuxEngine.AliEnginePublishState newState, int elapseSinceLastState, String channel);

Parameters

Parameter

Type

Description

oldState

AliRTCLinuxEngine.AliEnginePublishState

The previous publish state.

newState

AliRTCLinuxEngine.AliEnginePublishState

The current publish state.

elapseSinceLastState

int

The elapsed time since the last state change.

channel

String

The current channel ID.

onSubscribeAudioFrame

Triggered when you receive subscribed audio data.

void onSubscribeAudioFrame(String uid, AliRTCLinuxEngine.AudioFrame frame);
Note

This callback provides the audio data from a single remote user, identified by their uid, before audio mixing. The SDK triggers this callback when you call subscribeRemoteAudioStream and set the subscription type to AliEngineAudiosourceSub.

Parameters

Parameter

Type

Description

uid

String

The ID of the remote user.

frame

AliRTCLinuxEngine.AudioFrame

The audio frame.

onSubscribeMixedAudioFrame

Reports the mixed audio frame from subscribed remote users.

void onSubscribeMixedAudioFrame(AliRTCLinuxEngine.AudioFrame frame);
Note

This callback provides mixed audio data from all subscribed remote users, ready for playback. You receive this callback after calling subscribeRemoteAudioStream and setting the subscription type to AliEngineAudiosourceSub.

Parameters

Parameter

Type

Description

frame

AliRTCLinuxEngine.AudioFrame

The mixed audio frame.

onSubscribeAudioAac

For custom audio archiving, this callback delivers individual audio streams transcoded to the AAC format.

void onSubscribeAudioAac(String uid, AliRTCLinuxEngine.AudioFrame frame);

Parameters

Parameter

Type

Description

uid

String

The remote user ID.

frame

AliRTCLinuxEngine.AudioFrame

AAC-encoded audio data in the ADTS format, which can be saved and played directly.

onSubscribeMixedAudioAac

For custom audio archiving, this callback provides the mixed audio stream, transcoded to the AAC format.

void onSubscribeMixedAudioAac(AliRTCLinuxEngine.AudioFrame frame);

Parameters

Parameter

Type

Description

frame

AliRTCLinuxEngine.AudioFrame

AAC-encoded audio data in ADTS format, ready to be saved and played.

onRemoteVideoSample

Triggered when video data is received from a subscribed remote user.

void onRemoteVideoSample(String uid, AliRTCLinuxEngine.VideoFrame frame);

Parameters

Parameter

Type

Description

uid

String

The user ID of the remote user.

frame

AliRTCLinuxEngine.VideoFrame

A frame of raw video data in YUV I420 format.

onRemoteVideoEncodedSample

Reports an encoded video sample from a subscribed remote stream.

void onRemoteVideoEncodedSample(String uid, AliRTCLinuxEngine.VideoFrame frame);

Parameters

Parameter

Type

Description

uid

String

The ID of the remote user.

frame

AliRTCLinuxEngine.VideoFrame

The encoded video data, formatted as an H.264 NALU.

onMediaExtensionMsgReceived

Occurs when a media extension message is received.

void onMediaExtensionMsgReceived(String uid, byte[] msg);
Note

Other participants in the channel receive this callback when a participant calls sendMediaExtensionMsg.

Parameters

Parameter

Type

Description

uid

String

The user ID of the sender.

msg

byte[]

The extension message content.

onSnapshotComplete

Reports the result of a snapshot operation.

void onSnapshotComplete(String uid, AliRTCLinuxEngine.VideoTrack videoSource, byte[] rgba, int width, int height, boolean success);

Parameters

Parameter

Type

Description

uid

String

The user ID.

videoSource

AliRTCLinuxEngine.VideoTrack

The video track from which the snapshot was captured.

rgba

byte[]

The snapshot data in RGBA format if the operation succeeds; otherwise, null.

width

int

The width of the snapshot in pixels.

height

int

The height of the snapshot in pixels.

success

boolean

true if the snapshot was captured successfully; false otherwise.

onPlaybackAudioFrameBeforeMixing

Provides the audio data from each remote user before mixing.

void onPlaybackAudioFrameBeforeMixing(String uid, AliRTCLinuxEngine.AudioFrame frame);
Note

To trigger this callback, call subscribeRemoteAudioStream and set the subscription type to AliEngineAudiosourceSub.

Parameters

Parameter

Type

Description

uid

String

The remote user ID.

frame

AliRTCLinuxEngine.AudioFrame

The audio frame.

onUpdateRoleNotify

Called when the user's role changes.

void onUpdateRoleNotify(AliRTCLinuxEngine.AliEngineClientRole oldRole, AliRTCLinuxEngine.AliEngineClientRole newRole);
Note

This callback is triggered after a successful call to setClientRole.

Parameters

Parameter

Type

Description

oldRole

AliRTCLinuxEngine.AliEngineClientRole

The previous role.

newRole

AliRTCLinuxEngine.AliEngineClientRole

The new role.

onDataChannelMsg

Occurs when a message is received on the data channel.

void onDataChannelMsg(String uid, AliRTCLinuxEngine.AliRtcDataChannelMsg msg);
Note

The ARTC data channel requires an established audio and video stream. To send a message, you must be publishing a stream. To receive a message, you must be subscribed to a stream. Bidirectional communication requires an established audio and video stream.

Parameters

Parameter

Type

Description

uid

String

The user ID of the message sender.

msg

AliRTCLinuxEngine.AliRtcDataChannelMsg

The received message.