AliRtcEngine interface

更新时间:
复制 MD 格式

This topic describes the AliRtcEngine interface for the Android software development kit (SDK).

Contents

Note The `ALI_RTC_INTERFACE` class is deprecated in versions 1.17 and later. Its parameters and enumeration classes were migrated to the `AliRtcEngine` class.

Basic interfaces

APIDescriptionSupported in the versions above
setH5CompatibleModeSets the H5 compatibility mode.1.1
getH5CompatibleModeChecks whether the current mode is H5 compatible.1.1
getInstanceCreates an AliRTCEngine instance. Only one instance can exist at a time. This method must be called in the main thread.1.1
getInstanceCreates an AliRTCEngine instance and lets you configure special SDK features by passing parameters. Only one instance can exist at a time. This method must be called in the main thread.1.1
setRtcEngineEventListenerSets a listener for local user behavior callbacks.1.1
setRtcEngineNotifySets a listener for remote user behavior notifications.1.1
destroyDestroys the SDK.1.1
uploadLogUploads logs.1.15

Channel-related interfaces

APIDescriptionSupported in this and later versions
setAutoPublishSets whether to automatically publish and subscribe to streams. Use the setAutoPublishSubscribe interface instead.1.1
joinChannelJoins a channel.1.1
leaveChannelLeaves a channel.1.1
isInCallChecks whether the user is in a channel.1.1
setChannelProfileSets the channel mode.1.15
setAutoPublishSubscribeSets whether to automatically publish or subscribe to streams.1.17

Publishing-related interfaces

APIDescriptionSupported in the preceding versions
isAutoPublishQueries whether the current mode is auto-publish.1.1
configLocalCameraPublishSets whether to allow publishing the camera stream.1.1
isLocalCameraPublishEnabledQueries whether publishing the camera stream is allowed.1.1
configLocalScreenPublishSets whether to allow publishing the screen stream.1.1
isLocalScreenPublishEnabledQueries whether publishing the screen stream is allowed.1.1
configLocalAudioPublishSets whether to allow publishing the audio stream.1.1
isLocalAudioPublishEnabledQueries whether publishing the audio stream is allowed.1.1
configLocalSimulcastSets whether to allow publishing the secondary video stream.1.1
isLocalSimulcastEnabledQueries whether publishing the secondary video stream is allowed.1.1
publishManually publishes video and audio streams.1.1

Subscription-related interfaces

APIDescriptionSupported in the versions above
isAutoSubscribeQueries whether the current mode is auto-subscribe.1.1
configRemoteCameraTrackSets whether to subscribe to the remote camera stream.1.1
configRemoteScreenTrackSets whether to subscribe to the remote screen stream.1.1
configRemoteAudioSets whether to subscribe to the remote audio stream.1.1
subscribeManually subscribes to video and audio streams.1.1
registerTexturePreObserverSubscribes to pre-processing texture data.1.15
unRegisterTexturePreObserverUnsubscribes from pre-processing texture data.1.15

Video-related interfaces

APIDescriptionSupported in the versions above
setVideoProfileSets the parameters for the video stream.1.1
getVideoProfileQueries the current video stream parameters.1.1
setLocalViewConfigSets the rendering window and drawing parameters for the local preview.1.1
muteLocalCameraSets whether to stop publishing the local video stream.1.1
setRemoteViewConfigSets the rendering window and drawing parameters for the remote video.1.1
switchCameraSwitches between the front and rear cameras.1.1
getCurrentCameraTypeGets the current camera type.1.1
setPreCameraTypeSets the default camera direction.1.1
getPreCameraTypeGets the default camera direction.1.1
setCameraZoomSets camera parameters.1.1
isCameraOnChecks whether the camera is on.1.1
isCameraSupportExposurePointChecks whether the camera supports manual exposure.1.14
isCameraSupportFocusPointSpecifies whether the camera supports manual focus.1.14
setCameraExposurePointSets the coordinates for manual exposure.1.14
setCameraFocusPointSets the coordinates for manual focus.1.14
isCameraFlashChecks whether the flash is on.1.14
getCameraZoomGets the camera's zoom value.1.14
registerPreprocessVideoObserverRegisters for facial recognition pre-processing.1.14
muteAllRemoteVideoRenderingMutes or unmutes the rendering of all remote video tracks.1.16.2
setBeautyEffectSets basic retouching effects.1.17.9
registerVideoSampleObserverRegisters for video data callbacks.1.17
unRegisterVideoSampleObserverUnregisters from video data callbacks.1.17
setVideoEncoderConfigurationSets video encoding properties.1.17.31
isCameraAutoFocusChecks whether autofocus is enabled.1.17
registerVideoRawDataInterfaceRegisters the external video data callback interface.1.17
unRegisterVideoRawDataInterfaceUnregisters the external video data callback interface.1.17
createRenderSurfaceViewCreates a SurfaceView rendering view.1.17.39
createRenderTextureViewCreates a TextureView rendering view.1.17.39
enableLocalVideoDisables or re-enables local video capture.1.17.39

Audio-related interfaces

