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 = void (RTCSessionDescriptionInit description);
11 callback RTCPeerConnectionErrorCallback = void (DOMException error);
12 callback RTCStatsCallback = void (RTCStatsReport report);
14 enum RTCSignalingState {
18 "have-local-pranswer",
19 "have-remote-pranswer",
23 enum RTCIceGatheringState {
29 enum RTCIceConnectionState {
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,
51 dictionary RTCDataChannelInit {
52 boolean ordered = true;
54 unsigned short maxPacketLifeTime;
56 unsigned short maxRetransmits;
57 DOMString protocol = "";
58 boolean negotiated = false;
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",
82 interface RTCPeerConnection : EventTarget {
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;
111 [Pref="media.peerconnection.identity.enabled"]
112 readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
113 [Pref="media.peerconnection.identity.enabled"]
114 readonly attribute DOMString? idpLoginUrl;
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();
142 void mozSetPacketCallback(mozPacketCallback callback);
144 void mozEnablePacketDump(unsigned long level,
145 mozPacketDumpType type,
148 void mozDisablePacketDump(unsigned long level,
149 mozPacketDumpType type,
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);
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);