UNPKG

@telnyx/webrtc

Version:
73 lines (72 loc) 2.71 kB
import BrowserSession from '../BrowserSession'; import { WebRTCStatsReporter } from '../util/debug'; import { PeerType } from './constants'; import { IVertoCallOptions } from './interfaces'; export declare type RestartIceResult = { started: boolean; reason?: string; }; export default class Peer { type: PeerType; private options; instance: RTCPeerConnection; onSdpReadyTwice: ((data: RTCSessionDescription) => void) | null; statsReporter: WebRTCStatsReporter | null; isIceRestarting: boolean; iceDone: boolean; private _constraints; private _session; private _negotiating; private _prevConnectionState; private _restartedIceOnConnectionStateFailed; private _trickleIceSdpFn; private _registerPeerEvents; private _sleepWakeupIntervalId; private _iceGatheringSafetyTimeout; private _gatheredCandidatesCount; private static readonly ICE_GATHERING_SAFETY_TIMEOUT_MS; private _firstMediaTrackMarked; private _timingsCollected; private _iceRestartTimeoutId; private static readonly ICE_RESTART_TIMEOUT_MS; constructor(type: PeerType, options: IVertoCallOptions, session: BrowserSession, trickleIceSdpFn: (sdp: RTCSessionDescriptionInit) => void, registerPeerEvents: (instance: RTCPeerConnection) => void); finishIceRestart(): void; restartIce(): RestartIceResult; get isOffer(): boolean; get isAnswer(): boolean; get isDebugEnabled(): boolean; get debugOutput(): "socket" | "file"; get restartedIceOnConnectionStateFailed(): boolean; isConnectionHealthy(): boolean; startNegotiation(): void; startTrickleIceNegotiation(): Promise<void>; private _emitNegotiationError; private _logTransceivers; private handleSignalingStateChangeEvent; private handleNegotiationNeededEvent; private handleTrackEvent; private handleConnectionStateChange; tryCollectTimings(): void; private createPeerConnection; private _handleIceConnectionStateChange; private _handleIceGatheringStateChange; incrementGatheredCandidates(): void; private _startIceGatheringSafetyTimeout; private _clearIceGatheringSafetyTimeout; init(): Promise<void>; private _getSenderByKind; private _checkMediaToNegotiate; private _createOffer; private _setRemoteDescription; private _createAnswer; private _setLocalDescription; private _setCodecs; private _sdpReady; private _retrieveLocalStream; private _isOffer; private _isAnswer; private _isTrickleIce; private _config; restartStatsReporter(): Promise<void>; close(): Promise<void>; }