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 */ 9 10callback RTCSessionDescriptionCallback = void (RTCSessionDescriptionInit description); 11callback RTCPeerConnectionErrorCallback = void (DOMException error); 12callback RTCStatsCallback = void (RTCStatsReport report); 13 14enum RTCSignalingState { 15 "stable", 16 "have-local-offer", 17 "have-remote-offer", 18 "have-local-pranswer", 19 "have-remote-pranswer", 20 "closed" 21}; 22 23enum RTCIceGatheringState { 24 "new", 25 "gathering", 26 "complete" 27}; 28 29enum RTCIceConnectionState { 30 "new", 31 "checking", 32 "connected", 33 "completed", 34 "failed", 35 "disconnected", 36 "closed" 37}; 38 39dictionary RTCDataChannelInit { 40 boolean ordered = true; 41 unsigned short maxPacketLifeTime; 42 unsigned short maxRetransmits; 43 DOMString protocol = ""; 44 boolean negotiated = false; 45 unsigned short id; 46 47 // These are deprecated due to renaming in the spec, but still supported for Fx53 48 unsigned short maxRetransmitTime; 49}; 50 51dictionary RTCOfferAnswerOptions { 52// boolean voiceActivityDetection = true; // TODO: support this (Bug 1184712) 53}; 54 55dictionary RTCAnswerOptions : RTCOfferAnswerOptions { 56}; 57 58dictionary RTCOfferOptions : RTCOfferAnswerOptions { 59 boolean offerToReceiveVideo; 60 boolean offerToReceiveAudio; 61 boolean iceRestart = false; 62}; 63 64[Pref="media.peerconnection.enabled", 65 JSImplementation="@mozilla.org/dom/peerconnection;1", 66 Constructor (optional RTCConfiguration configuration, 67 optional object? constraints)] 68interface RTCPeerConnection : EventTarget { 69 [Throws, StaticClassOverride="mozilla::dom::RTCCertificate"] 70 static Promise<RTCCertificate> generateCertificate (AlgorithmIdentifier keygenAlgorithm); 71 72 [Pref="media.peerconnection.identity.enabled"] 73 void setIdentityProvider (DOMString provider, 74 optional RTCIdentityProviderOptions options); 75 [Pref="media.peerconnection.identity.enabled"] 76 Promise<DOMString> getIdentityAssertion(); 77 Promise<RTCSessionDescriptionInit> createOffer (optional RTCOfferOptions options); 78 Promise<RTCSessionDescriptionInit> createAnswer (optional RTCAnswerOptions options); 79 Promise<void> setLocalDescription (RTCSessionDescriptionInit description); 80 Promise<void> setRemoteDescription (RTCSessionDescriptionInit description); 81 readonly attribute RTCSessionDescription? localDescription; 82 readonly attribute RTCSessionDescription? currentLocalDescription; 83 readonly attribute RTCSessionDescription? pendingLocalDescription; 84 readonly attribute RTCSessionDescription? remoteDescription; 85 readonly attribute RTCSessionDescription? currentRemoteDescription; 86 readonly attribute RTCSessionDescription? pendingRemoteDescription; 87 readonly attribute RTCSignalingState signalingState; 88 Promise<void> addIceCandidate ((RTCIceCandidateInit or RTCIceCandidate)? candidate); 89 readonly attribute boolean? canTrickleIceCandidates; 90 readonly attribute RTCIceGatheringState iceGatheringState; 91 readonly attribute RTCIceConnectionState iceConnectionState; 92 [Pref="media.peerconnection.identity.enabled"] 93 readonly attribute Promise<RTCIdentityAssertion> peerIdentity; 94 [Pref="media.peerconnection.identity.enabled"] 95 readonly attribute DOMString? idpLoginUrl; 96 97 [ChromeOnly] 98 attribute DOMString id; 99 100 RTCConfiguration getConfiguration (); 101 [Deprecated="RTCPeerConnectionGetStreams"] 102 sequence<MediaStream> getLocalStreams (); 103 [Deprecated="RTCPeerConnectionGetStreams"] 104 sequence<MediaStream> getRemoteStreams (); 105 void addStream (MediaStream stream); 106 107 // replaces addStream; fails if already added 108 // because a track can be part of multiple streams, stream parameters 109 // indicate which particular streams should be referenced in signaling 110 111 RTCRtpSender addTrack(MediaStreamTrack track, 112 MediaStream stream, 113 MediaStream... moreStreams); 114 void removeTrack(RTCRtpSender sender); 115 116 RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind, 117 optional RTCRtpTransceiverInit init); 118 119 sequence<RTCRtpSender> getSenders(); 120 sequence<RTCRtpReceiver> getReceivers(); 121 sequence<RTCRtpTransceiver> getTransceivers(); 122 123 void close (); 124 attribute EventHandler onnegotiationneeded; 125 attribute EventHandler onicecandidate; 126 attribute EventHandler onsignalingstatechange; 127 attribute EventHandler onaddstream; // obsolete 128 attribute EventHandler onaddtrack; // obsolete 129 attribute EventHandler ontrack; // replaces onaddtrack and onaddstream. 130 attribute EventHandler onremovestream; 131 attribute EventHandler oniceconnectionstatechange; 132 attribute EventHandler onicegatheringstatechange; 133 134 Promise<RTCStatsReport> getStats (optional MediaStreamTrack? selector); 135 136 // Data channel. 137 RTCDataChannel createDataChannel (DOMString label, 138 optional RTCDataChannelInit dataChannelDict); 139 attribute EventHandler ondatachannel; 140}; 141 142// Legacy callback API 143 144partial interface RTCPeerConnection { 145 146 // Dummy Promise<void> return values avoid "WebIDL.WebIDLError: error: 147 // We have overloads with both Promise and non-Promise return types" 148 149 Promise<void> createOffer (RTCSessionDescriptionCallback successCallback, 150 RTCPeerConnectionErrorCallback failureCallback, 151 optional RTCOfferOptions options); 152 Promise<void> createAnswer (RTCSessionDescriptionCallback successCallback, 153 RTCPeerConnectionErrorCallback failureCallback); 154 Promise<void> setLocalDescription (RTCSessionDescriptionInit description, 155 VoidFunction successCallback, 156 RTCPeerConnectionErrorCallback failureCallback); 157 Promise<void> setRemoteDescription (RTCSessionDescriptionInit description, 158 VoidFunction successCallback, 159 RTCPeerConnectionErrorCallback failureCallback); 160 Promise<void> addIceCandidate (RTCIceCandidate candidate, 161 VoidFunction successCallback, 162 RTCPeerConnectionErrorCallback failureCallback); 163 Promise<void> getStats (MediaStreamTrack? selector, 164 RTCStatsCallback successCallback, 165 RTCPeerConnectionErrorCallback failureCallback); 166}; 167