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) => void);
    onConnectionStateChange: null | (() => void);
    onDataChannel: null | ((event) => void);
    onGatheringStateChange: null | (() => void);
    onHandshakeStateChange: null | (() => void);
    onTrack: null | ((event) => void);
    signalingState: string;
    addCandidate(candidate): Promise<void>;
    addTrack(track, stream): IPeerConnectionSender;
    close(): void;
    collectReceiversStats(receivers, collector): Promise<void>;
    collectSendersStats(senders, collector): Promise<void>;
    createAnswer(offer): Promise<IPeerConnectionSessionDescription>;
    createDataChannel(label): IPeerConnectionDataChannelConnector;
    createOffer(options?): Promise<IPeerConnectionSessionDescription>;
    handleAnswer(answer, negotiationHandler): Promise<void>;
    removeTrack(sender): void;
    replaceTrack(track, sender): Promise<void>;
    restartHandshake(): void;
    setEncodingParameters(sender, scaleResolutionDownBy, maxFramerate, maxBitrate, priority): 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) => void)

The callback for when a candidate is received.

Type declaration

onConnectionStateChange: null | (() => void)

The callback for when the connection state changes.

Type declaration

    • (): void
    • Returns void

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

The callback for when a data channel is received.

Type declaration

onGatheringStateChange: null | (() => void)

The callback for when the candidate gathering state changes.

Type declaration

    • (): void
    • Returns void

onHandshakeStateChange: null | (() => void)

The callback for when the handshake state changes.

Type declaration

    • (): void
    • Returns void

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

The callback for when a track is received.

Type declaration

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

    • receivers: Map<string, Set<MediaStreamTrack>>

      The receivers to collect stats for.

    • collector: ((stats, streamId) => void)

      The callback to send the stats to.

    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

Generated using TypeDoc