This topic describes the public interfaces of the audio and video call API for Android.
Interface type | API | Description |
Basic interfaces | Creates an AlipayRtcEngine instance. Only one instance can exist at a time. | |
Sets the listener for callback events and the corresponding handler. | ||
Sets the listener for Instant Messaging (IM) text message interaction. | ||
Sets the listener for invitation messages in invitation mode. | ||
Sets the local preview listener in custom stream ingest mode. | ||
Destroys the engine. | ||
For apps other than Alipay, notifies the SDK when the app moves to the background or returns to the foreground. This is used to manage camera state, floating window permissions, and floating window visibility.
| ||
Room-related interfaces | Creates a room. | |
Joins a room. | ||
Leaves a room. | ||
Sets whether to automatically publish and subscribe to streams. | ||
Publishing-related interfaces | Queries whether the current mode is auto-publish mode. | |
Sets whether to allow publishing video streams. | ||
Gets the current auto-publish configuration. | ||
Manually publishes the configured audio and video streams. | ||
Unpublishes a stream. | ||
Switches the publishing resolution. | ||
Pushes custom image data for custom stream ingest. | ||
Subscription-related interfaces | Queries whether the current mode is auto-subscribe mode. | |
Manually subscribes to video and audio streams. | ||
Unsubscribes from a stream. | ||
Video-related interfaces | Sets whether to pause publishing the local video stream. | |
Sets whether to pause publishing all local video streams. | ||
Switches between the front and rear cameras. | ||
Sets whether to pause playback of a remote video stream. | ||
Sets whether to pause playback of all remote video streams. | ||
Audio-related interfaces | Sets whether to pause publishing the local audio. | |
Sets whether to pause all local audio streams. | ||
Sets whether to pause playback of a remote audio stream. | ||
Sets whether to pause playback of all remote audio streams. | ||
Sets whether to switch to speaker output. | ||
Preview interfaces | Starts the local camera preview. | |
Stops the local camera preview. | ||
Query remote user interface | Gets information about remote users. | |
Other interfaces | Sets custom log output. | |
Invites a user to join. | ||
Replies to an invitation. | ||
Sends a text message. | ||
Takes a screenshot of a video stream. | ||
If your application handles permission requests, you must use this interface to pass the permission request result to the SDK for processing. | ||
The result callback for the screen sharing permission request. |
getInstance
Declaration:
public static AlipayRtcEngine getInstance( Context context )Description: Creates an AlipayRtcEngine instance. Only one instance can exist at a time.
NoteThe context must be an activity context because this operation involves permission requests.
Parameters:
Parameter
Type
Description
context
Context
The context.
Return value: None.
setRtcListenerAndHandler
Declaration:
public void setRtcEngineEventListener( AlipayRtcEngineEventListener listener, Handler handler )Description: Sets the listener for callback events.
Parameters:
Parameter
Type
Description
listener
AlipayRtcEngineEventListener
The listener that receives callback events.
handler
Handler
The handler for callback events. This parameter is required. Create a new thread to process callbacks instead of using the main thread handler.
If this parameter is not set, no callbacks can be received.
Return value: None.
setImListener
Declaration:
public void setImListener( AlipayRtcEngineIMListener imListener )Description: Sets the listener for text message interaction.
Parameters:
Parameter
Type
Description
listener
AlipayRtcEngineIMListener
The text interaction listener.
Return value: None.
setInviteListener
Declaration:
public void setInviteListener( AlipayRtcEngineInviteListener inviteListener )Description: Sets the listener for invitation messages in invitation mode.
Parameters:
Parameter
Type
Description
listener
AlipayRtcEngineInviteListener
The interaction listener in invitation mode.
Return value: None.
setCustomPublishListener
Declaration:
public void setCustomPublishListener( AlipayRtcEngineCustomPublishListener listener )Description: Sets the local preview listener for custom stream ingest mode. This mode includes screen sharing and custom stream ingest. If you are not using custom stream ingest mode, you do not need to set this parameter.
Parameters:
Parameter
Type
Description
listener
AlipayRtcEngineCustomPublishListener
The local view interaction listener for custom stream ingest.
Return value: None.
destroy
Declaration:
public void destroy()Description: Destroys the engine instance. After you call this method, the user leaves the room and the local engine is destroyed. To use the features again, you must call
getInstance()to reinitialize the engine.Parameters: None.
Return value: None.
onUserLeaveOrReturn
Declaration:
public void onUserLeaveOrReturn( int type )Description: The service calls this method to notify the SDK that the application has moved between the foreground and background.
Parameters:
Parameter
Type
Description
type
int
A flag that indicates the foreground or background state:
1: The app moves from the background to the foreground.
0: The app moves from the foreground to the background.
Return value: None.
createRoom
Declaration:
public void createRoom( CreateRoomParams params )Description: Creates a room. After the room is created, you can notify other users and invite them to join the room. The
void onRoomInfo( RoomInfo info )callback returns the result of the room creation. For more information, see Callback functions.Parameters:
Parameter
Type
Description
params
CreateRoomParams
The information required to create a room. For more information, see Key parameters.
Return value: None.
joinRoom
Declaration:
public void joinRoom( JoinRoomParams params )Description: Joins a room created by another user. The operation fails if the room is invalid. The
void onEnterRoom( int result )callback returns the result of the operation. For more information, see Callback functions.Parameters:
Parameter
Type
Description
params
JoinRoomParams
The information required to join a room. For more information, see Key parameters.
Return value: None.
leaveRoom
Declaration:
public void leaveRoom()Description: Leaves a room. If a user joined the room by calling `joinRoom`, they can rejoin after leaving. The room is dissolved and cannot be entered again after all members have left. The
void onLeaveRoom( int result )callback returns the result of the operation. For more information, see Callback functions.Parameters: None.
Return value: None.
setAutoPublishSubscribe
Declaration:
public void setAutoPublishSubscribe( boolean autoPub, boolean autoSub )Description: Sets whether to automatically publish and subscribe to streams. By default, streams are automatically published and subscribed. You must call this method before `createRoom` or `joinRoom`.
Parameters:
Parameter
Type
Description
autoPub
boolean
Automatic publishing
true: Automatically publish streams.
false: Manually publish streams.
autoSub
boolean
Specifies whether to automatically subscribe to streams:
true: Automatically subscribe to streams.
false: Manually subscribe to streams.
Return value: None.
isAutoPublish
Declaration:
public boolean isAutoPublish()Description: Checks whether the current mode is auto-publish mode.
Parameters: None.
Return value: Returns `true` if auto-publish mode is enabled. Otherwise, returns `false`.
configAutoPublish
Declaration:
public void configAutoPublish( PublishConfig config )Description: Configures the format for automatically published audio and video streams. If this method is not called, the default configuration is used. By default, both audio and video are published, and the video format is `PROFILE_360_640P_15`.
Parameters:
Parameter
Type
Description
config
PublishConfig
The publishing configuration. For more information, see Key parameters.
Return value: None.
getCurrentAutoPublishConfig
Declaration:
public PublishConfig getCurrentAutoPublishConfig()Description: Retrieves the current auto-publish configuration.
Parameters: None.
Return value: PublishConfig. The publishing configuration. For more information, see Key parameters.
publish
Declaration:
public void publish( PublishConfig config )Description: Publishes a media stream. If auto-publishing is disabled, you can call this method to manually publish a media stream.
Parameters:
Parameter
Type
Description
config
PublishConfig
The configuration for this media stream publication. For more information, see Key parameters.
Return value: None.
unpublish
Declaration:
public void unpublish( UnpublishConfig config )Description: Unpublishes a media stream. After publishing a media stream, a user can call this method to unpublish it. To publish the stream again, the user must call the `publish` method.
Parameters:
Parameter
Type
Description
config
UnpublishConfig
Information about the stream to be unpublished. For more information, see Key parameters.
Return value: None.
updateVideoProfile
Declaration:
public void updateVideoProfile( VideoProfile videoProfile, int maxBitrate, PublishVideoSource videoSource )Description: Dynamically switches the publishing resolution during stream publishing.
Parameters:
Parameter
Type
Description
videoProfile
VideoProfile
The configuration value for the target resolution. For more information, see Key parameters.
maxBitrate
int
The maximum bitrate for the target resolution, in kbps. If you set this to 0 or a negative value, the default bitrate is used. Otherwise, the specified maximum bitrate is used.
videoSource
PublishVideoSource
The media source for which to switch the target resolution.
Return value: None.
pushCustomVideoData
Declaration:
public void pushCustomVideoData(byte[] bytes, int width, int height, int rotation )Description: Pushes custom image data for stream ingest. On Android, only the NV21 data format is supported.
Parameters:
Parameter
Type
Description
bytes
byte[]
Image data in NV21 format.
width
int
Image width.
height
int
Image height.
rotation
int
Image rotation angle.
Return value: None.
isAutoSubscribe
Declaration:
public boolean isAutoSubscribe()Description: Checks whether the current mode is auto-subscribe mode.
Parameters: None.
Return value: Returns `true` if auto-subscribe mode is enabled. Otherwise, returns `false`.
subscribe
Declaration:
public void subscribe( SubscribeConfig config )Description: Subscribes to a media stream.
Parameters:
Parameter
Type
Description
config
SubscribeConfig
The configuration of the stream to subscribe to. For more information, see Key parameters.
Return value: None.
unsubscribe
Declaration:
public void unsubscribe( UnsubscribeConfig config )Description: Unsubscribes from a media stream.
Parameters:
Parameter
Type
Description
config
UnsubscribeConfig
Configuration of the subscribed stream. For more information, see Important Parameters.
Return value: None.
muteLocalVideo
Declaration:
public void muteLocalVideo( LocalVideoInfo info, boolean muted )Description: Pauses publishing the local video stream. You can call this method to temporarily pause and later resume pushing the local video stream.
Parameters:
Parameter
Type
Description
info
LocalVideoInfo
Information about the local video stream. For more information, see Key parameters.
muted
boolean
Specifies whether to pause publishing the local video stream:
true: Pause pushing the local video.
false: Resume pushing the local video.
Return value: None.
muteAllLocalVideo
Declaration:
public void muteAllLocalVideo( boolean muted )Description: Pauses publishing all local video streams. You can call this method to pause or resume pushing when multiple local streams need to be paused simultaneously.
Parameters:
Parameter
Type
Description
muted
boolean
Specifies whether to pause publishing all local video streams:
true: Pause pushing all local video streams.
false: All local video streams continue to be pushed.
Return value: None.
switchCamera
Declaration:
public void switchCamera()Description: Switches between the front and rear cameras.
Parameters: None.
Return value: None.
muteRemoteVideo
Declaration:
public void muteRemoteVideo( RemoteVideoInfo info, boolean muted )Description: Pauses subscribing to a remote video stream. You can call this method to temporarily pause and later resume subscribing to the remote video stream.
Parameters:
Parameter
Type
Description
info
RemoteVideoInfo
Information about the remote video stream. For more information, see Key parameters.
muted
boolean
Specifies whether to pause subscribing to all remote video streams:
true: Pause subscribing to the remote video stream.
false: Resume subscribing to the remote video stream.
Return value: None.
muteAllRemoteVideo
Declaration:
public void muteAllRemoteVideo( boolean muted )Description: Pauses the playback of all remote video streams. You can call this method when multiple remote streams need to be paused simultaneously.
Parameters:
Parameter
Type
Description
muted
boolean
Specifies whether to pause playback of all remote video streams:
true: Pause playback of all remote video streams.
false: Resume playback of all remote video streams.
Return value: None.
muteLocalAudio
Declaration:
public void muteLocalAudio( LocalAudioInfo info, boolean muted )Description: Pauses pushing the local audio stream.
Parameters:
Parameter
Type
Description
info
LocalAudioInfo
Information about the local audio stream. For more information, see Key parameters.
In camera mode, you can set this to null.
muted
boolean
Specifies whether to pause pushing the local audio stream:
true: Pause pushing the audio stream.
false: Continues to push the audio stream.
Return value: None.
muteAllLocalAudio
Declaration:
public void muteAllLocalAudio( boolean muted )Description: Pauses pushing all local audio streams. When multiple local audio streams are being pushed, you can use this method to pause or resume the operation.
Parameters:
Parameter
Type
Description
muted
boolean
Specifies whether to pause pushing all local audio streams:
true: Pause pushing all audio streams.
false: Continues to push all audio streams.
Return value: None.
muteRemoteAudio
Declaration:
public void muteRemoteAudio( RemoteAudioInfo info, boolean muted )Description: Pauses subscribing to a remote audio stream.
Parameters:
Parameter
Type
Description
info
RemoteAudioInfo
Information about the remote audio stream. For more information, see Key parameters.
muted
boolean
Specifies whether to pause subscribing to the remote audio stream:
true: Pause subscribing to the audio stream.
false: The audio stream subscription continues.
Return value: None.
muteAllRemoteAudio
Declaration:
public void muteAllRemoteAudio( boolean muted )Description: Pauses subscribing to all remote audio streams. When you are subscribed to multiple remote audio streams, you can use this method to pause or resume the operation.
Parameters:
Parameter
Type
Description
muted
boolean
Specifies whether to pause subscribing to all remote audio streams:
true: Pause subscribing to all audio streams.
false: Maintains the subscription to all audio streams.
Return value: None.
enableSpeaker
Declaration:
public void enableSpeaker( boolean enable )Description: Sets whether to route audio to the speakerphone.
Parameters:
Parameter
Type
Description
enable
boolean
Specifies whether to switch to speaker output:
true: Switch to speaker output.
false: Switch to non-speaker output.
Return value: None.
startCameraPreview
Declaration:
public void startCameraPreview()Description: Starts the local camera preview. This operation requires that camera permission is granted and hardware resources are prepared.
Parameters: None.
Return value: None.
stopCameraPreview
Declaration:
public void stopCameraPreview()Description: Stops the local camera preview. After the preview stops, the unpublish operation is triggered. To publish again, you must first start the camera preview. You can publish only after the preview starts successfully.
Parameters: None.
Return value: None.
getRemoteUsers
Declaration:
public List<ParticipantInfo> getRemoteUsers()Description: Retrieves information about other members in the room.
Parameters: None.
Return value: Returns a list of other members in the room. For more information about ParticipantInfo, see Key parameters.
setLogger
Declaration:
public void setLogger( Logger logger )Description: Sets a custom logger.
Parameters:
Parameter
Type
Description
logger
Logger
The interface for custom log output. You must implement this interface.
Return value: None.
invite
Declaration:
public String invite( InviteParams params )Description: Invites a user to join the call.
Parameters:
Parameter
Type
Description
params
InviteParams
The invitation configuration. For more information, see Key parameters.
Return value: String. The ID of this invitation. Subsequent result notifications are identified by this ID.
replyInvite
Declaration:
public void replyInvite(ReplyOfInviteParam params)Description: Replies to an invitation.
Parameters:
Parameter
Type
Description
params
ReplyOfInviteParam
The configuration for replying to an invitation. For more information, see Key parameters.
Return value: None.
sendMessage
Declaration:
public void sendMessage( Msg4Send msg4Send )Description: Sends a text message.
Parameters:
Parameter
Type
Description
msg4Send
Msg4Send
The configuration for sending a text message. For more information, see Key parameters.
Return value: None.
snapshot
Declaration:
public void snapshot( FeedInfo info )Description: Takes a screenshot of a stream.
Parameters:
Parameter
Type
Description
info
FeedInfo
Information about the stream to capture. For more information, see Key parameters.
Return value: None.
onRequestPermissionsResult
Declaration:
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)Description: Passes the permission request result to the SDK.
Parameters: Refer to Android permission requests and pass the results directly to the SDK for processing. If your application handles permission requests, you must use this method to pass the results to the SDK.
Return value: None.
onActivityResult
Declaration:
public void onActivityResult(int requestCode, int resultCode, Intent data)Description: Passes the result of the screen sharing permission request activity to the SDK.
Parameters: Refer to the result callback for an Android activity. Pass the result directly to the SDK for processing.
Return value: None.