API Docs for:
Show:

rtc.Stream Class

Defined in: src/stream.coffee:8
Module: rtc

A wrapper around an HTML5 MediaStream

Constructor

rtc.Stream

(
  • stream
)

Defined in src/stream.coffee:8

Parameters:

  • stream RTCDataStream

    The native stream

Item Index

Events

Methods

canClone

() Boolean static

Checks whether cloning stream is supported by the browser. See clone() for details

Returns:

Boolean:

true if cloning is supported, false otherwise

clone

() rtc.Stream

Clones the stream. You can change both streams independently, for example mute tracks. You will have to stop() both streams individually when you are done.

This is currently not supported in Firefox and expected to be implemented in version 47. Use Stream.canClone() to check whether cloning is supported by your browser.

Returns:

rtc.Stream:

A clone of the stream

createStream

(
  • [config={audio: true, video: true}]
)
Promise -> rtc.Stream static

Creates a stream using getUserMedia()

Parameters:

  • [config={audio: true, video: true}] Object optional

    The configuration to pass to getUserMedia()

Returns:

Promise -> rtc.Stream:

Promise to the stream

Example:

var stream = rtc.Stream.createStream({audio: true, video: false});
rtc.MediaDomElement($('video'), stream);

getTracks

(
  • [type='both']
)
Array

Gets the tracks of the given type

Parameters:

  • [type='both'] 'audio' | 'video' | 'both' optional

    The type of tracks to get

Returns:

Array:

An Array of the tracks

hasTracks

(
  • [type='both']
)
Number

Checks whether the stream has any tracks of the given type

Parameters:

  • [type='both'] 'audio' | 'video' | 'both' optional

    The type of track to check for

Returns:

Number:

The amount of tracks of the given type

id

() String

Get the id of the stream. This is neither user defined nor human readable.

Returns:

String:

The id of the underlying stream

mute

(
  • [muted=true]
  • [type='audio']
)
Boolean

Mutes or unmutes tracks of the stream

Parameters:

  • [muted=true] Boolean optional

    Mute on true and unmute on false

  • [type='audio'] 'audio' | 'video' | 'both' optional

    The type of tracks to mute or unmute

Returns:

Boolean:

Whether the tracks were muted or unmuted

stop

()

Stops the stream

toggleMute

(
  • [type='audio']
)
Boolean

Toggles the mute state of tracks of the stream

Parameters:

  • [type='audio'] 'audio' | 'video' | 'both' optional

    The type of tracks to mute or unmute

Returns:

Boolean:

Whether the tracks were muted or unmuted

Events

mute_changed

(
  • type
  • muted
)

Emitted when tracks are muted or unmuted. Only triggered when changes are made through this objects mute functions.

Parameters:

  • type 'audio' | 'video' | 'both'

    The type of tracks which changed

  • muted Boolean

    true if tracks were muted, false if they were unmuted