Title: [204595] trunk/Source/WebCore
Revision
204595
Author
[email protected]
Date
2016-08-18 09:06:19 -0700 (Thu, 18 Aug 2016)

Log Message

[MediaStream] cleanup MediaConstraints
https://bugs.webkit.org/show_bug.cgi?id=160957

Reviewed by Antoine Quint.

No new tests, no behavior change.

* Modules/mediastream/CaptureDeviceManager.cpp:
(CaptureDeviceManager::sessionSupportsConstraint): Use MediaConstraint::type

* bindings/js/JSMediaDevicesCustom.cpp:
(WebCore::initializeStringConstraintWithList): MediaConstraint::create now takes the constraint
type, not name.
(WebCore::createStringConstraint): Ditto.
(WebCore::createBooleanConstraint): Ditto.
(WebCore::createDoubleConstraint): Ditto.
(WebCore::createIntConstraint): Ditto.
(WebCore::parseMediaTrackConstraintSetForKey): Pass constraint type.

* platform/mediastream/MediaConstraints.cpp:
(WebCore::MediaConstraint::create): MediaConstraint constructor now takes the constraint.
(WebCore::IntConstraint::create): Take type, not name.
(WebCore::IntConstraint::setMin): Ditto.
(WebCore::DoubleConstraint::create): Ditto.
(WebCore::BooleanConstraint::create): Ditto.
(WebCore::StringConstraint::create): Ditto.
* platform/mediastream/MediaConstraints.h:

* platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp:
(WebCore::RealtimeMediaSourceSupportedConstraints::nameForConstraint): Make static.
(WebCore::RealtimeMediaSourceSupportedConstraints::constraintFromName): Ditto.
* platform/mediastream/RealtimeMediaSourceSupportedConstraints.h:

* platform/mediastream/mac/AVCaptureDeviceManager.mm:
(WebCore::AVCaptureDeviceManager::sessionSupportsConstraint): Use MediaConstraint::type

* platform/mediastream/mac/AVVideoCaptureSource.mm:
(WebCore::AVVideoCaptureSource::applyConstraints): nameForConstraint is a static method. Add
error logging.

* platform/mock/MediaConstraintsMock.cpp:
(WebCore::isSatisfiable): Use constraint type.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (204594 => 204595)


--- trunk/Source/WebCore/ChangeLog	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/ChangeLog	2016-08-18 16:06:19 UTC (rev 204595)
@@ -1,3 +1,48 @@
+2016-08-18  Eric Carlson  <[email protected]>
+
+        [MediaStream] cleanup MediaConstraints
+        https://bugs.webkit.org/show_bug.cgi?id=160957
+
+        Reviewed by Antoine Quint.
+
+        No new tests, no behavior change.
+
+        * Modules/mediastream/CaptureDeviceManager.cpp:
+        (CaptureDeviceManager::sessionSupportsConstraint): Use MediaConstraint::type
+
+        * bindings/js/JSMediaDevicesCustom.cpp:
+        (WebCore::initializeStringConstraintWithList): MediaConstraint::create now takes the constraint
+        type, not name.
+        (WebCore::createStringConstraint): Ditto.
+        (WebCore::createBooleanConstraint): Ditto.
+        (WebCore::createDoubleConstraint): Ditto.
+        (WebCore::createIntConstraint): Ditto.
+        (WebCore::parseMediaTrackConstraintSetForKey): Pass constraint type.
+
+        * platform/mediastream/MediaConstraints.cpp:
+        (WebCore::MediaConstraint::create): MediaConstraint constructor now takes the constraint.
+        (WebCore::IntConstraint::create): Take type, not name.
+        (WebCore::IntConstraint::setMin): Ditto.
+        (WebCore::DoubleConstraint::create): Ditto.
+        (WebCore::BooleanConstraint::create): Ditto.
+        (WebCore::StringConstraint::create): Ditto.
+        * platform/mediastream/MediaConstraints.h:
+
+        * platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp:
+        (WebCore::RealtimeMediaSourceSupportedConstraints::nameForConstraint): Make static.
+        (WebCore::RealtimeMediaSourceSupportedConstraints::constraintFromName): Ditto.
+        * platform/mediastream/RealtimeMediaSourceSupportedConstraints.h:
+
+        * platform/mediastream/mac/AVCaptureDeviceManager.mm:
+        (WebCore::AVCaptureDeviceManager::sessionSupportsConstraint): Use MediaConstraint::type
+
+        * platform/mediastream/mac/AVVideoCaptureSource.mm:
+        (WebCore::AVVideoCaptureSource::applyConstraints): nameForConstraint is a static method. Add
+        error logging.
+
+        * platform/mock/MediaConstraintsMock.cpp:
+        (WebCore::isSatisfiable): Use constraint type.
+
 2016-08-18  Rawinder Singh  <[email protected]>
 
         [web-animations] Add Animatable, AnimationEffect, KeyframeEffect and Animation interface

