Bug 1634779 - pt 2. Partially revert Bug 1603006 r=kmag
[gecko.git] / dom / webidl / RTCPeerConnection.webidl
blob437e445781810cb58e04051c2169a21848d9bb53
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/.
5  *
6  * The origin of this IDL file is
7  * http://w3c.github.io/webrtc-pc/#interface-definition
8  */
10 callback RTCSessionDescriptionCallback = void (RTCSessionDescriptionInit description);
11 callback RTCPeerConnectionErrorCallback = void (DOMException error);
12 callback RTCStatsCallback = void (RTCStatsReport report);
14 enum RTCSignalingState {
15     "stable",
16     "have-local-offer",
17     "have-remote-offer",
18     "have-local-pranswer",
19     "have-remote-pranswer",
20     "closed"
23 enum RTCIceGatheringState {
24     "new",
25     "gathering",
26     "complete"
29 enum RTCIceConnectionState {
30     "new",
31     "checking",
32     "connected",
33     "completed",
34     "failed",
35     "disconnected",
36     "closed"
39 enum mozPacketDumpType {
40   "rtp", // dump unencrypted rtp as the MediaPipeline sees it
41   "srtp", // dump encrypted rtp as the MediaPipeline sees it
42   "rtcp", // dump unencrypted rtcp as the MediaPipeline sees it
43   "srtcp" // dump encrypted rtcp as the MediaPipeline sees it
46 callback mozPacketCallback = void (unsigned long level,
47                                    mozPacketDumpType type,
48                                    boolean sending,
49                                    ArrayBuffer packet);
51 dictionary RTCDataChannelInit {
52   boolean        ordered = true;
53   [EnforceRange]
54   unsigned short maxPacketLifeTime;
55   [EnforceRange]
56   unsigned short maxRetransmits;
57   DOMString      protocol = "";
58   boolean        negotiated = false;
59   [EnforceRange]
60   unsigned short id;
62   // These are deprecated due to renaming in the spec, but still supported for Fx53
63   unsigned short maxRetransmitTime;
66 dictionary RTCOfferAnswerOptions {
67 //  boolean voiceActivityDetection = true; // TODO: support this (Bug 1184712)
70 dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
73 dictionary RTCOfferOptions : RTCOfferAnswerOptions {
74   boolean offerToReceiveVideo;
75   boolean offerToReceiveAudio;
76   boolean iceRestart = false;
79 [Pref="media.peerconnection.enabled",
80  JSImplementation="@mozilla.org/dom/peerconnection;1",
81  Exposed=Window]
82 interface RTCPeerConnection : EventTarget  {
83   [Throws]
84   constructor(optional RTCConfiguration configuration = {},
85               optional object? constraints);
87   [Throws, StaticClassOverride="mozilla::dom::RTCCertificate"]
88   static Promise<RTCCertificate> generateCertificate (AlgorithmIdentifier keygenAlgorithm);
90   [Pref="media.peerconnection.identity.enabled"]
91   void setIdentityProvider (DOMString provider,
92                             optional RTCIdentityProviderOptions options = {});
93   [Pref="media.peerconnection.identity.enabled"]
94   Promise<DOMString> getIdentityAssertion();
95   Promise<RTCSessionDescriptionInit> createOffer (optional RTCOfferOptions options = {});
96   Promise<RTCSessionDescriptionInit> createAnswer (optional RTCAnswerOptions options = {});
97   Promise<void> setLocalDescription (optional RTCSessionDescriptionInit description = {});
98   Promise<void> setRemoteDescription (optional RTCSessionDescriptionInit description = {});
99   readonly attribute RTCSessionDescription? localDescription;
100   readonly attribute RTCSessionDescription? currentLocalDescription;
101   readonly attribute RTCSessionDescription? pendingLocalDescription;
102   readonly attribute RTCSessionDescription? remoteDescription;
103   readonly attribute RTCSessionDescription? currentRemoteDescription;
104   readonly attribute RTCSessionDescription? pendingRemoteDescription;
105   readonly attribute RTCSignalingState signalingState;
106   Promise<void> addIceCandidate (optional (RTCIceCandidateInit or RTCIceCandidate) candidate = {});
107   readonly attribute boolean? canTrickleIceCandidates;
108   readonly attribute RTCIceGatheringState iceGatheringState;
109   readonly attribute RTCIceConnectionState iceConnectionState;
110   void restartIce ();
111   [Pref="media.peerconnection.identity.enabled"]
112   readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
113   [Pref="media.peerconnection.identity.enabled"]
114   readonly attribute DOMString? idpLoginUrl;
116   [ChromeOnly]
117   attribute DOMString id;
119   RTCConfiguration      getConfiguration ();
120   [Deprecated="RTCPeerConnectionGetStreams"]
121   sequence<MediaStream> getLocalStreams ();
122   [Deprecated="RTCPeerConnectionGetStreams"]
123   sequence<MediaStream> getRemoteStreams ();
124   void addStream (MediaStream stream);
126   // replaces addStream; fails if already added
127   // because a track can be part of multiple streams, stream parameters
128   // indicate which particular streams should be referenced in signaling
130   RTCRtpSender addTrack(MediaStreamTrack track,
131                         MediaStream... streams);
132   void removeTrack(RTCRtpSender sender);
134   RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
135                                    optional RTCRtpTransceiverInit init = {});
137   sequence<RTCRtpSender> getSenders();
138   sequence<RTCRtpReceiver> getReceivers();
139   sequence<RTCRtpTransceiver> getTransceivers();
141   [ChromeOnly]
142   void mozSetPacketCallback(mozPacketCallback callback);
143   [ChromeOnly]
144   void mozEnablePacketDump(unsigned long level,
145                            mozPacketDumpType type,
146                            boolean sending);
147   [ChromeOnly]
148   void mozDisablePacketDump(unsigned long level,
149                             mozPacketDumpType type,
150                             boolean sending);
152   void close ();
153   attribute EventHandler onnegotiationneeded;
154   attribute EventHandler onicecandidate;
155   attribute EventHandler onsignalingstatechange;
156   attribute EventHandler onaddstream; // obsolete
157   attribute EventHandler onaddtrack;  // obsolete
158   attribute EventHandler ontrack;     // replaces onaddtrack and onaddstream.
159   attribute EventHandler oniceconnectionstatechange;
160   attribute EventHandler onicegatheringstatechange;
162   Promise<RTCStatsReport> getStats (optional MediaStreamTrack? selector = null);
164   // Data channel.
165   RTCDataChannel createDataChannel (DOMString label,
166                                     optional RTCDataChannelInit dataChannelDict = {});
167   attribute EventHandler ondatachannel;
170 // Legacy callback API
172 partial interface RTCPeerConnection {
174   // Dummy Promise<void> return values avoid "WebIDL.WebIDLError: error:
175   // We have overloads with both Promise and non-Promise return types"
177   Promise<void> createOffer (RTCSessionDescriptionCallback successCallback,
178                              RTCPeerConnectionErrorCallback failureCallback,
179                              optional RTCOfferOptions options = {});
180   Promise<void> createAnswer (RTCSessionDescriptionCallback successCallback,
181                               RTCPeerConnectionErrorCallback failureCallback);
182   Promise<void> setLocalDescription (RTCSessionDescriptionInit description,
183                                      VoidFunction successCallback,
184                                      RTCPeerConnectionErrorCallback failureCallback);
185   Promise<void> setRemoteDescription (RTCSessionDescriptionInit description,
186                                       VoidFunction successCallback,
187                                       RTCPeerConnectionErrorCallback failureCallback);
188   Promise<void> addIceCandidate (RTCIceCandidate candidate,
189                                  VoidFunction successCallback,
190                                  RTCPeerConnectionErrorCallback failureCallback);