SRTC instance
Create an instance withnew SRTC(initParams); almost all operations are exposed through this instance.
- One instance can call
joinmultiple times to join several channels at once; eachjoinreturns that channel’s Channel object - In-channel events are delivered through the
srtc.onNotifyChannelEventcallback; with multiple channels, use each channel’schannel.onNotifyEventto tell them apart. See Multi-channel (Chinese)
Channel and token
A channel is the container for a multi-user audio and video session, uniquely identified by its channel name. Users who join the same channel can send and receive audio and video streams with each other. A token is the credential for joining a channel. Your server issues it through the STMLink server API, and it carries the channel name, user ID, permissions, and other information. Every join requires a valid token.join. Single-channel apps don’t need to care about it—the srtc instance keeps all channel-level methods (internally acting on the current channel); you only need it to specify the target when you join multiple channels at once. See Multi-channel (Chinese).
After joining, you can get channel and user information at any time with these methods:
Track system
A track is the smallest unit of audio and video data; each audio or video stream is a track.Class hierarchy
Track types
Local track lifecycle
Event system
SRTC provides two sets of event callbacks:In-channel events (onNotifyChannelEvent)
Listen for channel connection state, remote users joining and leaving, remote track changes, local device state, and more:Out-of-channel message events (onNotifyImEvent)
Listen for IM messages (callsrtc.enableIm(token) first to enable IM):
Audience mode (is_audience)
WhenUserInfo.is_audience is true, the user has joined the channel as an audience member:
- Audience members only receive audio and video streams and can’t publish local tracks
- Whether a user joins as audience is decided when the server issues the token
- Use the
ChannelEventType.ME_UPDATEevent to detect changes to your own audience status