| /* |
| * Copyright (C) 2012 Google Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer |
| * in the documentation and/or other materials provided with the |
| * distribution. |
| * 3. Neither the name of Google Inc. nor the names of its contributors |
| * may be used to endorse or promote products derived from this |
| * software without specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| */ |
| |
| // https://w3c.github.io/webrtc-pc/#state-definitions |
| |
| enum RTCSignalingState { |
| "stable", |
| "have-local-offer", |
| "have-remote-offer", |
| "have-local-pranswer", |
| "have-remote-pranswer", |
| "closed" |
| }; |
| |
| enum RTCIceConnectionState { |
| "new", |
| "checking", |
| "connected", |
| "completed", |
| "failed", |
| "disconnected", |
| "closed" |
| }; |
| |
| enum RTCPeerConnectionState { |
| "new", |
| "connecting", |
| "connected", |
| "disconnected", |
| "failed", |
| "closed" |
| }; |
| |
| // https://w3c.github.io/webrtc-pc/#interface-definition |
| |
| // TODO(guidou): Many types are of the wrong type in this interface: |
| // * Dictionary -> specific dictionary types like RTCConfiguration |
| [ |
| ActiveScriptWrappable, |
| // TODO(guidou): There should only be one constructor argument. |
| Constructor(optional RTCConfiguration configuration, optional Dictionary mediaConstraints), |
| ConstructorCallWith=ExecutionContext, |
| RaisesException=Constructor, |
| Exposed=Window |
| ] interface RTCPeerConnection : EventTarget { |
| [CallWith=ScriptState] Promise<RTCSessionDescription> createOffer(optional RTCOfferOptions options); |
| [CallWith=ScriptState] Promise<RTCSessionDescription> createAnswer(optional RTCAnswerOptions options); |
| [CallWith=ScriptState] Promise<void> setLocalDescription(RTCSessionDescriptionInit description); |
| readonly attribute RTCSessionDescription? localDescription; |
| readonly attribute RTCSessionDescription? currentLocalDescription; |
| readonly attribute RTCSessionDescription? pendingLocalDescription; |
| [CallWith=ScriptState] Promise<void> setRemoteDescription(RTCSessionDescriptionInit description); |
| readonly attribute RTCSessionDescription? remoteDescription; |
| readonly attribute RTCSessionDescription? currentRemoteDescription; |
| readonly attribute RTCSessionDescription? pendingRemoteDescription; |
| [CallWith=ScriptState, RaisesException, MeasureAs=RTCPeerConnectionAddIceCandidatePromise] Promise<void> addIceCandidate((RTCIceCandidateInit or RTCIceCandidate) candidate); |
| readonly attribute RTCSignalingState signalingState; |
| readonly attribute RTCIceGatheringState iceGatheringState; |
| readonly attribute RTCIceConnectionState iceConnectionState; |
| readonly attribute RTCPeerConnectionState connectionState; |
| // readonly attribute boolean? canTrickleIceCandidates; |
| [CallWith=ScriptState] RTCConfiguration getConfiguration(); |
| [CallWith=ScriptState, RaisesException] void setConfiguration(RTCConfiguration configuration); |
| void close(); |
| attribute EventHandler onnegotiationneeded; |
| attribute EventHandler onicecandidate; |
| attribute EventHandler onsignalingstatechange; |
| attribute EventHandler oniceconnectionstatechange; |
| attribute EventHandler onconnectionstatechange; |
| attribute EventHandler onicegatheringstatechange; |
| |
| // https://w3c.github.io/webrtc-pc/#legacy-interface-extensions |
| // These methods return Promise<void> because having Promise-based versions requires that all overloads return Promises. |
| [CallWith=ScriptState, RaisesException] Promise<void> createOffer(RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, optional Dictionary rtcOfferOptions); |
| // TODO(guidou): There should be no mediaConstraints argument. |
| [CallWith=ScriptState] Promise<void> createAnswer(RTCSessionDescriptionCallback successCallback, RTCPeerConnectionErrorCallback failureCallback, optional Dictionary mediaConstraints); |
| // TODO(guidou): The failureCallback argument should be non-optional. |
| // TODO(crbug.com/841185): |failureCallback| is not nullable in the spec. |
| [CallWith=ScriptState] Promise<void> setLocalDescription(RTCSessionDescriptionInit description, VoidFunction successCallback, optional RTCPeerConnectionErrorCallback? failureCallback); |
| // TODO(guidou): The failureCallback argument should be non-optional. |
| // TODO(crbug.com/841185): |failureCallback| is not nullable in the spec. |
| [CallWith=ScriptState] Promise<void> setRemoteDescription(RTCSessionDescriptionInit description, VoidFunction successCallback, optional RTCPeerConnectionErrorCallback? failureCallback); |
| [CallWith=ScriptState, RaisesException, MeasureAs=RTCPeerConnectionAddIceCandidateLegacy] Promise<void> addIceCandidate((RTCIceCandidateInit or RTCIceCandidate) candidate, VoidFunction successCallback, RTCPeerConnectionErrorCallback failureCallback); |
| |
| // Legacy getStats() API. The returned metrics are a completely different |
| // set of metrics than the standard compliant version, presented in a |
| // different format. They are undocumented, implementation-specific and |
| // should go away but it is still heavily used. The selector argument can |
| // optionally be used to filter the results only to return metrics relevant |
| // for the selector. |
| // TODO(hbos): Deprecate and remove this API. https://crbug.com/822696 |
| [CallWith=ScriptState, LegacyInterfaceTypeChecking] Promise<void> getStats(RTCStatsCallback successCallback, MediaStreamTrack? selector); |
| // Due to a limitation of generated V8 bindings (https://crbug.com/828401), |
| // it is not possible to express both legacy and spec-compliant versions of |
| // getStats() in IDL. This version implements two different APIs with custom |
| // bindings to resolve which one to call in RTCPeerConnection.cpp: |
| // |
| // 1. Promise<void> getStats(RTCStatsCallback successCallback, optional MediaStreamTrack? selector); |
| // This is the legacy getStats() API handling the case when the selector |
| // argument is missing, for more details on the legacy API and the IDL |
| // for when the selector is present, see above. |
| // |
| // 2. Promise<RTCStatsReport> getStats(optional MediaStreamTrack? selector = null); |
| // This is the spec-compliant version of getStats(). Spec for API: |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getstats |
| // Spec for metrics: https://w3c.github.io/webrtc-stats/ |
| // List of implemented stats: |
| // https://cs.chromium.org/chromium/src/third_party/webrtc/api/stats/rtcstats_objects.h |
| // See also RTCRtpSender.getStats() and RTCRtpReceiver.getStats(). |
| [CallWith=ScriptState] Promise<any> getStats(optional any callbackOrSelector); |
| |
| // RTP Media API |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-gettransceivers |
| [Measure] sequence<RTCRtpTranceiver> getTransceivers(); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getsenders |
| [Measure] sequence<RTCRtpSender> getSenders(); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getreceivers |
| [Measure] sequence<RTCRtpReceiver> getReceivers(); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver |
| [Measure, RaisesException] RTCRtpTransceiver addTransceiver( |
| (MediaStreamTrack or DOMString) track_or_kind, |
| optional RTCRtpTransceiverInit init); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtrack |
| [Measure, RaisesException] RTCRtpSender addTrack(MediaStreamTrack track, MediaStream... streams); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack |
| [Measure, RaisesException] void removeTrack(RTCRtpSender sender); |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-ontrack |
| attribute EventHandler ontrack; |
| |
| // https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api |
| [CallWith=ScriptState, RaisesException] RTCDataChannel createDataChannel(USVString label, optional RTCDataChannelInit dataChannelDict); |
| attribute EventHandler ondatachannel; |
| |
| // Certificate management |
| // https://w3c.github.io/webrtc-pc/#sec.cert-mgmt |
| [RaisesException, CallWith=ScriptState] static Promise<RTCCertificate> generateCertificate(AlgorithmIdentifier keygenAlgorithm); |
| |
| // Non-standard or removed from the spec: |
| [Measure] sequence<MediaStream> getLocalStreams(); |
| [Measure] sequence<MediaStream> getRemoteStreams(); |
| // TODO(hbos): Remove |mediaConstraints|, they are no longer supported. |
| [Measure, CallWith=ScriptState, RaisesException] void addStream(MediaStream stream, optional Dictionary mediaConstraints); |
| [Measure, RaisesException] void removeStream(MediaStream stream); |
| [Measure, RaisesException] RTCDTMFSender createDTMFSender(MediaStreamTrack track); |
| attribute EventHandler onaddstream; |
| attribute EventHandler onremovestream; |
| |
| [OriginTrialEnabled=RtcPeerConnectionId, CallWith=ScriptState, MeasureAs=RtcPeerConnectionId] readonly attribute DOMString id; |
| }; |
| |
| // https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionerrorcallback |
| callback RTCPeerConnectionErrorCallback = void (DOMException error); |
| |
| // https://w3c.github.io/webrtc-pc/#dom-rtcsessiondescriptioncallback |
| // TODO(yukishiino): The argument type must be RTCSessionDescriptionInit instead |
| // of RTCSessionDescription. |
| callback RTCSessionDescriptionCallback = void (RTCSessionDescription description); |
| |
| // No spec. Blink specific definition. |
| callback RTCStatsCallback = void (RTCStatsResponse response); |