rtc.Stream Class
A wrapper around an HTML5 MediaStream
Constructor
rtc.Stream
-
stream
Parameters:
-
stream
RTCDataStreamThe native stream
Item Index
Methods
- canClone static
- clone
- createStream static
- getTracks
- hasTracks
- id
- mute
- stop
- toggleMute
Events
Methods
canClone
()
Boolean
static
Checks whether cloning stream is supported by the browser. See clone()
for details
Returns:
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:
A clone of the stream
createStream
-
[config={audio: true, video: true}]
Creates a stream using getUserMedia()
Parameters:
-
[config={audio: true, video: true}]
Object optionalThe configuration to pass to
getUserMedia()
Returns:
Promise to the stream
Example:
var stream = rtc.Stream.createStream({audio: true, video: false});
rtc.MediaDomElement($('video'), stream);
getTracks
-
[type='both']
Gets the tracks of the given type
Parameters:
-
[type='both']
'audio' | 'video' | 'both' optionalThe type of tracks to get
Returns:
An Array of the tracks
hasTracks
-
[type='both']
Checks whether the stream has any tracks of the given type
Parameters:
-
[type='both']
'audio' | 'video' | 'both' optionalThe type of track to check for
Returns:
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:
The id of the underlying stream
mute
-
[muted=true]
-
[type='audio']
Mutes or unmutes tracks of the stream
Parameters:
-
[muted=true]
Boolean optionalMute on
true
and unmute onfalse
-
[type='audio']
'audio' | 'video' | 'both' optionalThe type of tracks to mute or unmute
Returns:
Whether the tracks were muted or unmuted
stop
()
Stops the stream
toggleMute
-
[type='audio']
Toggles the mute state of tracks of the stream
Parameters:
-
[type='audio']
'audio' | 'video' | 'both' optionalThe type of tracks to mute or unmute
Returns:
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
Booleantrue
if tracks were muted,false
if they were unmuted