

onRemoteUserEnterRoom(B) and onUserVideoAvailable(B,true). Therefore, users in room 101 can subscribe to the audio and video of anchor B.onRemoteUserEnterRoom(A) and onUserVideoAvailable(A,true). Therefore, users in room 102 can subscribe to the audio and video of anchor A.ConnectOtherRoom to establish the cross-room connection. Please do not call it in both directions.ConnectOtherRoom multiple times. Currently, a single anchor can connect with up to 9 other room anchors.
public void connectOtherRoom(String roomId, String userId) {try {JSONObject jsonObj = new JSONObject();// Take the room ID string as an example, numeric room ID key:roomIdjsonObj.put("strRoomId", roomId);jsonObj.put("userId", userId);mTRTCCloud.ConnectOtherRoom(jsonObj.toString());} catch (JSONException e) {e.printStackTrace();}}// Result callback for requesting cross-room mic-connection.@Overridepublic void onConnectOtherRoom(String userId, int errCode, String errMsg) {// userId: The user ID of the anchor in the other room you want to initiate the cross-room link-up// errCode: Error code. ERR_NULL indicates the request is successful// errMsg: Error message.}
- (void)connectOtherRoom:(NSString *)roomId {NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] init];// Take the room ID string as an example, numeric room ID key:roomId[jsonDict setObject:roomId forKey:@"strRoomId"];[jsonDict setObject:self.userId forKey:@"userId"];NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:NSJSONWritingPrettyPrinted error:nil];NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];[self.trtcCloud connectOtherRoom:jsonString];}// Result callback for requesting cross-room mic-connection.- (void)onConnectOtherRoom:(NSString *)userId errCode:(TXLiteAVError)errCode errMsg:(NSString *)errMsg {// userId: The user ID of the anchor in the other room you want to initiate the cross-room link-up// errCode: Error code. ERR_NULL indicates the request is successful// errMsg: Error message}
ConnectOtherRoom to establish the cross-room connection. Please do not call it in both directions.@Overridepublic void onUserAudioAvailable(String userId, boolean available) {// The remote user publishes/unpublishes their 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, view);} else {// Unsubscribe to the remote user's video stream and release the rendering control.mTRTCCloud.stopRemoteView(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG);}}
- (void)onUserAudioAvailable:(NSString *)userId available:(BOOL)available {// The remote user publishes/unpublishes their audio.// Under the automatic subscription mode, you do not need to do anything. The SDK will automatically play the remote user's audio.}- (void)onUserVideoAvailable:(NSString *)userId available:(BOOL)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.[self.trtcCloud startRemoteView:userId streamType:TRTCVideoStreamTypeBig view:self.remoteView];} else {// Unsubscribe to the remote user's video stream and release the rendering control.[self.trtcCloud stopRemoteView:userId streamType:TRTCVideoStreamTypeBig];}}
// Exiting cross-room mic-connection.mTRTCCloud.DisconnectOtherRoom();// Result callback for exiting cross-room mic-connection.@Overridepublic void onDisConnectOtherRoom(int errCode, String errMsg) {super.onDisConnectOtherRoom(errCode, errMsg);}
// Exiting cross-room mic-connection.[self.trtcCloud disconnectOtherRoom];// Result callback for exiting cross-room mic-connection.- (void)onDisconnectOtherRoom:(TXLiteAVError)errCode errMsg:(NSString *)errMsg {}

{"SdkAppId": 1400000000,"RoomId": "A","RoomIdType": 1,"AgentParams": {"UserId": "A_Agent","UserSig": "eJwtjMEKgkAUAP9lz2Hv6b40oU...","MaxIdleTime": 50},"WithTranscoding": 1,"AudioParams": {"AudioEncode": {"Codec": 0,"SampleRate": 48000,"Channel": 2,"BitRate": 64}},"FeedBackRoomParams": [{"RoomId": "B","RoomIdType": 1,"UserId": "A_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."},{"RoomId": "N","RoomIdType": 1,"UserId": "A_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."}]}
{"SdkAppId": 1400000000,"RoomId": "B","RoomIdType": 1,"AgentParams": {"UserId": "B_Agent","UserSig": "eJwtjMEKgkAUAP9lz2Hv6b40oU...","MaxIdleTime": 50},"WithTranscoding": 1,"AudioParams": {"AudioEncode": {"Codec": 0,"SampleRate": 48000,"Channel": 2,"BitRate": 64}},"FeedBackRoomParams": [{"RoomId": "A","RoomIdType": 1,"UserId": "B_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."},{"RoomId": "N","RoomIdType": 1,"UserId": "B_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."}]}
{"SdkAppId": 1400000000,"RoomId": "N","RoomIdType": 1,"AgentParams": {"UserId": "N_Agent","UserSig": "eJwtjMEKgkAUAP9lz2Hv6b40oU...","MaxIdleTime": 50},"WithTranscoding": 1,"AudioParams": {"AudioEncode": {"Codec": 0,"SampleRate": 48000,"Channel": 2,"BitRate": 64}},"FeedBackRoomParams": [{"RoomId": "A","RoomIdType": 1,"UserId": "N_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."},{"RoomId": "B","RoomIdType": 1,"UserId": "N_Feed","UserSig": "eJwtzEELgkAUBOD-sldD3745..."}]}
Solution Type | Solution Strength | Solution Disadvantages | Room and User Limit | Recommended Use Cases |
The call logic for two-person PK is simple | The call logic for multi-person PK is complex | A single host can PK with up to 9 other hosts in different rooms | Two rooms, single host (double) cross-room PK | |
Pure server-side scheme, client-side does not require additional processing | There are additional costs for robot streaming and mixing | Support up to 11 rooms for cross-room PK at the same time, each room supports up to 16 hosts participating in cross-room PK at the same time | Multiple rooms, multi-host (multi-person) cross-room PK, pure server-side management |
Feedback