Bug 1213517 - add webidl for track.getConstraints() and track.getSettings(). r=smaug
☠☠ backed out by d2021311169e ☠ ☠
authorJan-Ivar Bruaroey <jib@mozilla.com>
Fri, 13 Nov 2015 23:27:39 -0500
changeset 305336 f22693a94979d311cda86e948e2ef58929e71932
parent 305335 53900593419c215f37e70c40763ca8b45d86ecb5
child 305337 3764e2fac76589db751cb980b585df99ec7d3556
push id79558
push usercbook@mozilla.com
push dateMon, 18 Jul 2016 15:11:40 +0000
treeherdermozilla-inbound@003901a846c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1213517
milestone50.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 1213517 - add webidl for track.getConstraints() and track.getSettings(). r=smaug MozReview-Commit-ID: D15Lo3e1giL
dom/media/MediaStreamTrack.cpp
dom/media/MediaStreamTrack.h
dom/webidl/MediaStreamTrack.webidl
dom/webidl/MediaTrackSettings.webidl
dom/webidl/moz.build
--- a/dom/media/MediaStreamTrack.cpp
+++ b/dom/media/MediaStreamTrack.cpp
@@ -245,16 +245,26 @@ MediaStreamTrack::Stop()
   DOMMediaStream::TrackPort* port = mOwningStream->FindOwnedTrackPort(*this);
   MOZ_ASSERT(port, "A MediaStreamTrack must exist in its owning DOMMediaStream");
   RefPtr<Pledge<bool>> p = port->BlockSourceTrackId(mInputTrackID, BlockingMode::CREATION);
   Unused << p;
 
   mReadyState = MediaStreamTrackState::Ended;
 }
 
+void MediaStreamTrack::GetConstraints(dom::MediaTrackConstraints& aResult)
+{
+  aResult = mConstraints;
+}
+
+void MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult)
+{
+  aResult = mSettings;
+}
+
 already_AddRefed<Promise>
 MediaStreamTrack::ApplyConstraints(const MediaTrackConstraints& aConstraints,
                                    ErrorResult &aRv)
 {
   if (MOZ_LOG_TEST(gMediaStreamTrackLog, LogLevel::Info)) {
     nsString str;
     aConstraints.ToJSON(str);
 
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -9,16 +9,18 @@
 #include "mozilla/DOMEventTargetHelper.h"
 #include "nsError.h"
 #include "nsID.h"
 #include "nsIPrincipal.h"
 #include "StreamTracks.h"
 #include "MediaTrackConstraints.h"
 #include "mozilla/CORSMode.h"
 #include "PrincipalChangeObserver.h"
+#include "mozilla/dom/MediaStreamTrackBinding.h"
+#include "mozilla/dom/MediaTrackSettingsBinding.h"
 
 namespace mozilla {
 
 class DOMMediaStream;
 class MediaEnginePhotoCallback;
 class MediaInputPort;
 class MediaStream;
 class MediaStreamGraph;
@@ -258,16 +260,19 @@ public:
 
   // WebIDL
   virtual void GetKind(nsAString& aKind) = 0;
   void GetId(nsAString& aID) const;
   void GetLabel(nsAString& aLabel) { GetSource().GetLabel(aLabel); }
   bool Enabled() { return mEnabled; }
   void SetEnabled(bool aEnabled);
   void Stop();
+  void GetConstraints(dom::MediaTrackConstraints& aResult);
+  void GetSettings(dom::MediaTrackSettings& aResult);
+
   already_AddRefed<Promise>
   ApplyConstraints(const dom::MediaTrackConstraints& aConstraints, ErrorResult &aRv);
   already_AddRefed<MediaStreamTrack> Clone();
   MediaStreamTrackState ReadyState() { return mReadyState; }
 
   IMPL_EVENT_HANDLER(ended)
 
   /**
@@ -421,14 +426,16 @@ protected:
   // Keep tracking MediaStreamTrackListener and DirectMediaStreamTrackListener,
   // so we can remove them in |Destory|.
   nsTArray<RefPtr<MediaStreamTrackListener>> mTrackListeners;
   nsTArray<RefPtr<DirectMediaStreamTrackListener>> mDirectTrackListeners;
   nsString mID;
   MediaStreamTrackState mReadyState;
   bool mEnabled;
   const bool mRemote;
+  dom::MediaTrackConstraints mConstraints;
+  dom::MediaTrackSettings mSettings;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* MEDIASTREAMTRACK_H_ */
--- a/dom/webidl/MediaStreamTrack.webidl
+++ b/dom/webidl/MediaStreamTrack.webidl
@@ -79,15 +79,15 @@ interface MediaStreamTrack : EventTarget
 //              attribute EventHandler          onunmute;
 //  readonly    attribute boolean               _readonly;
 //  readonly    attribute boolean               remote;
     readonly    attribute MediaStreamTrackState readyState;
                 attribute EventHandler          onended;
     MediaStreamTrack       clone ();
     void                   stop ();
 //  MediaTrackCapabilities getCapabilities ();
-//  MediaTrackConstraints  getConstraints ();
-//  MediaTrackSettings     getSettings ();
+    MediaTrackConstraints  getConstraints ();
+    MediaTrackSettings     getSettings ();
 
     [Throws]
     Promise<void>          applyConstraints (optional MediaTrackConstraints constraints);
 //              attribute EventHandler          onoverconstrained;
 };
new file mode 100644
--- /dev/null
+++ b/dom/webidl/MediaTrackSettings.webidl
@@ -0,0 +1,33 @@
+/* -*- 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/mediacapture-main/getusermedia.html
+ */
+
+dictionary MediaTrackSettings {
+    long      width;
+    long      height;
+    double    frameRate;
+    DOMString facingMode;
+    DOMString deviceId;
+
+    // Mozilla-specific extensions:
+
+    // http://fluffy.github.io/w3c-screen-share/#screen-based-video-constraints
+    // OBE by http://w3c.github.io/mediacapture-screen-share
+
+    DOMString mediaSource;
+
+    // Experimental https://bugzilla.mozilla.org/show_bug.cgi?id=1131568#c3
+    //              https://bugzilla.mozilla.org/show_bug.cgi?id=1193075
+
+    long long browserWindow;
+    boolean scrollWithPage;
+    long viewportOffsetX;
+    long viewportOffsetY;
+    long viewportWidth;
+    long viewportHeight;
+};
\ No newline at end of file
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -301,16 +301,17 @@ WEBIDL_FILES = [
     'MediaRecorder.webidl',
     'MediaSource.webidl',
     'MediaStream.webidl',
     'MediaStreamAudioDestinationNode.webidl',
     'MediaStreamAudioSourceNode.webidl',
     'MediaStreamError.webidl',
     'MediaStreamTrack.webidl',
     'MediaTrackConstraintSet.webidl',
+    'MediaTrackSettings.webidl',
     'MediaTrackSupportedConstraints.webidl',
     'MenuBoxObject.webidl',
     'MessageChannel.webidl',
     'MessageEvent.webidl',
     'MessagePort.webidl',
     'MessagePortList.webidl',
     'MimeType.webidl',
     'MimeTypeArray.webidl',