Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / webidl / RTCPeerConnection.webidl
blob8fb908788e67633c0dd51dd1eea8d269bacee383
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 = undefined (RTCSessionDescriptionInit description);
11 callback RTCPeerConnectionErrorCallback = undefined (DOMException error);
12 callback RTCStatsCallback = undefined (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 RTCPeerConnectionState {
40   "closed",
41   "failed",
42   "disconnected",
43   "new",
44   "connecting",
45   "connected"
48 enum mozPacketDumpType {
49   "rtp", // dump unencrypted rtp as the MediaPipeline sees it
50   "srtp", // dump encrypted rtp as the MediaPipeline sees it
51   "rtcp", // dump unencrypted rtcp as the MediaPipeline sees it
52   "srtcp" // dump encrypted rtcp as the MediaPipeline sees it
55 callback mozPacketCallback = undefined (unsigned long level,
56                                         mozPacketDumpType type,
57                                         boolean sending,
58                                         ArrayBuffer packet);
60 dictionary RTCDataChannelInit {
61   boolean        ordered = true;
62   [EnforceRange]
63   unsigned short maxPacketLifeTime;
64   [EnforceRange]
65   unsigned short maxRetransmits;
66   DOMString      protocol = "";
67   boolean        negotiated = false;
68   [EnforceRange]
69   unsigned short id;
71   // These are deprecated due to renaming in the spec, but still supported for Fx53
72   unsigned short maxRetransmitTime;
75 dictionary RTCOfferAnswerOptions {
76 //  boolean voiceActivityDetection = true; // TODO: support this (Bug 1184712)
79 dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
82 dictionary RTCOfferOptions : RTCOfferAnswerOptions {
83   boolean offerToReceiveVideo;
84   boolean offerToReceiveAudio;
85   boolean iceRestart = false;
88 [Pref="media.peerconnection.enabled",
89  JSImplementation="@mozilla.org/dom/peerconnection;1",
90  Exposed=Window]
91 interface RTCPeerConnection : EventTarget  {
92   [Throws]
93   constructor(optional RTCConfiguration configuration = {},
94               optional object? constraints);
96   [Throws, StaticClassOverride="mozilla::dom::RTCCertificate"]
97   static Promise<RTCCertificate> generateCertificate (AlgorithmIdentifier keygenAlgorithm);
99   undefined setIdentityProvider (DOMString provider,
100                                  optional RTCIdentityProviderOptions options = {});
101   Promise<DOMString> getIdentityAssertion();
102   Promise<RTCSessionDescriptionInit> createOffer (optional RTCOfferOptions options = {});
103   Promise<RTCSessionDescriptionInit> createAnswer (optional RTCAnswerOptions options = {});
104   Promise<undefined> setLocalDescription (optional RTCSessionDescriptionInit description = {});
105   Promise<undefined> setRemoteDescription (optional RTCSessionDescriptionInit description = {});
106   readonly attribute RTCSessionDescription? localDescription;
107   readonly attribute RTCSessionDescription? currentLocalDescription;
108   readonly attribute RTCSessionDescription? pendingLocalDescription;
109   readonly attribute RTCSessionDescription? remoteDescription;
110   readonly attribute RTCSessionDescription? currentRemoteDescription;
111   readonly attribute RTCSessionDescription? pendingRemoteDescription;
112   readonly attribute RTCSignalingState signalingState;
113   Promise<undefined> addIceCandidate (optional (RTCIceCandidateInit or RTCIceCandidate) candidate = {});
114   readonly attribute boolean? canTrickleIceCandidates;
115   readonly attribute RTCIceGatheringState iceGatheringState;
116   readonly attribute RTCIceConnectionState iceConnectionState;
117   readonly attribute RTCPeerConnectionState connectionState;
118   undefined restartIce ();
119   readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
120   readonly attribute DOMString? idpLoginUrl;
122   [ChromeOnly]
123   attribute DOMString id;
125   RTCConfiguration      getConfiguration ();
126   undefined setConfiguration(optional RTCConfiguration configuration = {});
127   [Deprecated="RTCPeerConnectionGetStreams"]
128   sequence<MediaStream> getLocalStreams ();
129   [Deprecated="RTCPeerConnectionGetStreams"]
130   sequence<MediaStream> getRemoteStreams ();
131   undefined addStream (MediaStream stream);
133   // replaces addStream; fails if already added
134   // because a track can be part of multiple streams, stream parameters
135   // indicate which particular streams should be referenced in signaling
137   RTCRtpSender addTrack(MediaStreamTrack track,
138                         MediaStream... streams);
139   undefined removeTrack(RTCRtpSender sender);
141   [Throws]
142   RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
143                                    optional RTCRtpTransceiverInit init = {});
145   sequence<RTCRtpSender> getSenders();
146   sequence<RTCRtpReceiver> getReceivers();
147   sequence<RTCRtpTransceiver> getTransceivers();
149   [ChromeOnly]
150   undefined mozSetPacketCallback(mozPacketCallback callback);
151   [ChromeOnly]
152   undefined mozEnablePacketDump(unsigned long level,
153                                 mozPacketDumpType type,
154                                 boolean sending);
155   [ChromeOnly]
156   undefined mozDisablePacketDump(unsigned long level,
157                                  mozPacketDumpType type,
158                                  boolean sending);
160   undefined close ();
161   attribute EventHandler onnegotiationneeded;
162   attribute EventHandler onicecandidate;
163   attribute EventHandler onsignalingstatechange;
164   attribute EventHandler onaddstream; // obsolete
165   attribute EventHandler onaddtrack;  // obsolete
166   attribute EventHandler ontrack;     // replaces onaddtrack and onaddstream.
167   attribute EventHandler oniceconnectionstatechange;
168   attribute EventHandler onicegatheringstatechange;
169   attribute EventHandler onconnectionstatechange;
171   Promise<RTCStatsReport> getStats (optional MediaStreamTrack? selector = null);
173   readonly attribute RTCSctpTransport? sctp;
174   // Data channel.
175   RTCDataChannel createDataChannel (DOMString label,
176                                     optional RTCDataChannelInit dataChannelDict = {});
177   attribute EventHandler ondatachannel;
180 // Legacy callback API
182 partial interface RTCPeerConnection {
184   // Dummy Promise<undefined> return values avoid "WebIDL.WebIDLError: error:
185   // We have overloads with both Promise and non-Promise return types"
187   Promise<undefined> createOffer (RTCSessionDescriptionCallback successCallback,
188                                   RTCPeerConnectionErrorCallback failureCallback,
189                                   optional RTCOfferOptions options = {});
190   Promise<undefined> createAnswer (RTCSessionDescriptionCallback successCallback,
191                                    RTCPeerConnectionErrorCallback failureCallback);
192   Promise<undefined> setLocalDescription (RTCSessionDescriptionInit description,
193                                           VoidFunction successCallback,
194                                           RTCPeerConnectionErrorCallback failureCallback);
195   Promise<undefined> setRemoteDescription (RTCSessionDescriptionInit description,
196                                            VoidFunction successCallback,
197                                            RTCPeerConnectionErrorCallback failureCallback);
198   Promise<undefined> addIceCandidate (RTCIceCandidate candidate,
199                                       VoidFunction successCallback,
200                                       RTCPeerConnectionErrorCallback failureCallback);