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

networkCheck

Pre-call network check: call it before joining. It doesn’t require joining a channel and doesn’t use token authentication. It checks 5 items in order (network permission, network connection, MTU, DNS resolution, server connectivity), calls onItem each time an item completes, and finally returns a summary. Each item times out after 3 seconds by default (adjustable with timeoutMs). Within the server connectivity item, the SDK API is tested first, then signaling and media in parallel, so the whole check takes at most about 3 item timeouts (about 9 seconds by default).
Return value: Promise<NetworkCheckResult>, always 5 items in a fixed order; see Pre-call network check types
  • Web platform limitations: browsers have no queryable network permission, can’t access raw UDP, and can’t resolve domain names on their own, so the permission, mtu, and dns items are always unsupported (DNS resolution failures show up in the server connectivity item). Signaling is tested over WebSocket only.
  • When the server’s streaming media isn’t seastart, the media sub-check in the server connectivity item is skipped (vendor_not_supported).
  • The server must provide the network check API. With an older server version that lacks it, the server connectivity item is fail (api_unreachable, with data.api.httpStatus 404), and the signaling and media sub-checks are skipped.
  • An instance can run only one check at a time; calling it again while a check is in progress throws 106005. When canceled by cancelNetworkCheck, it throws 106026. When appId / serverUrl is missing and token can’t be decoded, it throws 106031. destroy() automatically cancels a check in progress.

cancelNetworkCheck

Cancels the network check in progress; networkCheck then ends with 106026 (Cancelled). Has no effect when no check is running.

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.

setRemoteUserVolume

Sets the playback volume of a remote user. It only affects how loud you hear that user locally and does not affect other members. A typical use is simultaneous interpretation: lower the speaker’s original voice while the interpretation audio plays, and restore it afterward.
Return value: whether the setting took effect. Returns false (with a warn log, no exception) when the channel uses server-side mixing or you have already left the channel.
  • Applies to all audio tracks of the user (microphone + system audio from screen sharing), and audio tracks the user publishes later pick it up automatically. The setting is cleared when the user leaves the channel; the user has the original volume after joining again
  • When playing through subscribeRemoteAudioMixTrack, the volume is adjusted per user, with a ramp and no popping, and the setting survives resubscribing to the mixed audio track. When playing tracks individually through subscribeRemoteAudioTrack, it sets the playback volume of that track (no ramp)
  • Per-user adjustment isn’t possible with server-side mixing (only one mixed audio stream) or the composite video stream; in that case it returns false
  • Parameters are validated before the checks above: invalid parameters always throw
Calling it on the srtc instance before joining a channel throws NotInChannel.

getRemoteUserVolume

Gets the playback volume of a remote user.
Return value: from 0 to 1; returns 1 if never set (or the user has left).

playAudioClip

Plays an audio clip into your local audio output (such as interpretation audio for simultaneous interpretation). Only you hear it; it isn’t published to the channel.
Return value: a clip handle AudioClipHandle, with duration (length in seconds), stop() (stops immediately; safe to call repeatedly), and ended (resolves when playback finishes or is stopped; never rejects).
  • While the mixed audio track from subscribeRemoteAudioMixTrack is playing, the clip is merged into the mix and comes out of the same speaker as remote voices (following the mix’s output device)
  • In other cases (server-side mixing, per-track playback, or the mixed audio track not yet started with startPlay), the clip plays through a separate <audio> element. The output device is opt.deviceId; if not passed, it uses the device specified in the last startPlay of the mixed audio track
  • When the browser blocks autoplay, the SDK’s built-in prompt dialog appears and playback starts after the user clicks. With opt.disableAutoPlayDialog: true, no dialog appears and the call rejects with PlayFailed
  • No queuing: multiple calls play simultaneously on top of each other; queue or interrupt clips in your own code
  • When you leave the channel, all clips in progress stop (and ended resolves)
Exceptions:

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.