APIDescriptionSupported in the preceding versions
setAudioOnlyModeSets the mode to audio-only or audio-and-video.1.1
isAudioOnlyQueries whether the current mode is audio-only.1.1
muteRemoteAudioPlayingSets whether to stop playing the remote audio stream.1.1
enableSpeakerphoneSwitches between earpiece and speakerphone output.1.1
isSpeakerOnQueries whether the speakerphone is on.1.1
startAudioCaptureStarts audio capture.1.11
stopAudioCaptureStops audio capture.1.11
startAudioPlayerStarts audio playback.1.11
stopAudioPlayerStops audio playback.1.11
enableEarBackEnables in-ear monitoring.1.15
startAudioAccompanyStarts playing audio accompaniment.1.15
pauseAudioAccompanyPauses audio accompaniment.1.15
resumeAudioAccompanyResumes audio accompaniment.1.15
stopAudioAccompanyStops playing audio accompaniment.1.15
setAudioAccompanyPublishVolumeSets the publishing volume for audio accompaniment.1.15
setAudioAccompanyPlayoutVolumeSets the local volume for audio accompaniment.1.15
getAudioAccompanyPublishVolumeGets the publishing volume for audio accompaniment.1.15
getAudioAccompanyPlayoutVolumeGets the local volume for audio accompaniment.1.15
setAudioAccompanyVolumeSets the publishing and local volumes for audio accompaniment.1.15
preloadAudioEffectPreloads a sound effect.1.15
unloadAudioEffectPurges a preloaded sound effect.1.15
playAudioEffectStarts playing a sound effect.1.15
setAudioEffectPublishVolumeSets the publishing volume for a sound effect.1.15
getAudioEffectPublishVolumeGets the publishing volume for a sound effect.1.15
setAudioEffectPlayoutVolumeSets the local volume for a sound effect.1.15
getAudioEffectPlayoutVolumeGets the local volume for a sound effect.1.15
pauseAudioEffectPauses a sound effect.1.15
resumeAudioEffectResumes a sound effect.1.15
stopAudioEffectStops a sound effect.1.15
setEarBackVolumeSets the in-ear monitoring volume.1.15
setRecordingVolumeSets the recording volume.1.16
setPlayoutVolumeSets the playback volume.1.16
muteAllRemoteAudioPlayingStops playing all remote audio streams.1.16.2
registerAudioVolumeObserverRegisters for volume callbacks.1.16.2
unRegisterAudioVolumeObserverUnregisters from volume callbacks.1.16.2
startRecordStarts recording to a file.1.17
stopRecordStops recording to a file.1.17
setAudioEffectReverbModeSets the reverb effect mode.1.17
setAudioEffectReverbParamTypeSets the reverb effect type.1.17
setVolumeCallbackIntervalMsSets the volume callback frequency and smoothing coefficient.1.17
setExternalAudioSourceSets whether to use external audio data as the input source for stream ingest.1.17.9
pushExternalAudioFrameRawDataInputs audio data.1.17.9
setExternalAudioVolumeSets the external audio input volume.1.17.9
getExternalAudioVolumeGets the external audio input volume.1.17.9
setMixedWithMicSets whether to mix external audio input with audio captured by the microphone.1.17.9
setExteranlAudioRenderSets whether to enable playback of external audio input.1.17.9
pushExternalAudioRenderRawDataInputs audio playback data.1.17.9
getCurrentClientRoleGets the current role.1.17.9
setSubscribeAudioNumChannelSets the number of sound channels for the audio callback.1.17.13
setSubscribeAudioSampleRateSets the audio sampling rate for the audio callback.1.17.13
requestAudioFocusRequests audio focus.1.17.19
abandonAudioFocusAbandons audio focus.1.17.19
registerAudioObserverRegisters for audio data callbacks.1.17
muteLocalMicCaptures local audio.1.17.30
getAudioAccompanyDurationGets the duration of the audio accompaniment file.1.17.30
getAudioAccompanyCurrentPositionGets the playback progress of the music file.1.17.30
setAudioAccompanyPositionSets the playback position of the audio file.1.17.30
stopAllAudioEffectsStops playing all sound effects.1.17.30
setAllAudioEffectsPublishVolumeSets the publishing volume for all sound effects.1.17.30
setAllAudioEffectsPlayoutVolumeSets the local playback volume for all sound effects.1.17.30
pauseAllAudioEffectsPauses all sound effects.1.17.30
resumeAllAudioEffectsResumes playing all sound effects.1.17.30
unRegisterAudioObserverUnregisters from audio data callbacks.1.17

Preview interfaces

APIDescriptionThe preceding versions are supported
startPreviewStarts the local preview.1.1
stopPreviewStops the local preview.1.1
enableHighDefinitionPreviewSets whether to enable high-definition preview.1.16

Remote user query interfaces

APIDescriptionSupported since
getOnlineRemoteUsersGets the list of online remote users.1.1
getUserInfoQueries remote user information.1.1
isUserOnlineQueries whether a user is online.1.1
getMediaInfoWithUserIdGets media stream information.1.9

Other interfaces

APIDescriptionSupported in the above versions
setLogLevelSets the log level.1.1
getSdkVersionGets the SDK version number.1.1
setClientRoleSets the user role.1.16
setLogDirPathSets the path to save SDK log files.1.16.2
setDeviceOrientationModeSets the device orientation (portrait or landscape).1.16.2
startNetworkQualityProbeTestStarts a network quality probe test.1.16.2
stopNetworkQualityProbeTestStops a network quality probe test.1.16.2
postFeedbackSubmits SDK issue feedback.1.17.13
sendMediaExtensionMsgSends a media extension message.1.17.1
respondMessageNotificationSends a message notification.1.17
refreshAuthInfoRefreshes the token.1.17.41

