Callbacks and listeners

更新时间:
复制 MD 格式

This topic describes the callbacks and listeners in the Android software development kit (SDK) API.

Table of contents

AliRtcEngineEventListener: Callbacks for local user events.
APIDescriptionMinimum supported version
onJoinChannelResultCallback for the result of joining a channel.1.1
onLiveStreamingSignalingResultCallback for low-latency interactive stream pulling.2.1
onLeaveChannelResultCallback for the result of leaving a channel.1.1
onAudioPublishStateChangedCallback for audio ingest state changes.2.1
onVideoPublishStateChangedCallback for video ingest state changes.2.1
onDualStreamPublishStateChangedCallback for secondary video stream ingest state changes.2.1
onScreenSharePublishStateChangedCallback for screen sharing ingest state changes.2.1
onAudioSubscribeStateChangedCallback for audio subscription state changes.2.1
onVideoSubscribeStateChangedCallback for camera stream subscription state changes.2.1
onSubscribeStreamTypeChangedCallback for changes in the subscribed camera stream type (high or low resolution).2.1
onScreenShareSubscribeStateChangedCallback for screen sharing stream subscription state changes.2.1
onNetworkQualityChangedCallback for when network quality changes.1.1
onNetworkQualityProbeTestCallback for network quality probing.1.16.2
onOccurWarningWarning callback.1.1
onOccurErrorError callback.1.1
onPerformanceLowCallback for when the current device performance is low.1.16
onPerformanceRecoveryCallback for when the current device performance recovers.1.16
onConnectionLostCallback for network disconnection.1.14
onTryToReconnectCallback for attempting to reconnect to the network.1.14
onConnectionRecoveryCallback for successful network reconnection.1.14
onConnectionStatusChangeCallback for network connection status changes.2.1
onUpdateRoleNotifyCallback for when the user role changes.1.16
onSnapshotCompleteSnapshot callback.2.1
onPublishLiveStreamStateChangedCallback for bypass stream ingest state changes.2.1
onPublishTaskStateChangedCallback for bypass task state changes.2.1
AliRtcEngineNotify: Callbacks for remote user events.
APIDescriptionMinimum supported version
onRemoteUserOnLineNotifyCallback for when a remote user comes online.1.1
onRemoteUserOffLineNotifyCallback for when a remote user goes offline.1.1
onRemoteTrackAvailableNotifyCallback for when a remote user's audio or video stream changes.1.1
onFirstRemoteVideoFrameDrawnCallback for when the first frame of a remote video stream is rendered.1.16.2
onFirstLocalVideoFrameDrawnThis message is triggered when the first video frame starts to display in the preview.1.17.2
onFirstVideoFrameReceivedCallback for receiving the first video frame from a remote user.2.1
onFirstVideoPacketSentCallback for sending the first video packet.2.1
onFirstAudioPacketSentCallback for sending the first audio packet.2.1
onFirstVideoPacketReceivedCallback for receiving the first video packet.2.1
onFirstAudioPacketReceivedCallback for receiving the first audio packet.2.1
onFirstRemoteAudioDecodedCallback for when the first frame of remote audio is decoded.2.1
onByeCallback for when you are removed from a channel by the server or the channel is closed.1.1
onAliRtcStatsCallback for current session statistics.1.16
onUserAudioMutedNotification that a remote user has stopped sending audio data.1.16.3
onUserVideoMutedNotification that a remote user is sending black video frames.1.16.3
onUserVideoEnabledNotification that a remote user has disabled camera stream capture.2.1
onUserAudioInterruptedBeginNotification that a user's audio is interrupted.1.17
onUserAudioInterruptedEndedNotification that a user's audio interruption has ended.1.17
onUserWillResignActiveA remote user's application has moved to the background.1.17
onUserWillBecomeActiveA remote user's application has returned to the foreground.1.17
onAudioPlayingStateChangedCallback for local audio accompaniment playback.1.16.2
onRemoteAudioAccompanyStartedA remote user's audio accompaniment has started playing.2.1
onRemoteAudioAccompanyFinishedA remote user's audio accompaniment has finished playing.2.1
onAudioEffectFinishedCallback for when a local sound effect finishes playing.1.17.30
onMediaRecordEventRecording event callback.1.17
onRtcLocalVideoStatsCallback for local video statistics.1.17
onRtcRemoteVideoStatsCallback for remote video statistics.1.17
onRtcRemoteAudioStatsRemote audio statistics.2.1
onRtcLocalAudioStatsLocal audio statistics.2.1
onMediaExtensionMsgReceivedCallback for receiving media extension messages.1.17.1
onUplinkChannelMessageNotification of the result of sending a message from the client to the server.2.1
onAudioFocusChangeCallback for the result of an audio focus change.1.17
onAudioRouteChangedCallback for when the audio route changes.2.1
onMessageSignaling channel for the SaaS layer.2.1
onChannelRelayStateChangedCross-channel co-streaming state changes.2.1
onChannelRelayEventCross-channel co-streaming events.2.1
onRemoteVideoChangedCallback for remote video stream changes.2.4
AliRtcVideoObserver: Callbacks for raw video data.
APIDescriptionMinimum supported version
onLocalVideoSampleSubscribed local captured video data.1.17
onRemoteVideoSampleSubscribed remote video data.1.17
onPreEncodeVideoSampleSubscribed local pre-encoding video data.2.1
onGetVideoFormatPreferenceVideo data output format.2.1
onGetObservedFramePositionVideo data output position.2.1
onGetIfUserFetchObserverDataIndicates whether the video output data is fetched by the user.2.4
onGetVideoAlignmentVideo data output alignment.2.4
onGetObserverDataMirrorAppliedIndicates whether the video output data requires mirroring.2.4
onGetSmoothRenderingEnabledIndicates whether the pulled video stream data is output smoothly.2.4
AliRtcAudioObserver: Callbacks for raw audio data.
APIDescriptionMinimum supported version
onCaptureRawDataLocal captured audio data.1.17
onCaptureDataLocal ingested audio data.1.17
onRenderDataLocal subscribed audio data.1.17
onPlaybackAudioFrameBeforeMixingAudio data of a specified user before mixing.2.1
AliRtcAudioVolumeObserver: Callbacks for audio volume.
APIDescriptionMinimum supported version
onAudioVolumeCallback for user audio volume.1.16.2
onActiveSpeakerThe current subscribed speaker.2.1
AliRtcTextureObserver: Callbacks for video texture.
APIDescriptionMinimum supported version
onTextureCreateCallback for video GL texture creation.1.15
onTextureUpdateCallback for video GL texture updates.1.15
onTextureDestroyCallback for video GL texture destruction.1.15

