Interface RTCPeerConnection
canTrickleIceCandidates: boolean;
connectionState: RTCPeerConnectionState;
currentLocalDescription: RTCSessionDescription;
currentRemoteDescription: RTCSessionDescription;
iceConnectionState: RTCIceConnectionState;
iceGatheringState: RTCIceGatheringState;
localDescription: RTCSessionDescription;
onconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any);
ondatachannel: ((this: RTCPeerConnection, ev: RTCDataChannelEvent) => any);
onicecandidate: ((this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any);
onicecandidateerror: ((this: RTCPeerConnection, ev: RTCPeerConnectionIceErrorEvent) => any);
oniceconnectionstatechange: ((this: RTCPeerConnection, ev: Event) => any);
onicegatheringstatechange: ((this: RTCPeerConnection, ev: Event) => any);
onnegotiationneeded: ((this: RTCPeerConnection, ev: Event) => any);
onsignalingstatechange: ((this: RTCPeerConnection, ev: Event) => any);
ontrack: ((this: RTCPeerConnection, ev: RTCTrackEvent) => any);
pendingLocalDescription: RTCSessionDescription;
pendingRemoteDescription: RTCSessionDescription;
remoteDescription: RTCSessionDescription;
sctp: RTCSctpTransport;
signalingState: RTCSignalingState;
addEventListener<K>(type: K, listener: ((this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any), options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
addIceCandidate(candidate?: RTCIceCandidateInit): Promise<void>;
addIceCandidate(candidate: RTCIceCandidateInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
addTransceiver(trackOrKind: string | MediaStreamTrack, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
close(): void;
createAnswer(options?: RTCAnswerOptions): Promise<RTCSessionDescriptionInit>;
createAnswer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
createOffer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise<void>;
dispatchEvent(event: Event): boolean;
getConfiguration(): RTCConfiguration;
getReceivers(): RTCRtpReceiver[];
getSenders(): RTCRtpSender[];
getStats(selector?: MediaStreamTrack): Promise<RTCStatsReport>;
getTransceivers(): RTCRtpTransceiver[];
removeEventListener<K>(type: K, listener: ((this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any), options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
removeTrack(sender: RTCRtpSender): void;
restartIce(): void;
setConfiguration(configuration?: RTCConfiguration): void;
setLocalDescription(description?: RTCLocalSessionDescriptionInit): Promise<void>;
setLocalDescription(description: RTCLocalSessionDescriptionInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
setRemoteDescription(description: RTCSessionDescriptionInit, successCallback: VoidFunction, failureCallback: RTCPeerConnectionErrorCallback): Promise<void>;
}
Hierarchy
- EventTarget
- RTCPeerConnection (view full)
Index
Properties
Methods
Properties
Readonly
canTrickleIceCandidates
Readonly
connectionState
Readonly
currentLocalDescription
Readonly
currentRemoteDescription
Readonly
iceConnectionState
Readonly
iceGatheringState
Readonly
localDescription
onconnectionstatechange
ondatachannel
onicecandidate
onicecandidateerror
oniceconnectionstatechange
onicegatheringstatechange
onnegotiationneeded
onsignalingstatechange
ontrack
Readonly
pendingLocalDescription
Readonly
pendingRemoteDescription
Readonly
remoteDescription
Readonly
sctp
Readonly
signalingState
Methods
addEventListener
- add
Event <K>(type, listener, options?): voidListener Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Type Parameters
- K extends keyof RTCPeerConnectionEventMap
Parameters
- type: K
- listener: ((this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any)
- (this, ev): any
Parameters
- this: RTCPeerConnection
- ev: RTCPeerConnectionEventMap[K]
Returns any
Optional
options: boolean | AddEventListenerOptions
Returns void
- add
Event (type, listener, options?): voidListener Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | AddEventListenerOptions
Returns void
addIceCandidate
- add
Ice (candidate?): Promise<void>Candidate Parameters
Optional
candidate: RTCIceCandidateInit
Returns Promise<void>
- add
Ice (candidate, successCallback, failureCallback): Promise<void>Candidate Parameters
- candidate: RTCIceCandidateInit
- successCallback: VoidFunction
- failureCallback: RTCPeerConnectionErrorCallback
Returns Promise<void>
addTrack
- add
Track (track, ...streams): RTCRtpSender Parameters
- track: MediaStreamTrack
Rest
...streams: MediaStream[]
Returns RTCRtpSender
addTransceiver
- add
Transceiver (trackOrKind, init?): RTCRtpTransceiver Parameters
- trackOrKind: string | MediaStreamTrack
Optional
init: RTCRtpTransceiverInit
Returns RTCRtpTransceiver
close
createAnswer
- create
Answer (options?): Promise<RTCSessionDescriptionInit> Parameters
Optional
options: RTCAnswerOptions
Returns Promise<RTCSessionDescriptionInit>
- create
Answer (successCallback, failureCallback): Promise<void> Parameters
- successCallback: RTCSessionDescriptionCallback
- failureCallback: RTCPeerConnectionErrorCallback
Returns Promise<void>
createDataChannel
- create
Data (label, dataChannelDict?): RTCDataChannelChannel Parameters
- label: string
Optional
dataChannelDict: RTCDataChannelInit
Returns RTCDataChannel
createOffer
- create
Offer (options?): Promise<RTCSessionDescriptionInit> Parameters
Optional
options: RTCOfferOptions
Returns Promise<RTCSessionDescriptionInit>
- create
Offer (successCallback, failureCallback, options?): Promise<void> Parameters
- successCallback: RTCSessionDescriptionCallback
- failureCallback: RTCPeerConnectionErrorCallback
Optional
options: RTCOfferOptions
Returns Promise<void>
dispatchEvent
- dispatch
Event (event): boolean Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Parameters
- event: Event
Returns boolean
getConfiguration
- get
Configuration (): RTCConfiguration Returns RTCConfiguration
getReceivers
- get
Receivers (): RTCRtpReceiver[] Returns RTCRtpReceiver[]
getSenders
- get
Senders (): RTCRtpSender[] Returns RTCRtpSender[]
getStats
- get
Stats (selector?): Promise<RTCStatsReport> Parameters
Optional
selector: MediaStreamTrack
Returns Promise<RTCStatsReport>
getTransceivers
- get
Transceivers (): RTCRtpTransceiver[] Returns RTCRtpTransceiver[]
removeEventListener
- remove
Event <K>(type, listener, options?): voidListener Removes the event listener in target's event listener list with the same type, callback, and options.
Type Parameters
- K extends keyof RTCPeerConnectionEventMap
Parameters
- type: K
- listener: ((this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any)
- (this, ev): any
Parameters
- this: RTCPeerConnection
- ev: RTCPeerConnectionEventMap[K]
Returns any
Optional
options: boolean | EventListenerOptions
Returns void
- remove
Event (type, listener, options?): voidListener Removes the event listener in target's event listener list with the same type, callback, and options.
Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | EventListenerOptions
Returns void
removeTrack
- remove
Track (sender): void Parameters
- sender: RTCRtpSender
Returns void
restartIce
setConfiguration
- set
Configuration (configuration?): void Parameters
Optional
configuration: RTCConfiguration
Returns void
setLocalDescription
- set
Local (description?): Promise<void>Description Parameters
Optional
description: RTCLocalSessionDescriptionInit
Returns Promise<void>
- set
Local (description, successCallback, failureCallback): Promise<void>Description Parameters
- description: RTCLocalSessionDescriptionInit
- successCallback: VoidFunction
- failureCallback: RTCPeerConnectionErrorCallback
Returns Promise<void>
setRemoteDescription
- set
Remote (description): Promise<void>Description Parameters
- description: RTCSessionDescriptionInit
Returns Promise<void>
- set
Remote (description, successCallback, failureCallback): Promise<void>Description Parameters
- description: RTCSessionDescriptionInit
- successCallback: VoidFunction
- failureCallback: RTCPeerConnectionErrorCallback
Returns Promise<void>
A WebRTC connection between the local computer and a remote peer. It provides methods to connect to a remote peer, maintain and monitor the connection, and close the connection once it's no longer needed.
MDN Reference