author | Jan-Ivar Bruaroey <jib@mozilla.com> |
Fri, 18 Sep 2015 14:03:30 -0400 | |
changeset 263460 | d03c69e05eed0f72517dec6cf8213c6610c7a34f |
parent 263459 | 0783f2174228ea14bcfcaaed3fbff28b4fb56014 |
child 263461 | 4013ca84d244faa3361641a441a5efccf0f6e2d4 |
push id | 65318 |
push user | rjesup@wgate.com |
push date | Sun, 20 Sep 2015 18:19:14 +0000 |
treeherder | mozilla-inbound@4013ca84d244 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jesup, bz |
bugs | 1181896 |
milestone | 43.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
|
--- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -948,18 +948,18 @@ GetSources(MediaEngine *engine, dom::Med } } } // Apply constrains to a supplied list of sources (removes items from the list) template<class DeviceType> static void -ApplyConstraints(const MediaTrackConstraints &aConstraints, - nsTArray<nsRefPtr<DeviceType>>& aSources) +SelectSettings(const MediaTrackConstraints &aConstraints, + nsTArray<nsRefPtr<DeviceType>>& aSources) { auto& c = aConstraints; // First apply top-level constraints. // Stack constraintSets that pass, starting with the required one, because the // whole stack must be re-satisfied each time a capability-set is ruled out // (this avoids storing state or pushing algorithm into the lower-level code). @@ -1004,18 +1004,18 @@ ApplyConstraints(const MediaTrackConstra aSources.AppendElements(Move(rejects)); aggregateConstraints.RemoveElementAt(aggregateConstraints.Length() - 1); } } } } static bool -ApplyConstraints(MediaStreamConstraints &aConstraints, - nsTArray<nsRefPtr<MediaDevice>>& aSources) +SelectSettings(MediaStreamConstraints &aConstraints, + nsTArray<nsRefPtr<MediaDevice>>& aSources) { // Since the advanced part of the constraints algorithm needs to know when // a candidate set is overconstrained (zero members), we must split up the // list into videos and audios, and put it back together again at the end. bool overconstrained = false; nsTArray<nsRefPtr<VideoDevice>> videos; nsTArray<nsRefPtr<AudioDevice>> audios; @@ -1028,26 +1028,26 @@ ApplyConstraints(MediaStreamConstraints nsRefPtr<AudioDevice> audio = static_cast<AudioDevice*>(source.get()); audios.AppendElement(audio); } } aSources.Clear(); MOZ_ASSERT(!aSources.Length()); if (IsOn(aConstraints.mVideo)) { - ApplyConstraints(GetInvariant(aConstraints.mVideo), videos); + SelectSettings(GetInvariant(aConstraints.mVideo), videos); if (!videos.Length()) { overconstrained = true; } for (auto& video : videos) { aSources.AppendElement(video); } } if (IsOn(aConstraints.mAudio)) { - ApplyConstraints(GetInvariant(aConstraints.mAudio), audios); + SelectSettings(GetInvariant(aConstraints.mAudio), audios); if (!audios.Length()) { overconstrained = true; } for (auto& audio : audios) { aSources.AppendElement(audio); } } return !overconstrained; @@ -1901,17 +1901,17 @@ MediaManager::GetUserMedia(nsPIDOMWindow nsRefPtr<nsPIDOMWindow> window = static_cast<nsPIDOMWindow*> (nsGlobalWindow::GetInnerWindowWithId(windowID)); if (!mgr || !window) { return; } // Apply any constraints. This modifies the list. - if (!ApplyConstraints(c, *devices)) { + if (!SelectSettings(c, *devices)) { nsRefPtr<MediaStreamError> error = new MediaStreamError(window, NS_LITERAL_STRING("NotFoundError")); onFailure->OnError(error); return; } nsCOMPtr<nsISupportsArray> devicesCopy; // before we give up devices below if (!askPermission) {
--- a/dom/media/MediaStreamError.cpp +++ b/dom/media/MediaStreamError.cpp @@ -7,20 +7,20 @@ #include "MediaStreamError.h" #include "mozilla/dom/MediaStreamErrorBinding.h" #include "nsContentUtils.h" namespace mozilla { BaseMediaMgrError::BaseMediaMgrError(const nsAString& aName, const nsAString& aMessage, - const nsAString& aConstraintName) + const nsAString& aConstraint) : mName(aName) , mMessage(aMessage) - , mConstraintName(aConstraintName) + , mConstraint(aConstraint) { if (mMessage.IsEmpty()) { if (mName.EqualsLiteral("NotFoundError")) { mMessage.AssignLiteral("The object can not be found here."); } else if (mName.EqualsLiteral("PermissionDeniedError")) { mMessage.AssignLiteral("The user did not grant permission for the operation."); } else if (mName.EqualsLiteral("SourceUnavailableError")) { mMessage.AssignLiteral("The source of the MediaStream could not be " @@ -38,18 +38,18 @@ BaseMediaMgrError::BaseMediaMgrError(con NS_IMPL_ISUPPORTS0(MediaMgrError) namespace dom { MediaStreamError::MediaStreamError( nsPIDOMWindow* aParent, const nsAString& aName, const nsAString& aMessage, - const nsAString& aConstraintName) - : BaseMediaMgrError(aName, aMessage, aConstraintName) + const nsAString& aConstraint) + : BaseMediaMgrError(aName, aMessage, aConstraint) , mParent(aParent) {} NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaStreamError, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaStreamError) NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaStreamError) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamError) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) @@ -70,15 +70,15 @@ MediaStreamError::GetName(nsAString& aNa void MediaStreamError::GetMessage(nsAString& aMessage) const { aMessage = mMessage; } void -MediaStreamError::GetConstraintName(nsAString& aConstraintName) const +MediaStreamError::GetConstraint(nsAString& aConstraint) const { - aConstraintName = mConstraintName; + aConstraint = mConstraint; } } // namespace dom } // namespace mozilla
--- a/dom/media/MediaStreamError.h +++ b/dom/media/MediaStreamError.h @@ -29,66 +29,66 @@ class MediaStreamError; } // namespace dom class BaseMediaMgrError { friend class dom::MediaStreamError; protected: BaseMediaMgrError(const nsAString& aName, const nsAString& aMessage, - const nsAString& aConstraintName); + const nsAString& aConstraint); const nsString mName; nsString mMessage; - const nsString mConstraintName; + const nsString mConstraint; }; class MediaMgrError final : public nsISupports, public BaseMediaMgrError { public: explicit MediaMgrError(const nsAString& aName, const nsAString& aMessage = EmptyString(), - const nsAString& aConstraintName = EmptyString()) - : BaseMediaMgrError(aName, aMessage, aConstraintName) {} + const nsAString& aConstraint = EmptyString()) + : BaseMediaMgrError(aName, aMessage, aConstraint) {} NS_DECL_THREADSAFE_ISUPPORTS private: ~MediaMgrError() {} }; namespace dom { class MediaStreamError final : public nsISupports, public BaseMediaMgrError, public nsWrapperCache { public: MediaStreamError(nsPIDOMWindow* aParent, const nsAString& aName, const nsAString& aMessage = EmptyString(), - const nsAString& aConstraintName = EmptyString()); + const nsAString& aConstraint = EmptyString()); MediaStreamError(nsPIDOMWindow* aParent, const BaseMediaMgrError& aOther) - : BaseMediaMgrError(aOther.mName, aOther.mMessage, aOther.mConstraintName) + : BaseMediaMgrError(aOther.mName, aOther.mMessage, aOther.mConstraint) , mParent(aParent) {} NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaStreamError) NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASTREAMERROR_IMPLEMENTATION_IID) virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; nsPIDOMWindow* GetParentObject() const { return mParent; } void GetName(nsAString& aName) const; void GetMessage(nsAString& aMessage) const; - void GetConstraintName(nsAString& aConstraintName) const; + void GetConstraint(nsAString& aConstraint) const; private: virtual ~MediaStreamError() {} nsRefPtr<nsPIDOMWindow> mParent; }; NS_DEFINE_STATIC_IID_ACCESSOR(MediaStreamError,
--- a/dom/webidl/MediaStreamError.webidl +++ b/dom/webidl/MediaStreamError.webidl @@ -12,10 +12,10 @@ // TODO: This is an 'exception', not an interface, by virtue of needing to be // passed as a promise rejection-reason. Revisit if DOMException grows a customArg [ExceptionClass, NoInterfaceObject] interface MediaStreamError { readonly attribute DOMString name; readonly attribute DOMString? message; - readonly attribute DOMString? constraintName; + readonly attribute DOMString? constraint; };
--- a/dom/webidl/MediaStreamTrack.webidl +++ b/dom/webidl/MediaStreamTrack.webidl @@ -32,16 +32,19 @@ enum MediaSourceEnum { "other" }; typedef (long or ConstrainLongRange) ConstrainLong; typedef (double or ConstrainDoubleRange) ConstrainDouble; typedef (boolean or ConstrainBooleanParameters) ConstrainBoolean; typedef (DOMString or sequence<DOMString> or ConstrainDOMStringParameters) ConstrainDOMString; +// Note: When adding new constraints, remember to update the SelectSettings() +// function in MediaManager.cpp to make OverconstrainedError's constraint work! + dictionary MediaTrackConstraintSet { ConstrainLong width; ConstrainLong height; ConstrainDouble frameRate; ConstrainDOMString facingMode; DOMString mediaSource = "camera"; long long browserWindow; boolean scrollWithPage;