Details

  • onJoinChannelResult: Callback for the result of joining a channel.
    public void onJoinChannelResult(int result, String channel, int elapsed);
    ParameterTypeDescription
    resultintThe result of joining the channel. 0 indicates success. A non-zero value indicates an error. For more information, see Error codes.
    channelStringThe channel ID.
    elapsedintThe time elapsed to join the channel, in milliseconds.
  • onLiveStreamingSignalingResult: Callback for low-latency interactive stream pulling.
    public void onLiveStreamingSignalingResult(int result);
    ParameterTypeDescription
    resultintThe result of pulling the live stream. 0 indicates success. A non-zero value indicates failure.
  • onLeaveChannelResult: Callback for the result of leaving a channel.

    The SDK returns this callback after you call the leaveChannel method. If you destroy the SDK instance immediately after leaving the channel, you will not receive this callback.

    public void onLeaveChannelResult(int result, AliRtcEngine.AliRtcStats stats);
    ParameterTypeDescription
    resultintThe result of leaving the channel. 0 indicates success. A non-zero value indicates an error.
    statsAliRtcStatsA summary of data statistics for the session in the channel.
  • onAudioPublishStateChanged: Callback for changes in the audio stream ingest state.
    public void onAudioPublishStateChanged(AliRtcEngine.AliRtcPublishState oldState , 
                                           AliRtcEngine.AliRtcPublishState newState,
                                               int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous ingest state.
    newStateAliRtcPublishStateThe current ingest state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onVideoPublishStateChanged: Callback for changes in the video stream ingest state.
    public void onVideoPublishStateChanged(AliRtcEngine.AliRtcPublishState oldState , 
                                           AliRtcEngine.AliRtcPublishState newState, 
                                           int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous ingest state.
    newStateAliRtcPublishStateThe current ingest state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onDualStreamPublishStateChanged: Callback for changes in the secondary video stream ingest state.
    public void onDualStreamPublishStateChanged(AliRtcEngine.AliRtcPublishState oldState , 
                                                AliRtcEngine.AliRtcPublishState newState, 
                                                int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous ingest state.
    newStateAliRtcPublishStateThe current ingest state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onScreenSharePublishStateChanged: Callback for changes in the screen sharing ingest state.
    public void onScreenSharePublishStateChanged(AliRtcEngine.AliRtcPublishState oldState ,
                                                 AliRtcEngine.AliRtcPublishState newState,
                                                 int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous ingest state.
    newStateAliRtcPublishStateThe current ingest state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onAudioSubscribeStateChanged: Callback for changes in the audio subscription state.
    public void onAudioSubscribeStateChanged(String uid,
                                             AliRtcEngine.AliRtcSubscribeState oldState,
                                             AliRtcEngine.AliRtcSubscribeState newState,
                                             int elapseSinceLastState, String channel);
    ParameterTypeDescription
    uidStringThe remote user ID.
    oldStateAliRtcSubscribeStateThe previous subscription state.
    newStateAliRtcSubscribeStateThe current subscription state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onVideoSubscribeStateChanged: Callback for changes in the camera stream subscription state.
    public void onVideoSubscribeStateChanged(String uid,
                                             AliRtcEngine.AliRtcSubscribeState oldState,
                                             AliRtcEngine.AliRtcSubscribeState newState,
                                             int elapseSinceLastState, String channel);
    ParameterTypeDescription
    uidStringThe remote user ID.
    oldStateAliRtcSubscribeStateThe previous subscription state.
    newStateAliRtcSubscribeStateThe current subscription state.
    elapseSinceLastStateintThe time interval since the last state change.
    channelStringThe current channel ID.
  • onSubscribeStreamTypeChanged: Callback for changes in the subscribed camera stream type (high-resolution or low-resolution).
    public void onSubscribeStreamTypeChanged(String uid,
                                             AliRtcEngine.AliRtcVideoStreamType oldStreamType,
                                             AliRtcEngine.AliRtcVideoStreamType newStreamType,
                                             int elapseSinceLastState, String channel);
    ParameterTypeDescription
    uidStringThe remote user ID.
    oldStateAliRtcVideoStreamTypeThe previous subscription state.
    newStateAliRtcVideoStreamTypeThe current subscription state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onScreenShareSubscribeStateChanged: Callback for changes in the screen sharing stream subscription state.
    public void onScreenShareSubscribeStateChanged(String uid,
                                                   AliRtcEngine.AliRtcSubscribeState oldState,
                                                   AliRtcEngine.AliRtcSubscribeState newState,
                                                   int elapseSinceLastState, String channel);
    ParameterTypeDescription
    uidStringThe remote user ID.
    oldStateAliRtcSubscribeStateThe previous subscription state.
    newStateAliRtcSubscribeStateThe current subscription state.
    elapseSinceLastStateintThe time interval since the last state change, in milliseconds.
    channelStringThe current channel ID.
  • onNetworkQualityChanged: Callback for when network quality changes.
    public void onNetworkQualityChanged(String uid, AliRtcNetworkQuality upQuality, AliRtcNetworkQuality downQuality);
    ParameterTypeDescription
    uidStringThe ID of the user whose network quality has changed. An empty user ID indicates the local user. Other values indicate a remote user.
    upQualityAliRtcNetworkQualityThe uplink network quality.
    downQualityAliRtcNetworkQualityThe downlink network quality.
  • onNetworkQualityProbeTest: Callback for network quality probing.
    public void onNetworkQualityProbeTest(AliRtcNetworkQuality quality);
    ParameterTypeDescription
    networkQualityAliRtcNetworkQualityThe network quality.
  • onOccurWarning: Callback for warnings.

    You can ignore warning callbacks. These warnings do not affect normal operations.

    public void onOccurWarning(int warn, String message);
    ParameterTypeDescription
    warnintThe warning type.
    msgStringThe warning description.
  • onOccurError: Callback for errors.
    Note If the error parameter is 16908812 or 33620229, first call the destroy method to destroy the instance. Then, create a new SDK instance and call the joinChannel method to join the channel.
    public void onOccurError(int error, String message);
    ParameterTypeDescription
    errorintThe error type.
    msgStringThe error description.
  • onPerformanceLow: Callback for when the current device performance is low.
    public void onPerformanceLow();
  • onPerformanceRecovery: Callback for when the current device performance recovers.
    public void onPermormanceRecovery();
  • onConnectionLost: Callback for network disconnection.
    public void onConnectionLost();
  • onTryToReconnect: Callback for network reconnection attempts.
    public void onTryToReconnect();
  • onConnectionRecovery: Callback for successful network reconnection.
    public void onConnectionRecovery();
  • onConnectionStatusChange: Callback for changes in the network connection status.
    public void onConnectionStatusChange(AliRtcEngine.AliRtcConnectionStatus status,
                                         AliRtcEngine.AliRtcConnectionStatusChangeReason reason);
    ParameterTypeDescription
    statusAliRtcConnectionStatusThe current network connection status.
    reasonAliRtcConnectionStatusChangeReasonThe reason for the network connection status change.
  • onUpdateRoleNotify: Callback for when the user role changes.
    public void onUpdateRoleNotify(AliRtcEngine.AliRTCSdkClientRole oldRole, 
                                   AliRtcEngine.AliRTCSdkClientRole newRole);
    ParameterTypeDescription
    oldRoleAliRTCSdkClientRoleThe role before the switch.
    newRoleAliRTCSdkClientRoleThe role after the switch.
  • onSnapshotComplete: Callback for snapshot completion.
    public void onSnapshotComplete(String userId, AliRtcVideoTrack trackType,
                                   Bitmap bitmap, boolean success);
    ParameterTypeDescription
    userIdStringThe user ID.
    trackTypeAliRtcVideoTrackThe video track for the snapshot.
    bitmapBitmapThe returned Bitmap object of the snapshot.
    successbooleanIndicates whether the snapshot was successful.
  • onPublishLiveStreamStateChanged: Callback for changes in the bypass stream ingest state.
    public void onPublishLiveStreamStateChanged(String streamUrl, AliRtcLiveTranscodingState state, AliEngineLiveTranscodingErrorCode errorCode);
    ParameterTypeDescription
    streamUrlStringThe ingest URL.
    stateAliRtcLiveTranscodingStateThe bypass live streaming state.
    errorCodeAliEngineLiveTranscodingErrorCodeThe error code.
  • onPublishTaskStateChanged: Callback for changes in the bypass task state.
    public void onPublishTaskStateChanged(String streamUrl, AliRtcTrascodingPublishTaskStatus state);
    ParameterTypeDescription
    streamUrlStringThe ingest URL.
    stateAliRtcTrascodingPublishTaskStatusThe bypass live stream ingest task status.
  • onRemoteUserOnLineNotify: Callback for when a remote user goes online.
    public void onRemoteUserOnLineNotify(String uid, int elapsed);
    ParameterTypeDescription
    uidStringThe remote user ID.
    elapsedintThe time elapsed for the user to join the channel, in milliseconds.
  • onRemoteUserOffLineNotify: Callback for when a remote user goes offline.
    public void onRemoteUserOffLineNotify(String uid, AliRtcUserOfflineReason reason);
    ParameterTypeDescription
    uidStringThe remote user ID.
    reasonAliRtcUserOfflineReasonThe reason why the user went offline.
  • onRemoteTrackAvailableNotify: Callback for when a remote user's audio or video stream becomes available.
    public void onRemoteTrackAvailableNotify(String uid, AliRtcAudioTrack audioTrack,
                                                        AliRtcVideoTrack videoTrack);
    ParameterTypeDescription
    uidStringThe remote user ID.
    audioTrackAliRtcAudioTrackThe remote user's audio stream after the change.
    videoTrackAliRtcVideoTrackThe remote user's video stream after the change.
  • onFirstRemoteVideoFrameDrawn: Callback for when the first frame of a remote video stream is rendered.
    public void onFirstRemoteVideoFrameDrawn(String uid,AliRtcVideoTrack videoTrack,
                                                 int width, int height, int elapsed);
    ParameterTypeDescription
    uidStringThe remote user ID.
    videoTrackAliRtcVideoTrackThe type of video stream being rendered.
    widthintThe video width.
    heightintThe video height.
    elapsedintThe total time elapsed, in milliseconds.
  • onFirstLocalVideoFrameDrawn: Callback triggered when the first local video frame is displayed in the preview.
    public void onFirstLocalVideoFrameDrawn(int width, int height, int elapsed);
    ParameterTypeDescription
    widthintThe video width.
    heightintThe video height.
    elapsedintThe total time elapsed, in milliseconds.
  • onFirstVideoFrameReceived: Callback for when the first video frame is received from a remote user.
    public void onFirstVideoFrameReceived(String uid, AliRtcVideoTrack videoTrack, int timeCost);
    ParameterTypeDescription
    uidStringThe remote user ID.
    videoTrackAliRtcVideoTrackThe type of video stream being rendered.
    timeCostintThe time elapsed, in milliseconds.
  • onFirstVideoPacketSent: Callback for when the first video packet is sent.
    public void onFirstVideoPacketSent(String userId, AliRtcVideoTrack videoTrack, int timeCost);
    ParameterTypeDescription
    userIdStringThe user ID.
    videoTrackAliRtcVideoTrackSends a video stream.
    timeCostintThe time elapsed, in milliseconds.
  • onFirstAudioPacketSent: Callback for when the first audio packet is sent.
    public void onFirstAudioPacketSent(String userId, int timeCost);
    ParameterTypeDescription
    userIdStringThe user ID.
    timeCostintThe time elapsed, in milliseconds.
  • onFirstVideoPacketReceived: Callback for when the first video packet is received.
    public void onFirstVideoPacketReceived(String userId, AliRtcVideoTrack videoTrack, int timeCost);
    ParameterTypeDescription
    userIdStringThe user ID.
    videoTrackAliRtcVideoTrackAccepts video streams.
    timeCostintThe time elapsed, in milliseconds.
  • onFirstAudioPacketReceived: Callback for when the first audio packet is received.
    public void onFirstAudioPacketReceived(String userId,int timeCost);
    ParameterTypeDescription
    userIdStringThe user ID.
    timeCostintThe time elapsed, in milliseconds.
  • onFirstRemoteAudioDecoded: Callback for when the first frame of remote audio is decoded.
    public void onFirstRemoteAudioDecoded(String uid, int timeCost);
    ParameterTypeDescription
    uidStringThe remote user ID.
    elapsedintThe time elapsed, in milliseconds.
  • onBye: Callback for when you are removed from a channel by the server or when the channel is closed.
    public void onBye(int code);
    ParameterTypeDescription
    codeintThe onBye type. For more information, see AliRtcOnByeType.
  • onAliRtcStats: Callback for current session statistics.
    public void onAliRtcStats(AliRtcEngine.AliRtcStats stats);

    The SDK triggers this statistics callback every two seconds.

    ParameterTypeDescription
    statsAliRtcStatsThe session statistics.
  • onUserAudioMuted: Callback that notifies you when a remote user stops sending an audio stream.
    public void onUserAudioMuted(String uid ,boolean isMute);
    ParameterTypeDescription
    uidStringThe user who performed the muteAudio action.
    isMutebooleanIndicates whether the user is muted. Valid values:
    • true: Muted.
    • false: Unmuted.
  • onUserVideoMuted: Callback that notifies you when a remote user stops sending a video stream. When this occurs, black video frames are sent.
    public void onUserVideoMuted(String uid ,boolean isMute);
    ParameterTypeDescription
    uidStringThe user who performed the enableLocalVideo action.
    isMutebooleanIndicates whether to send black frames. Valid values:
    • true: Ingests black frames.
    • false: Ingests normally.
  • onUserVideoEnabled: Callback that notifies you when a remote user enables or disables their camera stream capture.
    public void onUserVideoEnabled(String uid, boolean isMute);
    ParameterTypeDescription
    uidStringThe remote user ID.
    isMutebooleanIndicates whether camera stream capture is enabled. Valid values:
    • true: Enables camera stream capture.
    • false: Disables camera stream capture.
  • onUserAudioInterruptedBegin: Callback for when a user's audio is interrupted.
    public void onUserAudioInterruptedBegin(String uid);
    ParameterTypeDescription
    uidStringThe user whose audio is interrupted.
  • onUserAudioInterruptedEnded: Callback for when a user's audio interruption ends.
    public void onUserAudioInterruptedEnded(String uid);
    ParameterTypeDescription
    uidStringThe user whose audio was interrupted.
  • onUserWillResignActive: Callback for when a remote user's application moves to the background.
    public void onUserWillResignActive(String uid);
    ParameterTypeDescription
    uidStringThe user ID.
  • onUserWillBecomeActive: Callback for when a remote user's application returns to the foreground.
    public void onUserWillBecomeActive(String uid);
    ParameterTypeDescription
    uidStringThe user ID.
  • onAudioPlayingStateChanged: Callback for changes in the local audio accompaniment playback state.
    public void onAudioPlayingStateChanged(AliRtcEngine.AliRtcAudioPlayingStateCode playState, 
                                           AliRtcEngine.AliRtcAudioPlayingErrorCode errorCode);
    ParameterTypeDescription
    playStateAliRtcAudioPlayingStateCodeThe current playback state.
    errorCodeAliRtcAudioPlayingErrorCodeThe error code.
  • onRemoteAudioAccompanyStarted: Callback for when a remote user starts playing audio accompaniment.
    public void onRemoteAudioAccompanyStarted(String uid);
    ParameterTypeDescription
    uidStringThe user ID.
  • onRemoteAudioAccompanyFinished: Callback for when a remote user finishes playing audio accompaniment.
    public void onRemoteAudioAccompanyFinished(String uid);
    ParameterTypeDescription
    uidStringThe user ID.
  • onAudioEffectFinished: Callback for when a local sound effect finishes playing.
    void OnAudioEffectFinished(int soundId);
    ParameterTypeDescription
    soundIdintThe ID that the user assigned to the sound effect file.
  • onMediaRecordEvent: Callback for recording events.
    public void onMediaRecordEvent(int event, String filePath);
    ParameterTypeDescription
    eventintThe recording event. Valid values:
    • 0: Recording started.
    • 1: Recording ended.
    • 2: Failed to open the file.
    • 3: Failed to write to the file.
    filePathStringThe path of the recording file.
  • onRtcLocalVideoStats: Local video statistics.
    public void onRtcLocalVideoStats(AliRtcEngine.RtcLocalVideoStats localVideoStats);

    The SDK triggers this statistics callback every two seconds.

    ParameterTypeDescription
    localVideoStatsRtcLocalVideoStatsThe local video statistics.
  • onRtcRemoteVideoStats: Remote video statistics.
    public void onRtcRemoteVideoStats(AliRtcEngine.RtcRemoteVideoStats aliRtcStats);

    The SDK triggers this statistics callback every two seconds.

    ParameterTypeDescription
    remoteVideoStatsRtcRemoteVideoStatsThe remote video statistics.
  • onRtcRemoteAudioStats: Remote audio statistics.
    public void onRtcRemoteAudioStats(AliRtcEngine.RtcRemoteAudioStats aliRtcStats);

    The SDK triggers this statistics callback every two seconds.

    ParameterTypeDescription
    aliRtcStatsRtcRemoteAudioStatsThe remote audio statistics.
  • onRtcLocalAudioStats: Local audio statistics.
    public void onRtcLocalAudioStats(AliRtcEngine.RtcLocalAudioStats aliRtcStats);

    The SDK triggers this statistics callback every two seconds.

    ParameterTypeDescription
    aliRtcStatsRtcLocalAudioStatsThe local audio statistics.
  • onMediaExtensionMsgReceived: Callback for when a media extension message is received.
    public void onMediaExtensionMsgReceived(String uid, byte[] message);

    When a user in the channel sends custom data, you can receive the data through this callback.

    ParameterTypeDescription
    uidStringThe user ID.
    messagebyte[]The received custom data.
  • onUplinkChannelMessage: Callback for the SaaS layer that provides the result of sending a message from the client to the server.
    public void onUplinkChannelMessage(int result, String contentType, String content);
    ParameterTypeDescription
    resultintThe result of sending the message.
    contentTypeStringThe signaling type.
    contentStringThe signaling content.
  • onAudioFocusChange: Callback that notifies you of an audio focus change.
    public void onAudioFocusChange(int focusChange);

    The SDK manages audio focus internally. If an external source takes audio focus, you must request it again after receiving this callback from the SDK.

    ParameterTypeDescription
    focusChangeintThe audio status.
  • onAudioRouteChanged: Callback for when the audio route changes.
    public void onAudioRouteChanged(AliRtcEngine.AliRtcAudioRouteType routing);
    ParameterTypeDescription
    routingAliRtcAudioRouteTypeThe currently used audio route.
  • onMessage: Callback for receiving messages from the SaaS layer signaling channel.
    public void onMessage(String tid, String contentType, String content);
    ParameterTypeDescription
    tidStringThe signaling ID.
    contentTypeStringThe signaling type.
    contentStringThe signaling content.
  • onChannelRelayStateChanged: Callback for changes in the cross-channel media relay state.
    public void onChannelRelayStateChanged(int state, int code, String message);
    ParameterTypeDescription
    stateintThe current co-streaming state.
    codeintThe current status code.
    msgStringThe status description.
  • onChannelRelayEvent: Callback for cross-channel media relay events.
    public void onChannelRelayEvent(int event);
    ParameterTypeDescription
    eventintThe status code.
  • onRemoteVideoChanged: Callback for changes in the remote video stream.
    public void onRemoteVideoChanged(String uId, AliRtcVideoTrack videoTrack, AliRtcVideoState videoState, AliRtcVideoReason videoReason);
    ParameterTypeDescription
    uIdStringThe user ID.
    videoTrackAliRtcVideoTrackThe video stream type.
    videoStateAliRtcVideoStateThe change in the video stream state.
    videoReasonAliRtcVideoReasonThe reason that triggered the change in the video stream state.
  • onLocalVideoSample: Callback that provides the captured local video data.
    public boolean onLocalVideoSample(AliVideoSourceType sourceType,
                                      AliRtcVideoSample videoSample){return false;}

    If you return true, the data is written back to the SDK. This applies only to the I420 format.

    If you return false, the data is not written back to the SDK.

    ParameterTypeDescription
    sourceTypeAliVideoSourceTypeThe video stream type.
    videoSampleAliRtcVideoSampleThe frame data.
  • onRemoteVideoSample: Callback that provides the subscribed remote video data.
    public boolean onRemoteVideoSample(String uid, AliVideoSourceType sourceType, 
                                       AliRtcVideoSample videoSample){return false;}

    If you return true, the data is written back to the SDK. This applies only to the I420 format.

    If you return false, the data is not written back to the SDK.

    ParameterTypeDescription
    uidStringThe user ID.
    sourceTypeAliVideoSourceTypeThe video stream type.
    videoSampleAliRtcVideoSampleThe frame data.
  • onPreEncodeVideoSample: Callback that provides the local video data before encoding.
    public boolean onPreEncodeVideoSample(AliVideoSourceType sourceType, 
                                          AliRtcVideoSample videoRawData){return false;}

    If you return true, the data is written back to the SDK. This applies only to the I420 format.

    If you return false, the data is not written back to the SDK.

    ParameterTypeDescription
    videoSourceAliVideoSourceTypeThe video stream type.
    videoRawDataAliRtcVideoSampleThe frame data.
  • onGetVideoFormatPreference: Callback to specify the preferred output format for video data.
    public AliEngineVideoFormat onGetVideoFormatPreference()
    {return AliEngineVideoFormat.AliEngineVideoFormatI420;}
  • onGetObservedFramePosition: Callback to specify the position in the pipeline from which to output video data.
    public int onGetObservedFramePosition()
    {return AliEngineVideoObserPosition.AliEnginePositionPostCapture.getValue() | 
    AliEngineVideoObserPosition.AliEnginePositionPreRender.getValue();}
  • onGetIfUserFetchObserverData: Callback to specify whether the user fetches the video data.
    public boolean onGetIfUserFetchObserverData(){return false;}
    Return value

    true: The user fetches the video data. false: The SDK provides the video data through a callback. The default value is false.

  • onGetVideoAlignment: Callback to specify the memory alignment for the video data output.
    public int onGetVideoAlignment(){
                return AliRtcVideoObserAlignment.AliRtcAlignmentDefault.getValue();
            }
    Return value

    Returns the data alignment for the raw data callback. The default value is AliRtcAlignmentDefault.

  • onGetObserverDataMirrorApplied: Callback to specify whether mirroring is applied to the output video data.
    public boolean onGetObserverDataMirrorApplied(){return false;}
    Return value

    true: Mirroring is applied to the output video data. false: Mirroring is not applied to the output video data. The default value is false.

  • onGetSmoothRenderingEnabled: Callback to specify whether to enable smooth rendering for the output video data.
    public boolean onGetSmoothRenderingEnabled(){return false;}
    Return value

    true: Smooth rendering is enabled. false: The video data is output directly. The default value is false.

    Note Smooth rendering only takes effect if onGetIfUserFetchObserverData returns false.
  • onCaptureRawData: Callback that provides the captured raw local audio data.
    void onCaptureRawData(AliRtcAudioSample aliAudioSample);
    ParameterTypeDescription
    aliAudioSampleAliRtcAudioSampleThe audio data.
  • onCaptureData: Callback that provides the local audio data for stream ingest.
    void onCaptureData(AliRtcAudioSample aliAudioSample);
    ParameterTypeDescription
    aliAudioSampleAliRtcAudioSampleThe audio data.
  • onRenderData: Callback that provides the remote audio data for playback.
    void onRenderData(AliRtcAudioSample aliAudioSample);
    ParameterTypeDescription
    aliAudioSampleAliRtcAudioSampleThe audio data.
  • onPlaybackAudioFrameBeforeMixing: Callback that provides the audio data of a single remote user before mixing.
    void onPlaybackAudioFrameBeforeMixing(String uid, AliRtcAudioSample aliAudioSample);
    ParameterTypeDescription
    uidStringThe user ID.
    aliAudioSampleAliRtcAudioSampleThe audio data.
  • onAudioVolume: Callback that reports the volume, voice status, and user ID of subscribed users.
    public void onAudioVolume(List<AliRtcEngine.AliRtcAudioVolume> speakers, int totalVolume);
    ParameterTypeDescription
    speakersList<AliRtcEngine.AliRtcAudioVolume>An array of user volume information, including the user ID, voice status, and volume.

    When the user ID is 0, it indicates the local speaker.

    totalVolumeintThe total volume after mixing. The range is [0, 255].

    In the local user's callback, totalVolume is the volume of the local user after mixing. In a remote user's callback, totalVolume is the total volume of all speakers after mixing.

  • onActiveSpeaker: Callback that reports the currently active speaker.
    public void OnActiveSpeaker(String uid);
    ParameterTypeDescription
    uidStringThe speaker's user ID. When the user ID is 0, it indicates the local speaker. This returns the ID of the user with the loudest voice over the current time period, not the user with the loudest instantaneous voice.
  • onTextureCreate: Callback for when a video GL texture is created.
    void onTextureCreate(long context);
    ParameterTypeDescription
    contextlongThe OpenGL thread-related context variable.
  • onTextureUpdate: Callback for when a video GL texture is updated.
    int onTextureUpdate(int textureId, int width, int height, AliRtcVideoSample videoSample);
    ParameterTypeDescription
    textureIdintThe ID of the video data texture type.
    widthintThe width.
    heightintThe height.
    videoSampleAliRtcVideoSampleThe video data.
  • onTextureDestroy: Callback for when a video GL texture is destroyed.
    void onTextureDestroy();