1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
6 * The origin of this IDL file is
7 * http://w3c.github.io/webrtc-pc/#interface-definition
10 callback RTCSessionDescriptionCallback = undefined (RTCSessionDescriptionInit description);
11 callback RTCPeerConnectionErrorCallback = undefined (DOMException error);
12 callback RTCStatsCallback = undefined (RTCStatsReport report);
14 enum RTCSignalingState {
18 "have-local-pranswer",
19 "have-remote-pranswer",
23 enum RTCIceGatheringState {
29 enum RTCIceConnectionState {
39 enum RTCPeerConnectionState {
48 dictionary RTCDataChannelInit {
49 boolean ordered = true;
50 unsigned short maxPacketLifeTime;
51 unsigned short maxRetransmits;
52 DOMString protocol = "";
53 boolean negotiated = false;
56 // These are deprecated due to renaming in the spec, but still supported for Fx53
57 unsigned short maxRetransmitTime;
60 dictionary RTCOfferAnswerOptions {
61 // boolean voiceActivityDetection = true; // TODO: support this (Bug 1184712)
64 dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
67 dictionary RTCOfferOptions : RTCOfferAnswerOptions {
68 boolean offerToReceiveVideo;
69 boolean offerToReceiveAudio;
70 boolean iceRestart = false;
73 [Pref="media.peerconnection.enabled",
74 JSImplementation="@mozilla.org/dom/peerconnection;1",
75 Constructor (optional RTCConfiguration configuration,
76 optional object? constraints)]
77 interface RTCPeerConnection : EventTarget {
78 [Throws, StaticClassOverride="mozilla::dom::RTCCertificate"]
79 static Promise<RTCCertificate> generateCertificate (AlgorithmIdentifier keygenAlgorithm);
81 [Pref="media.peerconnection.identity.enabled"]
82 undefined setIdentityProvider (DOMString provider,
83 optional RTCIdentityProviderOptions options);
84 [Pref="media.peerconnection.identity.enabled"]
85 Promise<DOMString> getIdentityAssertion();
86 Promise<RTCSessionDescriptionInit> createOffer (optional RTCOfferOptions options);
87 Promise<RTCSessionDescriptionInit> createAnswer (optional RTCAnswerOptions options);
88 Promise<undefined> setLocalDescription (RTCSessionDescriptionInit description);
89 Promise<undefined> setRemoteDescription (RTCSessionDescriptionInit description);
90 readonly attribute RTCSessionDescription? localDescription;
91 readonly attribute RTCSessionDescription? currentLocalDescription;
92 readonly attribute RTCSessionDescription? pendingLocalDescription;
93 readonly attribute RTCSessionDescription? remoteDescription;
94 readonly attribute RTCSessionDescription? currentRemoteDescription;
95 readonly attribute RTCSessionDescription? pendingRemoteDescription;
96 readonly attribute RTCSignalingState signalingState;
97 Promise<undefined> addIceCandidate ((RTCIceCandidateInit or RTCIceCandidate)? candidate);
98 readonly attribute boolean? canTrickleIceCandidates;
99 readonly attribute RTCIceGatheringState iceGatheringState;
100 readonly attribute RTCIceConnectionState iceConnectionState;
101 readonly attribute RTCPeerConnectionState connectionState;
102 [Pref="media.peerconnection.identity.enabled"]
103 readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
104 [Pref="media.peerconnection.identity.enabled"]
105 readonly attribute DOMString? idpLoginUrl;
108 attribute DOMString id;
110 RTCConfiguration getConfiguration ();
111 [Deprecated="RTCPeerConnectionGetStreams"]
112 sequence<MediaStream> getLocalStreams ();
113 [Deprecated="RTCPeerConnectionGetStreams"]
114 sequence<MediaStream> getRemoteStreams ();
115 undefined addStream (MediaStream stream);
117 // replaces addStream; fails if already added
118 // because a track can be part of multiple streams, stream parameters
119 // indicate which particular streams should be referenced in signaling
121 RTCRtpSender addTrack(MediaStreamTrack track,
123 MediaStream... moreStreams);
124 undefined removeTrack(RTCRtpSender sender);
126 RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
127 optional RTCRtpTransceiverInit init);
129 sequence<RTCRtpSender> getSenders();
130 sequence<RTCRtpReceiver> getReceivers();
131 sequence<RTCRtpTransceiver> getTransceivers();
134 attribute EventHandler onnegotiationneeded;
135 attribute EventHandler onicecandidate;
136 attribute EventHandler onsignalingstatechange;
137 attribute EventHandler onaddstream; // obsolete
138 attribute EventHandler onaddtrack; // obsolete
139 attribute EventHandler ontrack; // replaces onaddtrack and onaddstream.
140 attribute EventHandler onremovestream;
141 attribute EventHandler oniceconnectionstatechange;
142 attribute EventHandler onicegatheringstatechange;
143 attribute EventHandler onconnectionstatechange;
145 Promise<RTCStatsReport> getStats (optional MediaStreamTrack? selector);
148 RTCDataChannel createDataChannel (DOMString label,
149 optional RTCDataChannelInit dataChannelDict);
150 attribute EventHandler ondatachannel;
153 // Legacy callback API
155 partial interface RTCPeerConnection {
157 // Dummy Promise<undefined> return values avoid "WebIDL.WebIDLError: error:
158 // We have overloads with both Promise and non-Promise return types"
160 Promise<undefined> createOffer (RTCSessionDescriptionCallback successCallback,
161 RTCPeerConnectionErrorCallback failureCallback,
162 optional RTCOfferOptions options);
163 Promise<undefined> createAnswer (RTCSessionDescriptionCallback successCallback,
164 RTCPeerConnectionErrorCallback failureCallback);
165 Promise<undefined> setLocalDescription (RTCSessionDescriptionInit description,
166 VoidFunction successCallback,
167 RTCPeerConnectionErrorCallback failureCallback);
168 Promise<undefined> setRemoteDescription (RTCSessionDescriptionInit description,
169 VoidFunction successCallback,
170 RTCPeerConnectionErrorCallback failureCallback);
171 Promise<undefined> addIceCandidate (RTCIceCandidate candidate,
172 VoidFunction successCallback,
173 RTCPeerConnectionErrorCallback failureCallback);
174 Promise<undefined> getStats (MediaStreamTrack? selector,
175 RTCStatsCallback successCallback,
176 RTCPeerConnectionErrorCallback failureCallback);