///
import { Deferred } from './internal/promise';
import { EventEmitter } from 'events';
import { Stream, StreamTrackType } from './stream';
import { StreamTransceiverFactory } from './types';
export interface FingerprintInfo {
type: string;
hash: string;
}
export interface PeerConnectionFingerprints {
local?: FingerprintInfo;
remote?: FingerprintInfo;
}
export declare type RemoteStreamDescription = Record;
export interface AnnotateSessionDescription extends RTCSessionDescriptionInit {
streams: RemoteStreamDescription;
}
export interface TransceiverData {
kind: StreamTrackType;
transceiver: RTCRtpTransceiver;
}
export declare type TransceiverCleanup = () => void;
interface StreamData {
transceivers: ReadonlyArray;
cleanups: ReadonlyArray;
}
/**
* @module rtc
*/
/**
* Wrapper around native RTCPeerConnection
*
* Provides events for new streams and data channels. Signaling information has
* to be forwarded from events emitted by this object to the remote
* PeerConnection.
*
* @class rtc.PeerConnection
* @extends events.EventEmitter
*
* @constructor
* @param {Boolean} offering True if the local peer should initiate the connection
* @param {Object} options Options object passed on from `Room`
*/
export declare class PeerConnection extends EventEmitter {
offering: boolean;
options: any;
no_gc_bugfix: Array;
pc: RTCPeerConnection;
connect_d: Deferred;
connected: boolean;
signaling_pending: Array;
current_streams: Map;
pending_streams: Map;
remote_streams?: RemoteStreamDescription;
renegotiate: boolean;
/**
* New local ICE candidate which should be signaled to remote peer
* @event ice_candiate
* @param {Object} candidate The ice candidate
*/
/**
* New remote stream was added to the PeerConnection
* @event stream_added
* @param {rtc.Stream} stream The stream
*/
/**
* New DataChannel to the remote peer is ready to be used
* @event data_channel_ready
* @param {rtc.DataChannel} channel The data channel
*/
/**
* New offer or answer which should be signaled to the remote peer
* @event signaling
* @param {Object} obj The signaling message
*/
/**
* The PeerConnection was closed
* @event closed
*/
constructor(offering: boolean, options: Record);
fingerprints(): PeerConnectionFingerprints;
/**
* Add new signaling information received from remote peer
* @method signaling
* @param {Object} data The signaling information
*/
signaling(data: AnnotateSessionDescription): Promise;
/**
* Add a remote ICE candidate
* @method addIceCandidate
* @param {Object} desc The candidate
*/
addIceCandidate(desc: RTCIceCandidateInit): void;
/**
* Returns the options for the offer/answer
* @method _oaOptions
* @private
* @return {Object}
*/
_oaOptions(): any;
/**
* Create offer, set it on local description and emit it
* @method _offer
* @private
*/
_offer(): Promise;
/**
* Create answer, set it on local description and emit it
* @method _offer
* @private
*/
_answer(): Promise;
/**
* Set local description and emit it
* @method _processLocalSdp
* @private
* @param {Object} sdp The local SDP
* @return {Promise} Promise which will be resolved once the local description was set successfully
*/
_processLocalSdp(sdp: RTCSessionDescriptionInit): Promise;
/**
* Mark connection attempt as failed
* @method _connectError
* @private
* @param {Error} err Error causing connection to fail
*/
_connectError(err: Error): void;
setStreams(new_streams: Map>): void;
_mapTransceivers(): void;
_createTransceivers(): void;
/**
* Remove local stream
* @method removeStream
* @param {rtc.Stream} stream The local stream
*/
removeSream(stream: Stream): void;
/**
* Add DataChannel. Will only actually do something if `offering` is `true`.
* @method addDataChannel
* @param {String} name Name of the data channel
* @param {Object} desc Options passed to `RTCPeerConnection.createDataChannel()`
*/
addDataChannel(name: string, options: RTCDataChannelInit): void;
negotiate(): void;
/**
* Establish connection with remote peer. Connection will be established once both peers have called this functio
* @method connect
* @return {Promise} Promise which will be resolved once the connection is established
*/
connect(): Promise;
/**
* Close the connection to the remote peer
* @method close
*/
close(): void;
}
export {};