Bug 1290948 - Part 2: webidl for RTCRtpTransceiver and supporting interfaces r+jib, r+ehsan r=ehsan+251051,jib
☠☠ backed out by e077a6e6e842 ☠ ☠
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 23 Aug 2017 15:47:54 -0500
changeset 443514 49878c508ce6741eceb48ffe337796d5e7897497
parent 443513 bbe53fb92e21bfd5ec6ace0a854a483dbf4514ab
child 443515 56c169018cebfab1e4bb3a34b1aeddba2fec3d66
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1290948, 251051
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1290948 - Part 2: webidl for RTCRtpTransceiver and supporting interfaces r+jib, r+ehsan r=ehsan+251051,jib MozReview-Commit-ID: DmXufKwCAyW
dom/bindings/Bindings.conf
dom/webidl/MediaStream.webidl
dom/webidl/MediaStreamList.webidl
dom/webidl/PeerConnectionImpl.webidl
dom/webidl/PeerConnectionObserver.webidl
dom/webidl/RTCPeerConnection.webidl
dom/webidl/RTCRtpSender.webidl
dom/webidl/RTCRtpTransceiver.webidl
dom/webidl/RTCTrackEvent.webidl
dom/webidl/TransceiverImpl.webidl
dom/webidl/moz.build
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -691,16 +691,22 @@ DOMInterfaces = {
 },
 
 'PeerConnectionImpl': {
     'nativeType': 'mozilla::PeerConnectionImpl',
     'headerFile': 'PeerConnectionImpl.h',
     'wrapperCache': False
 },
 
+'TransceiverImpl': {
+    'nativeType': 'mozilla::TransceiverImpl',
+    'headerFile': 'TransceiverImpl.h',
+    'wrapperCache': False
+},
+
 'Plugin': {
     'headerFile' : 'nsPluginArray.h',
     'nativeType': 'nsPluginElement',
 },
 
 'PluginArray': {
     'nativeType': 'nsPluginArray',
 },
--- a/dom/webidl/MediaStream.webidl
+++ b/dom/webidl/MediaStream.webidl
@@ -38,9 +38,14 @@ interface MediaStream : EventTarget {
     MediaStream                clone ();
     readonly    attribute boolean      active;
                 attribute EventHandler onaddtrack;
     //             attribute EventHandler onremovetrack;
     readonly attribute double currentTime;
 
     [ChromeOnly, Throws]
     static Promise<long> countUnderlyingStreams();
+
+    // Webrtc allows the remote side to name a stream whatever it wants, and we
+    // need to surface this to content.
+    [ChromeOnly]
+    void assignId(DOMString id);
 };
