Class: Stream

Stream(sc, id, localId, pc)

new Stream(sc, id, localId, pc)

Stream encapsulates a MediaStream, a set of tracks. A stream is said to go "up" if it is from the client to the server, and "down" otherwise.
Parameters:
Name Type Description
sc ServerConnection
id string
localId string
pc RTCPeerConnection
Source:

Members

(constant) id :string

The id of this stream.
Type:
  • string
Source:

label :string

The label assigned by the originator to this stream.
Type:
  • string
Source:

localDescriptionSent :boolean

Indicates whether we have already sent a local description.
Type:
  • boolean
Source:

localIceCandidates :Array.<RTCIceCandidate>

Buffered local ICE candidates. This will be flushed by flushLocalIceCandidates after we send a local description.
Type:
  • Array.<RTCIceCandidate>
Source:

(constant) localId :string

The local id of this stream.
Type:
  • string
Source:

onclose

onclose is called when the stream is closed. Replace will be true if the stream is being replaced by another one with the same id.
Source:

ondowntrack

ondowntrack is called whenever a new track is added to a stream. If the stream parameter differs from its previous value, then it indicates that the old stream has been discarded.
Source:

onerror

onerror is called whenever a fatal error occurs. The stream will then be closed, and onclose called normally.
Source:

onnegotiationcompleted

onnegotiationcompleted is called whenever negotiation or renegotiation has completed.
Source:

onstats

onstats is called when we have new statistics about the connection
Source:

onstatus

onstatus is called whenever the status of the stream changes.
Source:

pc :RTCPeerConnection

The associated RTCPeerConnection. This is null before the stream is connected, and may change over time.
Type:
  • RTCPeerConnection
Source:

remoteIceCandidates :Array.<RTCIceCandidate>

Buffered remote ICE candidates. This will be flushed by flushRemoteIceCandidates when we get a remote SDP description.
Type:
  • Array.<RTCIceCandidate>
Source:

replace :string

The id of the stream that we are currently replacing.
Type:
  • string
Source:

(constant) sc :ServerConnection

The associated ServerConnection.
Type:
Source:

source :string

For down streams, the id of the client that created the stream.
Type:
  • string
Source:

stats :Object.<string, unknown>

The statistics last computed by the stats handler. This is a dictionary indexed by track id, with each value a dictionary of statistics.
Type:
  • Object.<string, unknown>
Source:

statsHandler :number

The id of the periodic handler that computes statistics, as returned by setInterval.
Type:
  • number
Source:

stream :MediaStream

The associated MediaStream. This is null before the stream is connected, and may change over time.
Type:
  • MediaStream
Source:

(constant) up :boolean

Indicates whether the stream is in the client->server direction.
Type:
  • boolean
Source:

userdata

userdata is a convenient place to attach data to a Stream. It is not used by the library.
Source:

username :string

For down streams, the username of the client who created the stream.
Type:
  • string
Source:

Methods

abort()

abort requests that the server close a down stream.
Source:

close(replaceopt)

close closes a stream. For streams in the up direction, this may be called at any time. For streams in the down direction, this will be called automatically when the server signals that it is closing a stream.
Parameters:
Name Type Attributes Description
replace boolean <optional>
- true if the stream is being replaced by another one with the same id
Source:

flushLocalIceCandidates()

flushLocalIceCandidates flushes any buffered local ICE candidates. It is called when we send an offer.
Source:

flushRemoteIceCandidates()

flushRemoteIceCandidates flushes any buffered remote ICE candidates. It is called automatically when we get a remote description.
Source:

gotLocalIce(candidate)

gotLocalIce is Called when we get a local ICE candidate. Don't call this.
Parameters:
Name Type Description
candidate RTCIceCandidate
Source:

negotiate(restartIceopt)

negotiate negotiates or renegotiates an up stream. It is called automatically when required. If the client requires renegotiation, it is probably better to call restartIce which will cause negotiate to be called asynchronously.
Parameters:
Name Type Attributes Description
restartIce boolean <optional>
Whether to restart ICE.
Source:

request(what)

request sets the list of tracks. If this is not called, or called with a null argument, then the default is provided by ServerConnection.request.
Parameters:
Name Type Description
what Array.<string> a sequence of 'audio', 'video' or 'video-low'.
Source:

restartIce()

restartIce causes an ICE restart on a stream. For up streams, it is called automatically when ICE signals that the connection has failed, but may also be called by the application. For down streams, it requests that the server perform an ICE restart. In either case, it returns immediately, negotiation will happen asynchronously.
Source:

setStatsInterval(ms)

setStatsInterval sets the interval in milliseconds at which the onstats handler will be called. This is only useful for up streams.
Parameters:
Name Type Description
ms number The interval in milliseconds.
Source:

setStream(stream)

setStream sets the stream of an upwards connection.
Parameters:
Name Type Description
stream MediaStream
Source:

updateStats()

updateStats is called periodically, if requested by setStatsInterval, in order to recompute stream statistics and invoke the onstats handler.
Source: