Class: MediaConnection

MediaConnection

Class that manages media connections to other peers.

Members

id

An id to uniquely identify the connection.

localStream :MediaStream

The local MediaStream.
Type:
  • MediaStream

metadata :object

Any additional information to send to the peer.
Type:
  • object

open :boolean

Whether the Connection has been opened or not.
Type:
  • boolean

peer :string

The remote peerId.
Type:
  • string
Deprecated:
  • Use remoteId instead.

remoteId :string

PeerId of the peer this connection is connected to.
Type:
  • string

type :string

The connection type. Either 'media' or 'data'.
Type:
  • string

Methods

answer(stream, optionsopt)

Create and send an answer message.
Parameters:
Name Type Attributes Description
stream MediaStream The stream to send to the peer.
options object <optional>
Optional arguments for the connection.
Properties
Name Type Attributes Description
videoBandwidth number <optional>
A max video bandwidth(kbps)
audioBandwidth number <optional>
A max audio bandwidth(kbps)
videoCodec string <optional>
A video codec like 'H264'
audioCodec string <optional>
A video codec like 'PCMU'

close()

Disconnect from remote peer.
Fires:

replaceStream(newStream)

Replace the stream being sent with a new one.
Parameters:
Name Type Description
newStream MediaStream The stream to replace the old stream with.

Events

close

Connection closed event.

removeStream

MediaStream from peer was removed.
Type:
  • MediaStream

stream

MediaStream received from peer.
Type:
  • MediaStream