MediaStreamHelpers

MediaStreamHelpers

All helper and utility functions for MediaStream class are listed here.

Source:

Methods

(private, static) addLocalMediaStreams(targetMid, roomState)

Function that sets User's Stream to send to Peer connection. Priority for shareScreen() Stream over MediaStream.getUserMedia Stream.

Parameters:
Name Type Description
targetMid String

The mid of the target peer

roomState SkylinkState

Skylink State of current room

Source:

(static) dispatchOnLocalStreamEnded(room, stream, isScreensharing)

Function that handles the RTCPeerConnection.removeTracks(sender) on the local MediaStream.

Parameters:
Name Type Default Description
room SkylinkRoom
stream MediaStream

The stream.

isScreensharing boolean false
Source:
Fires:
  • event:streamEnded

(static) getStreams(roomState) → {streamList}

Function that returns all active user streams including screenshare stream if present.

Parameters:
Name Type Description
roomState SkylinkState
Source:

(static) getStreamSources() → {Promise|Object|Object|Array|Object|String|String|String|Array|Object|Object|Array|Object}

Function that returns the camera and microphone sources.

Source:

(static) muteStreams(roomState, options, streamId)

Parameters:
Name Type Description
roomState SkylinkState
options boolean
Properties
Name Type Description
audioMuted boolean
videoMuted boolean
streamId String
Source:
Fires:
  • streamMuted, peerUpdated,event: localMediaMuted

(private, static) onRemoteTrackAdded(stream, currentRoomState, targetMid, isScreensharing, isVideo, isAudio-)

Function that handles the RTCPeerConnection.ontrack event on remote stream added.

Parameters:
Name Type Description
stream MediaStream

https://developer.mozilla.org/en-US/docs/Web/API/MediaStream

currentRoomState SkylinkState

Current room state

targetMid String

The mid of the target peer

isScreensharing boolean

The flag if incoming stream is a screenshare stream.

isVideo boolean

The flag if incoming stream has a video track.

isAudio- boolean

The flag if incoming stream has an audio track.

Source:
Fires:
  • event:onIncomingStream
  • event:peerUpdated

(static) onStreamAccessError(error, reject, roomKey, audioSettings, videoSettings, resolve) → {Promise.<(MediaStream|never)>}

Parameters:
Name Type Description
error Error

The error object.

reject function

Reject function from promise.

roomKey String

The room rid.

audioSettings JSON

The audio media options.

videoSettings JSON

The video media options.

resolve object

The resolved promise.

Source:
Fires:
  • event:mediaAccessError
  • event:mediaAccessFallback

(private, static) parseMediaOptions(options, roomState) → {SkylinkState}

Parameters:
Name Type Description
options GetUserMediaOptions
roomState SkylinkState
Source:

(private, static) parseStreamSettings(options, type) → {Object}

Parse the options provided to make sure they are compatible

Parameters:
Name Type Default Description
options GetUserMediaOptions
type String | null null

The type of stream i.e. audio or video

Source:

(static) prepMediaAccessRequest(params) → {Promise}

Helper function for MediaStream.getUserMedia

Parameters:
Name Type Description
params GetUserMediaOptions

The camera Stream configuration options.

Source:

(private, static) processStreamInState(stream, settings, roomkey, isScreensharingopt, isAudioFallbackopt)

Function that processes the streams object in the state.

Parameters:
Name Type Attributes Default Description
stream MediaStream null

User MediaStream object

settings GetUserMediaOptions

Options used to get the peer-media stream

roomkey SkylinkRoom.id

Room's id

isScreensharing boolean <optional>
false

isScreensharing

isAudioFallback boolean <optional>
false

isAudioFallback

Source:
Fires:
  • event:mediaAccessSuccess

(static) removeTracks(room, stream)

Function that removes the tracks from the peer connection.

Parameters:
Name Type Description
room SkylinkRoom
stream MediaStream
Source:

(static) sendStream(roomState, options)

Function that sends a MediaStream if provided or gets and sends an new getUserMedia stream.

Parameters:
Name Type Default Description
roomState SkylinkState
options MediaStream | Object null
Source:
Fires:
  • onIncomingStream,event: peerUpdated