rtcpool.connection

class ManagedConnection(conn, id, desc_ref)

A class wrapping RTCPeerConnection which exposes intuitive, high level methods for interacting with the connection while hiding the ICE layer and negotiation-related aspects, as these are handled entirely internally.

Creates a ManagedConnection for the given RTCPeerConnection.

Note

This is used internally by Pool to setup connections. There should be no need to call this in your code.

Arguments
  • conn (RTCPeerConnection()) – The RTCPeerConnection to wrap

  • id (UUID()) – The unique ID of the connection in the pool

  • desc_ref (Object()) – A reference to the Object containing the connection’s description.

ManagedConnection.description

type: Object

The description of the peer.

This object should not be modified, as this can produce unpredictable results and goes against the spirit of descriptions.

ManagedConnection.id

The ID of the peer.

ManagedConnection.addEventListener(evt_type, args)

A proxy for adding listeners to the managed peer connection. Only permits exposed event types, as many events fired by RTCPeerConnection are purely used for negotiation and detecting negotiation success/failure.

ManagedConnection.addTrack(track, streams)

A proxy for RTCPeerConnection.addTrack

ManagedConnection.dataChannel(label, options, raw=false)

Create a data channel with the given label and options.

If raw is true, the channel will be returned immediately, without waiting for the channel to open.

If raw is false, returns a Promise that resolves to the channel when the channel has opened.

Arguments
  • label (string()) – The label of the data channel.

  • options (Object()) – The options to use to create the data channel.

  • raw (Boolean()) – Whether to return the channel immediately or return a Promise.

Returns

Promise.<RTCDataChannel>|RTCDataChannel – A promise resolving to the created channel, or the channel itself.

ManagedConnection.removeEventListener(args)

A proxy for removing listeners from the managed connection.

ManagedConnection.removeTrack(sender)

A proxy for RTCPeerConnection.removeTrack