TRTCMeeting (Android)

Last updated: 2021-04-12 16:58:11

    TRTCMeeting has the following features based on Tencent Real-Time Communication (TRTC) and Instant Messaging (IM):

    • The chairperson can create a meeting room, and the participants can enter the room ID to join the meeting.
    • The participants can share their screens with each other.
    • All users can send various text and custom messages.

    TRTCMeeting is an open-source class depending on two closed-source Tencent Cloud SDKs. For the specific implementation process, please see Video Conferencing (Android).

    • TRTC SDK: the TRTC SDK is used as the low-latency video conferencing component.
    • IM SDK: the MeetingRoom feature of the IM SDK is used to implement chat rooms in meetings.

    TRTCMeeting API Overview

    Basic SDK APIs

    API Description
    sharedInstance Gets singleton object.
    destroySharedInstance Terminates singleton object.
    setDelegate Sets event callback.
    setDelegateHandler Sets the thread where the event callback is.
    login Logs in.
    logout Logs out.
    setSelfProfile Modifies personal information.

    Meeting room APIs

    API Description
    createMeeting Creates meeting room (called by chairperson).
    destroyMeeting Terminates meeting room (called by chairperson).
    enterMeeting Enters meeting room (called by participant).
    leaveMeeting Exits meeting room (called by participant).

    Remote user APIs

    API Description
    getUserInfoList Gets the list of all users in room. This API will take effect only if it is called after enterMeeting() succeeds.
    getUserInfo Gets the details of specified user in room. This API will take effect only if it is called after enterMeeting() succeeds.
    startRemoteView Plays back the remote video image of specified member.
    stopRemoteView Stops playing back remote video image.
    setRemoteViewFillMode Sets the rendering mode of remote image based on user ID.
    setRemoteViewRotation Sets the clockwise rotation angle of remote image.
    muteRemoteAudio Mutes specified member.
    muteRemoteVideoStream Blocks the video stream of specified member.

    Local video operation APIs

    API Description
    startCameraPreview Enables the preview image of local video.
    stopCameraPreview Stops local video capturing and preview.
    switchCamera Switches between front and rear cameras.
    setVideoResolution Sets resolution.
    setVideoFps Sets frame rate.
    setVideoBitrate Sets bitrate.
    setLocalViewMirror Sets the mirroring preview mode of local image.

    Local audio operation APIs

    API Description
    startMicrophone Enables mic capturing.
    stopMicrophone Stops mic capturing.
    setAudioQuality Sets audio quality.
    muteLocalAudio Mutes local audio.
    setSpeaker Enables speaker.
    setAudioCaptureVolume Sets mic capturing volume level.
    setAudioPlayoutVolume Sets playback volume level.
    startFileDumping Starts audio recording.
    stopFileDumping Stops audio recording.
    enableAudioEvaluation Enables volume level reminder.

    Screen sharing APIs

    API Description
    startScreenCapture Starts screen sharing.
    stopScreenCapture Stops screen sharing.
    pauseScreenCapture Pauses screen sharing.
    resumeScreenCapture Resumes screen sharing.

    Beauty filter APIs

    API Description
    getBeautyManager Gets beauty filter management object TXBeautyManager.

    Sharing APIs

    API Description
    getLiveBroadcastingURL Gets CDN sharing link.

    Message sending APIs

    API Description
    sendRoomTextMsg Broadcasts text message in room. This API is generally used for chat.
    sendRoomCustomMsg Sends custom (signaling) message.

    TRTCMeetingDelegate API Overview

    General event callbacks

    API Description
    onError Callback for error.

    Meeting room event callbacks

    API Description
    onRoomDestroy Callback for meeting room termination.
    onNetworkQuality Callback for network status.
    onUserVolumeUpdate Callback for user call volume level.

    Member entry/exit event callbacks

    API Description
    onUserEnterRoom Notification of new member's room entry.
    onUserLeaveRoom Notification of member's room exit.

    Member audio/video event callbacks

    API Description
    onUserVideoAvailable Notification of member enabling/disabling camera.
    onUserAudioAvailable Notification of member enabling/disabling mic.

    Message event callbacks

    API Description
    onRecvRoomTextMsg Receipt of text message.
    onRecvRoomCustomMsg Receipt of custom message.

    Screen sharing event callbacks

    API Description
    onScreenCaptureStarted Notification of screen sharing start.
    onScreenCapturePaused Callback for screen sharing pause.
    onScreenCaptureResumed Callback for screen sharing resumption.
    onScreenCaptureStoped Callback for screen sharing stop.

    Basic SDK APIs

    sharedInstance

    This API is used to get the TRTCMeeting singleton object.

     public static synchronized TRTCMeeting sharedInstance(Context context);
    

    The parameters are as detailed below:

    Parameter Type Description
    context Context Android context, which will be converted to ApplicationContext for the system APIs to call.

    destroySharedInstance

    This API is used to terminate the TRTCMeeting singleton object.

    Note:

    After the instance is terminated, the externally cached TRTCMeeting instance cannot be used, and you need to call sharedInstance again to get a new instance.

    public static void destroySharedInstance();
    

    setDelegate

    This API is used to get the event callback of TRTCMeeting. You can use TRTCMeetingDelegate to get various status notifications of TRTCMeeting.

    public abstract void setDelegate(TRTCMeetingDelegate delegate);
    

    Note:

    setDelegate is the delegation callback of TRTCMeeting.

    setDelegateHandler

    This API is used to set the thread where the event callback is.

    public abstract void setDelegateHandler(Handler handler);
    

    The parameters are as detailed below:

    Parameter Type Description
    handler Handler Notifies various status notification callbacks in TRTCMeeting through this handler. Please do not use this parameter together with setDelegate.

    login

    This API is used to log in.

    public abstract void login(int sdkAppId,
         String userId, String userSig,
         TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    sdkAppId int You can view the SDKAppID in the TRTC Console > Application Management > "Application Info".
    userId String ID of current user, which is a string that can contain only letters (a–z and A–Z), digits (0–9), hyphens (-), and underscores (_).
    userSig String Tencent Cloud's proprietary security protection signature. For more information on how to get it, please see How to Calculate UserSig.
    callback ActionCallback Callback for login. The code will be 0 if the operation succeeds.

    logout

    This API is used to log out.

    public abstract void logout(TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    callback ActionCallback Callback for logout. The code will be 0 if the operation succeeds.

    setSelfProfile

    This API is used to modify the personal information.

    public abstract void setSelfProfile(String userName, String avatarURL, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    userName String Nickname.
    avatarURL String Profile photo address.
    callback ActionCallback Callback for personal information setting. The code will be 0 if the operation succeeds.

    Meeting Room APIs

    createMeeting

    This API is used to create a meeting (called by the chairperson).

    public abstract void createMeeting(int roomId, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    roomId int Meeting room ID. You need to assign and manage the IDs in a centralized manner.
    callback ActionCallback Callback for room creation result. The code will be 0 if the operation succeeds.

    Generally, the chairperson calls the APIs in the following steps:

    1. The chairperson calls createMeeting() to create a meeting. No matter whether the room is successfully created, the result will be notified to the chairperson through ActionCallback.
    2. The chairperson calls startCameraPreview() to enable camera preview. At this time, the beauty filter parameters can be adjusted.
    3. The chairperson calls startMicrophone() to enable mic capturing.

    destroyMeeting

    This API is used to terminate a meeting room (called by the chairperson). After creating a meeting, the chairperson can call this API to terminate it.

    public abstract void destroyMeeting(int roomId, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    roomId int Meeting room ID. You need to assign and manage the IDs in a centralized manner.
    callback ActionCallback Callback for room termination result. The code will be 0 if the operation succeeds.

    enterMeeting

    This API is used to enter a meeting (called by the participant).

    public abstract void enterMeeting(int roomId, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    roomId int Meeting room ID.
    callback ActionCallback Callback for room entry result. The code will be 0 if the operation succeeds.

    Generally, the participant joins a meeting in the following steps:

    1. The participant calls enterMeeting and passes in roomId to enter the meeting room.
    2. The participant calls startCameraPreview() to enable camera preview and calls startMicrophone() to enable mic capturing.
    3. The participant receives the onUserVideoAvailable event and calls startRemoteView(userId) and passes in the userId of the target member to start playback.

    leaveMeeting

    This API is used to leave a meeting (called by the participant).

    public abstract void leaveMeeting(TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    callback ActionCallback Callback for room exit result. The code will be 0 if the operation succeeds.

    Remote User APIs

    getUserInfoList

    This API is used to get the list of all users in the room. It will take effect only if it is called after enterMeeting() succeeds.

    public abstract void getUserInfoList(TRTCMeetingCallback.UserListCallback userListCallback);
    

    The parameters are as detailed below:

    Parameter Type Description
    userListCallback UserListCallback Callback for user details.

    getUserInfo

    This API is used to get the details of a specified user in the room. It will take effect only if it is called after enterMeeting() succeeds.

    public abstract void getUserInfo(String userId, TRTCMeetingCallback.UserListCallback userListCallback);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    userListCallback UserListCallback Callback for user details.

    startRemoteView

    This API is used to play back the remote video image of a specified member. It can be called when the callback of onUserVideoAvailable() is true.

    public abstract void startRemoteView(String userId, TXCloudVideoView view, final TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String ID of the user whose video image is to be played back.
    view TXCloudVideoView view control that carries the video image.
    callback ActionCallback Callback for operation.

    stopRemoteView

    This API is used to stop playing back the remote video image. It can be called when the callback of onUserVideoAvailable() is false.

    public abstract void stopRemoteView(String userId, final TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String ID of the user whose video image is to be stopped.
    callback ActionCallback Callback for operation.

    setRemoteViewFillMode

    This API is used to set the rendering mode of the remote video image based on user ID.

    public abstract void setRemoteViewFillMode(String userId, int fillMode);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    fillMode int Fill or fit mode. Default value: fill (FILL). For more information, please see TRTC SDK.

    setRemoteViewRotation

    This API is used to set the clockwise rotation angle of the remote image.

    public abstract void setRemoteViewRotation(String userId, int rotation);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    rotation int Clockwise rotation angle. For more information, please see TRTC SDK.

    muteRemoteAudio

    This API is used to mute the remote audio.

    public abstract void muteRemoteAudio(String userId, boolean mute);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    mute boolean true: mutes; false: unmutes.

    muteRemoteVideoStream

    This API is used to block the remote video stream of a specified member.

    public abstract void muteRemoteVideoStream(String userId, boolean mute);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    mute boolean true: blocks; false: unblocks.

    Local Video Operation APIs

    startCameraPreview

    This API is used to enable the preview image of local video.

    public abstract void startCameraPreview(boolean isFront, TXCloudVideoView view);
    

    The parameters are as detailed below:

    Parameter Type Description
    isFront boolean true: front camera; false: rear camera.
    view TXCloudVideoView Control that carries the video image.

    stopCameraPreview

    This API is used to stop local video capturing and preview.

    public abstract void stopCameraPreview();
    

    switchCamera

    This API is used to switch between front and rear cameras.

    public abstract void switchCamera(boolean isFront);
    

    The parameters are as detailed below:

    Parameter Type Description
    isFront boolean Switches between front and rear cameras. true: front camera; false: rear camera.

    setVideoResolution

    This API is used to set the resolution.

    public abstract void setVideoResolution(int resolution);
    

    The parameters are as detailed below:

    Parameter Type Description
    resolution int Video resolution. For more information, please see TRTC SDK.

    setVideoFps

    This API is used to set the frame rate.

    public abstract void setVideoFps(int fps);
    

    The parameters are as detailed below:

    Parameter Type Description
    fps int Video capturing frame rate.

    Note:

    Recommended value: 15 or 20 fps. If the frame rate is lower than 5 fps, there will be obvious lagging; if lower than 10 fps but higher than 5 fps, there will be slight lagging; if higher than 20 fps, too many resources will be wasted (the frame rate of movies is generally 24 fps).

    setVideoBitrate

    This API is used to set the bitrate.

    public abstract void setVideoBitrate(int bitrate);
    

    The parameters are as detailed below:

    Parameter Type Description
    bitrate int Bitrate. The SDK encodes streams at the target video bitrate and will actively reduce the bitrate only if the network conditions are poor. For more information, please see TRTC SDK.

    Note:

    Recommended value: please see the optimal bitrate for each tier in TRTCVideoResolution. You can also slightly increase the optimal bitrate. For example, TRTC_VIDEO_RESOLUTION_1280_720 corresponds to the target bitrate of 1,200 Kbps, and you can also set the bitrate to 1,500 Kbps for higher definition.

    setLocalViewMirror

    This API is used to set the mirroring preview mode of local video image.

    public abstract void setLocalViewMirror(int type);
    

    The parameters are as detailed below:

    Parameter Type Description
    type int Mirroring mode. For more information, please see TRTC SDK.

    Local Audio Operation APIs

    startMicrophone

    This API is used to enable mic capturing.

    public abstract void startMicrophone();
    

    stopMicrophone

    This API is used to stop mic capturing.

    public abstract void stopMicrophone();
    

    setAudioQuality

    This API is used to set the audio quality.

    public abstract void setAudioQuality(int quality);
    

    The parameters are as detailed below:

    Parameter Type Description
    quality int Audio quality. For more information, please see TRTC SDK.

    muteLocalAudio

    This API is used to mute/unmute the local audio.

    public abstract void muteLocalAudio(boolean mute);
    

    The parameters are as detailed below:

    Parameter Type Description
    mute boolean Mutes/Unmutes. For more information, please see TRTC SDK.

    setSpeaker

    This API is used to enable the speaker.

    public abstract void setSpeaker(boolean useSpeaker);
    

    The parameters are as detailed below:

    Parameter Type Description
    useSpeaker boolean true: speaker; false: receiver.

    setAudioCaptureVolume

    This API is used to set the mic capturing volume level.

    public abstract void setAudioCaptureVolume(int volume);
    

    The parameters are as detailed below:

    Parameter Type Description
    volume int Capture volume level. Value range: 0–100. Default value: 100.

    setAudioPlayoutVolume

    This API is used to set the playback volume level.

    public abstract void setAudioPlayoutVolume(int volume);
    

    The parameters are as detailed below:

    Parameter Type Description
    volume int Playback volume level. Value range: 0–100. Default value: 100.

    startFileDumping

    This API is used to start audio recording.

    public abstract void startFileDumping(TRTCCloudDef.TRTCAudioRecordingParams trtcAudioRecordingParams);
    

    The parameters are as detailed below:

    Parameter Type Description
    trtcAudioRecordingParams TRTCCloudDef.TRTCAudioRecordingParams Audio recording parameters. For more information, please see TRTC SDK.

    Note:

    After this API is called, the SDK will record all audios (such as local audio, remote audio, and background music) in the current call to a file. No matter whether room entry is performed, this API will take effect once called. If audio recording is still ongoing when exitMeeting is called, it will stop automatically.

    stopFileDumping

    This API is used to stop audio recording.

    public abstract void stopFileDumping();
    

    enableAudioEvaluation

    This API is used to enable the volume level reminder.

    public abstract void enableAudioEvaluation(boolean enable);
    

    The parameters are as detailed below:

    Parameter Type Description
    enable boolean true: enables; false: disables.

    Note:

    After this feature is enabled, the result of volume level evaluation by the SDK will be obtained in onUserVolumeUpdate.

    Screen Sharing APIs

    startScreenCapture

    This API is used to start screen sharing.

    public abstract void startScreenCapture(TRTCCloudDef.TRTCVideoEncParam encParams, TRTCCloudDef.TRTCScreenShareParams screenShareParams);
    

    The parameters are as detailed below:

    Parameter Type Description
    encParams TRTCCloudDef.TRTCVideoEncParam Screen sharing encoding parameters. We recommend you use the above configuration. If you set encParams to null, the encoding parameter settings before startScreenCapture is called will be used.
    screenShareParams TRTCCloudDef.TRTCScreenShareParams Special screen sharing configuration. We recommend you set floatingView which can prevent the application from being killed by the system and help protect user privacy.

    Note:

    For more information, please see TRTC SDK.

    stopScreenCapture

    This API is used to stop screen sharing.

    public abstract void stopScreenCapture();
    

    pauseScreenCapture

    This API is used to pause screen sharing.

    public abstract void pauseScreenCapture();
    

    resumeScreenCapture

    This API is used to resume screen sharing.

    public abstract void resumeScreenCapture();
    

    Sharing APIs

    getLiveBroadcastingURL

    This API is used to get the CDN sharing link.

    public abstract String getLiveBroadcastingURL();
    

    The returned values are as detailed below:

    Returned Value Type Description
    url String CDN sharing link.

    Beauty Filter APIs

    getBeautyManager

    This API is used to get the beauty filter management object TXBeautyManager.

    public abstract TXBeautyManager getBeautyManager();
    

    You can use the following features with beauty filter management:

    • Set beauty effects such as "beauty filter style", "brightening", "rosy skin", "eye enlarging", "face slimming", "chin slimming", "chin lengthening or shortening", "face shortening", "nose narrowing", "eye brightening", "teeth whitening", "eye bag removal", "wrinkle removal", and "smile line removal".
    • Adjust the "hairline", "eye distance", "eye corners", "mouth shape", "nose wing", "nose position", "lip thickness", and "face shape".
    • Set animated effects such as facial pendants (materials).
    • Add makeup effects.
    • Recognize gestures.

    Message Sending APIs

    sendRoomTextMsg

    This API is used to broadcast a text message in the room.

    public abstract void sendRoomTextMsg(String message, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    message String Text message.
    callback ActionCallback Callback for sending result.

    sendRoomCustomMsg

    This API is used to send a custom text message.

    public abstract void sendRoomCustomMsg(String cmd, String message, TRTCMeetingCallback.ActionCallback callback);
    

    The parameters are as detailed below:

    Parameter Type Description
    cmd String Custom command word used to distinguish between different message types.
    message String Text message.
    callback ActionCallback Callback for sending result.

    TRTCMeetingDelegate Event Callbacks

    General Event Callbacks

    onError

    Callback for error.

    Note:

    The SDK encountered an irrecoverable error and must be listened on. Corresponding UI reminders should be displayed based on the actual conditions.

    void onError(int code, String message);
    

    The parameters are as detailed below:

    Parameter Type Description
    code int Error code.
    message String Error message.

    Room Event Callbacks

    onRoomDestroy

    Callback for room termination. When the chairperson exits the room, all users in the room will receive this callback.

    void onRoomDestroy(String roomId);
    

    The parameters are as detailed below:

    Parameter Type Description
    roomId String Room ID.

    onNetworkQuality

    Callback for network status.

     void onNetworkQuality(TRTCCloudDef.TRTCQuality localQuality, List<TRTCCloudDef.TRTCQuality> remoteQuality);
    

    The parameters are as detailed below:

    Parameter Type Description
    localQuality TRTCCloudDef.TRTCQuality Upstream network quality.
    remoteQuality List<TRTCCloudDef.TRTCQuality> Downstream network quality.

    Note:

    For more information, please see TRTC SDK.

    onUserVolumeUpdate

    Notification to all members of the volume level after the volume level reminder is enabled.

    void onUserVolumeUpdate(String userId, int volume);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    volume int Volume level. Value range: 0–100.

    Member Entry/Exit Event Callbacks

    onUserEnterRoom

    Notification of new member's room entry.

    void onUserEnterRoom(String userId);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID of the new member who enters the room.

    onUserLeaveRoom

    Notification of member's room exit.

    void onUserLeaveRoom(String userId);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID of the member who exits the room.

    Member Audio/Video Event Callbacks

    onUserVideoAvailable

    Notification of member enabling/disabling camera.

    void onUserVideoAvailable(String userId, boolean available);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    available boolean true: the camera is enabled; false: the camera is disabled.

    onUserAudioAvailable

    Notification of member enabling/disabling mic.

    void onUserAudioAvailable(String userId, boolean available);
    

    The parameters are as detailed below:

    Parameter Type Description
    userId String User ID.
    available boolean true: the mic is enabled; false: the mic is disabled;

    Message Event Callbacks

    onRecvRoomTextMsg

    Receipt of text message.

    void onRecvRoomTextMsg(String message, TRTCMeetingDef.UserInfo userInfo);
    

    The parameters are as detailed below:

    Parameter Type Description
    message String Text message.
    user UserInfo User information of sender.

    onRecvRoomCustomMsg

    Receipt of custom message.

    void onRecvRoomCustomMsg(String cmd, String message, TRTCMeetingDef.UserInfo userInfo);
    

    The parameters are as detailed below:

    Parameter Type Description
    command String Custom command word used to distinguish between different message types.
    message String Text message.
    user UserInfo User information of sender.

    Screen Sharing Event Callbacks

    onScreenCaptureStarted

    Screen sharing start notification.

    void onScreenCaptureStarted();
    

    onScreenCapturePaused

    Screen sharing pause notification.

    void onScreenCapturePaused();
    

    onScreenCaptureResumed

    Screen sharing resumption notification.

    void onScreenCaptureResumed();
    

    onScreenCaptureStoped

    Screen sharing stop notification.

    void onScreenCaptureStopped(int reason);
    

    The parameters are as detailed below:

    Parameter Type Description
    reason int Reason for stop. 0: the user stopped proactively; 1: stopped due to preemption by another application.