Interface IPeerConnectionConnector

The peer connection connector interface - used to establish a connection between two peers.

interface IPeerConnectionConnector {
    canAddCandidates: boolean;
    canRestartHandshake: boolean;
    connectionState: string;
    gatheringState: string;
    handshakeState: string;
    onCandidate: null | ((event: IPeerConnectionHandshakeCandidateEvent) => void);
    onConnectionStateChange: null | (() => void);
    onDataChannel: null | ((event: IPeerConnectionDataChannelEvent) => void);
    onGatheringStateChange: null | (() => void);
    onHandshakeStateChange: null | (() => void);
    onTrack: null | ((event: IPeerConnectionTrackEvent) => void);
    signalingState: string;
    addCandidate(candidate: IPeerConnectionHandshakeCandidate): Promise<void>;
    addTrack(track: MediaStreamTrack, stream: MediaStream): IPeerConnectionSender;
    close(): void;
    collectReceiversStats(receivers: Map<string, Set<MediaStreamTrack>>, collector: ((stats: PeerConnectionStatsReport[][], streamId: string) => void)): Promise<void>;
    collectSendersStats(senders: Map<string, IPeerConnectionSenderMap>, collector: ((stats: PeerConnectionStatsReport[][], streamId: string) => void)): Promise<void>;
    createAnswer(offer: IPeerConnectionSessionDescription): Promise<IPeerConnectionSessionDescription>;
    createDataChannel(label: string): IPeerConnectionDataChannelConnector;
    createOffer(options?: IPeerConnectionOfferOptions): Promise<IPeerConnectionSessionDescription>;
    handleAnswer(answer: IPeerConnectionSessionDescription, negotiationHandler: (() => void)): Promise<void>;
    removeTrack(sender: IPeerConnectionSender): void;
    replaceTrack(track: MediaStreamTrack, sender: IPeerConnectionSender): Promise<void>;
    restartHandshake(): void;
    setEncodingParameters(sender: IPeerConnectionSender, scaleResolutionDownBy: number, maxFramerate: number, maxBitrate: number, priority: MediaStreamPriority): void;
}

Properties

canAddCandidates: boolean

Whether or not candidates can be added to the connection.

canRestartHandshake: boolean

Whether or not the handshake function exists.

connectionState: string

The current connection state.

gatheringState: string

The current gathering state.

handshakeState: string

The current handshake state.

onCandidate: null | ((event: IPeerConnectionHandshakeCandidateEvent) => void)

The callback for when a candidate is received.

onConnectionStateChange: null | (() => void)

The callback for when the connection state changes.

onDataChannel: null | ((event: IPeerConnectionDataChannelEvent) => void)

The callback for when a data channel is received.

onGatheringStateChange: null | (() => void)

The callback for when the candidate gathering state changes.

onHandshakeStateChange: null | (() => void)

The callback for when the handshake state changes.

onTrack: null | ((event: IPeerConnectionTrackEvent) => void)

The callback for when a track is received.

signalingState: string

The current signaling state.

Methods

  • Closes the connection.

    Returns void

  • Collects the stats for the receivers. The collector must be called with the stats for each stream.

    Parameters

    Returns Promise<void>

    A promise that resolves when the stats have been collected.

  • Collects the stats for the senders. The collector must be called with the stats for each stream.

    Parameters

    Returns Promise<void>

    A promise that resolves when the stats have been collected.

  • Handles an answer to an offer.

    Parameters

    • answer: IPeerConnectionSessionDescription

      The answer to handle.

    • negotiationHandler: (() => void)

      The handler to call after the answer has been handled.

        • (): void
        • Returns void

    Returns Promise<void>

    A promise that resolves when the answer has been handled.

  • Removes a track from the connection.

    Parameters

    Returns void

  • Restarts the handshake.

    Returns void

  • Sets the encoding parameters for the sender.

    Parameters

    • sender: IPeerConnectionSender

      The sender to set the encoding parameters for.

    • scaleResolutionDownBy: number

      The scale resolution down by value.

    • maxFramerate: number

      The max framerate value.

    • maxBitrate: number

      The max bitrate value.

    • priority: MediaStreamPriority

      The priority for the media stream.

    Returns void