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.EnvWebInfo; see EnvWebInfo
onNotifyChannelEvent
In-channel event callback. We recommend registering it beforejoin.
onNotifyImEvent
Out-of-channel IM event callback.join
Joins a channel and returns that channel’s Channel object. Get the channel info withchannel.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:joinused to returnChannelInfoand 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.channel.leave(); to leave a specific channel, call leave() on its Channel object directly.
getChannelInfo
Gets the current channel info. Returnsnull 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 aTrackMetric 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 thangetStreamMetric.
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 customMediaStreamTrack.
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 customMediaStreamTrack.
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.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).
unpublishLocalTrack
Unpublishes a local track; remote users receive theUSER_TRACK_REMOVE event.
enableLocalTrack
Resumes sending data for a paused local track.Remote users receive theTRACK_UNMUTEDevent. For how it differs frompublishLocalTrack, see Mute vs. unpublish.
disableLocalTrack
Pauses sending data for a local track without unpublishing it.Remote users receive theTRACK_MUTEDevent. For how it differs fromunpublishLocalTrack, 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.RemoteVideoMcuTrackextendsRemoteVideoTrackand 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 ofidanddesc; 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.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.