RTCEngine join multiple channels at the same time within one initialization cycle. Each join(...) returns an RTCChannel handle. Local camera, microphone, and screen capture are shared by the Engine, while each channel’s signaling, media streaming session, users, remote tracks, and statistics are independent of one another.
Objects and scopes
:::note
The first
join is the “default channel”, not the first channel to reach onJoinSucceed. After the default channel is left, the next newly created channel can take the default slot. Multi-channel apps should always keep and use the RTCChannel returned by each join, rather than relying on the flat APIs to infer the target channel.
:::
Integration flow
1. Create the Engine
Multiple channels need only oneRTCEngine:
2. Start shared capture
Capture and per-channel publishing are independent. The following tracks are shared within the Engine and started only once:RTCResultListener.onSuccess() before publishing. Setting a local audio frame listener alone doesn’t open the microphone; if you need PCM, you still have to call micTrack.startCapture(...).
3. Create callbacks for each channel and join
The initialRTCClientEvent must be passed in through this join(...) call, because the join success or failure event may follow immediately. RTCChannel.setRtcClientEvent(...) is only for replacing or unbinding the listener after the join succeeds.
onJoinSucceed(...) is dispatched only after join(...) returns. A non-null handle only means the request was accepted; channel operations such as publishing and subscribing called before the success callback are blocked with CHANNEL_NOT_START.
4. Subscribe and render per channel
Remote tracks must be obtained and subscribed through the sameRTCChannel that produced the event:
uid / trackId from channel A and query or subscribe with it on channel B’s handle. Even if the strings are identical, users, tracks, and media state are not shared between the two channel sessions.
Shared capture and per-channel publishing
Capture, publishing, and muting are three different layers:
So unpublishing in channel A doesn’t affect channel B, but calling
micTrack.stopCapture() or cameraTrack.stopCapture() closes the shared data source, and every channel still publishing that track loses its capture data.
Leaving and releasing
To leave a single channel, call its handle; other channels are unaffected:releaseSDK() releases all channels and shared resources in the current initialization cycle as a fallback. To use the SDK again, call initSDK() again.
Failures and error handling
join(...)returnsnull: the request was rejected before the channel session was created; the status code from this call’sonJoinFailed(...)is still authoritative.- Joining the same channel twice:
onJoinFailed(channel, RtcChannelErrorCode.CHANNEL_ALREADY_EXISTS)(102208); the existing channel and listener are unaffected. - SDK not initialized or already released:
join(...)synchronously throwsSdkNotInitializedException. - Asynchronous operations that fail after joining: reported through each operation’s
RTCResultListener.onFail(code). - Operations blocked by the Engine or global errors: reported through
RTCEngineEvent.onError(channelId, errorCode, message). - Channel disconnects and reconnects: distinguished by
onDisconnected,onReconnecting, andonReconnected, which carry thechannelparameter.
102xxx domain constants, see Error codes. For the full channel API, see RTCChannel.