Skip to navigation

StreamManager (class)

Web SDK v5 API reference
View as Markdown

Stream

Class that provides API for creating and managing audio and video streams.

Methods

createAudioStream

createAudioStream(config: AudioConfig, deviceId?: string): Promise<LocalStream>

Creates an audio stream.

Returns a promise that resolves to a LocalStream object.

Parameters

ParameterTypeRequirementDescription
configAudioConfigRequiredAudio stream configuration
deviceIdstringOptionalPreferred audio device id

Returns: Promise<LocalStream>

createScreenSharingStream

createScreenSharingStream(config?: ScreenSharingConfig): Promise<LocalScreenSharingStream[]>

Creates a screen sharing stream.

Returns a promise that resolves to a LocalScreenSharingStream object.

Parameters

ParameterTypeRequirementDescription
configScreenSharingConfigOptionalScreen sharing configuration

Returns: Promise<LocalScreenSharingStream[]>

createVideoStream

createVideoStream(config: VideoConfig, deviceId?: string): Promise<LocalStream>

Creates a video stream.

The specified quality in the video configuration can be lowered if the device cannot provided, or if the stream capture has already begun.

Please avoid concurrent calls of this method with DevicePermission.requestCameraPermission and getUserMedia.

Returns a promise that resolves to a LocalStream object.

Parameters

ParameterTypeRequirementDescription
configVideoConfigRequiredVideo stream configuration
deviceIdstringOptionalPreferred video device id

Returns: Promise<LocalStream>

getStream

getStream(id: string): null | LocalStream | LocalScreenSharingStream

Returns a local audio or video stream by its id or null if there is no stream with the provided id.

Parameters

ParameterTypeRequirementDescription
idstringRequiredStream id

Returns: null | LocalStream | LocalScreenSharingStream

stopStream

stopStream(id: string): void

Stops and removes a stream by its id.

Stream stop results in closing all MediaStreamTrack associated with the stream and releasing its source (microphone, camera, or display)

After calling this method, the stream cannot be obtained by the StreamManager.getStream method.

Parameters

ParameterTypeRequirementDescription
idstringRequiredStream id

Returns: void

wrapAudioStream

wrapAudioStream(stream: MediaStream): LocalStream

Creates a local audio stream with a provided MediaStream object.

Parameters

ParameterTypeRequirementDescription
streamMediaStreamRequiredMediaStream object

Returns: LocalStream

wrapVideoStream

wrapVideoStream(stream: MediaStream): LocalStream

Creates a local video stream with a provided MediaStream object.

Parameters

ParameterTypeRequirementDescription
streamMediaStreamRequiredMediaStream object

Returns: LocalStream