srtc.Channel represents a joined channel connection. It’s created with await Channel.join(...), supports async with, and leaves the channel automatically on exit. One process can hold multiple Channel objects at the same time, independent of each other.
Call every method within the asyncio event loop. On failure, it raises srtc.SdkError.
Lifecycle
Channel.join
Raises:
SdkError. Common ones include an invalid token (1021 / 1032), the concurrency limit being reached (1033), and no available node (1034 / 1035); see Error codes.
leave
async with, it’s called automatically on exit.
wait_closed
Brief disconnects caused by network jitter are reconnected automatically by the SDK;
on_connection_state(RECONNECTING) fires during that time, and wait_closed doesn’t end. It returns only when reconnection is abandoned and the channel is fully left.closed
disconnect_reason
None when not disconnected.
Querying info
The following properties read the local cache without going over the network, so you can call them at any time.Subscribing
Whenauto_subscribe_audio / auto_subscribe_video is enabled, you don’t need to subscribe manually.
subscribe_audio / subscribe_video
uid and track_id come from the on_track_added event or UserInfo.stream_tracks.
To subscribe to the channel’s composite stream, pass srtc.MCU_PUBLISHER_UID as uid, and srtc.TRACK_AMCU_ID (audio) or srtc.TRACK_MCU_ID (video) as track_id.
unsubscribe
request_key_frame
decode_video is on, the SDK requests one automatically on decoding errors, so you usually don’t need to call it manually.
switch_layer
on_layer_switched.
Publishing
publish_audio
AudioTrack; then push data with await track.write(pcm).
Raises:
SdkError, such as publishing negotiation failure (180300) or timeout (180302).
unpublish
Consuming media data
Choose either approach: implementon_audio_frame / on_video_frame in ChannelHandler, or use the async for below. The latter fits linear AI processing flows better.
audio_frames
frame.uid to tell speakers apart), in the audio_format given when joining. Iteration ends naturally after the channel disconnects.
video_frames
When consumption can’t keep up, the SDK drops the oldest frames (the audio buffer holds about 10 seconds, video 60 frames), so latency doesn’t grow without bound. You can run multiple
async for loops at the same time, and each one gets all frames.