Modified: trunk/Source/WebCore/Modules/mediastream/CaptureDeviceManager.cpp (204594 => 204595)


--- trunk/Source/WebCore/Modules/mediastream/CaptureDeviceManager.cpp	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/Modules/mediastream/CaptureDeviceManager.cpp	2016-08-18 16:06:19 UTC (rev 204595)
@@ -154,7 +154,7 @@
 bool CaptureDeviceManager::sessionSupportsConstraint(const CaptureSessionInfo*, RealtimeMediaSource::Type type, const MediaConstraint& constraint)
 {
     const RealtimeMediaSourceSupportedConstraints& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints();
-    MediaConstraintType constraintType = supportedConstraints.constraintFromName(constraint.name());
+    MediaConstraintType constraintType = constraint.type();
     if (!supportedConstraints.supportsConstraint(constraintType))
         return false;
 

Modified: trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp (204594 => 204595)


--- trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp	2016-08-18 16:06:19 UTC (rev 204595)
@@ -58,9 +58,9 @@
     }
 }
 
-static RefPtr<StringConstraint> createStringConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, ConstraintSetType constraintSetType)
+static RefPtr<StringConstraint> createStringConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
 {
-    auto constraint = StringConstraint::create(name);
+    auto constraint = StringConstraint::create(type);
 
     // Dictionary constraint value.
     Dictionary dictionaryValue;
@@ -120,9 +120,9 @@
     return nullptr;
 }
 
-static RefPtr<BooleanConstraint> createBooleanConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, ConstraintSetType constraintSetType)
+static RefPtr<BooleanConstraint> createBooleanConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
 {
-    auto constraint = BooleanConstraint::create(name);
+    auto constraint = BooleanConstraint::create(type);
 
     // Dictionary constraint value.
     Dictionary dictionaryValue;
@@ -159,9 +159,9 @@
     return nullptr;
 }
 
-static RefPtr<DoubleConstraint> createDoubleConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, ConstraintSetType constraintSetType)
+static RefPtr<DoubleConstraint> createDoubleConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
 {
-    auto constraint = DoubleConstraint::create(name);
+    auto constraint = DoubleConstraint::create(type);
 
     // Dictionary constraint value.
     Dictionary dictionaryValue;
@@ -206,9 +206,9 @@
     return nullptr;
 }
 
