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

    Interface IConnector

    IConnector is a common interface for representing a stream connection with the server.

    This interface can serve the both roles: player or streamer.

    interface IConnector {
        closed: boolean;
        codecs: Set<string>;
        log: ILog;
        opened: boolean;
        stream?: MediaStream;
        streamName: string;
        close(error?: ConnectorError): void;
        connectionInfos(cacheDuration?: number): Promise<ConnectionInfos>;
        off(name: "close" | "Close" | "Open" | "open", event: Function): boolean;
        on(
            name: "close" | "Close" | "Open" | "open",
            event: Function,
            options?: { signal?: AbortSignal },
        ): void;
        once(
            name: "close" | "Close" | "Open" | "open",
            event: Function,
            options?: { signal?: AbortSignal },
        ): void;
        onClose(error?: ConnectorError): void;
        onOpen(stream: MediaStream): void;
        replaceTrack(
            kind: "audio" | "video",
            track: MediaStreamTrack | null,
        ): Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    closed: boolean

    True when connector is closed, in other words when onClose event is fired

    codecs: Set<string>

    Indicate codecs supported, should be set before than onOpen happen

    log: ILog

    Start a log

    a Log object with the levels of log to call

    opened: boolean

    True when connector is opened, in other words when onOpen event is fired

    stream?: MediaStream

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

    streamName: string

    Stream name, for example as+bc3f535f-37f3-458b-8171-b4c5e77a6137

    Methods

    • Request connections infos with caching option to save loading cost

      Parameters

      • OptionalcacheDuration: number

        indicate how many time we can cache the last connection informations

      Returns Promise<ConnectionInfos>

      Promise with a ConnectionInfos on success

    • 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

    • Parameters

      • kind: "audio" | "video"

        'video' or 'audio' to replace the track of the given kind

      • track: MediaStreamTrack | null

      Returns Promise<void>

      Promise that resolves when the track is replaced

      Error if the kind is not supported or if the operation fails

      This method allows to replace the current track of the given kind with a new one. If the track is null, it will remove the current track of that kind.

    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