import MediaStream from './MediaStream'; import MediaStreamTrack from './MediaStreamTrack'; import RTCCertificate from './RTCCertificate'; import RTCDataChannel from './RTCDataChannel'; import RTCDataChannelEvent from './RTCDataChannelEvent'; import RTCIceCandidateEvent from './RTCIceCandidateEvent'; import RTCRtpReceiver from './RTCRtpReceiver'; import RTCRtpSender from './RTCRtpSender'; import RTCRtpTransceiver from './RTCRtpTransceiver'; import RTCSessionDescription, { RTCSessionDescriptionInit } from './RTCSessionDescription'; import RTCTrackEvent from './RTCTrackEvent'; import { RTCOfferOptions } from './RTCUtil'; import { Event, EventTarget } from './vendor/event-target-shim'; type RTCSignalingState = 'stable' | 'have-local-offer' | 'have-remote-offer' | 'have-local-pranswer' | 'have-remote-pranswer' | 'closed'; type RTCIceGatheringState = 'new' | 'gathering' | 'complete'; type RTCPeerConnectionState = 'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed'; type RTCIceConnectionState = 'new' | 'checking' | 'connected' | 'completed' | 'failed' | 'disconnected' | 'closed'; type RTCDataChannelInit = { ordered?: boolean; maxPacketLifeTime?: number; maxRetransmits?: number; protocol?: string; negotiated?: boolean; id?: number; }; type RTCIceServer = { credential?: string; url?: string; urls?: string | string[]; username?: string; }; type RTCConfiguration = { bundlePolicy?: 'balanced' | 'max-compat' | 'max-bundle'; certificates?: RTCCertificate[]; iceCandidatePoolSize?: number; iceServers?: RTCIceServer[]; iceTransportPolicy?: 'all' | 'relay'; rtcpMuxPolicy?: 'negotiate' | 'require'; }; type RTCPeerConnectionEventMap = { connectionstatechange: Event<'connectionstatechange'>; icecandidate: RTCIceCandidateEvent<'icecandidate'>; icecandidateerror: RTCIceCandidateEvent<'icecandidateerror'>; iceconnectionstatechange: Event<'iceconnectionstatechange'>; icegatheringstatechange: Event<'icegatheringstatechange'>; negotiationneeded: Event<'negotiationneeded'>; signalingstatechange: Event<'signalingstatechange'>; datachannel: RTCDataChannelEvent<'datachannel'>; track: RTCTrackEvent<'track'>; error: Event<'error'>; }; export default class RTCPeerConnection extends EventTarget { localDescription: RTCSessionDescription | null; remoteDescription: RTCSessionDescription | null; signalingState: RTCSignalingState; iceGatheringState: RTCIceGatheringState; connectionState: RTCPeerConnectionState; iceConnectionState: RTCIceConnectionState; _pcId: number; _transceivers: { order: number; transceiver: RTCRtpTransceiver; }[]; _remoteStreams: Map; _pendingTrackEvents: any[]; _pendingMuteStates: Map; static generateCertificate(keygenAlgorithm: string | { name: string; namedCurve?: string; modulusLength?: number; publicExponent?: Uint8Array; hash?: string; }): Promise; constructor(configuration?: RTCConfiguration); get onconnectionstatechange(): EventTarget.CallbackFunction> | null; set onconnectionstatechange(value: EventTarget.CallbackFunction> | null); get onicecandidate(): EventTarget.CallbackFunction> | null; set onicecandidate(value: EventTarget.CallbackFunction> | null); get onicecandidateerror(): EventTarget.CallbackFunction> | null; set onicecandidateerror(value: EventTarget.CallbackFunction> | null); get oniceconnectionstatechange(): EventTarget.CallbackFunction> | null; set oniceconnectionstatechange(value: EventTarget.CallbackFunction> | null); get onicegatheringstatechange(): EventTarget.CallbackFunction> | null; set onicegatheringstatechange(value: EventTarget.CallbackFunction> | null); get onnegotiationneeded(): EventTarget.CallbackFunction> | null; set onnegotiationneeded(value: EventTarget.CallbackFunction> | null); get onsignalingstatechange(): EventTarget.CallbackFunction> | null; set onsignalingstatechange(value: EventTarget.CallbackFunction> | null); get ondatachannel(): EventTarget.CallbackFunction> | null; set ondatachannel(value: EventTarget.CallbackFunction> | null); get ontrack(): EventTarget.CallbackFunction> | null; set ontrack(value: EventTarget.CallbackFunction> | null); get onerror(): EventTarget.CallbackFunction> | null; set onerror(value: EventTarget.CallbackFunction> | null); createOffer(options?: RTCOfferOptions): Promise; createAnswer(): Promise; setConfiguration(configuration: any): void; setLocalDescription(sessionDescription?: RTCSessionDescription | RTCSessionDescriptionInit): Promise; setRemoteDescription(sessionDescription: RTCSessionDescription | RTCSessionDescriptionInit): Promise; addIceCandidate(candidate: any): Promise; /** * @brief Adds a new track to the {@link RTCPeerConnection}, * and indicates that it is contained in the specified {@link MediaStream}s. * This method has to be synchronous as the W3C API expects a track to be returned * @param {MediaStreamTrack} track The track to be added * @param {...MediaStream} streams One or more {@link MediaStream}s the track needs to be added to * https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack */ addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender; addTransceiver(source: 'audio' | 'video' | MediaStreamTrack, init: any): RTCRtpTransceiver; removeTrack(sender: RTCRtpSender): void; getStats(selector?: MediaStreamTrack): Promise; getTransceivers(): RTCRtpTransceiver[]; getSenders(): RTCRtpSender[]; getReceivers(): RTCRtpReceiver[]; close(): void; restartIce(): void; _registerEvents(): void; /** * Creates a new RTCDataChannel object with the given label. The * RTCDataChannelInit dictionary can be used to configure properties of the * underlying channel such as data reliability. * * @param {string} label - the value with which the label attribute of the new * instance is to be initialized * @param {RTCDataChannelInit} dataChannelDict - an optional dictionary of * values with which to initialize corresponding attributes of the new * instance such as id */ createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel; /** * Check whether a media stream track exists already in a sender. * See https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack for more information */ _trackExists(track: MediaStreamTrack): boolean; /** * Updates transceivers after offer/answer updates if necessary. */ _updateTransceivers(transceiverUpdates: any, removeStopped?: boolean): void; /** * Inserts transceiver into the transceiver array in the order they are created (timestamp). * @param order an index that refers to when it it was created relatively. * @param transceiver the transceiver object to be inserted. */ _insertTransceiverSorted(order: number, transceiver: RTCRtpTransceiver): void; } export {};