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 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,
60 dictionary RTCDataChannelInit {
61 boolean ordered = true;
63 unsigned short maxPacketLifeTime;
65 unsigned short maxRetransmits;
66 DOMString protocol = "";
67 boolean negotiated = false;
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",
91 interface RTCPeerConnection : EventTarget {
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;
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);
142 RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
143 optional RTCRtpTransceiverInit init = {});
145 sequence<RTCRtpSender> getSenders();
146 sequence<RTCRtpReceiver> getReceivers();
147 sequence<RTCRtpTransceiver> getTransceivers();
150 undefined mozSetPacketCallback(mozPacketCallback callback);
152 undefined mozEnablePacketDump(unsigned long level,
153 mozPacketDumpType type,
156 undefined mozDisablePacketDump(unsigned long level,
157 mozPacketDumpType type,
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;
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);