Skip to main content
SRTC is the main entry point of the Web SDK. Create an instance with new SRTC(initParams). The channel-level methods on this page (publishing, subscribing, user queries, leave, etc.) are equivalent to the methods of the same name on the Channel object returned by join, and act on the current (default) channel. When you join multiple channels at once, call them on each Channel object instead to specify the target. See Multi-channel.

constructor


buildInfo

Gets the SDK build information.

getEnvInfo

Gets the WebRTC capability detection result for the current browser. We recommend calling it as early as possible after initialization.
Returns: EnvWebInfo; see EnvWebInfo

onNotifyChannelEvent

In-channel event callback. We recommend registering it before join.
For the full list of event types, see Events.

onNotifyImEvent

Out-of-channel IM event callback.

join

Joins a channel and returns that channel’s Channel object. Get the channel info with channel.getInfo().
You can call it multiple times to join several channels at once. Single-channel apps can ignore the return value and keep using the channel-level methods on the srtc instance (which act on the current channel). For the Channel object’s methods and multi-channel usage, see Multi-channel.
Migrating from older versions: join used to return ChannelInfo and now returns a Channel object; the old return value is equivalent to (await srtc.join(token)).getInfo().

leave

Leaves the channel. For local tracks, the SDK automatically stops capture, stops playback, or removes play views after leaving.
With multiple channels, it acts on the earliest-joined channel and is equivalent to that channel’s channel.leave(); to leave a specific channel, call leave() on its Channel object directly.

getChannelInfo

Gets the current channel info. Returns null when not in a channel.

getUserInfo

Gets the info of a given user in the channel.

getUsersInfo

Gets the info of all users in the channel, as either an array or a map.

getStreamMetric

Gets the current full media metric snapshot, including overall network statistics and a TrackMetric for each local/remote track.
Throws if called when not in a channel. For field details, see Network quality.

getNetworkStats

Gets the current overall network statistics. Use it when you only care about the network overview (bitrate, packet loss, RTT, available bandwidth); it’s lighter than getStreamMetric.
Throws if called when not in a channel.

getConnectionQuality

Gets the current connection quality evaluation, returning the uplink/downlink levels, the overall level, MOS, and the triggering reasons. The SDK evaluates internally over a 2-second sliding window.
Throws if called when not in a channel. For apps, we recommend subscribing to the ChannelEventType.CONNECTION_QUALITY_CHANGED event to be notified of changes passively.

getDevices

Enumerates media devices.

createLocalMicTrack

Creates a microphone audio track.

createLocalCustomAudioTrack

Creates a local audio track from a custom MediaStreamTrack.

createLocalCameraTrack

Creates a camera video track.

createLocalScreenTrack

Creates a screen sharing video track.
A system audio track is created as well by default. Whether system audio can actually be captured also depends on the browser’s capabilities and on whether the user checks “Share audio” in the system sharing dialog.

createLocalCustomVideoTrack

Creates a local video track from a custom MediaStreamTrack.

createLocalCompositeRecorder

Creates a local composite recorder, used in the browser to composite the video tiles and audio tracks that the current page needs to record into a local recording file.
The returned LocalCompositeRecorder is only responsible for media compositing and the MediaRecorder lifecycle; your app computes the view—video grids, paging, speaker layout, screen sharing priority, and so on—and passes it in through videoItems and updateVideoItems(...).
For detailed usage, see Local recording.

publishLocalTrack

Publishes a local track to the channel; after publishing, remote users can subscribe to it.
Returns: TrackInfo, a snapshot of this publication’s track description in the channel; to get the latest value later, use channel.getPublishInfo(track).
Within one channel, only one track per desc can be published. Publishing the same desc again with a different track (for example, a mic track is already published and you publish a second mic) throws; publishing the same track again is unaffected and remains idempotent.So serialize entry points such as turning on the microphone or camera yourself: if you publish again before the previous publishLocalTrack has finished awaiting, two tracks publish at the same time, and you usually only keep a reference to the one created later, so the one published first can never be unpublished.

unpublishLocalTrack

Unpublishes a local track; remote users receive the USER_TRACK_REMOVE event.

enableLocalTrack

Resumes sending data for a paused local track.
Remote users receive the TRACK_UNMUTED event. For how it differs from publishLocalTrack, see Mute vs. unpublish.

disableLocalTrack

Pauses sending data for a local track without unpublishing it.
Remote users receive the TRACK_MUTED event. For how it differs from unpublishLocalTrack, see Mute vs. unpublish.

subscribeRemoteAudioMixTrack

Subscribes to the channel-wide mixed audio track.

subscribeRemoteAudioTrack

Subscribes to a single audio stream of a given user.

subscribeRemoteVideoTrack

Subscribes to a given user’s video stream.

subscribeRemoteVideoMcuTrack

Subscribes to the remote composite video stream.
RemoteVideoMcuTrack extends RemoteVideoTrack and can be used like a regular remote video track.

unsubscribeRemoteTrack

Unsubscribes from a remote stream.

getRemoteTrack

Gets a subscribed remote track instance by user ID and either track ID or track description.
You must pass at least one of id and desc; otherwise it throws.

enableIm

Enables out-of-channel IM messages.
Returns: Promise<string>, the IM session sid.

disableIm

Disables out-of-channel IM messages.

destroy

Fully releases the SRTC instance: leaves all channels in turn, disables IM, and removes the listeners the instance registered on browser global objects (device plug/unplug, page visibility). It’s idempotent—repeated calls return immediately; calling the instance’s methods afterward throws.
Without destroy(), the global listeners keep holding a reference to the instance so it can’t be garbage-collected. So you must call it before an SPA route navigates away from the audio/video page, before a component unmounts, or before you create a new SRTC instance; apps whose instance lives as long as the page don’t need to call it. For everyday joining and leaving of channels, leave() (or channel.leave()) is enough, and the instance can be reused to join again.