Use HTTPConnector to negotiate a new RTCPeerConnection connection with the server using WHIP (WebRTC HTTP Ingest Protocol) or WHEP (WebRTC HTTP Egress Protocol).

Example

// Listener channel (no initial 'stream' parameter), listen to a stream without sending data
const connection = new HTTPConnector({endPoint, streamName});
// we get the media stream from server
connection.onOpen = stream => videoElement.srcObject = stream;

// Streamer channel (with initial 'stream' parameter), sends and receives media streams
const connection = new HTTPConnector({endPoint, streamName}, {stream: await navigator.mediaDevices.getUserMedia()});
// the media stream here is our local camera as passed in the above constructor
connection.onOpen = stream => {}

Hierarchy

Constructors

Properties

_fetch: AbortController
_url: URL
log: ILog

Start a log

Param

Returns

a Log object with the levels of log to call

Accessors

  • get stream(): undefined | MediaStream
  • Media Stream description delivred from the server if we are player, or build from the local camera if we are the streamer.

    Returns undefined | MediaStream

  • get streamName(): string
  • Stream name, for example as+bc3f535f-37f3-458b-8171-b4c5e77a6137

    Returns string

Methods

  • Main function which creates the RTCPeerConnection, creates the offer, calls the _sip method, then set the answer and calls onOpen

    Parameters

    • Optional iceServer: RTCIceServer

    Returns void

  • Operates Session Initiation Protocol, this method implement the logic to send the SDP offer to the server and get the SDP answer in response.

    Parameters

    • offer: string

      SIP Offer

    Returns Promise<string>

    a Promise with SIP Answer as result

  • Event unsubscription

    Parameters

    • name: "open" | "close" | "Close" | "Open"

      Name of event without the 'on' prefix (ex: 'log' to 'onLog' event declared)

    • event: Function

      Unsubscriber Function, must be the one passed to on or once subscription methods

    Returns boolean

  • Event subscription

    Parameters

    • name: "open" | "close" | "Close" | "Open"

      Name of event without the on prefix (ex: log to onLog event declared)

    • event: Function

      Subscriber Function

    • Optional options: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

        Optional AbortSignal to stop this or multiple subscriptions in same time

    Returns void

  • Event subscription only one time, once time fired it's automatically unsubscribe

    Parameters

    • name: "open" | "close" | "Close" | "Open"

      Name of event without the on prefix (ex: log to onLog event declared)

    • event: Function

      Subscriber Function

    • Optional options: {
          signal?: AbortSignal;
      }
      • Optional signal?: AbortSignal

    Returns void

Events

  • Call when connector is open

    Parameters

    • stream: MediaStream

      MediaStream description provided from the server if we are the player, or build from the local camera if we are the streamer.

    Returns void

Generated using TypeDoc