-static RefPtr<IntConstraint> createIntConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, ConstraintSetType constraintSetType)
+static RefPtr<IntConstraint> createIntConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
 {
-    auto constraint = IntConstraint::create(name);
+    auto constraint = IntConstraint::create(type);
 
     // Dictionary constraint value.
     Dictionary dictionaryValue;
@@ -255,8 +255,7 @@
 
 static void parseMediaTrackConstraintSetForKey(const Dictionary& mediaTrackConstraintSet, const String& name, MediaTrackConstraintSetMap& map, ConstraintSetType constraintSetType, RealtimeMediaSource::Type sourceType)
 {
-    auto& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints();
-    MediaConstraintType constraintType = supportedConstraints.constraintFromName(name);
+    MediaConstraintType constraintType = RealtimeMediaSourceSupportedConstraints::constraintFromName(name);
 
     RefPtr<MediaConstraint> mediaConstraint;
     if (sourceType == RealtimeMediaSource::Audio) {
@@ -263,17 +262,17 @@
         switch (constraintType) {
         case MediaConstraintType::SampleRate:
         case MediaConstraintType::SampleSize:
-            mediaConstraint = createIntConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         case MediaConstraintType::Volume:
-            mediaConstraint = createDoubleConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createDoubleConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         case MediaConstraintType::EchoCancellation:
-            mediaConstraint = createBooleanConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createBooleanConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         case MediaConstraintType::DeviceId:
         case MediaConstraintType::GroupId:
-            mediaConstraint = createStringConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createStringConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         default:
             LOG(Media, "parseMediaTrackConstraintSetForKey() - ignoring unsupported constraint '%s' for audio.", name.utf8().data());
@@ -284,16 +283,16 @@
         switch (constraintType) {
         case MediaConstraintType::Width:
         case MediaConstraintType::Height:
-            mediaConstraint = createIntConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createIntConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         case MediaConstraintType::AspectRatio:
         case MediaConstraintType::FrameRate:
-            mediaConstraint = createDoubleConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createDoubleConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         case MediaConstraintType::FacingMode:
         case MediaConstraintType::DeviceId:
         case MediaConstraintType::GroupId:
-            mediaConstraint = createStringConstraint(mediaTrackConstraintSet, name, constraintSetType);
+            mediaConstraint = createStringConstraint(mediaTrackConstraintSet, name, constraintType, constraintSetType);
             break;
         default:
             LOG(Media, "parseMediaTrackConstraintSetForKey() - ignoring unsupported constraint '%s' for video.", name.utf8().data());

Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.cpp	2016-08-18 16:06:19 UTC (rev 204595)
@@ -39,8 +39,7 @@
 
 RefPtr<MediaConstraint> MediaConstraint::create(const String& name)
 {
-    auto& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints();
-    MediaConstraintType constraintType = supportedConstraints.constraintFromName(name);
+    MediaConstraintType constraintType = RealtimeMediaSourceSupportedConstraints::constraintFromName(name);
 
     switch (constraintType) {
     case MediaConstraintType::Width:
@@ -47,17 +46,17 @@
     case MediaConstraintType::Height:
     case MediaConstraintType::SampleRate:
     case MediaConstraintType::SampleSize:
-        return IntConstraint::create(name);
+        return IntConstraint::create(constraintType);
     case MediaConstraintType::AspectRatio:
     case MediaConstraintType::FrameRate:
     case MediaConstraintType::Volume:
-        return DoubleConstraint::create(name);
+        return DoubleConstraint::create(constraintType);
     case MediaConstraintType::EchoCancellation:
-        return BooleanConstraint::create(name);
+        return BooleanConstraint::create(constraintType);
     case MediaConstraintType::FacingMode:
     case MediaConstraintType::DeviceId:
     case MediaConstraintType::GroupId:
-        return StringConstraint::create(name);
+        return StringConstraint::create(constraintType);
     case MediaConstraintType::Unknown:
         return nullptr;
     }
@@ -159,9 +158,9 @@
     return false;
 }
 
-Ref<IntConstraint> IntConstraint::create(const String& name)
+Ref<IntConstraint> IntConstraint::create(MediaConstraintType type)
 {
-    return adoptRef(*new IntConstraint(name));
+    return adoptRef(*new IntConstraint(type));
 }
 
 void IntConstraint::setMin(int value)
@@ -224,9 +223,9 @@
     return true;
 }
 
-Ref<DoubleConstraint> DoubleConstraint::create(const String& name)
+Ref<DoubleConstraint> DoubleConstraint::create(MediaConstraintType type)
 {
-    return adoptRef(*new DoubleConstraint(name));
+    return adoptRef(*new DoubleConstraint(type));
 }
 
 void DoubleConstraint::setMin(double value)
@@ -289,9 +288,9 @@
     return true;
 }
 
-Ref<BooleanConstraint> BooleanConstraint::create(const String& name)
+Ref<BooleanConstraint> BooleanConstraint::create(MediaConstraintType type)
 {
-    return adoptRef(*new BooleanConstraint(name));
+    return adoptRef(*new BooleanConstraint(type));
 }
 
 void BooleanConstraint::setExact(bool value)
@@ -324,9 +323,9 @@
     return true;
 }
 
-Ref<StringConstraint> StringConstraint::create(const String& name)
+Ref<StringConstraint> StringConstraint::create(MediaConstraintType type)
 {
-    return adoptRef(*new StringConstraint(name));
+    return adoptRef(*new StringConstraint(type));
 }
 
 void StringConstraint::setExact(const String& value)

Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.h (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2016-08-18 16:06:19 UTC (rev 204595)
@@ -34,6 +34,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "RealtimeMediaSourceSupportedConstraints.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
 #include <wtf/text/WTFString.h>
@@ -68,16 +69,17 @@
     virtual bool getExact(Vector<String>&) const;
     virtual bool getIdeal(Vector<String>&) const;
 
-    String name() const { return m_name; }
+    MediaConstraintType type() const { return m_type; }
 
+
 protected:
-    explicit MediaConstraint(const String& name)
-        : m_name(name)
+    explicit MediaConstraint(MediaConstraintType type)
+        : m_type(type)
     {
     }
 
 private:
-    String m_name;
+    MediaConstraintType m_type;
 };
 
 class NumericConstraint : public MediaConstraint {
@@ -86,8 +88,8 @@
     bool isMandatory() const override { return m_hasMin || m_hasMax || m_hasExact; }
 
 protected:
-    explicit NumericConstraint(const String& name)
-        : MediaConstraint(name)
+    explicit NumericConstraint(MediaConstraintType type)
+        : MediaConstraint(type)
     {
     }
 
@@ -110,7 +112,7 @@
 
 class IntConstraint final : public NumericConstraint {
 public:
-    static Ref<IntConstraint> create(const String& name);
+    static Ref<IntConstraint> create(MediaConstraintType);
 
     void setMin(int value);
     void setMax(int value);
@@ -123,8 +125,8 @@
     bool getIdeal(int&) const final;
 
 private:
-    explicit IntConstraint(const String& name)
-        : WebCore::NumericConstraint(name)
+    explicit IntConstraint(MediaConstraintType type)
+        : WebCore::NumericConstraint(type)
     {
     }
 
@@ -136,7 +138,7 @@
 
 class DoubleConstraint final : public NumericConstraint {
 public:
-    static Ref<DoubleConstraint> create(const String& name);
+    static Ref<DoubleConstraint> create(MediaConstraintType);
 
     void setMin(double value);
     void setMax(double value);
@@ -149,8 +151,8 @@
     bool getIdeal(double&) const final;
 
 private:
-    explicit DoubleConstraint(const String& name)
-        : WebCore::NumericConstraint(name)
+    explicit DoubleConstraint(MediaConstraintType type)
+        : WebCore::NumericConstraint(type)
     {
     }
 
@@ -162,7 +164,7 @@
 
 class BooleanConstraint final : public MediaConstraint {
 public:
-    static Ref<BooleanConstraint> create(const String& name);
+    static Ref<BooleanConstraint> create(MediaConstraintType);
 
     void setExact(bool value);
     void setIdeal(bool value);
@@ -174,8 +176,8 @@
     bool isMandatory() const final { return m_hasExact; }
 
 private:
-    explicit BooleanConstraint(const String& name)
-        : MediaConstraint(name)
+    explicit BooleanConstraint(MediaConstraintType type)
+        : MediaConstraint(type)
     {
     }
 
@@ -187,7 +189,7 @@
 
 class StringConstraint final : public MediaConstraint {
 public:
-    static Ref<StringConstraint> create(const String& name);
+    static Ref<StringConstraint> create(MediaConstraintType);
 
     void setExact(const String&);
     void appendExact(const String&);
@@ -201,8 +203,8 @@
     bool isMandatory() const final { return !m_exact.isEmpty(); }
 
 private:
-    explicit StringConstraint(const String& name)
-        : MediaConstraint(name)
+    explicit StringConstraint(MediaConstraintType type)
+        : MediaConstraint(type)
     {
     }
 

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.cpp	2016-08-18 16:06:19 UTC (rev 204595)
@@ -35,7 +35,7 @@
 
 namespace WebCore {
 
-const AtomicString& RealtimeMediaSourceSupportedConstraints::nameForConstraint(MediaConstraintType constraint) const
+const AtomicString& RealtimeMediaSourceSupportedConstraints::nameForConstraint(MediaConstraintType constraint)
 {
     static NeverDestroyed<AtomicString> unknownConstraintName(emptyString());
     static NeverDestroyed<AtomicString> widthConstraintName("width");
@@ -77,7 +77,7 @@
     }
 }
 
-MediaConstraintType RealtimeMediaSourceSupportedConstraints::constraintFromName(const String& constraintName) const
+MediaConstraintType RealtimeMediaSourceSupportedConstraints::constraintFromName(const String& constraintName)
 {
     static NeverDestroyed<HashMap<AtomicString, MediaConstraintType>> nameToConstraintMap;
     HashMap<AtomicString, MediaConstraintType>& nameToConstraintMapValue = nameToConstraintMap.get();

Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.h (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.h	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceSupportedConstraints.h	2016-08-18 16:06:19 UTC (rev 204595)
@@ -91,10 +91,11 @@
     bool supportsGroupId() const { return m_supportsGroupId; }
     void setSupportsGroupId(bool value) { m_supportsGroupId = value; }
 
-    const AtomicString& nameForConstraint(MediaConstraintType) const;
-    MediaConstraintType constraintFromName(const String& constraintName) const;
     bool supportsConstraint(MediaConstraintType) const;
 
+    static const AtomicString& nameForConstraint(MediaConstraintType);
+    static MediaConstraintType constraintFromName(const String&);
+
 private:
     bool m_supportsWidth { false };
     bool m_supportsHeight { false };

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm	2016-08-18 16:06:19 UTC (rev 204595)
@@ -267,7 +267,7 @@
 bool AVCaptureDeviceManager::sessionSupportsConstraint(const CaptureSessionInfo* session, RealtimeMediaSource::Type type, const MediaConstraint& constraint)
 {
     const RealtimeMediaSourceSupportedConstraints& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints();
-    MediaConstraintType constraintType = supportedConstraints.constraintFromName(constraint.name());
+    MediaConstraintType constraintType = constraint.type();
     if (!supportedConstraints.supportsConstraint(constraintType))
         return false;
 

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (204594 => 204595)


--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2016-08-18 16:06:19 UTC (rev 204595)
@@ -175,21 +175,17 @@
 
     // FIXME: Below needs to be refactored for https://bugs.webkit.org/show_bug.cgi?id=160579.
 
-    auto& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints();
-    String widthConstraintName = supportedConstraints.nameForConstraint(MediaConstraintType::Width);
-    String heightConstraintName = supportedConstraints.nameForConstraint(MediaConstraintType::Height);
-
     auto& mandatoryConstraints = constraints->mandatoryConstraints();
-
-    RefPtr<MediaConstraint> widthConstraint = mandatoryConstraints.get(widthConstraintName);
-    RefPtr<MediaConstraint> heightConstraint = mandatoryConstraints.get(heightConstraintName);
-
     int intValue;
 
+    String widthConstraintName = RealtimeMediaSourceSupportedConstraints::nameForConstraint(MediaConstraintType::Width);
+    auto widthConstraint = mandatoryConstraints.get(widthConstraintName);
     Optional<int> width;
     if (widthConstraint && widthConstraint->getExact(intValue))
         width = intValue;
 
+    String heightConstraintName = RealtimeMediaSourceSupportedConstraints::nameForConstraint(MediaConstraintType::Height);
+    auto heightConstraint = mandatoryConstraints.get(heightConstraintName);
     Optional<int> height;
     if (heightConstraint && heightConstraint->getExact(intValue))
         height = intValue;
@@ -196,23 +192,26 @@
     
     if (width && height) {
         NSString *preset = AVCaptureSessionInfo(session()).bestSessionPresetForVideoDimensions(width.value(), height.value());
-        if (!preset || ![session() canSetSessionPreset:preset])
+        if (!preset || ![session() canSetSessionPreset:preset]) {
+            LOG(Media, "AVVideoCaptureSource::applyConstraints(%p), unable find or set preset for width: %i, height: %i", this, width.value(), height.value());
             return false;
+        }
 
         [session() setSessionPreset:preset];
     }
 
-    String frameRateConstraintName = supportedConstraints.nameForConstraint(MediaConstraintType::FrameRate);
-    RefPtr<MediaConstraint> frameRateConstraint = mandatoryConstraints.get(frameRateConstraintName);
+    String frameRateConstraintName = RealtimeMediaSourceSupportedConstraints::nameForConstraint(MediaConstraintType::FrameRate);
+    auto frameRateConstraint = mandatoryConstraints.get(frameRateConstraintName);
 
+    Optional<double> frameRate;
     double doubleValue;
-
-    Optional<double> frameRate;
     if (frameRateConstraint && frameRateConstraint->getExact(doubleValue))
         frameRate = doubleValue;
 
-    if (frameRate && !setFrameRateConstraint(frameRate.value(), 0))
+    if (frameRate && !setFrameRateConstraint(frameRate.value(), 0)) {
+        LOG(Media, "AVVideoCaptureSource::applyConstraints(%p), unable set frame rate to %f", this, frameRate.value());
         return false;
+    }
 
     return true;
 }

Modified: trunk/Source/WebCore/platform/mock/MediaConstraintsMock.cpp (204594 => 204595)


--- trunk/Source/WebCore/platform/mock/MediaConstraintsMock.cpp	2016-08-18 13:58:37 UTC (rev 204594)
+++ trunk/Source/WebCore/platform/mock/MediaConstraintsMock.cpp	2016-08-18 16:06:19 UTC (rev 204595)
@@ -101,23 +101,23 @@
 
 static bool isSatisfiable(RealtimeMediaSource::Type type, const MediaConstraint& constraint)
 {
-    const String& name = constraint.name();
+    MediaConstraintType constraintType = constraint.type();
 
     if (type == RealtimeMediaSource::Audio) {
-        if (name == "sampleRate" || name == "sampleSize")
+        if (constraintType == MediaConstraintType::SampleRate || constraintType == MediaConstraintType::SampleSize)
             return isIntMediaConstraintSatisfiable(constraint);
-        if (name == "volume")
+        if (constraintType == MediaConstraintType::Volume)
             return isDoubleMediaConstraintSatisfiable(constraint);
-        if (name == "echoCancellation")
+        if (constraintType == MediaConstraintType::EchoCancellation)
             return isBooleanMediaConstraintSatisfiable(constraint);
-        if (name == "deviceId" || name == "groupId")
+        if (constraintType == MediaConstraintType::DeviceId || constraintType == MediaConstraintType::GroupId)
             return isStringMediaConstraintSatisfiable(constraint);
     } else if (type == RealtimeMediaSource::Video) {
-        if (name == "width" || name == "height")
+        if (constraintType == MediaConstraintType::Width || constraintType == MediaConstraintType::Height)
             return isIntMediaConstraintSatisfiable(constraint);
-        if (name == "aspectRatio" || name == "frameRate")
+        if (constraintType == MediaConstraintType::AspectRatio || constraintType == MediaConstraintType::FrameRate)
             return isDoubleMediaConstraintSatisfiable(constraint);
-        if (name == "facingMode" || name == "deviceId" || name == "groupId")
+        if (constraintType == MediaConstraintType::FacingMode || constraintType == MediaConstraintType::DeviceId || constraintType == MediaConstraintType::GroupId)
             return isStringMediaConstraintSatisfiable(constraint);
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to