By default, only users in the same room can communicate with each other through audio and video streams. Information between different rooms is isolated. You can use the cross-channel subscription feature to enable communication between different rooms to meet your business requirements in specific scenarios, such as co-streaming. This topic describes how to implement cross-channel subscription and provides the relevant sample code.
How it works
When Streamer A1 subscribes to the stream of Streamer B1 in Room B, if Room B or Streamer B1 does not exist, A1 waits until the app cancels the cross-channel subscription. This simplifies the processing logic.
Sample code
Subscribe to audio and video streams across channels
Sample code for Android:
/* Subscribe to the camera stream and audio stream of B1 in Room B. */ mAliRtcEngine.subscribeRemoteDestChannelStream("B","B1",AliRtcVideoTrack.AliRtcVideoTrackCamera,true,true);
Sample code for iOS:
/* Subscribe to the camera stream and audio stream of B1 in Room B. */ [self.engine subscribeRemoteDestChannelStream:@"B" uid:@"B1" track:AliRtcVideoTrackCamera subAudio:YES sub:YES];
Sample code for Windows:
/* Subscribe to the camera stream and audio stream of B1 in Room B. */ mAliRtcEngine->SubscribeRemoteDestChannelStream("B","B1",AliEngineVideoTrackCamera,true,true);
Cancel cross-channel subscription to audio and video streams
Sample code for Android:
/* Unsubscribe from the camera stream and audio stream of B1 in Room B. */ mAliRtcEngine.subscribeRemoteDestChannelStream("B","B1",AliRtcVideoTrack.AliRtcVideoTrackNo,false,false);
Sample code for iOS:
/* Unsubscribe from the camera stream and audio stream of B1 in Room B. */ [self.engine subscribeRemoteDestChannelStream:@"B" uid:@"B1" track:AliRtcVideoTrackNo subAudio:NO sub:NO];
Sample code for Windows:
/* Unsubscribe from the camera stream and audio stream of B1 in Room B. */ mAliRtcEngine->SubscribeRemoteDestChannelStream("B","B1",AliEngineVideoTrackCamera,false,false);