deleted file mode 100644
--- a/dom/webidl/MediaStreamList.webidl
+++ /dev/null
@@ -1,11 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-[ChromeOnly]
-interface MediaStreamList {
-  getter MediaStream? (unsigned long index);
-  readonly attribute unsigned long length;
-};
--- a/dom/webidl/PeerConnectionImpl.webidl
+++ b/dom/webidl/PeerConnectionImpl.webidl
@@ -36,38 +36,34 @@ interface PeerConnectionImpl  {
 
   /* Stats call, calls either |onGetStatsSuccess| or |onGetStatsError| on our
      observer. (see the |PeerConnectionObserver| interface) */
   [Throws]
   void getStats(MediaStreamTrack? selector);
 
   /* Adds the tracks created by GetUserMedia */
   [Throws]
-  void addTrack(MediaStreamTrack track, MediaStream... streams);
-  [Throws]
   void removeTrack(MediaStreamTrack track);
   [Throws]
-  void insertDTMF(RTCRtpSender sender, DOMString tones,
+  TransceiverImpl createTransceiverImpl(DOMString kind,
+                                        MediaStreamTrack? track);
+  [Throws]
+  boolean checkNegotiationNeeded();
+  [Throws]
+  void insertDTMF(TransceiverImpl transceiver, DOMString tones,
                   optional unsigned long duration = 100,
                   optional unsigned long interToneGap = 70);
   [Throws]
   DOMString getDTMFToneBuffer(RTCRtpSender sender);
   [Throws]
-  void replaceTrack(MediaStreamTrack thisTrack, MediaStreamTrack withTrack);
-  [Throws]
-  void setParameters(MediaStreamTrack track,
-                     optional RTCRtpParameters parameters);
-  [Throws]
-  RTCRtpParameters getParameters(MediaStreamTrack track);
+  void replaceTrackNoRenegotiation(TransceiverImpl transceiverImpl,
+                                   MediaStreamTrack? withTrack);
   [Throws]
   void closeStreams();
 
-  sequence<MediaStream> getLocalStreams();
-  sequence<MediaStream> getRemoteStreams();
-
   void addRIDExtension(MediaStreamTrack recvTrack, unsigned short extensionId);
   void addRIDFilter(MediaStreamTrack recvTrack, DOMString rid);
 
   void enablePacketDump(unsigned long level,
                         mozPacketDumpType type,
                         boolean sending);
 
   void disablePacketDump(unsigned long level,
--- a/dom/webidl/PeerConnectionObserver.webidl
+++ b/dom/webidl/PeerConnectionObserver.webidl
@@ -18,37 +18,37 @@ interface PeerConnectionObserver
   void onCreateAnswerError(unsigned long name, DOMString message);
   void onSetLocalDescriptionSuccess();
   void onSetRemoteDescriptionSuccess();
   void onSetLocalDescriptionError(unsigned long name, DOMString message);
   void onSetRemoteDescriptionError(unsigned long name, DOMString message);
   void onAddIceCandidateSuccess();
   void onAddIceCandidateError(unsigned long name, DOMString message);
   void onIceCandidate(unsigned short level, DOMString mid, DOMString candidate);
-  void onNegotiationNeeded();
 
   /* Stats callbacks */
   void onGetStatsSuccess(optional RTCStatsReportInternal report);
   void onGetStatsError(unsigned long name, DOMString message);
 
-  /* replaceTrack callbacks */
-  void onReplaceTrackSuccess();
-  void onReplaceTrackError(unsigned long name, DOMString message);
-
   /* Data channel callbacks */
   void notifyDataChannel(DataChannel channel);
 
   /* Notification of one of several types of state changed */
   void onStateChange(PCObserverStateType state);
 
   /* Changes to MediaStreamTracks */
-  void onAddStream(MediaStream stream);
   void onRemoveStream(MediaStream stream);
-  void onAddTrack(MediaStreamTrack track, sequence<MediaStream> streams);
-  void onRemoveTrack(MediaStreamTrack track);
+  void onTrack(DOMString webrtcTrackId, sequence<DOMString> streamIds);
+
+  /* Transceiver management; called when setRemoteDescription causes a
+     transceiver to be created on the C++ side */
+  void onTransceiverNeeded(DOMString kind, TransceiverImpl transceiverImpl);
 
   /* DTMF callback */
-  void onDTMFToneChange(DOMString trackId, DOMString tone);
+  void onDTMFToneChange(MediaStreamTrack track, DOMString tone);
 
   /* Packet dump callback */
   void onPacket(unsigned long level, mozPacketDumpType type, boolean sending,
                 ArrayBuffer packet);
+
+  /* Transceiver sync */
+  void syncTransceivers();
 };
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -123,18 +123,22 @@ interface RTCPeerConnection : EventTarge
   // because a track can be part of multiple streams, stream parameters
   // indicate which particular streams should be referenced in signaling
 
   RTCRtpSender addTrack(MediaStreamTrack track,
                         MediaStream stream,
                         MediaStream... moreStreams);
   void removeTrack(RTCRtpSender sender);
 
+  RTCRtpTransceiver addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
+                                   optional RTCRtpTransceiverInit init);
+
   sequence<RTCRtpSender> getSenders();
   sequence<RTCRtpReceiver> getReceivers();
+  sequence<RTCRtpTransceiver> getTransceivers();
 
   [ChromeOnly]
   void mozAddRIDExtension(RTCRtpReceiver receiver, unsigned short extensionId);
   [ChromeOnly]
   void mozAddRIDFilter(RTCRtpReceiver receiver, DOMString rid);
   [ChromeOnly]
   void mozSetPacketCallback(mozPacketCallback callback);
   [ChromeOnly]
--- a/dom/webidl/RTCRtpSender.webidl
+++ b/dom/webidl/RTCRtpSender.webidl
@@ -64,16 +64,25 @@ dictionary RTCRtpParameters {
   sequence<RTCRtpHeaderExtensionParameters> headerExtensions;
   RTCRtcpParameters                         rtcp;
   sequence<RTCRtpCodecParameters>           codecs;
 };
 
 [Pref="media.peerconnection.enabled",
  JSImplementation="@mozilla.org/dom/rtpsender;1"]
 interface RTCRtpSender {
-  readonly attribute MediaStreamTrack track;
+  readonly attribute MediaStreamTrack? track;
   Promise<void> setParameters (optional RTCRtpParameters parameters);
   RTCRtpParameters getParameters();
-  Promise<void> replaceTrack(MediaStreamTrack track);
+  Promise<void> replaceTrack(MediaStreamTrack? withTrack);
   Promise<RTCStatsReport> getStats();
   [Pref="media.peerconnection.dtmf.enabled"]
   readonly attribute RTCDTMFSender? dtmf;
+  // Ugh, can't use a ChromeOnly attibute sequence<MediaStream>...
+  [ChromeOnly]
+  sequence<MediaStream> getStreams();
+  [ChromeOnly]
+  void setStreams(sequence<MediaStream> streams);
+  [ChromeOnly]
+  void setTrack(MediaStreamTrack? track);
+  [ChromeOnly]
+  void checkWasCreatedByPc(RTCPeerConnection pc);
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/RTCRtpTransceiver.webidl
@@ -0,0 +1,75 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://w3c.github.io/webrtc-pc/#rtcrtptransceiver-interface
+ */
+
+enum RTCRtpTransceiverDirection {
+    "sendrecv",
+    "sendonly",
+    "recvonly",
+    "inactive"
+};
+
+dictionary RTCRtpTransceiverInit {
+    RTCRtpTransceiverDirection         direction = "sendrecv";
+    sequence<MediaStream>              streams = [];
+    // TODO: bug 1396918
+    // sequence<RTCRtpEncodingParameters> sendEncodings;
+};
+
+[Pref="media.peerconnection.enabled",
+ JSImplementation="@mozilla.org/dom/rtptransceiver;1"]
+interface RTCRtpTransceiver {
+    readonly attribute DOMString?                  mid;
+    [SameObject]
+    readonly attribute RTCRtpSender                sender;
+    [SameObject]
+    readonly attribute RTCRtpReceiver              receiver;
+    readonly attribute boolean                     stopped;
+             attribute RTCRtpTransceiverDirection  direction;
+    readonly attribute RTCRtpTransceiverDirection? currentDirection;
+
+    // Mostly for testing
+    [Pref="media.peerconnection.remoteTrackId.enabled"]
+    readonly attribute DOMString?                  remoteTrackId;
+
+    void stop();
+    // TODO: bug 1396922
+    // void setCodecPreferences(sequence<RTCRtpCodecCapability> codecs);
+
+    [ChromeOnly]
+    void setRemoteTrackId(DOMString trackId);
+    [ChromeOnly]
+    void setAddTrackMagic();
+    [ChromeOnly]
+    readonly attribute boolean addTrackMagic;
+    [ChromeOnly]
+    void setCurrentDirection(RTCRtpTransceiverDirection direction);
+    [ChromeOnly]
+    void setDirectionInternal(RTCRtpTransceiverDirection direction);
+    [ChromeOnly]
+    void setMid(DOMString mid);
+    [ChromeOnly]
+    void unsetMid();
+    [ChromeOnly]
+    void setStopped();
+    [ChromeOnly]
+    void remove();
+
+    [ChromeOnly]
+    DOMString getKind();
+    [ChromeOnly]
+    boolean hasBeenUsedToSend();
+    [ChromeOnly]
+    void sync();
+
+    [ChromeOnly]
+    void insertDTMF(DOMString tones,
+                    optional unsigned long duration = 100,
+                    optional unsigned long interToneGap = 70);
+};
+
--- a/dom/webidl/RTCTrackEvent.webidl
+++ b/dom/webidl/RTCTrackEvent.webidl
@@ -6,22 +6,24 @@
  * The origin of this IDL file is
  * http://w3c.github.io/webrtc-pc/#idl-def-RTCTrackEvent
  */
 
 dictionary RTCTrackEventInit : EventInit {
     required RTCRtpReceiver        receiver;
     required MediaStreamTrack      track;
     sequence<MediaStream> streams = [];
+    required RTCRtpTransceiver     transceiver;
 };
 
 [Pref="media.peerconnection.enabled",
  Constructor(DOMString type, RTCTrackEventInit eventInitDict)]
 interface RTCTrackEvent : Event {
     readonly        attribute RTCRtpReceiver           receiver;
     readonly        attribute MediaStreamTrack         track;
 
 // TODO: Use FrozenArray once available. (Bug 1236777)
 //  readonly        attribute FrozenArray<MediaStream> streams;
 
     [Frozen, Cached, Pure]
     readonly        attribute sequence<MediaStream> streams; // workaround
+    readonly        attribute RTCRtpTransceiver transceiver;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/TransceiverImpl.webidl
@@ -0,0 +1,23 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * PeerConnection.js' interface to the C++ TransceiverImpl.
+ *
+ * Do not confuse with RTCRtpTransceiver. This interface is purely for
+ * communication between the PeerConnection JS DOM binding and the C++
+ * implementation.
+ *
+ * See media/webrtc/signaling/src/peerconnection/TransceiverImpl.h
+ *
+ */
+
+// Constructed by PeerConnectionImpl::CreateTransceiverImpl.
+[ChromeOnly]
+interface TransceiverImpl {
+  MediaStreamTrack getReceiveTrack();
+  [Throws]
+  void syncWithJS(RTCRtpTransceiver transceiver);
+};
+
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -200,19 +200,16 @@ with Files("MediaEncryptedEvent.webidl")
     BUG_COMPONENT = ("Core", "Audio/Video")
 
 with Files("MediaKey*"):
     BUG_COMPONENT = ("Core", "Audio/Video: Playback")
 
 with Files("Media*List*"):
     BUG_COMPONENT = ("Core", "CSS Parsing and Computation")
 
-with Files("MediaStreamList.webidl"):
-    BUG_COMPONENT = ("Core", "Web Audio")
-
 with Files("*Record*"):
     BUG_COMPONENT = ("Core", "Audio/Video: Recording")
 
 with Files("Media*Track*"):
     BUG_COMPONENT = ("Core", "WebRTC: Audio/Video")
 
 with Files("Mouse*"):
     BUG_COMPONENT = ("Core", "DOM: Events")
@@ -988,32 +985,33 @@ WEBIDL_FILES = [
     'XULDocument.webidl',
     'XULElement.webidl',
     'XULTemplateBuilder.webidl',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     WEBIDL_FILES += [
         'DataChannel.webidl',
-        'MediaStreamList.webidl',
         'PeerConnectionImpl.webidl',
         'PeerConnectionImplEnums.webidl',
         'PeerConnectionObserver.webidl',
         'PeerConnectionObserverEnums.webidl',
         'RTCCertificate.webidl',
         'RTCConfiguration.webidl',
         'RTCDTMFSender.webidl',
         'RTCIceCandidate.webidl',
         'RTCIdentityAssertion.webidl',
         'RTCIdentityProvider.webidl',
         'RTCPeerConnection.webidl',
         'RTCPeerConnectionStatic.webidl',
         'RTCRtpReceiver.webidl',
         'RTCRtpSender.webidl',
+        'RTCRtpTransceiver.webidl',
         'RTCSessionDescription.webidl',
+        'TransceiverImpl.webidl',
         'WebrtcDeprecated.webidl',
         'WebrtcGlobalInformation.webidl',
     ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     WEBIDL_FILES += [
         'SpeechGrammar.webidl',
         'SpeechGrammarList.webidl',