API details

  • setH5CompatibleMode: Sets whether to enable H5 compatibility.

    AliRtcEngine.setH5CompatibleMode(int enable)           
    Parameter description
    NameTypeDescription
    enableint0 indicates not compatible with H5. 1 indicates compatible with H5. The default is not compatible with H5.
    Important You must call this method before you create an `AliRtcEngine` instance.
  • getH5CompatibleMode: Checks whether H5 compatibility is enabled.

    public static int getH5CompatibleMode()

    Return value

    A value of 1 indicates compatibility. A value of 0 indicates incompatibility.

    Important You must call this method after you create an `AliRtcEngine` instance.
  • getInstance: Creates an `AliRtcEngine` instance.

    public static AliRtcEngineImpl getInstance(Context context)          
    Parameter description
    NameTypeDescription
    contextContextThe context of the Android Activity.
    Important Only one instance can exist at a time. You must call this method in the main thread.
  • getInstance: Creates an `AliRtcEngine` instance and lets you configure special SDK features by passing parameters.

    public static AliRtcEngineImpl getInstance(Context context, String extras)
    Parameter description
    NameTypeDescription
    contextContextThe context of the Android Activity.
    extrasStringConfigures special SDK features using JSON. For more information, see extras features.
    Important Only one instance can exist at a time. You must call this method in the main thread.
  • setRtcEngineEventListener: Sets a listener for local user event callbacks.

    public abstract void setRtcEngineEventListener(AliRtcEngineEventListener listener)                    
    Parameter description
    NameTypeDescription
    listenerAliRtcEngineEventListenerThe listener that receives callback events.
  • setRtcEngineNotify: Sets a listener for remote user event notifications.

    public abstract void setRtcEngineNotify(AliRtcEngineNotify engineNotify)               
    Parameter description
    NameTypeDescription
    engineNotifyAliRtcEngineNotifyThe listener that receives notifications.
  • destroy: Destroys the SDK instance.

    In versions 1.15 and later, you can destroy the SDK only by calling the `destroy` method.

    In versions earlier than 1.15, the `AliRtcEngine` instance is destroyed when you leave a channel. To perform subsequent operations, such as joining another channel, you must call `getInstance` again to re-initialize the `AliRtcEngine` instance.

    public abstract void destroy();                  
    Important You must call this method in the main thread.
  • uploadLog: Uploads log files.

    AliRtcEngine.uploadLog();
    Important This method is `static` in versions 1.17 and later. In earlier versions, use public abstract void uploadLog();.
  • setAutoPublish: Controls whether to automatically publish and subscribe to streams.

    public int setAutoPublish(boolean autoPub, boolean autoSub);
    Parameters
    NameTypeDescription
    autoPubboolean`true`: Auto-publish. `false`: Manual publish. The default is auto-publish.
    autoSubboolean`true`: Auto-subscribe. `false`: Manual subscribe. The default is auto-subscribe.

    Return value

    A return value of 0 indicates that the method call succeeded. Any other value indicates that it failed.

    Important You must set this method before joining a channel.
  • joinChannel: Joins a channel.

    After you successfully join a channel, you must call `leaveChannel` to leave the current channel before you can join another one. If joining a channel fails, you do not need to call `leaveChannel` before you retry.

    public abstract void joinChannel(AliRtcAuthInfo authInfo, String userName)                    
    Parameter description
    NameTypeDescription
    authInfoAliRtcAuthInfoAuthentication information.
    userNameStringThe user's display name, not the user ID.
  • leaveChannel: Leaves a channel.

    public abstract void leaveChannel()                          

    In versions 1.15 and later, calling `leaveChannel` does not destroy the instance.

    In versions earlier than 1.15, the `AliRtcEngine` instance is destroyed when you leave a channel. To perform subsequent operations, such as joining another channel, you must call `getInstance` again to re-initialize the `AliRtcEngine` instance.

    • For SDK versions 1.8 and later, call the following method.
      public abstract void leaveChannel()                          
    • For SDK versions 1.7 and earlier, you must add the timeout parameter. We recommend that you set this parameter to 1000, which specifies a timeout of 1 second for the method call.
      public abstract void leaveChannel(long timeout)                          
  • isInCall: Checks whether the user is in a channel.

    public abstract boolean isInCall()                  

    Return value

    Returns `true` if the user is in a channel or `false` otherwise.

  • setChannelProfile: Sets the channel mode.

    public abstract int setChannelProfile(AliRTCSDK_Channel_Profile profile);
    Parameter description
    NameTypeDescription
    profileAliRTCSDK_Channel_ProfileThe channel mode type. The default is communication mode.

    Return value

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

    Important You can call this method only before `joinChannel`. You cannot reset the channel mode during a call. You can reset the channel mode after you call `leaveChannel`.
  • setAutoPublishSubscribe: Sets whether to automatically publish or subscribe to streams.

    public abstract int setAutoPublishSubscribe(boolean autoPub, boolean autoSub);
    Parameter description
    NameTypeDescription
    autoPubboolean`true`: Auto-publish. `false`: Manual publish. The default is auto-publish.
    autoSubboolean`true`: Auto-subscribe. `false`: Manual subscribe. The default is auto-subscribe.

    Return value

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

    Note You must call this method before joining a channel.
  • isAutoPublish: Checks whether auto-publish is enabled.

    public abstract boolean isAutoPublish()                  

    Return value

    true specifies automatic publishing, and false specifies manual publishing.

  • configLocalCameraPublish: Configures whether to publish the local camera stream.

    public abstract void configLocalCameraPublish(boolean enable)                
    Parameter description
    NameTypeDescription
    enableboolean`true` allows publishing the camera stream. `false` disallows it. The default is to allow publishing the camera stream.
    Important In manual publishing mode, you must call `publish` for this setting to take effect.
  • isLocalCameraPublishEnabled: Checks whether publishing the local camera stream is enabled.

    public abstract boolean isLocalCameraPublishEnabled()                   

    Return value

    A value of true indicates that it is allowed. A value of false indicates that it is not allowed.

  • configLocalScreenPublish: Configures whether to publish the local screen stream.

    public abstract void configLocalScreenPublish(boolean enable)                  
    Parameter description
    NameTypeDescription
    enableboolean`true` allows publishing the screen stream. `false` disallows it. The default is to not allow publishing the screen stream.
    Important In manual publishing mode, you must call `publish` for this setting to take effect.
  • isLocalScreenPublishEnabled: Checks whether publishing the local screen stream is enabled.

    public abstract boolean isLocalScreenPublishEnabled()                   

    Return value

    Returns `true` if publishing the screen stream is enabled or `false` if it is not.

  • configLocalAudioPublish: Configures whether to publish the local audio stream.

    public abstract void configLocalAudioPublish(boolean enable)          
    Parameter description
    NameTypeDescription
    enableboolean`true` allows publishing. `false` disallows it. The default is to allow publishing the audio stream.
    Important In manual publishing mode, you must call `publish` for this setting to take effect.
  • isLocalAudioPublishEnabled: Checks whether publishing the local audio stream is enabled.

    public abstract boolean isLocalAudioPublishEnabled()                
    Return value

    Returns `true` if publishing the audio stream is enabled or `false` if it is not.

  • configLocalSimulcast: Configures whether to publish the secondary video stream.

    public abstract int configLocalSimulcast(boolean enable, AliRtcVideoTrack track)        
    Parameter description
    NameTypeDescription
    enableboolean`true` allows publishing the secondary stream. `false` disallows it. The default is to allow publishing the secondary video stream.
    trackAliRtcVideoTrackThe stream type. Currently, only AliVideoTrackCamera (camera stream) is supported.

    Return value

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

    Important In manual publishing mode, you must call `publish` for this setting to take effect.
  • isLocalSimulcastEnabled: Checks whether publishing the secondary video stream is enabled.

    public abstract boolean isLocalSimulcastEnabled()                  

    Return value

    Returns `true` if publishing the secondary video stream is enabled or `false` if it is not.

  • publish: Manually publishes video and audio streams.

    public abstract void publish()                  
    • The behavior of `publish` depends on the configurations that are set by methods such as `configLocalCameraPublish`, `configLocalScreenPublish`, `configLocalAudioPublish`, and `configLocalSimulcast`.
    • You can configure the parameters of the preceding four methods to publish the corresponding video and audio streams.
    • You can use the `publish` method to both start and stop publishing.
    • To stop publishing, set the parameters of all four configuration methods to `false`, and then call `publish`.
    • You must call this method after you successfully join a channel.
  • isAutoSubscribe: Checks whether auto-subscribe is enabled.

    public abstract boolean isAutoSubscribe()                 

    Return value

    true indicates automatic subscription, and false indicates manual subscription.

  • configRemoteCameraTrack: Sets whether to subscribe to the remote camera stream.

    public abstract void configRemoteCameraTrack(String uid, boolean master, boolean enable)                  
    Parameter description
    NameTypeDescription
    uidStringThe user ID.
    masterboolean`true` subscribes to the main stream. `false` subscribes to the substream. The default is to subscribe to the main stream.
    enablebooleanThe default is not to subscribe. `true` subscribes to the remote camera stream. `false` stops subscribing to the remote camera stream.
    Important When you perform stream operations such as manual subscription or unsubscribing, you must call `subscribe` for this setting to take effect.
  • configRemoteScreenTrack: Sets whether to subscribe to the remote screen stream.

    public abstract void configRemoteScreenTrack(String uid, boolean enable)                  
    Parameter description
    NameTypeDescription
    uidStringThe user ID.
    enableboolean`true` subscribes to the remote screen stream. `false` stops subscribing to the remote screen stream. The default is not to subscribe to the remote screen stream.
    Important When you perform stream operations such as manual subscription or unsubscribing, you must call `subscribe` for this setting to take effect.
  • configRemoteAudio: Sets whether to subscribe to the remote audio stream.

    public abstract void configRemoteAudio(String uid, boolean enable)                  
    Parameter description
    NameTypeDescription
    uidStringThe user ID.
    enableboolean`true` subscribes to the remote audio stream. `false` stops subscribing to the remote audio stream. The default is to subscribe to the remote audio stream.
    Important When you perform stream operations such as manual subscription or unsubscribing, you must call `subscribe` for this setting to take effect.
  • subscribe: Manually subscribes to video and audio streams.

    public abstract int subscribe(String uid)                 
    • The behavior of `subscribe` depends on the configurations that are set by methods such as `configRemoteCameraTrack`, `configRemoteScreenTrack`, and `configRemoteAudio`.
    • You can configure the parameters of the preceding three methods to subscribe to the corresponding video and audio streams.
    • You can use the `subscribe` method to both start and stop a subscription.
    • To stop subscribing, set the parameters of all three configuration methods to `false`, and then call `subscribe`.
    Parameter description
    NameTypeDescription
    uidStringThe user ID.

    Return value

    Returns 0 if the method is executed. To confirm whether the subscription is successful, check the subscription callback result. A non-zero value indicates that the method execution was interrupted and the subscription failed.

  • registerTexturePreObserver: Subscribes to pre-processing texture data.
    public abstract void registerTexturePreObserver(String userId, AliRtcEngine.AliTextureObserver observer);
    Parameter description
    NameTypeDescription
    userIdStringThe ID of the user to subscribe to. For local retouching, you can enter an empty string ("") or the local user ID.
    observerAliTextureObserverThe video stream callback interface.
  • unRegisterTexturePreObserver: Unsubscribes from pre-processing texture data.
    public abstract void unRegisterTexturePreObserver(String userId);
    Parameter description
    NameTypeDescription
    userIdStringThe ID of the user to subscribe to. For local retouching, you can enter an empty string ("") or the local user ID.
  • setVideoProfile: Sets the video stream parameters.

    public abstract void setVideoProfile(AliRtcVideoProfile profile, AliRtcVideoTrack track)                   
    Parameter description
    NameTypeDescription
    profileAliRtcVideoProfileVideo stream parameters. The default is a camera stream with a resolution of 480 × 640 and a frame rate of 15.
    trackAliRtcVideoTrackThe type of video stream to set. The default is the camera stream.
  • getVideoProfile: Retrieves the current video stream parameters.

    public abstract AliRtcVideoProfile getVideoProfile(AliRtcVideoTrack track)                    
    Parameter description
    NameTypeDescription
    trackAliRtcVideoTrackThe type of video stream to query.

    Return value

    This method returns AliRtcVideoProfile (video stream specification data type).

  • setLocalViewConfig: Sets the rendering window and drawing parameters for the local preview.

    public abstract int setLocalViewConfig(AliVideoCanvas viewConfig, AliRtcVideoTrack track)                   
    • This method lets you switch the rendering window before or after you join a channel. If `viewConfig` or its rendering view member is `null`, rendering stops.
    • To reset the rendering mode during playback, keep the other member variables in `viewConfig` unchanged and modify only `renderMode`.
    • The default rendering mode in `viewConfig` is `AliRtcRenderModeAuto`.
    Parameter description
    NameTypeDescription
    viewConfigAliVideoCanvasRendering parameters, including the rendering window and rendering mode.
    trackAliRtcVideoTrackThe preview video track type can only be AliVideoTrackCamera (camera stream).
  • muteLocalCamera: Mutes or unmutes the local video stream.

    public abstract int muteLocalCamera(boolean mute, AliRtcVideoTrack track)                   
    Parameter description
    NameTypeDescription
    muteboolean`true` stops publishing the video stream. `false` resumes publishing. The default is to resume publishing.
    trackAliRtcVideoTrackThe type of video track whose publishing state needs to be changed. The default is the camera stream.

    Return value

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

    Important This method does not change the capture state of the video stream.
  • setRemoteViewConfig: Sets the rendering window and drawing parameters for the remote video.

    public abstract int setRemoteViewConfig(AliVideoCanvas canvas, String uid, AliRtcVideoTrack track)                    
    • This method lets you switch the rendering window before or after you join a channel. If `canvas` or its rendering view member is `null`, rendering of the corresponding stream stops.
    • To reset the rendering mode during playback, keep the other member variables in `canvas` unchanged and modify only `renderMode`.
    • The default rendering mode in `canvas` is `AliRtcRenderModeAuto`.
    • We recommend that you call this method after the subscription result callback.
    Parameter description
    NameTypeDescription
    canvasAliVideoCanvasRendering parameters, including the rendering window and rendering mode.
    uidStringThe user ID.
    trackAliRtcVideoTrackThe type of video track to set.

    Return value

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

  • switchCamera: Switches between the front and rear cameras.

    public abstract int switchCamera()                  

    Return value

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

  • getCurrentCameraType: Retrieves the current camera type.

    Returns the camera type AliRTCCameraType.

    public abstract AliRTCCameraType getCurrentCameraType()                   
  • setPreCameraType: Sets the default camera direction.

    public abstract void setPreCameraType(int faceTo)                    
    Parameter description
    NameTypeDescription
    faceToint0 for rear-facing, 1 for front-facing. The default value is 1.
  • getPreCameraType: Retrieves the default camera direction.

    public abstract int getPreCameraType()                  

    Return value

    Returns 0 for the rear camera or 1 for the front camera.

  • setCameraZoom: Sets the camera zoom factor.

    public abstract int setCameraZoom(float zoom, boolean flash, boolean autoFocus)                  
    Parameter description
    NameTypeDescription
    zoomfloatThe zoom level. The default value is 1.0.
    flashboolean`true` turns on the flash. `false` turns it off. The default is off.
    autoFocusboolean`true` enables autofocus. `false` disables it. The default is disabled.

    Return value

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

  • isCameraOn: Checks whether the camera is on.

    public abstract boolean isCameraOn()                   

    Return value

    Returns `true` if the camera is on or `false` if it is off.

  • isCameraSupportExposurePoint: Checks whether the camera supports manual exposure.

    public abstract boolean isCameraSupportExposurePoint();

    Return value

    true indicates that the feature is supported. false indicates that the feature is not supported.

  • isCameraSupportFocusPoint: Checks whether the camera supports manual focus.

    public abstract boolean isCameraSupportFocusPoint();

    Return value

    A value of true indicates that the feature is supported. A value of false indicates that the feature is not supported.

  • setCameraExposurePoint: Sets the coordinates for manual exposure.

    public abstract int setCameraExposurePoint(float x, float y);
    Parameter description
    NameTypeDescription
    xfloatThe x-coordinate.
    yfloatThe y-coordinate.

    Return value

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

  • setCameraFocusPoint: Sets the coordinates for manual focus.

    public abstract int setCameraFocusPoint(float x, float y);
    Parameter description
    NameTypeDescription
    xfloatThe x-coordinate.
    yfloatThe y-coordinate.

    Return value

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

  • isCameraFlash: Checks whether the camera flash is on.

    public abstract boolean isCameraFlash();

    Return value

    true means enabled, and false means disabled.

  • getCameraZoom: Retrieves the camera zoom value.

    public abstract float getCameraZoom();

    Return value

    The return value ranges from 0.0 to 1.0. A value of 0 indicates the minimum zoom that is supported by the camera. A value of 1 indicates the maximum zoom that is supported by the camera.

  • registerPreprocessVideoObserver: Registers for facial recognition pre-processing.

    public abstract void registerPreprocessVideoObserver(AliDetectObserver observer);
    Parameter description
    NameTypeDescription
    observerAliDetectObserverFacial recognition pre-processing.
  • muteAllRemoteAudioPlaying: Mutes all remote audio streams.

    public abstract int muteAllRemoteAudioPlaying(boolean mute);
    Parameter description
    NameTypeDescription
    muteboolean`true` stops playback. `false` resumes playback. The default is to resume playback.

    Return value

    Returns 0 on success. Other values are error codes.

    Important This method does not affect subscription or decoding. You can call this method before or after you join a channel.
  • setAudioOnlyMode: Switches between audio-only mode and audio-and-video mode.

    public abstract int setAudioOnlyMode(boolean audioOnly)                  
    Parameter description
    NameTypeDescription
    audioOnlyboolean`true` indicates only audio is published and subscribed. `false` indicates both audio and video are supported. The default is audio-and-video mode.

    Return value

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

    Note The default mode is audio-and-video. You must call this method before you call `joinChannel`.
  • isAudioOnly: Checks whether the current mode is audio-only.

    public abstract boolean isAudioOnly()                 

    Return value

    Returns `true` if the mode is audio-only or `false` if the mode is audio-and-video.

  • muteRemoteAudioPlaying: Mutes or unmutes a remote audio stream.

    public abstract int muteRemoteAudioPlaying(String uid, boolean mute)                   
    Parameter description
    NameTypeDescription
    uidStringThe user ID.
    muteboolean`true` stops playback. `false` resumes playback. The default is to resume playback.

    Return value

    Returns 0 on success or -1 on failure.

  • enableSpeakerphone: Switches the audio output between the earpiece and the speakerphone.

    public abstract int enableSpeakerphone(boolean enable)  
    Parameter description
    NameTypeDescription
    enableboolean`true` for speakerphone mode. `false` for earpiece mode. The default is speakerphone mode.

    Return value

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

    Important You must call this method in the main thread.
  • isSpeakerOn: Checks whether the speakerphone is enabled.

    public abstract boolean isSpeakerOn()                  

    Return value

    Returns `true` if the speakerphone is on or `false` if it is off.

  • startAudioCapture: Starts audio capture.

    You can start audio capture in advance. If you do not call this method, the SDK starts audio capture when stream ingest begins.

    public int startAudioCapture();

    Return value

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

  • stopAudioCapture: Stops audio capture.

    This method lets you control when to stop audio capture.

    public int stopAudioCapture();
  • startAudioPlayer: Starts audio playback.

    You can start audio playback in advance. If you do not call this method, the SDK starts audio playback after a stream is successfully subscribed.

    public int startAudioPlayer();

    Return value

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

  • stopAudioPlayer: Stops audio playback.

    public int stopAudioPlayer();

    Return value

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

    Important You must call this method before joining a channel.
  • enableEarBack: Enables or disables in-ear monitoring.

    public abstract int enableEarBack(boolean enable);
    Parameter description
    NameTypeDescription
    enableboolean`true` enables in-ear monitoring. `false` disables it. The default is disabled.

    Return value

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

  • startAudioAccompany: Starts playing audio accompaniment.

    public abstract int startAudioAccompany(String fileName, boolean onlyLocalPlay, boolean replaceMic, int loopCycles);
    Parameter description
    NameTypeDescription
    fileNameStringThe path of the accompaniment file. Supports local files and network URLs.
    onlyLocalPlayboolean`true` for local playback only. `false` for local playback and publishing to remote users.
    replaceMicboolean`true` replaces the local microphone audio stream with the accompaniment audio stream. `false` publishes both the accompaniment and microphone audio streams simultaneously.
    loopCyclesintThe number of times to loop playback. -1 indicates infinite looping.

    Return value

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

  • pauseAudioAccompany: Pauses audio accompaniment.

    public abstract int pauseAudioAccompany();

    Return value

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

  • resumeAudioAccompany: Resumes audio accompaniment.

    public abstract int resumeAudioAccompany();

    Return value

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

  • stopAudioAccompany: Stops playing audio accompaniment.

    public abstract int stopAudioAccompany();

    Return value

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

  • setAudioAccompanyPublishVolume: Sets the publishing volume for audio accompaniment.

    public abstract int setAudioAccompanyPublishVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe publishing volume for the accompaniment. The default value is 50.

    Return value

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

  • setAudioAccompanyPlayoutVolume: Sets the local playback volume for audio accompaniment.

    public abstract int setAudioAccompanyPlayoutVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe local playback volume for the accompaniment. The default value is 50.

    Return value

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

  • getAudioAccompanyPublishVolume: Retrieves the publishing volume for audio accompaniment.

    public abstract int getAudioAccompanyPublishVolume();

    Return value

    Returns the publishing volume of the accompaniment. The value ranges from 0 to 100. A return value of -1 indicates failure.

  • getAudioAccompanyPlayoutVolume: Retrieves the local playback volume for audio accompaniment.

    public abstract int getAudioAccompanyPlayoutVolume();

    Return value

    Returns the publishing volume of the accompaniment. The value ranges from 0 to 100. A return value of -1 indicates failure.

  • setAudioAccompanyVolume: Sets the publishing and local playback volumes for audio accompaniment.

    public abstract int setAudioAccompanyVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe local playback volume for the accompaniment. The default value is 50.

    Return value

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

  • preloadAudioEffect: Preloads a sound effect.

    public abstract int preloadAudioEffect(int soundId, String filePath);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID, generated by the caller.
    filePathStringThe path of the sound effect file.

    Return value

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

  • unloadAudioEffect: Unloads a preloaded sound effect.

    public abstract int unloadAudioEffect(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID. This should be the same ID passed during preloading.

    Return value

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

  • playAudioEffect: Starts playing a sound effect.

    public abstract int playAudioEffect(int soundId, String filePath, int cycles, boolean publish);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.
    filePathStringThe path of the sound effect file. Supports local files and network URLs.
    cyclesintThe number of times to loop playback. -1 indicates infinite looping.
    publishbooleanWhether to publish the sound effect audio stream to remote users.

    Return value

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

  • setAudioEffectPublishVolume: Sets the publishing volume for a sound effect.

    public abstract int setAudioEffectPublishVolume(int soundId, int volume);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.
    volumeintThe publishing volume for the sound effect. The value ranges from 0 to 100.

    Return value

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

  • getAudioEffectPublishVolume: Retrieves the publishing volume for a sound effect.

    Returns the publishing volume of the sound effect. The value ranges from 0 to 100. A return value of -1 indicates failure.

    public abstract int getAudioEffectPublishVolume(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.

    Return value

    Returns the publishing volume of the sound effect. The value ranges from 0 to 100. A return value of -1 indicates failure.

  • setAudioEffectPlayoutVolume: Sets the local playback volume for a sound effect.

    public abstract int setAudioEffectPlayoutVolume(int soundId, int volume);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.
    volumeintThe local playback volume for the sound effect. The value ranges from 0 to 100. The default value is 50.

    Return value

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

  • getAudioEffectPlayoutVolume: Retrieves the local playback volume for a sound effect.

    public abstract int getAudioEffectPlayoutVolume(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.

    Return value

    Returns the local playback volume of the sound effect. The value ranges from 0 to 100. A return value of -1 indicates failure.

  • pauseAudioEffect: Pauses a sound effect.

    public abstract int pauseAudioEffect(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.

    Return value

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

  • resumeAudioEffect: Resumes a sound effect.

    public abstract int resumeAudioEffect(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.

    Return value

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

  • stopAudioEffect: Stops a sound effect.

    public abstract int stopAudioEffect(int soundId);
    Parameter description
    NameTypeDescription
    soundIdintThe sound effect ID.

    Return value

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

  • setEarBackVolume: Sets the in-ear monitoring volume.

    public abstract int setEarBackVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe in-ear monitoring volume. The value ranges from 0 to 100. You can only set the volume when in-ear monitoring is enabled. Otherwise, the method returns an error. The default value is 100.

    Return value

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

  • setRecordingVolume: Sets the recording volume.

    public abstract int setRecordingVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe volume. The value ranges from 0 to 400. 0 means mute. The default value is 100.
    • Values greater than 100 amplify the volume.
    • Values less than 100 reduce the volume.

    Return value

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

    Important Recording volume adjustment: You can call this method if a remote user finds the playback volume too low even after the device's physical volume is set to the maximum. The recommended value is 100 to 200. Values over 200 may degrade audio quality.
  • setPlayoutVolume: Sets the playback volume.

    public abstract int setPlayoutVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe volume. The value ranges from 0 to 400. 0 means mute. The default value is 100.
    • Values greater than 100 amplify the volume.
    • Values less than 100 reduce the volume.

    Return value

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

    Important Playback volume adjustment: You can call this method if the local user finds the playback volume too low even after the device's physical volume is set to the maximum. The recommended value is 100 to 200. Values over 200 may degrade audio quality.
  • muteAllRemoteVideoRendering: Mutes or unmutes the rendering of all remote video tracks.

    public abstract int muteAllRemoteVideoRendering(boolean mute);
    Parameter description
    NameTypeDescription
    muteboolean`true` stops rendering. `false` resumes rendering. The default is to resume rendering.

    Return value

    Returns 0 on success. Other values are error codes.

    Important This method does not affect subscription or decoding. You can call this method before or after you join a channel.
  • setBeautyEffect: Sets basic retouching effects.

    public abstract int setBeautyEffect(boolean enable, AliRtcEngine.AliRtcBeautyConfig config);
    Parameter description
    NameTypeDescription
    enableboolean`true` enables effects. `false` disables them. The default is disabled.
    configAliRtcBeautyConfigBasic retouching parameters.

    Return value

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

    Important Currently, only whitening and smoothing are supported.
  • registerVideoSampleObserver: Registers for video data callbacks.

    public abstract void registerVideoSampleObserver(AliRtcEngine.AliVideoObserver aliVideoObserver);

    For more information, see Audio and video output.

    Parameter description
    NameTypeDescription
    aliVideoObserverAliVideoObserverThe video data callback interface.
  • unRegisterVideoSampleObserver: Unregisters from video data callbacks.
    public abstract void unRegisterVideoSampleObserver();
  • setVideoEncoderConfiguration: Sets video encoding properties.
    public abstract void setVideoEncoderConfiguration(AliRtcEngine.AliRtcVideoEncoderConfiguration config);
    Parameter description
    NameTypeDescription
    configAliRtcVideoEncoderConfigurationPredefined video encoding properties.
  • isCameraAutoFocus: Checks whether autofocus is enabled.
    public abstract boolean isCameraAutoFocus();

    Return value

    Returns `true` if autofocus is enabled or `false` if it is not.

  • registerVideoRawDataInterface: Registers the external video data callback interface.For more information, see Input external video stream.
    public abstract VideoRawDataInterface registerVideoRawDataInterface(AliRawDataStreamType streamType, AliRtcRenderMode renderMode);
    Parameter description
    NameTypeDescription
    streamTypeAliRawDataStreamTypeThe video stream type.
    renderModeAliRtcRenderModeThe rendering mode.

    Return value

    Returns the VideoRawDataInterface stream processing object.

  • unRegisterVideoRawDataInterface: Unregisters the external video data callback interface.For more information, see Input external video stream.
    public abstract void unRegisterVideoRawDataInterface(AliRawDataStreamType streamType);
    Parameter description
    NameTypeDescription
    streamTypeAliRawDataStreamTypeThe video stream type.
  • createRenderSurfaceView: Creates a SurfaceView rendering view.
    public abstract SophonSurfaceView createRenderSurfaceView(Context context);

    Parameter description

    NameTypeDescription
    contextContextThe context of the Android Activity.
  • createRenderTextureView: Creates a TextureView rendering view.
    public abstract SophonTextureView createRenderTextureView(Context context);

    Parameter description

    NameTypeDescription
    contextContextThe context of the Android Activity.
  • enableLocalVideo: Disables or re-enables local video capture.
    public abstract int enableLocalVideo(boolean enabled);

    Parameter description

    NameTypeDescription
    enabledbooleanDisables or re-enables local video capture. Valid values:
    • YES: Enable.
    • NO: Disable.

    Return value

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

  • registerAudioVolumeObserver: Registers for volume callbacks.

    public abstract void registerAudioVolumeObserver(AliRtcEngine.AliRtcAudioVolumeObserver observer);
    Parameter description
    NameTypeDescription
    observerAliRtcAudioVolumeObserverThe volume interface.
  • unRegisterAudioVolumeObserver: Unregisters from volume callbacks.
    public abstract void unRegisterAudioVolumeObserver();
  • startRecord: Starts recording audio to a file.

    public abstract boolean startRecord(AliRtcEngine.AliRtcRecordType recordType, AliRtcEngine.AliRtcRecordFormat recordFormat, String path, AliRtcEngine.AliRtcRecordAudioConfig audioConfig, AliRtcEngine.AliRtcRecordVideoConfig videoConfig);

    The recorded audio includes external input PCM data, locally captured audio, and audio data from remote streams.

    Parameter description
    NameTypeDescription
    recordTypeAliRtcRecordTypeThe record type.
    recordFormatAliRtcRecordFormatThe file format.
    pathStringThe path to store the recording file.
    audioConfigAliRtcRecordAudioConfig The audio property configuration for the recording.

    Return value

    Returns `true` on success or `false` on failure.

  • stopRecord: Stops recording.

    public abstract void stopRecord();

    You can use this method in conjunction with `startRecord`. Recording stops automatically after you call `leaveChannel`.

  • setAudioEffectReverbMode: Sets the reverb effect mode.

    public abstract int setAudioEffectReverbMode(AliRtcEngine.AliRTCSDK_AudioEffect_Reverb_Mode mode);
    Parameter description
    NameTypeDescription
    modeAliRTCSDK_AudioEffect_Reverb_ModeThe reverb mode type. The default is off.

    Return value

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

  • setAudioEffectReverbParamType: Sets the reverb effect type.

     public abstract int setAudioEffectReverbParamType(AliRtcEngine.AliRTCSDK_AudioEffect_Reverb_Param_Type type, float value);
    Parameter description
    NameTypeDescription
    typeAliRTCSDK_AudioEffect_Reverb_Param_TypeThe reverb effect type.
    valuefloatThe value corresponding to the reverb effect type.

    Return value

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

  • setVolumeCallbackIntervalMs: Sets the volume callback frequency and smoothing coefficient.

    public abstract int setVolumeCallbackIntervalMs(int interval, int smooth, int reportVad);
    Parameter description
    NameTypeDescription
    intervalintThe time interval in ms. The minimum value is 10 ms. The default is 160 ms.
    smoothintThe smoothing coefficient. A higher value means more smoothing. A lower value means better real-time performance. The value ranges from 0 to 9. The default is 3.
    reportVadintThe local voice activity detection switch. The default value is 1. Valid values:
    • 1: Enabled. The callback is triggered through the onAudioVolumeCallback interface.
    • 0: Disabled.

    Return value

    Returns 0 on success. Returns -1 if the interval is set to less than 10. Returns -2 if the smoothing coefficient is out of range.

  • setExternalAudioSource: Enables or disables using an external audio source for stream ingest.

    public abstract int setExternalAudioSource(boolean enable, int sampleRate, int channelsPerFrame);
    Parameter description
    NameTypeDescription
    enableboolean`true` enables using external audio data as the stream ingest input source. `false` stops it.
    sampleRateintThe sample rate of the external audio data.
    channelsPerFrameintThe number of sound channels for the external audio data. Mono and stereo are currently supported.

    Return value

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

  • pushExternalAudioFrameRawData: Inputs external audio data.

    public abstract int pushExternalAudioFrameRawData(byte[] data, int samples, long timestamp);
    Parameter description
    NameTypeDescription
    databyte[]The audio data. We recommend that the data not exceed 40 ms.
    samplesintThe sample rate.
    timestamplongThe timestamp. You can pass 0 for now.

    Return value

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

  • setExternalAudioVolume: Sets the external audio input volume.

    public abstract int setExternalAudioVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe volume. The value ranges from 0 to 100. The default value is 50.

    Return value

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

  • getExternalAudioVolume: Retrieves the external audio input volume.

    public abstract int getExternalAudioVolume();

    Return value

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

  • setMixedWithMic: Enables or disables mixing external audio with audio that is captured by the microphone.

    public abstract int setMixedWithMic(boolean mixed);
    Parameter description
    NameTypeDescription
    mixedboolean`true` enables mixing. `false` completely replaces the microphone-captured data. The default is to mix.

    Return value

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

  • setExteranlAudioRender: Enables or disables local playback of external audio.

    public abstract int setExteranlAudioRender(boolean enable, int sampleRate, int channelsPerFrame);
    Parameter description
    NameTypeDescription
    enableboolean`true` enables using external audio as the local playback input source. `false` stops it.
    sampleRateintThe sample rate of the external audio data.
    channelsPerFrameintThe number of sound channels for the external audio data. Mono and stereo are currently supported.

    Return value

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

  • pushExternalAudioRenderRawData: Inputs external audio data for local playback.

    public abstract int pushExternalAudioRenderRawData(byte[] audioSamples, int sampleLength, int sampleRate, int channelsPerFrame, long timestamp);
    Parameter description
    NameTypeDescription
    audioSamplesbyte[]The audio data.
    sampleLengthintThe length of the audio data.
    sampleRateintThe audio sampling rate.
    channelsPerFrameintThe number of audio channels.
    timestamplongThe timestamp. You can pass 0 for now.

    Return value

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

  • getCurrentClientRole: Retrieves the current user role.

    public abstract AliRtcEngine.AliRTCSDK_Client_Role getCurrentClientRole();

    Return value

    Returns the current user role.

  • setSubscribeAudioNumChannel: Sets the number of sound channels for the subscribed audio callback.

    public abstract void setSubscribeAudioNumChannel(AliRtcAudioNumChannel numChannel);
    Parameter description
    NameTypeDescription
    numChannelAliRtcAudioNumChannelThe audio channel. The default is mono audio.
  • setSubscribeAudioSampleRate: Sets the audio sampling rate for the subscribed audio callback.

    public abstract void setSubscribeAudioSampleRate(AliRtcAudioSampleRate sampleRate);
    Parameter description
    NameTypeDescription
    sampleRateAliRtcAudioSampleRateThe audio sampling rate. The default is 16K.
  • requestAudioFocus: Requests audio focus.
    public abstract int requestAudioFocus()

    Return value

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

  • abandonAudioFocus: Abandons audio focus.
    public abstract int abandonAudioFocus()

    Return value

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

  • registerAudioObserver: Registers for audio data callbacks.
    public abstract void registerAudioObserver(AliRtcEngine.AliAudioType audioType, AliRtcEngine.AliAudioObserver audioObserver);

    You can specify the type of audio data to output. To output multiple types of data, you must register each type separately. After registration, audio data is continuously returned through the `AliAudioObserver` callback. For more information, see Audio and video output.

    Parameter description
    NameTypeDescription
    audioTypeAliAudioTypeThe type of audio data for the callback.
    audioObserverAliAudioObserverThe audio data callback interface.
  • muteLocalMic: Mutes the local audio capture.

    public abstract int muteLocalMic(boolean mute, AliRtcEngine.AliRtcMuteLocalAudioMode var2);
    Parameter description
    NameTypeDescription
    mutebooleanYES sends empty frames for local audio capture. NO does not send empty frames.
    modeAliRtcMuteLocalAudioModeThe local mute mode.

    Return value

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

  • getAudioAccompanyDuration: Retrieves the duration of the accompaniment file in milliseconds.

    public int getAudioAccompanyDuration();
  • getAudioAccompanyCurrentPosition: Retrieves the playback progress of the accompaniment file in milliseconds.

    public int getAudioAccompanyCurrentPosition();
  • setAudioAccompanyPosition: Sets the playback position of the accompaniment file.

    public int setAudioAccompanyPosition(int posMs);
    Parameter description
    NameTypeDescription
    posMsAliRtcMuteLocalAudioModeThe local mute mode.

    Return value

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

  • stopAllAudioEffects: Stops playing all sound effects.

    public abstract int stopAllAudioEffects();

    Return value

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

  • setAllAudioEffectsPublishVolume: Sets the publishing volume for all sound effects.

    public abstract int setAllAudioEffectsPublishVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe mixing volume. The value ranges from 0 to 100. The default value is 50.

    Return value

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

  • setAllAudioEffectsPlayoutVolume: Sets the local playback volume for all sound effects.

    public abstract int setAllAudioEffectsPlayoutVolume(int volume);
    Parameter description
    NameTypeDescription
    volumeintThe mixing volume. The value ranges from 0 to 100. The default value is 50.

    Return value

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

  • pauseAllAudioEffects: Pauses all sound effects.

    public abstract int pauseAllAudioEffects();

    Return value

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

  • resumeAllAudioEffects: Resumes playing all sound effects.

    public abstract int resumeAllAudioEffects();

    Return value

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

  • unRegisterAudioObserver: Unregisters from audio data callbacks.

    public abstract void unRegisterAudioObserver(AliAudioType type);
    Parameter description
    NameTypeDescription
    typeAliAudioTypeThe type of audio data for the callback.
  • startPreview: Starts the local preview.

    public abstract int startPreview()

    Return value

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

    Important You can start the local preview before you join a channel. You must call `setLocalViewConfig` before you start the preview.
  • stopPreview: Stops the local preview.

    public abstract int stopPreview()                   

    Return value

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

  • enableHighDefinitionPreview: Enables or disables high-definition preview.

    Returns 0 on success. Returns -1 if the operation fails.

    public abstract int enableHighDefinitionPreview(boolean enable);
    Parameter description
    NameTypeDescription
    enableboolean`true` enables high-definition preview. `false` disables it. High-definition preview is enabled by default.

    Return value

    Returns 0 on success or -1 on failure.

  • getOnlineRemoteUsers: Retrieves a list of online remote users.

    public abstract String[] getOnlineRemoteUsers()                

    Return value

    Returns a list of user IDs.

    Important This method has a delay when called while joining a channel. We recommend that you call this method after the onRemoteUserOnLineNotify callback is triggered or maintain your own remote user list.
  • getUserInfo: Retrieves the information of a remote user.

    public abstract AliRtcRemoteUserInfo getUserInfo(String uid)                  
    Parameter description
    NameTypeDescription
    uidStringThe user ID.

    Return value

    Returns an AliRtcRemoteUserInfo object.

  • isUserOnline: Checks whether a specified user is online.

    public abstract boolean isUserOnline(String uid)
    Parameter description
    NameTypeDescription
    uidStringThe user ID.

    Return value

    Returns `true` if the user is online or `false` if the user is offline.

  • getMediaInfoWithUserId: Retrieves media stream information.

    public String getMediaInfoWithUserId(String userId, AliRtcVideoTrack track, String[] keys);
    Parameter description
    NameTypeDescription
    userIdStringThe user ID for which to get media stream information.
    trackAliRtcVideoTrackThe type of media stream to query.
    keysString[]The array of key values to query.
  • setLogLevel: Sets the log level.

    public abstract void setLogLevel(AliRtcLogLevel logLevel)         
    Parameter description
    NameTypeDescription
    logLevelAliRtcLogLevelThe log level. The default value is AliRtcLogLevelInfo.
  • getSdkVersion: Retrieves the SDK version number.

    public abstract String getSdkVersion()                   
  • setClientRole: Sets the user role.

    public abstract int setClientRole(AliRTCSDK_Client_Role role);
    Parameter description
    NameTypeDescription
    roleAliRTCSDK_Client_RoleThe user role type. The default is viewer role.

    Return value

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

    Important You can call this method only when the channel mode is `InteractiveLive`. You can set the role before or during a session. On success, you receive the `onUpdateRoleNotify` callback. To switch the role from Interactive to Live, you must stop stream ingest first. Otherwise, the method call fails.
  • setLogDirPath: Sets the path where the SDK log files are saved.

    public static int setLogDirPath(String logDirPath)
    Parameter description
    NameTypeDescription
    logDirPathStringThe absolute path to save log files.

    Return value

    Returns 0 on success. Other values are error codes.

    Important You must call this method before you call any other SDK methods to prevent log loss. You must also ensure that the specified directory exists and is writable.
  • setDeviceOrientationMode: Sets the device orientation (portrait or landscape).

    public abstract void setDeviceOrientationMode(AliRtcEngine.AliRtcOrientationMode mode);
    Parameter description
    NameTypeDescription
    modeAliRtcOrientationModeThe device orientation. Valid values:
    • AliRtcOrientationModePortrait (default): Fixed portrait mode.
    • AliRtcOrientationModeLandscapeLeft: Fixed left landscape mode.
    • AliRtcOrientationModeLandscapeRight: Fixed right landscape mode.
    • AliRtcOrientationModeAuto: Automatic rotation mode.

    Return value

    Returns 0 on success. Other values are error codes.

    Important Currently, only fixed portrait and landscape modes are supported. You must set the orientation before you publish a stream or start a preview.
  • startNetworkQualityProbeTest: Starts a network quality probe test.

    public abstract int startNetworkQualityProbeTest();

    Return value

    Returns 0 on success. Other values are error codes.

    Important You must call this method before you join a channel. The test stops automatically after you join the channel. The test results are returned in the onNetworkQualityProbeTest callback.
  • stopNetworkQualityProbeTest: Stops a network quality probe test.

    public abstract int stopNetworkQualityProbeTest();

    Return value

    Returns 0 on success. Other values are error codes.

  • postFeedback: Submits SDK issue feedback.
    public abstract void postFeedback(String uid, String channelId, String description, AliRtcFeedbackType type, long timeStamp);
    Parameter description
    NameTypeDescription
    uidStringThe current user ID.
    channelIdStringThe current channel ID.
    descriptionStringThe problem description (supports Chinese and English).
    typeAliRtcFeedbackTypeThe problem type (see AliRtcFeedbackType comments).
    timeStamplongThe timestamp when the problem occurred (Unix timestamp). Approximate time is acceptable. You can pass 0.
  • sendMediaExtensionMsg: Sends a media extension message.
    public abstract int sendMediaExtensionMsg(byte[]message, int repeatCount);
    Parameter description
    ParameterTypeDescription
    messageStringCustom message data. The length is limited to 8 bytes.
    repeatCountintThe number of times to send the message.

    Return value

    • 0: The message is sent.
    • -1: You are not publishing a stream, so custom messages cannot be sent.
    • -2: A parameter is invalid. The message length exceeds 8 bytes, or `repeatCount` is less than or equal to 0.
    • -3: Messages are sent too frequently. You must reduce the sending frequency.
    Important You can use the audio and video data tunnel to send custom messages to other users in the channel. The following prerequisites must be met:
    • You have joined the channel and are publishing a stream.
    • Other users in the channel have subscribed to your audio and video streams. After the message is sent, the result is returned in the onMediaExtensionMsgReceived callback.
  • respondMessageNotification: Sends a message notification.
    public abstract int respondMessageNotification(String tid, String contentType, String content);
    Parameter description
    ParameterTypeDescription
    tidStringThe message ID.
    contentTypeStringThe message content type.
    contentStringThe message content.

    Return value

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

  • refreshAuthInfo: Refreshes the token.
    public abstract int refreshAuthInfo(AliRtcAuthInfo auth_info);
    Parameter description
    ParameterTypeDescription
    auth_infoAliRtcAuthInfoUser authentication information.

    Return value

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