Overview
Strengths
Use Cases




// RTC Engine SDK for the Lite Edition, including two features, that is, RTC and live streaming playback.dependencies {implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'}
repositories.defaultConfig {ndk {abiFilters "armeabi-v7a", "arm64-v8a"}}
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><uses-permission android:name="android.permission.BLUETOOTH" /><uses-permission android:name="android.permission.CAMERA" /><uses-feature android:name="android.hardware.camera.autofocus" />
android:hardwareAccelerated="false". Disabling hardware acceleration will result in failure to render the other party's video stream.targetSdkVersion is 31 or the target device runs Android 12 or later, it is mandatory to dynamically request the android.permission.BLUETOOTH_CONNECT permission in the code to ensure proper Bluetooth feature. For more details, see Android Official Documentation.-keep class com.tencent.** { *; }

// Create an RTC Engine SDK instance (singleton mode).TRTCCloud mTRTCCloud = TRTCCloud.sharedInstance(context);// Set an event listener.mTRTCCloud.setListener(trtcSdkListener);// Notifications from various SDK events (e.g., error codes, warning codes, audio and video status parameters, etc.).private TRTCCloudListener trtcSdkListener = new TRTCCloudListener() {@Overridepublic void onError(int errCode, String errMsg, Bundle extraInfo) {Log.d(TAG, errCode + errMsg);}@Overridepublic void onWarning(int warningCode, String warningMsg, Bundle extraInfo) {Log.d(TAG, warningCode + warningMsg);}};// Remove the event listenermTRTCCloud.setListener(null);// Terminate the TRTC SDK instance (singleton mode).TRTCCloud.destroySharedInstance();
rtmp://intl-rtmp.rtc.qq.com/push/roomID?sdkappid=application&userid=username&usersig=signature
rtmp://intl-rtmp.rtc.qq.com/push/hello-string-room?sdkappid=140**66&userid=rtmp2&usersig=eJw1jdERBZ8qKGRj8Yp-wVbvmGMVZqS7w-mMDQL

roomId and string type strRoomId. The rooms of these two types are not interconnected. It is recommended to unify the room ID type.TRTC_APP_SCENE_VIDEOCALL mode for entering a room, as it ensures lower latency.
public void enterRoomByAudience(String roomId, String userId) {TRTCCloudDef.TRTCParams params = new TRTCCloudDef.TRTCParams();// Take the room ID string as an example.params.strRoomId = roomId;params.userId = userId;// UserSig obtained from the business backend.params.userSig = getUserSig(userId);// Replace with your SDKAppID.params.sdkAppId = SDKAppID;mTRTCCloud.enterRoom(params, TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL);}// Event callback for the result of entering the room.@Overridepublic void onEnterRoom(long result) {if (result > 0) {// The result represents the time taken to join the room (in milliseconds).Log.d(TAG, "Enter room succeed");} else {// The result represents the error code when you fail to enter the room.Log.d(TAG, "Enter room failed");}}
@Overridepublic void onUserAudioAvailable(String userId, boolean available) {// The remote user publishes/unpublishes the audio.// Under the automatic subscription mode, you do not need to do anything. The SDK will automatically play the remote user's audio.}@Overridepublic void onUserVideoAvailable(String userId, boolean available) {// The remote user publishes/unpublishes the primary video.if (available) {// Subscribe to the remote user's video stream and bind the video rendering control.mTRTCCloud.startRemoteView(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, TXCloudVideoView view);} else {// Unsubscribe to the remote user's video stream and release the rendering control.mTRTCCloud.stopRemoteView(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG);}}
TRTCCloudDef.TRTCRenderParams params = new TRTCCloudDef.TRTCRenderParams();params.mirrorType = TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_AUTO; // Video mirror mode.params.fillMode = TRTCCloudDef.TRTC_VIDEO_RENDER_MODE_FILL; // Video fill mode.params.rotation = TRTCCloudDef.TRTC_VIDEO_ROTATION_0; // Video rotation angle.// Set the rendering mode for the remote video.mTRTCCloud.setRemoteRenderParams(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, params)
public void exitRoom() {mTRTCCloud.stopLocalAudio();mTRTCCloud.stopLocalPreview();mTRTCCloud.exitRoom();}// Event callback for exiting the room.@Overridepublic void onExitRoom(int reason) {if (reason == 0) {Log.d(TAG, "Actively call exitRoom to exit the room.");} else if (reason == 1) {Log.d(TAG, "Removed from the current room by the server.");} else if (reason == 2) {Log.d(TAG, "The current room has been dissolved.");}}
onExitRoom callback notification to inform you.enterRoom again or switch to another audio and video SDK, wait for the onExitRoom callback before proceeding. Otherwise, you may encounter various exceptional issues such as the camera, microphone device being forcibly occupied.DismissRoom for dissolving rooms with numeric types and the API DismissRoomByStrRoomId for dissolving rooms with string types. You can use these server-side APIs to remove all users from the room and dissolve the room.exitRoom to exit the room. Once all anchors and audiences have exited the room, the room will be automatically dissolved according to the RTC Engine room lifecycle rules. For details, see RTC Engine Exit the Room.onError callback. For details, see RTC Engine Error Codes.Error Example | Value | Description |
ERR_TRTC_INVALID_USER_SIG | -3320 | The room entry parameter UserSig is incorrect. Check whether TRTCParams.userSig is empty. |
ERR_TRTC_USER_SIG_CHECK_FAILED | -100018 | UserSig verification failed. Check if the parameter TRTCParams.userSig is filled in correctly or has expired. |
Error Example | Value | Description |
ERR_TRTC_CONNECT_SERVER_TIMEOUT | -3308 | The room entry request timed out. Check whether your Internet connection is lost or if a VPN is enabled. You may also attempt to switch to 4G for testing. |
ERR_TRTC_INVALID_SDK_APPID | -3317 | The room entry parameter sdkAppId is incorrect. Check whether TRTCParams.sdkAppId is empty |
ERR_TRTC_INVALID_ROOM_ID | -3318 | The room entry parameter roomId is incorrect.Check whether TRTCParams.roomId or TRTCParams.strRoomId is empty. Note that roomId and strRoomId cannot be used interchangeably. |
ERR_TRTC_INVALID_USER_ID | -3319 | The room entry parameter userId is incorrect. Check whether TRTCParams.userId is empty. |
ERR_TRTC_ENTER_ROOM_REFUSED | -3340 | The room entry request was denied. Check whether enterRoom is called consecutively to enter rooms with the same ID. |
Error Example | Value | Description |
ERR_CAMERA_START_FAIL | -1301 | Failed to turn the camera on. For example, if there is an exception for the camera's configuration program (driver) on a Windows or Mac device, you should try disabling then re-enabling the device, restarting the machine, or updating the configuration program. |
ERR_MIC_START_FAIL | -1302 | Failed to turn the microphone on. For example, if there is an exception for the microphone's configuration program (driver) on a Windows or Mac device, you should try disabling and then re-enabling the device, restarting the machine, or updating the configuration program. |
ERR_CAMERA_NOT_AUTHORIZED | -1314 | The camera is unauthorized. This typically occurs on mobile devices, probably because the user denied the permission. |
ERR_MIC_NOT_AUTHORIZED | -1317 | The microphone is unauthorized. This typically occurs on mobile devices, probably because the user denied the permission. |
ERR_CAMERA_OCCUPY | -1316 | The camera is occupied. Try a different camera. |
ERR_MIC_OCCUPY | -1319 | The microphone is occupied. For example, when the user is currently having a call on a mobile device, the microphone cannot be turned on. |

Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan