@ceeblue/webrtc-client
    Preparing search index...

    Class HTTPConnector

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

    // 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 (View Summary)

    Index

    Constructors

    Properties

    log: ILog

    Start a log

    a Log object with the levels of log to call

    Accessors

    • get stream(): MediaStream | undefined

      Media Stream description delivred from the server if we are player, or build from the local camera if we are the streamer.

      Returns MediaStream | undefined

    • 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

      • OptionaliceServer: 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: "close" | "Close" | "Open" | "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: "close" | "Close" | "Open" | "open"

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

      • event: Function

        Subscriber Function

      • Optionaloptions: { signal?: AbortSignal }
        • Optionalsignal?: 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: "close" | "Close" | "Open" | "open"

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

      • event: Function

        Subscriber Function

      • Optionaloptions: { signal?: AbortSignal }
        • Optionalsignal?: AbortSignal

          Optional AbortSignal to stop this or multiple subscriptions in same time

      Returns void

    • Hot-swap a track on the existing RTCPeerConnection without renegotiation.

      Parameters

      • kind: "audio" | "video"

        'audio' | 'video'

      • track: MediaStreamTrack | null

        A MediaStreamTrack to send, or null to stop sending that kind.

      Returns Promise<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