Skip to main content

SRTC instance

Create an instance with new SRTC(initParams); almost all operations are exposed through this instance.
  • One instance can call join multiple times to join several channels at once; each join returns that channel’s Channel object
  • In-channel events are delivered through the srtc.onNotifyChannelEvent callback; with multiple channels, use each channel’s channel.onNotifyEvent to 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.
You can perform channel-level operations such as publishing, subscribing, and leaving directly on the Channel object returned by 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 (call srtc.enableIm(token) first to enable IM):
For the full event list, see Events (Chinese).

Audience mode (is_audience)

When UserInfo.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_UPDATE event to detect changes to your own audience status