Remove MediaConstraintsData and MediaConstraintsImpl
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2017 08:51:50 +0000 (08:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 May 2017 08:51:50 +0000 (08:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172132

Patch by Youenn Fablet <youenn@apple.com> on 2017-05-16
Reviewed by Eric Carlson.

Source/WebCore:

No observable change of behavior.

Removing MediaConstraintsData and MediaConstraintsImpl allows simplifying the code.
Further simplified the code by making MediaConstraints no longer ref counted and now a struct.
Simplified some RealtimeMediaSource subclasses by removing unused MediaConstraints class members.

* CMakeLists.txt: Removing MediaConstraintsImpl.cpp.
* Modules/mediastream/MediaConstraintsImpl.cpp: Removed.
* Modules/mediastream/MediaConstraintsImpl.h: Removed.
* Modules/mediastream/MediaDevices.cpp:
(WebCore::createMediaConstraints):
(WebCore::MediaDevices::getUserMedia):
(WebCore::createMediaConstraintsImpl): Deleted.
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::createMediaConstraints):
(WebCore::MediaStreamTrack::applyConstraints):
(WebCore::createMediaConstraintsImpl): Deleted.
* Modules/mediastream/MediaTrackConstraints.cpp:
(WebCore::createMediaConstraints):
(WebCore::createMediaConstraintsImpl): Deleted.
* Modules/mediastream/MediaTrackConstraints.h:
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::start):
(WebCore::UserMediaRequest::UserMediaRequest):
(WebCore::UserMediaRequest::allow):
* Modules/mediastream/UserMediaRequest.h:
(WebCore::UserMediaRequest::audioConstraints):
(WebCore::UserMediaRequest::videoConstraints):
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/MediaConstraints.cpp:
(WebCore::addDefaultVideoConstraints):
(WebCore::MediaConstraints::isConstraintSet):
(WebCore::MediaConstraints::setDefaultVideoConstraints):
* platform/mediastream/MediaConstraints.h:
(WebCore::MediaConstraints::~MediaConstraints): Deleted.
(WebCore::MediaConstraints::MediaConstraints): Deleted.
* platform/mediastream/MediaStreamConstraintsValidationClient.h:
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::selectSettings):
(WebCore::RealtimeMediaSource::supportsConstraints):
(WebCore::RealtimeMediaSource::applyConstraints):
* platform/mediastream/RealtimeMediaSourceCenter.cpp:
(WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):
* platform/mediastream/RealtimeMediaSourceCenter.h:
* platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
(WebCore::RealtimeIncomingAudioSource::supportedConstraints): Deleted.
* platform/mediastream/mac/RealtimeIncomingAudioSource.h:
* platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
(WebCore::RealtimeIncomingVideoSource::supportedConstraints): Deleted.
* platform/mediastream/mac/RealtimeIncomingVideoSource.h:
* platform/mock/MockRealtimeMediaSource.h:
(WebCore::MockRealtimeMediaSource::constraints): Deleted.

Source/WebKit2:

Removing MediaConstraintsData and MediaConstraintsImpl allows simplifying the code.
Further simplified the code by making MediaConstraints no longer ref counted and now a struct.

* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<MediaConstraints>::encode):
(IPC::ArgumentCoder<MediaConstraints>::decode):
(IPC::ArgumentCoder<MediaConstraintsData>::encode): Deleted.
(IPC::ArgumentCoder<MediaConstraintsData>::decode): Deleted.
* Shared/WebCoreArgumentCoders.h:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
(WebKit::UserMediaCaptureManagerProxy::applyConstraints):
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
* UIProcess/UserMediaPermissionRequestManagerProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestUserMediaPermissionForFrame):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
* WebProcess/cocoa/UserMediaCaptureManager.cpp:
(WebKit::UserMediaCaptureManager::applyConstraints):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216918 268f45cc-cd09-0410-ab3c-d52691b4dbfc

36 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaConstraintsImpl.cpp [deleted file]
Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h [deleted file]
Source/WebCore/Modules/mediastream/MediaDevices.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaTrackConstraints.cpp
Source/WebCore/Modules/mediastream/MediaTrackConstraints.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mediastream/MediaConstraints.cpp
Source/WebCore/platform/mediastream/MediaConstraints.h
Source/WebCore/platform/mediastream/MediaStreamConstraintsValidationClient.h
Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp
Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h
Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.cpp
Source/WebCore/platform/mediastream/mac/RealtimeIncomingAudioSource.h
Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.cpp
Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSource.h
Source/WebCore/platform/mock/MockRealtimeMediaSource.h
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit/messages.py
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h
Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
Source/WebKit2/WebProcess/cocoa/UserMediaCaptureManager.cpp

index 1a86472..822703b 100644 (file)
@@ -944,7 +944,6 @@ set(WebCore_SOURCES
     Modules/mediasource/VideoPlaybackQuality.cpp
 
     Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
-    Modules/mediastream/MediaConstraintsImpl.cpp
     Modules/mediastream/MediaDeviceInfo.cpp
     Modules/mediastream/MediaDevices.cpp
     Modules/mediastream/MediaDevicesEnumerationRequest.cpp
index 38cd34a..0fdd733 100644 (file)
@@ -1,3 +1,63 @@
+2017-05-16  Youenn Fablet  <youenn@apple.com>
+
+        Remove MediaConstraintsData and MediaConstraintsImpl
+        https://bugs.webkit.org/show_bug.cgi?id=172132
+
+        Reviewed by Eric Carlson.
+
+        No observable change of behavior.
+
+        Removing MediaConstraintsData and MediaConstraintsImpl allows simplifying the code.
+        Further simplified the code by making MediaConstraints no longer ref counted and now a struct.
+        Simplified some RealtimeMediaSource subclasses by removing unused MediaConstraints class members.
+
+        * CMakeLists.txt: Removing MediaConstraintsImpl.cpp.
+        * Modules/mediastream/MediaConstraintsImpl.cpp: Removed.
+        * Modules/mediastream/MediaConstraintsImpl.h: Removed.
+        * Modules/mediastream/MediaDevices.cpp:
+        (WebCore::createMediaConstraints):
+        (WebCore::MediaDevices::getUserMedia):
+        (WebCore::createMediaConstraintsImpl): Deleted.
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::createMediaConstraints):
+        (WebCore::MediaStreamTrack::applyConstraints):
+        (WebCore::createMediaConstraintsImpl): Deleted.
+        * Modules/mediastream/MediaTrackConstraints.cpp:
+        (WebCore::createMediaConstraints):
+        (WebCore::createMediaConstraintsImpl): Deleted.
+        * Modules/mediastream/MediaTrackConstraints.h:
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::start):
+        (WebCore::UserMediaRequest::UserMediaRequest):
+        (WebCore::UserMediaRequest::allow):
+        * Modules/mediastream/UserMediaRequest.h:
+        (WebCore::UserMediaRequest::audioConstraints):
+        (WebCore::UserMediaRequest::videoConstraints):
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/MediaConstraints.cpp:
+        (WebCore::addDefaultVideoConstraints):
+        (WebCore::MediaConstraints::isConstraintSet):
+        (WebCore::MediaConstraints::setDefaultVideoConstraints):
+        * platform/mediastream/MediaConstraints.h:
+        (WebCore::MediaConstraints::~MediaConstraints): Deleted.
+        (WebCore::MediaConstraints::MediaConstraints): Deleted.
+        * platform/mediastream/MediaStreamConstraintsValidationClient.h:
+        * platform/mediastream/RealtimeMediaSource.cpp:
+        (WebCore::RealtimeMediaSource::selectSettings):
+        (WebCore::RealtimeMediaSource::supportsConstraints):
+        (WebCore::RealtimeMediaSource::applyConstraints):
+        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
+        (WebCore::RealtimeMediaSourceCenter::validateRequestConstraints):
+        * platform/mediastream/RealtimeMediaSourceCenter.h:
+        * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp:
+        (WebCore::RealtimeIncomingAudioSource::supportedConstraints): Deleted.
+        * platform/mediastream/mac/RealtimeIncomingAudioSource.h:
+        * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp:
+        (WebCore::RealtimeIncomingVideoSource::supportedConstraints): Deleted.
+        * platform/mediastream/mac/RealtimeIncomingVideoSource.h:
+        * platform/mock/MockRealtimeMediaSource.h:
+        (WebCore::MockRealtimeMediaSource::constraints): Deleted.
+
 2017-05-16  Andy Estes  <aestes@apple.com>
 
         [Cocoa] Tell NEFilterSource about the presenting app's PID
diff --git a/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.cpp b/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.cpp
deleted file mode 100644 (file)
index dfedbb7..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2016 Apple 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.
- */
-
-#include "config.h"
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "MediaConstraintsImpl.h"
-
-namespace WebCore {
-
-static inline void addDefaultVideoConstraints(MediaTrackConstraintSetMap& videoConstraints, bool addFrameRateConstraint, bool addSizeConstraint, bool addFacingModeConstraint)
-{
-    if (addFrameRateConstraint) {
-        DoubleConstraint frameRateConstraint({ }, MediaConstraintType::FrameRate);
-        frameRateConstraint.setIdeal(30);
-        videoConstraints.set(MediaConstraintType::FrameRate, WTFMove(frameRateConstraint));
-    }
-    if (addSizeConstraint) {
-        IntConstraint widthConstraint({ }, MediaConstraintType::Width);
-        widthConstraint.setIdeal(640);
-        videoConstraints.set(MediaConstraintType::Width, WTFMove(widthConstraint));
-
-        IntConstraint heightConstraint({ }, MediaConstraintType::Height);
-        heightConstraint.setIdeal(480);
-        videoConstraints.set(MediaConstraintType::Height, WTFMove(heightConstraint));
-    }
-    if (addFacingModeConstraint) {
-        StringConstraint facingModeConstraint({ }, MediaConstraintType::FacingMode);
-        facingModeConstraint.setIdeal(ASCIILiteral("user"));
-        videoConstraints.set(MediaConstraintType::FacingMode, WTFMove(facingModeConstraint));
-    }
-}
-
-bool MediaConstraintsData::isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&& callback)
-{
-    if (callback(mandatoryConstraints))
-        return true;
-
-    for (const auto& constraint : advancedConstraints) {
-        if (callback(constraint))
-            return true;
-    }
-    return false;
-}
-
-void MediaConstraintsData::setDefaultVideoConstraints()
-{
-    // 640x480, 30fps, font-facing camera
-    bool hasFrameRateConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
-        return !!constraint.frameRate();
-    });
-
-    bool hasSizeConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
-        return !!constraint.width() || !!constraint.height();
-    });
-
-    bool hasFacingModeConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
-        return !!constraint.facingMode();
-    });
-
-    if (hasFrameRateConstraints && hasSizeConstraints && hasFacingModeConstraints)
-        return;
-
-    addDefaultVideoConstraints(mandatoryConstraints, !hasFrameRateConstraints, !hasSizeConstraints, !hasFacingModeConstraints);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
diff --git a/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h b/Source/WebCore/Modules/mediastream/MediaConstraintsImpl.h
deleted file mode 100644 (file)
index 3df1aa4..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#if ENABLE(MEDIA_STREAM)
-
-#include "ExceptionBase.h"
-#include "MediaConstraints.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-struct MediaConstraintsData {
-    MediaConstraintsData() = default;
-    MediaConstraintsData(MediaTrackConstraintSetMap&& mandatoryConstraints, Vector<MediaTrackConstraintSetMap>&& advancedConstraints, bool isValid)
-        : mandatoryConstraints(WTFMove(mandatoryConstraints))
-        , advancedConstraints(WTFMove(advancedConstraints))
-        , isValid(isValid)
-    {
-    }
-    MediaConstraintsData(const MediaConstraintsData& constraints, const String& hashSalt)
-        : mandatoryConstraints(constraints.mandatoryConstraints)
-        , advancedConstraints(constraints.advancedConstraints)
-        , deviceIDHashSalt(hashSalt)
-        , isValid(constraints.isValid)
-    {
-    }
-    MediaConstraintsData(const MediaConstraints& constraints)
-        : mandatoryConstraints(constraints.mandatoryConstraints())
-        , advancedConstraints(constraints.advancedConstraints())
-        , deviceIDHashSalt(constraints.deviceIDHashSalt())
-        , isValid(constraints.isValid())
-    {
-    }
-
-    void setDefaultVideoConstraints();
-    bool isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&&);
-
-    MediaTrackConstraintSetMap mandatoryConstraints;
-    Vector<MediaTrackConstraintSetMap> advancedConstraints;
-    String deviceIDHashSalt;
-    bool isValid { false };
-};
-
-class MediaConstraintsImpl final : public MediaConstraints {
-public:
-    static Ref<MediaConstraintsImpl> create(MediaTrackConstraintSetMap&& mandatoryConstraints, Vector<MediaTrackConstraintSetMap>&& advancedConstraints, bool isValid) { return create(MediaConstraintsData(WTFMove(mandatoryConstraints), WTFMove(advancedConstraints), isValid)); }
-    static Ref<MediaConstraintsImpl> create(MediaConstraintsData&& data) { return adoptRef(*new MediaConstraintsImpl(WTFMove(data))); }
-
-    MediaConstraintsImpl() = default;
-    virtual ~MediaConstraintsImpl() = default;
-
-    const MediaTrackConstraintSetMap& mandatoryConstraints() const final { return m_data.mandatoryConstraints; }
-    const Vector<MediaTrackConstraintSetMap>& advancedConstraints() const final { return m_data.advancedConstraints; }
-    bool isValid() const final { return m_data.isValid; }
-
-    const String& deviceIDHashSalt() const final { return m_data.deviceIDHashSalt; }
-    void setDeviceIDHashSalt(const String& salt) final { m_data.deviceIDHashSalt = salt; }
-
-    const MediaConstraintsData& data() const { return m_data; }
-    void setDefaultVideoConstraints() { m_data.setDefaultVideoConstraints(); }
-
-private:
-    WEBCORE_EXPORT explicit MediaConstraintsImpl(MediaConstraintsData&& data) : m_data(WTFMove(data)) { }
-
-    MediaConstraintsData m_data;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(MEDIA_STREAM)
index cfda721..41e595d 100644 (file)
@@ -37,7 +37,6 @@
 #include "Document.h"
 #include "Event.h"
 #include "EventNames.h"
-#include "MediaConstraintsImpl.h"
 #include "MediaDevicesRequest.h"
 #include "MediaTrackSupportedConstraints.h"
 #include "UserMediaRequest.h"
@@ -78,14 +77,16 @@ Document* MediaDevices::document() const
     return downcast<Document>(scriptExecutionContext());
 }
 
-static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const Variant<bool, MediaTrackConstraints>& constraints)
+static MediaConstraints createMediaConstraints(const Variant<bool, MediaTrackConstraints>& constraints)
 {
     return WTF::switchOn(constraints,
-        [&] (bool constraints) {
-            return MediaConstraintsImpl::create({ }, { }, constraints);
+        [&] (bool isValid) {
+            MediaConstraints constraints;
+            constraints.isValid = isValid;
+            return constraints;
         },
-        [&] (const MediaTrackConstraints& constraints) {
-            return createMediaConstraintsImpl(constraints);
+        [&] (const MediaTrackConstraints& trackConstraints) {
+            return createMediaConstraints(trackConstraints);
         }
     );
 }
@@ -96,10 +97,10 @@ ExceptionOr<void> MediaDevices::getUserMedia(const StreamConstraints& constraint
     if (!document)
         return Exception { INVALID_STATE_ERR };
 
-    auto audioConstraints = createMediaConstraintsImpl(constraints.audio);
-    auto videoConstraints = createMediaConstraintsImpl(constraints.video);
-    if (videoConstraints->isValid())
-        videoConstraints->setDefaultVideoConstraints();
+    auto audioConstraints = createMediaConstraints(constraints.audio);
+    auto videoConstraints = createMediaConstraints(constraints.video);
+    if (videoConstraints.isValid)
+        videoConstraints.setDefaultVideoConstraints();
     return UserMediaRequest::start(*document, WTFMove(audioConstraints), WTFMove(videoConstraints), WTFMove(promise));
 }
 
index 177ef72..0c592a3 100644 (file)
@@ -33,7 +33,7 @@
 #include "Event.h"
 #include "EventNames.h"
 #include "JSOverconstrainedError.h"
-#include "MediaConstraintsImpl.h"
+#include "MediaConstraints.h"
 #include "MediaStream.h"
 #include "MediaStreamPrivate.h"
 #include "NotImplemented.h"
@@ -246,11 +246,14 @@ MediaStreamTrack::TrackCapabilities MediaStreamTrack::getCapabilities() const
     return result;
 }
 
-static Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const std::optional<MediaTrackConstraints>& constraints)
+static MediaConstraints createMediaConstraints(const std::optional<MediaTrackConstraints>& constraints)
 {
-    if (!constraints)
-        return MediaConstraintsImpl::create({ }, { }, true);
-    return createMediaConstraintsImpl(constraints.value());
+    if (!constraints) {
+        MediaConstraints validConstraints;
+        validConstraints.isValid = true;
+        return validConstraints;
+    }
+    return createMediaConstraints(constraints.value());
 }
 
 void MediaStreamTrack::applyConstraints(const std::optional<MediaTrackConstraints>& constraints, DOMPromiseDeferred<void>&& promise)
@@ -269,7 +272,7 @@ void MediaStreamTrack::applyConstraints(const std::optional<MediaTrackConstraint
         weakThis->m_promise->resolve();
         weakThis->m_constraints = constraints.value_or(MediaTrackConstraints { });
     };
-    m_private->applyConstraints(createMediaConstraintsImpl(constraints), WTFMove(successHandler), WTFMove(failureHandler));
+    m_private->applyConstraints(createMediaConstraints(constraints), WTFMove(successHandler), WTFMove(failureHandler));
 }
 
 void MediaStreamTrack::addObserver(Observer& observer)
index c4c4cf1..c4a3fca 100644 (file)
@@ -27,7 +27,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
-#include "MediaConstraintsImpl.h"
+#include "MediaConstraints.h"
 
 namespace WebCore {
 
@@ -190,9 +190,13 @@ static Vector<MediaTrackConstraintSetMap> convertAdvancedToInternalForm(const st
     return convertAdvancedToInternalForm(optionalVector.value());
 }
 
-Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const MediaTrackConstraints& constraints)
+MediaConstraints createMediaConstraints(const MediaTrackConstraints& trackConstraints)
 {
-    return MediaConstraintsImpl::create(convertToInternalForm(ConstraintSetType::Mandatory, constraints), convertAdvancedToInternalForm(constraints.advanced), true);
+    MediaConstraints constraints;
+    constraints.mandatoryConstraints = convertToInternalForm(ConstraintSetType::Mandatory, trackConstraints);
+    constraints.advancedConstraints = convertAdvancedToInternalForm(trackConstraints.advanced);
+    constraints.isValid = true;
+    return constraints;
 }
 
 }
index 3bccdae..0395476 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-class MediaConstraintsImpl;
+struct MediaConstraints;
 
 struct ConstrainBooleanParameters {
     std::optional<bool> exact;
@@ -79,7 +79,7 @@ struct MediaTrackConstraints : MediaTrackConstraintSet {
     std::optional<Vector<MediaTrackConstraintSet>> advanced;
 };
 
-Ref<MediaConstraintsImpl> createMediaConstraintsImpl(const MediaTrackConstraints&);
+MediaConstraints createMediaConstraints(const MediaTrackConstraints&);
 
 }
 
index a086ef3..e89f8f7 100644 (file)
 #include "JSMediaStream.h"
 #include "JSOverconstrainedError.h"
 #include "MainFrame.h"
-#include "MediaConstraintsImpl.h"
+#include "MediaConstraints.h"
 #include "RealtimeMediaSourceCenter.h"
 #include "Settings.h"
 #include "UserMediaController.h"
 
 namespace WebCore {
 
-ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&& promise)
+ExceptionOr<void> UserMediaRequest::start(Document& document, MediaConstraints&& audioConstraints, MediaConstraints&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&& promise)
 {
     auto* userMedia = UserMediaController::from(document.page());
     if (!userMedia)
         return Exception { NOT_SUPPORTED_ERR }; // FIXME: Why is it better to return an exception here instead of rejecting the promise as we do just below?
 
-    if (!audioConstraints->isValid() && !videoConstraints->isValid()) {
+    if (!audioConstraints.isValid && !videoConstraints.isValid) {
         promise.reject(TypeError);
         return { };
     }
@@ -64,7 +64,7 @@ ExceptionOr<void> UserMediaRequest::start(Document& document, Ref<MediaConstrain
     return { };
 }
 
-UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&& promise)
+UserMediaRequest::UserMediaRequest(Document& document, UserMediaController& controller, MediaConstraints&& audioConstraints, MediaConstraints&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&& promise)
     : ContextDestructionObserver(&document)
     , m_audioConstraints(WTFMove(audioConstraints))
     , m_videoConstraints(WTFMove(videoConstraints))
@@ -180,10 +180,10 @@ void UserMediaRequest::allow(String&& audioDeviceUID, String&& videoDeviceUID, S
         m_promise.resolve(stream);
     };
 
-    m_audioConstraints->setDeviceIDHashSalt(String(deviceIdentifierHashSalt));
-    m_videoConstraints->setDeviceIDHashSalt(WTFMove(deviceIdentifierHashSalt));
+    m_audioConstraints.deviceIDHashSalt = deviceIdentifierHashSalt;
+    m_videoConstraints.deviceIDHashSalt = WTFMove(deviceIdentifierHashSalt);
 
-    RealtimeMediaSourceCenter::singleton().createMediaStream(WTFMove(callback), m_allowedAudioDeviceUID, m_allowedVideoDeviceUID, &m_audioConstraints.get(), &m_videoConstraints.get());
+    RealtimeMediaSourceCenter::singleton().createMediaStream(WTFMove(callback), m_allowedAudioDeviceUID, m_allowedVideoDeviceUID, &m_audioConstraints, &m_videoConstraints);
 }
 
 void UserMediaRequest::deny(MediaAccessDenialReason reason, const String& invalidConstraint)
index 5393bfd..b1ac5b2 100644 (file)
 
 #include "ActiveDOMObject.h"
 #include "JSDOMPromiseDeferred.h"
+#include "MediaConstraints.h"
 
 namespace WebCore {
 
-class MediaConstraintsImpl;
 class MediaStream;
 class SecurityOrigin;
 class UserMediaController;
 
 class UserMediaRequest : public RefCounted<UserMediaRequest>, private ContextDestructionObserver {
 public:
-    static ExceptionOr<void> start(Document&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&&);
+    static ExceptionOr<void> start(Document&, MediaConstraints&& audioConstraints, MediaConstraints&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&&);
 
     virtual ~UserMediaRequest();
 
@@ -61,8 +61,8 @@ public:
     const Vector<String>& audioDeviceUIDs() const { return m_audioDeviceUIDs; }
     const Vector<String>& videoDeviceUIDs() const { return m_videoDeviceUIDs; }
 
-    const MediaConstraintsImpl& audioConstraints() const { return m_audioConstraints; }
-    const MediaConstraintsImpl& videoConstraints() const { return m_videoConstraints; }
+    const MediaConstraints& audioConstraints() const { return m_audioConstraints; }
+    const MediaConstraints& videoConstraints() const { return m_videoConstraints; }
 
     const String& allowedAudioDeviceUID() const { return m_allowedAudioDeviceUID; }
     const String& allowedVideoDeviceUID() const { return m_allowedVideoDeviceUID; }
@@ -72,12 +72,12 @@ public:
     WEBCORE_EXPORT Document* document() const;
 
 private:
-    UserMediaRequest(Document&, UserMediaController&, Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&&);
+    UserMediaRequest(Document&, UserMediaController&, MediaConstraints&& audioConstraints, MediaConstraints&& videoConstraints, DOMPromiseDeferred<IDLInterface<MediaStream>>&&);
 
     void contextDestroyed() final;
     
-    Ref<MediaConstraintsImpl> m_audioConstraints;
-    Ref<MediaConstraintsImpl> m_videoConstraints;
+    MediaConstraints m_audioConstraints;
+    MediaConstraints m_videoConstraints;
 
     Vector<String> m_videoDeviceUIDs;
     Vector<String> m_audioDeviceUIDs;
index cbe315c..6578b3d 100644 (file)
                07846385145B1B8E00A58DF1 /* JSTrackCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 07846384145B1B8E00A58DF1 /* JSTrackCustom.h */; };
                0787C4691BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0787C4671BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.cpp */; };
                0787C46A1BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 0787C4681BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.h */; };
-               078E08FE17D14CEE00420AA1 /* MediaConstraintsImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B4A17CEC32700848E51 /* MediaConstraintsImpl.cpp */; };
                078E08FF17D14CEE00420AA1 /* MediaStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B4C17CEC32700848E51 /* MediaStream.cpp */; };
                078E090017D14CEE00420AA1 /* MediaStreamEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B4F17CEC32700848E51 /* MediaStreamEvent.cpp */; };
                078E090117D14CEE00420AA1 /* MediaStreamRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B5217CEC32700848E51 /* MediaStreamRegistry.cpp */; };
                078E090C17D14CEE00420AA1 /* RTCSessionDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B7A17CEC32700848E51 /* RTCSessionDescription.cpp */; };
                078E091217D14CEE00420AA1 /* UserMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B8E17CEC32700848E51 /* UserMediaController.cpp */; };
                078E091317D14CEE00420AA1 /* UserMediaRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07221B9017CEC32700848E51 /* UserMediaRequest.cpp */; };
-               078E091417D14D1C00420AA1 /* MediaConstraintsImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B4B17CEC32700848E51 /* MediaConstraintsImpl.h */; settings = {ATTRIBUTES = (Private, ); }; };
                078E091517D14D1C00420AA1 /* MediaStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B4D17CEC32700848E51 /* MediaStream.h */; };
                078E091617D14D1C00420AA1 /* MediaStreamEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B5017CEC32700848E51 /* MediaStreamEvent.h */; };
                078E091717D14D1C00420AA1 /* MediaStreamRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 07221B5317CEC32700848E51 /* MediaStreamRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
                071E496F1AD5AB5E008A50B4 /* MediaPlaybackTargetMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetMac.h; sourceTree = "<group>"; };
                0720B09E14D3323500642955 /* GenericEventQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GenericEventQueue.cpp; sourceTree = "<group>"; };
                0720B09F14D3323500642955 /* GenericEventQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericEventQueue.h; sourceTree = "<group>"; };
-               07221B4A17CEC32700848E51 /* MediaConstraintsImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaConstraintsImpl.cpp; sourceTree = "<group>"; };
-               07221B4B17CEC32700848E51 /* MediaConstraintsImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaConstraintsImpl.h; sourceTree = "<group>"; };
                07221B4C17CEC32700848E51 /* MediaStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaStream.cpp; sourceTree = "<group>"; };
                07221B4D17CEC32700848E51 /* MediaStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaStream.h; sourceTree = "<group>"; };
                07221B4E17CEC32700848E51 /* MediaStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaStream.idl; sourceTree = "<group>"; };
                                93A806121E03B51C008A1F26 /* DoubleRange.idl */,
                                93A806131E03B51C008A1F26 /* LongRange.h */,
                                93A806141E03B51C008A1F26 /* LongRange.idl */,
-                               07221B4A17CEC32700848E51 /* MediaConstraintsImpl.cpp */,
-                               07221B4B17CEC32700848E51 /* MediaConstraintsImpl.h */,
                                159AE82A1B3A402F0037478B /* MediaDeviceInfo.cpp */,
                                15145B8F1B3A1B3E00662BF7 /* MediaDeviceInfo.h */,
                                15145B911B3A1D4C00662BF7 /* MediaDeviceInfo.idl */,
                                5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */,
                                931BCC611124DFCB00BE70DD /* MediaCanStartListener.h in Headers */,
                                078E093A17D16E1C00420AA1 /* MediaConstraints.h in Headers */,
-                               078E091417D14D1C00420AA1 /* MediaConstraintsImpl.h in Headers */,
                                417253AB1354BBBC00360F2A /* MediaControlElements.h in Headers */,
                                DEBCCDD416646EAF00A452E1 /* MediaControlElementTypes.h in Headers */,
                                CDF65CC8145B1E7500C4C7AA /* MediaController.h in Headers */,
                                49E911C60EF86D47009D0CAF /* MatrixTransformOperation.cpp in Sources */,
                                5CBC8DAC1AAA302200E1C803 /* MediaAccessibilitySoftLink.cpp in Sources */,
                                1BE5BFC21D515715001666D9 /* MediaConstraints.cpp in Sources */,
-                               078E08FE17D14CEE00420AA1 /* MediaConstraintsImpl.cpp in Sources */,
                                417253AA1354BBBC00360F2A /* MediaControlElements.cpp in Sources */,
                                DEBCCDD516646EB200A452E1 /* MediaControlElementTypes.cpp in Sources */,
                                CD27F6E7145770D30078207D /* MediaController.cpp in Sources */,
index 1e7f7f7..ebe6035 100644 (file)
@@ -340,6 +340,62 @@ bool MediaTrackConstraintSetMap::isEmpty() const
     return !size();
 }
 
+static inline void addDefaultVideoConstraints(MediaTrackConstraintSetMap& videoConstraints, bool addFrameRateConstraint, bool addSizeConstraint, bool addFacingModeConstraint)
+{
+    if (addFrameRateConstraint) {
+        DoubleConstraint frameRateConstraint({ }, MediaConstraintType::FrameRate);
+        frameRateConstraint.setIdeal(30);
+        videoConstraints.set(MediaConstraintType::FrameRate, WTFMove(frameRateConstraint));
+    }
+    if (addSizeConstraint) {
+        IntConstraint widthConstraint({ }, MediaConstraintType::Width);
+        widthConstraint.setIdeal(640);
+        videoConstraints.set(MediaConstraintType::Width, WTFMove(widthConstraint));
+        
+        IntConstraint heightConstraint({ }, MediaConstraintType::Height);
+        heightConstraint.setIdeal(480);
+        videoConstraints.set(MediaConstraintType::Height, WTFMove(heightConstraint));
+    }
+    if (addFacingModeConstraint) {
+        StringConstraint facingModeConstraint({ }, MediaConstraintType::FacingMode);
+        facingModeConstraint.setIdeal(ASCIILiteral("user"));
+        videoConstraints.set(MediaConstraintType::FacingMode, WTFMove(facingModeConstraint));
+    }
+}
+
+bool MediaConstraints::isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&& callback)
+{
+    if (callback(mandatoryConstraints))
+        return true;
+    
+    for (const auto& constraint : advancedConstraints) {
+        if (callback(constraint))
+            return true;
+    }
+    return false;
+}
+
+void MediaConstraints::setDefaultVideoConstraints()
+{
+    // 640x480, 30fps, font-facing camera
+    bool hasFrameRateConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
+        return !!constraint.frameRate();
+    });
+    
+    bool hasSizeConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
+        return !!constraint.width() || !!constraint.height();
+    });
+    
+    bool hasFacingModeConstraints = isConstraintSet([](const MediaTrackConstraintSetMap& constraint) {
+        return !!constraint.facingMode();
+    });
+    
+    if (hasFrameRateConstraints && hasSizeConstraints && hasFacingModeConstraints)
+        return;
+    
+    addDefaultVideoConstraints(mandatoryConstraints, !hasFrameRateConstraints, !hasSizeConstraints, !hasFacingModeConstraints);
+}
+    
 }
 
 #endif // ENABLE(MEDIA_STREAM)
index 6636ac0..3c4864d 100644 (file)
 
 #include "RealtimeMediaSourceSupportedConstraints.h"
 #include <cstdlib>
+#include <wtf/Vector.h>
 
 namespace WebCore {
-
+    
 class MediaConstraint {
 public:
     enum class DataType { None, Integer, Double, Boolean, String };
@@ -803,21 +804,16 @@ private:
 #endif
 };
 
-class MediaConstraints : public RefCounted<MediaConstraints> {
-public:
-    virtual ~MediaConstraints() { }
-
-    virtual const MediaTrackConstraintSetMap& mandatoryConstraints() const = 0;
-    virtual const Vector<MediaTrackConstraintSetMap>& advancedConstraints() const = 0;
-    virtual bool isValid() const = 0;
+struct MediaConstraints {
+    void setDefaultVideoConstraints();
+    bool isConstraintSet(std::function<bool(const MediaTrackConstraintSetMap&)>&&);
 
-    virtual const String& deviceIDHashSalt() const = 0;
-    virtual void setDeviceIDHashSalt(const String&) = 0;
-
-protected:
-    MediaConstraints() { }
+    MediaTrackConstraintSetMap mandatoryConstraints;
+    Vector<MediaTrackConstraintSetMap> advancedConstraints;
+    String deviceIDHashSalt;
+    bool isValid { false };
 };
-
+    
 } // namespace WebCore
 
 #define SPECIALIZE_TYPE_TRAITS_MEDIACONSTRAINT(ConstraintType, predicate) \
index 973c9ee..49944a8 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef MediaStreamConstraintsValidationClient_h
-#define MediaStreamConstraintsValidationClient_h
+#pragma once
 
 #if ENABLE(MEDIA_STREAM)
 
@@ -33,8 +32,6 @@
 
 namespace WebCore {
 
-class MediaConstraints;
-
 class MediaStreamConstraintsValidationClient : public RefCounted<MediaStreamConstraintsValidationClient> {
 public:
     virtual ~MediaStreamConstraintsValidationClient() { }
@@ -46,5 +43,3 @@ public:
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
-
-#endif // MediaStreamConstraintsValidationClient_h
index f3c1201..4379a91 100644 (file)
@@ -526,12 +526,12 @@ bool RealtimeMediaSource::selectSettings(const MediaConstraints& constraints, Fl
 
     failedConstraint = emptyString();
 
-    // Check width, height, and frame rate separately, because while they may be supported individually the combination may not be supported.
+    // Check width, height and frame rate jointly, because while they may be supported individually the combination may not be supported.
     double distance = std::numeric_limits<double>::infinity();
-    if (!supportsSizeAndFrameRate(constraints.mandatoryConstraints().width(), constraints.mandatoryConstraints().height(), constraints.mandatoryConstraints().frameRate(), failedConstraint, m_fitnessScore))
+    if (!supportsSizeAndFrameRate(constraints.mandatoryConstraints.width(), constraints.mandatoryConstraints.height(), constraints.mandatoryConstraints.frameRate(), failedConstraint, m_fitnessScore))
         return false;
 
-    constraints.mandatoryConstraints().filter([&](const MediaConstraint& constraint) {
+    constraints.mandatoryConstraints.filter([&](const MediaConstraint& constraint) {
         if (!supportsConstraint(constraint))
             return false;
 
@@ -548,9 +548,9 @@ bool RealtimeMediaSource::selectSettings(const MediaConstraints& constraints, Fl
                 return false;
 
             ASSERT(constraint.isString());
-            ASSERT(!constraints.deviceIDHashSalt().isEmpty());
+            ASSERT(!constraints.deviceIDHashSalt.isEmpty());
 
-            auto hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, constraints.deviceIDHashSalt());
+            auto hashedID = RealtimeMediaSourceCenter::singleton().hashStringWithSalt(m_persistentID, constraints.deviceIDHashSalt);
             double constraintDistance = downcast<StringConstraint>(constraint).fitnessDistance(hashedID);
             if (std::isinf(constraintDistance)) {
                 failedConstraint = constraint.name();
@@ -587,7 +587,7 @@ bool RealtimeMediaSource::selectSettings(const MediaConstraints& constraints, Fl
     //     values of properties as exact.
     Vector<std::pair<double, MediaTrackConstraintSetMap>> supportedConstraints;
 
-    for (const auto& advancedConstraint : constraints.advancedConstraints()) {
+    for (const auto& advancedConstraint : constraints.advancedConstraints) {
         double constraintDistance = 0;
         bool supported = false;
 
@@ -697,7 +697,7 @@ bool RealtimeMediaSource::supportsConstraint(const MediaConstraint& constraint)
 
 bool RealtimeMediaSource::supportsConstraints(const MediaConstraints& constraints, String& invalidConstraint)
 {
-    ASSERT(constraints.isValid());
+    ASSERT(constraints.isValid);
 
     FlattenedConstraint candidates;
     if (!selectSettings(constraints, candidates, invalidConstraint, SelectType::ForSupportsConstraints))
@@ -759,7 +759,7 @@ void RealtimeMediaSource::applyConstraints(const FlattenedConstraint& constraint
 
 std::optional<std::pair<String, String>> RealtimeMediaSource::applyConstraints(const MediaConstraints& constraints)
 {
-    ASSERT(constraints.isValid());
+    ASSERT(constraints.isValid);
 
     FlattenedConstraint candidates;
     String failedConstraint;
index 78d2f81..27ece7a 100644 (file)
@@ -230,11 +230,11 @@ void RealtimeMediaSourceCenter::validateRequestConstraints(ValidConstraintsHandl
 
         String invalidConstraint;
         CaptureSourceOrError sourceOrError;
-        if (device.type() == CaptureDevice::DeviceType::Video && videoConstraints.isValid()) {
+        if (device.type() == CaptureDevice::DeviceType::Video && videoConstraints.isValid) {
             auto sourceOrError = videoFactory().createVideoCaptureSource(device.persistentId(), nullptr);
             if (sourceOrError && sourceOrError.captureSource->supportsConstraints(videoConstraints, invalidConstraint))
                 videoDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device.persistentId()});
-        } else if (device.type() == CaptureDevice::DeviceType::Audio && audioConstraints.isValid()) {
+        } else if (device.type() == CaptureDevice::DeviceType::Audio && audioConstraints.isValid) {
             auto sourceOrError = audioFactory().createAudioCaptureSource(device.persistentId(), nullptr);
             if (sourceOrError && sourceOrError.captureSource->supportsConstraints(audioConstraints, invalidConstraint))
                 audioDeviceInfo.append({sourceOrError.captureSource->fitnessScore(), device.persistentId()});
@@ -244,7 +244,7 @@ void RealtimeMediaSourceCenter::validateRequestConstraints(ValidConstraintsHandl
             firstInvalidConstraint = invalidConstraint;
     }
 
-    if ((audioConstraints.isValid() && audioDeviceInfo.isEmpty()) || (videoConstraints.isValid() && videoDeviceInfo.isEmpty())) {
+    if ((audioConstraints.isValid && audioDeviceInfo.isEmpty()) || (videoConstraints.isValid && videoDeviceInfo.isEmpty())) {
         invalidHandler(firstInvalidConstraint);
         return;
     }
index 57d7132..fe29f9e 100644 (file)
@@ -44,11 +44,12 @@ namespace WebCore {
 
 class CaptureDevice;
 class CaptureDeviceManager;
-class MediaConstraints;
 class RealtimeMediaSourceSettings;
 class RealtimeMediaSourceSupportedConstraints;
 class TrackSourceInfo;
 
+struct MediaConstraints;
+    
 class RealtimeMediaSourceCenter {
 public:
     virtual ~RealtimeMediaSourceCenter();
index ac82c66..74ba174 100644 (file)
@@ -144,11 +144,6 @@ const RealtimeMediaSourceSettings& RealtimeIncomingAudioSource::settings() const
     return m_currentSettings;
 }
 
-RealtimeMediaSourceSupportedConstraints& RealtimeIncomingAudioSource::supportedConstraints()
-{
-    return m_supportedConstraints;
-}
-
 AudioSourceProvider* RealtimeIncomingAudioSource::audioSourceProvider()
 {
     if (!m_audioSourceProvider) {
index 625e3d9..bf66bd9 100644 (file)
@@ -64,14 +64,9 @@ private:
     const RealtimeMediaSourceCapabilities& capabilities() const final;
     const RealtimeMediaSourceSettings& settings() const final;
 
-    MediaConstraints& constraints() { return *m_constraints.get(); }
-    RealtimeMediaSourceSupportedConstraints& supportedConstraints();
-
     AudioSourceProvider* audioSourceProvider() final;
 
     RealtimeMediaSourceSettings m_currentSettings;
-    RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
-    RefPtr<MediaConstraints> m_constraints;
     rtc::scoped_refptr<webrtc::AudioTrackInterface> m_audioTrack;
 
     RefPtr<WebAudioSourceProviderAVFObjC> m_audioSourceProvider;
index 14f8e18..3d8a6c0 100644 (file)
@@ -209,11 +209,6 @@ const RealtimeMediaSourceSettings& RealtimeIncomingVideoSource::settings() const
     return m_currentSettings;
 }
 
-RealtimeMediaSourceSupportedConstraints& RealtimeIncomingVideoSource::supportedConstraints()
-{
-    return m_supportedConstraints;
-}
-
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)
index d4a3f43..ce2a7b2 100644 (file)
@@ -61,9 +61,6 @@ private:
     const RealtimeMediaSourceCapabilities& capabilities() const final;
     const RealtimeMediaSourceSettings& settings() const final;
 
-    MediaConstraints& constraints() { return *m_constraints.get(); }
-    RealtimeMediaSourceSupportedConstraints& supportedConstraints();
-
     void processNewSample(CMSampleBufferRef, unsigned, unsigned, MediaSample::VideoRotation);
 
     bool applySize(const IntSize&) final { return true; }
@@ -75,8 +72,6 @@ private:
 
     RefPtr<Image> m_currentImage;
     RealtimeMediaSourceSettings m_currentSettings;
-    RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
-    RefPtr<MediaConstraints> m_constraints;
     rtc::scoped_refptr<webrtc::VideoTrackInterface> m_videoTrack;
     RetainPtr<CMSampleBufferRef> m_buffer;
     PixelBufferConformerCV m_conformer;
index 506e482..9507f01 100644 (file)
@@ -68,7 +68,6 @@ protected:
     const RealtimeMediaSourceCapabilities& capabilities() const override;
     const RealtimeMediaSourceSettings& settings() const override;
 
-    MediaConstraints& constraints() { return *m_constraints.get(); }
     RealtimeMediaSourceSupportedConstraints& supportedConstraints();
 
     unsigned deviceIndex() { return m_deviceIndex; }
@@ -84,7 +83,6 @@ private:
     RealtimeMediaSourceSettings m_currentSettings;
     RealtimeMediaSourceSupportedConstraints m_supportedConstraints;
     std::unique_ptr<RealtimeMediaSourceCapabilities> m_capabilities;
-    RefPtr<MediaConstraints> m_constraints;
     unsigned m_deviceIndex { 0 };
 };
 
index ed81e90..d538d73 100644 (file)
@@ -1,3 +1,38 @@
+2017-05-16  Youenn Fablet  <youenn@apple.com>
+
+        Remove MediaConstraintsData and MediaConstraintsImpl
+        https://bugs.webkit.org/show_bug.cgi?id=172132
+
+        Reviewed by Eric Carlson.
+
+        Removing MediaConstraintsData and MediaConstraintsImpl allows simplifying the code.
+        Further simplified the code by making MediaConstraints no longer ref counted and now a struct.
+
+        * Scripts/webkit/messages.py:
+        (headers_for_type):
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<MediaConstraints>::encode):
+        (IPC::ArgumentCoder<MediaConstraints>::decode):
+        (IPC::ArgumentCoder<MediaConstraintsData>::encode): Deleted.
+        (IPC::ArgumentCoder<MediaConstraintsData>::decode): Deleted.
+        * Shared/WebCoreArgumentCoders.h:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+        (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+        (WebKit::UserMediaCaptureManagerProxy::applyConstraints):
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in:
+        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+        (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
+        * UIProcess/UserMediaPermissionRequestManagerProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestUserMediaPermissionForFrame):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
+        (WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
+        * WebProcess/cocoa/UserMediaCaptureManager.cpp:
+        (WebKit::UserMediaCaptureManager::applyConstraints):
+
 2017-05-16  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [SOUP] Remove LATEST_RECORD_VERSION from GnuTLS priority string
index a3f05d8..fe6bf89 100644 (file)
@@ -360,7 +360,7 @@ def headers_for_type(type):
         'WebCore::Highlight': ['<WebCore/InspectorOverlay.h>'],
         'WebCore::KeyframeValueList': ['<WebCore/GraphicsLayer.h>'],
         'WebCore::KeypressCommand': ['<WebCore/KeyboardEvent.h>'],
-        'WebCore::MediaConstraintsData': ['<WebCore/MediaConstraintsImpl.h>'],
+        'WebCore::MediaConstraints': ['<WebCore/MediaConstraints.h>'],
         'WebCore::PasteboardImage': ['<WebCore/Pasteboard.h>'],
         'WebCore::PasteboardURL': ['<WebCore/Pasteboard.h>'],
         'WebCore::PasteboardWebContent': ['<WebCore/Pasteboard.h>'],
index 4e64cd4..4616aad 100644 (file)
 
 #if ENABLE(MEDIA_STREAM)
 #include <WebCore/CaptureDevice.h>
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #endif
 
 using namespace WebCore;
@@ -2389,7 +2389,7 @@ bool ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder, WebCore::Re
 }
 
 #if ENABLE(MEDIA_STREAM)
-void ArgumentCoder<MediaConstraintsData>::encode(Encoder& encoder, const WebCore::MediaConstraintsData& constraint)
+void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::MediaConstraints& constraint)
 {
     encoder << constraint.mandatoryConstraints
         << constraint.advancedConstraints
@@ -2397,7 +2397,7 @@ void ArgumentCoder<MediaConstraintsData>::encode(Encoder& encoder, const WebCore
         << constraint.isValid;
 }
 
-bool ArgumentCoder<MediaConstraintsData>::decode(Decoder& decoder, WebCore::MediaConstraintsData& constraints)
+bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaConstraints& constraints)
 {
     return decoder.decode(constraints.mandatoryConstraints)
         && decoder.decode(constraints.advancedConstraints)
index f70252d..a673f2a 100644 (file)
@@ -162,7 +162,7 @@ class MediaSessionMetadata;
 #if ENABLE(MEDIA_STREAM)
 namespace WebCore {
 class CaptureDevice;
-struct MediaConstraintsData;
+struct MediaConstraints;
 }
 #endif
 
@@ -640,9 +640,9 @@ template<> struct ArgumentCoder<WebCore::ShippingMethodUpdate> {
 #endif
 
 #if ENABLE(MEDIA_STREAM)
-template<> struct ArgumentCoder<WebCore::MediaConstraintsData> {
-    static void encode(Encoder&, const WebCore::MediaConstraintsData&);
-    static bool decode(Decoder&, WebCore::MediaConstraintsData&);
+template<> struct ArgumentCoder<WebCore::MediaConstraints> {
+    static void encode(Encoder&, const WebCore::MediaConstraints&);
+    static bool decode(Decoder&, WebCore::MediaConstraints&);
 };
 
 template<> struct ArgumentCoder<WebCore::CaptureDevice> {
index ee812d9..58633dd 100644 (file)
@@ -33,7 +33,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebProcessProxy.h"
 #include <WebCore/CARingBuffer.h>
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #include <WebCore/RealtimeMediaSourceCenter.h>
 #include <WebCore/WebAudioBufferList.h>
 #include <wtf/UniqueRef.h>
@@ -125,16 +125,15 @@ UserMediaCaptureManagerProxy::~UserMediaCaptureManagerProxy()
     m_process.removeMessageReceiver(Messages::UserMediaCaptureManagerProxy::messageReceiverName());
 }
 
-void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const String& deviceID, WebCore::RealtimeMediaSource::Type type, const MediaConstraintsData& constraintsData, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings& settings)
+void UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const String& deviceID, WebCore::RealtimeMediaSource::Type type, const MediaConstraints& constraints, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings& settings)
 {
     CaptureSourceOrError sourceOrError;
-    auto constraints = MediaConstraintsImpl::create(MediaConstraintsData(constraintsData));
     switch (type) {
     case WebCore::RealtimeMediaSource::Type::Audio:
-        sourceOrError = RealtimeMediaSourceCenter::singleton().audioFactory().createAudioCaptureSource(deviceID, constraints.ptr());
+        sourceOrError = RealtimeMediaSourceCenter::singleton().audioFactory().createAudioCaptureSource(deviceID, &constraints);
         break;
     case WebCore::RealtimeMediaSource::Type::Video:
-        sourceOrError = RealtimeMediaSourceCenter::singleton().videoFactory().createVideoCaptureSource(deviceID, constraints.ptr());
+        sourceOrError = RealtimeMediaSourceCenter::singleton().videoFactory().createVideoCaptureSource(deviceID, &constraints);
         break;
     case WebCore::RealtimeMediaSource::Type::None:
         ASSERT_NOT_REACHED();
@@ -185,9 +184,8 @@ void UserMediaCaptureManagerProxy::setEnabled(uint64_t id, bool enabled)
         iter->value->source().setEnabled(enabled);
 }
 
-void UserMediaCaptureManagerProxy::applyConstraints(uint64_t id, const WebCore::MediaConstraintsData& constraintsData)
+void UserMediaCaptureManagerProxy::applyConstraints(uint64_t id, const WebCore::MediaConstraints& constraints)
 {
-    auto constraints = MediaConstraintsImpl::create(MediaConstraintsData(constraintsData));
     auto iter = m_proxies.find(id);
     if (iter == m_proxies.end())
         return;
index 2a51d7c..80e33ff 100644 (file)
@@ -49,13 +49,13 @@ private:
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
 
-    void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const String& deviceID, WebCore::RealtimeMediaSource::Type, const WebCore::MediaConstraintsData&, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings&);
+    void createMediaSourceForCaptureDeviceWithConstraints(uint64_t id, const String& deviceID, WebCore::RealtimeMediaSource::Type, const WebCore::MediaConstraints&, bool& succeeded, String& invalidConstraints, WebCore::RealtimeMediaSourceSettings&);
     void startProducingData(uint64_t);
     void stopProducingData(uint64_t);
     void capabilities(uint64_t, WebCore::RealtimeMediaSourceCapabilities&);
     void setMuted(uint64_t, bool);
     void setEnabled(uint64_t, bool);
-    void applyConstraints(uint64_t, const WebCore::MediaConstraintsData&);
+    void applyConstraints(uint64_t, const WebCore::MediaConstraints&);
 
     class SourceProxy;
     friend class SourceProxy;
index a3c814f..6053371 100644 (file)
 # THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> UserMediaCaptureManagerProxy {
-    CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, String deviceID, WebCore::RealtimeMediaSource::Type type, struct WebCore::MediaConstraintsData constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings)
+    CreateMediaSourceForCaptureDeviceWithConstraints(uint64_t id, String deviceID, WebCore::RealtimeMediaSource::Type type, struct WebCore::MediaConstraints constraints) -> (bool success, String invalidConstraints, WebCore::RealtimeMediaSourceSettings settings)
     StartProducingData(uint64_t id)
     StopProducingData(uint64_t id)
     Capabilities(uint64_t id) -> (WebCore::RealtimeMediaSourceCapabilities capabilities)
     SetMuted(uint64_t id, bool muted)
     SetEnabled(uint64_t id, bool enabled)
-    ApplyConstraints(uint64_t id, struct WebCore::MediaConstraintsData constraints)
+    ApplyConstraints(uint64_t id, struct WebCore::MediaConstraints constraints)
 }
index c0bbf41..4395d39 100644 (file)
@@ -26,7 +26,7 @@
 #include "WebPageMessages.h"
 #include "WebPageProxy.h"
 #include "WebProcessProxy.h"
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #include <WebCore/MockRealtimeMediaSourceCenter.h>
 #include <WebCore/RealtimeMediaSource.h>
 #include <WebCore/SecurityOriginData.h>
@@ -251,7 +251,7 @@ void UserMediaPermissionRequestManagerProxy::scheduleNextRejection()
         m_rejectionTimer.startOneShot(Seconds(mimimumDelayBeforeReplying + randomNumber()));
 }
 
-void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData)
+void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints)
 {
 #if ENABLE(MEDIA_STREAM)
     auto invalidHandler = [this, userMediaID](const String& invalidConstraint) {
@@ -306,12 +306,11 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
         return;
     }
 
-    auto validateConstraintsHandler = [this, userMediaID, validHandler = WTFMove(validHandler), invalidHandler = WTFMove(invalidHandler), audioConstraintsData, videoConstraintsData](String&& deviceIdentifierHashSalt) mutable {
+    auto validateConstraintsHandler = [this, userMediaID, validHandler = WTFMove(validHandler), invalidHandler = WTFMove(invalidHandler), audioConstraints = WebCore::MediaConstraints(audioConstraints), videoConstraints = WebCore::MediaConstraints(videoConstraints)](String&& deviceIdentifierHashSalt) mutable {
         syncWithWebCorePrefs();
-
-        auto audioConstraints = MediaConstraintsImpl::create(MediaConstraintsData(audioConstraintsData, deviceIdentifierHashSalt));
-        auto videoConstraints = MediaConstraintsImpl::create(MediaConstraintsData(videoConstraintsData, deviceIdentifierHashSalt));
-
+        
+        audioConstraints.deviceIDHashSalt = deviceIdentifierHashSalt;
+        videoConstraints.deviceIDHashSalt = WTFMove(deviceIdentifierHashSalt);
         RealtimeMediaSourceCenter::singleton().validateRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), audioConstraints, videoConstraints);
     };
 
@@ -335,8 +334,8 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
     UNUSED_PARAM(frameID);
     UNUSED_PARAM(userMediaDocumentOriginIdentifier);
     UNUSED_PARAM(topLevelDocumentOriginIdentifier);
-    UNUSED_PARAM(audioConstraintsData);
-    UNUSED_PARAM(videoConstraintsData);
+    UNUSED_PARAM(audioConstraints);
+    UNUSED_PARAM(videoConstraints);
 #endif
 }
 
index fbbed59..4feceec 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 class CaptureDevice;
-struct MediaConstraintsData;
+struct MediaConstraints;
 class SecurityOrigin;
 };
 
@@ -65,7 +65,7 @@ public:
 
     void invalidatePendingRequests();
 
-    void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData);
+    void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints);
 
     void userMediaAccessWasGranted(uint64_t, const String& audioDeviceUID, const String& videoDeviceUID);
     void userMediaAccessWasDenied(uint64_t, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason);
index 06199ec..438debd 100644 (file)
 #endif
 
 #if ENABLE(MEDIA_STREAM)
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #endif
 
 // This controls what strategy we use for mouse wheel coalescing.
@@ -5744,19 +5744,19 @@ UserMediaPermissionRequestManagerProxy& WebPageProxy::userMediaPermissionRequest
 }
 #endif
 
-void WebPageProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraintsData, const WebCore::MediaConstraintsData& videoConstraintsData)
+void WebPageProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints)
 {
 #if ENABLE(MEDIA_STREAM)
     MESSAGE_CHECK(m_process->webFrame(frameID));
 
-    userMediaPermissionRequestManager().requestUserMediaPermissionForFrame(userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioConstraintsData, videoConstraintsData);
+    userMediaPermissionRequestManager().requestUserMediaPermissionForFrame(userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioConstraints, videoConstraints);
 #else
     UNUSED_PARAM(userMediaID);
     UNUSED_PARAM(frameID);
     UNUSED_PARAM(userMediaDocumentOriginIdentifier);
     UNUSED_PARAM(topLevelDocumentOriginIdentifier);
-    UNUSED_PARAM(audioConstraintsData);
-    UNUSED_PARAM(videoConstraintsData);
+    UNUSED_PARAM(audioConstraints);
+    UNUSED_PARAM(videoConstraints);
 #endif
 }
 
index 75e7418..188ac36 100644 (file)
@@ -164,7 +164,7 @@ class ValidationBubble;
 struct DictionaryPopupInfo;
 struct ExceptionDetails;
 struct FileChooserSettings;
-struct MediaConstraintsData;
+struct MediaConstraints;
 struct SecurityOriginData;
 struct TextAlternativeWithRange;
 struct TextCheckingResult;
@@ -1313,7 +1313,7 @@ private:
 #if ENABLE(MEDIA_STREAM)
     UserMediaPermissionRequestManagerProxy& userMediaPermissionRequestManager();
 #endif
-    void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraintsData& audioConstraints, const WebCore::MediaConstraintsData& videoConstraints);
+    void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, const WebCore::MediaConstraints& audioConstraints, const WebCore::MediaConstraints& videoConstraints);
     void enumerateMediaDevicesForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier);
 
     void runModal();
index b53cedb..55afcd0 100644 (file)
@@ -268,7 +268,7 @@ messages -> WebPageProxy {
     
 #if ENABLE(MEDIA_STREAM)
     # MediaSteam messages
-    RequestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, struct WebCore::MediaConstraintsData audioConstraintsData, struct WebCore::MediaConstraintsData videoConstraintsData)
+    RequestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier, struct WebCore::MediaConstraints audioConstraints, struct WebCore::MediaConstraints videoConstraints)
     EnumerateMediaDevicesForFrame(uint64_t userMediaID, uint64_t frameID, String userMediaDocumentOriginIdentifier, String topLevelDocumentOriginIdentifier)
 #endif
 
index 2d26a49..3fbcca9 100644 (file)
@@ -29,7 +29,7 @@
 #include <WebCore/Document.h>
 #include <WebCore/Frame.h>
 #include <WebCore/FrameLoader.h>
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/SecurityOriginData.h>
 
@@ -105,7 +105,7 @@ void UserMediaPermissionRequestManager::sendUserMediaRequest(UserMediaRequest& r
 
     SecurityOrigin* topLevelDocumentOrigin = request.topLevelDocumentOrigin();
     String topLevelDocumentOriginString = topLevelDocumentOrigin ? SecurityOriginData::fromSecurityOrigin(*topLevelDocumentOrigin).databaseIdentifier() : emptyString();
-    m_page.send(Messages::WebPageProxy::RequestUserMediaPermissionForFrame(requestID, webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(*request.userMediaDocumentOrigin()).databaseIdentifier(), topLevelDocumentOriginString, request.audioConstraints().data(), request.videoConstraints().data()));
+    m_page.send(Messages::WebPageProxy::RequestUserMediaPermissionForFrame(requestID, webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(*request.userMediaDocumentOrigin()).databaseIdentifier(), topLevelDocumentOriginString, request.audioConstraints(), request.videoConstraints()));
 }
 
 void UserMediaPermissionRequestManager::cancelUserMediaRequest(UserMediaRequest& request)
index 8d56cb2..fbd0eb2 100644 (file)
@@ -35,7 +35,7 @@
 #include "WebProcess.h"
 #include "WebProcessCreationParameters.h"
 #include <WebCore/CaptureDevice.h>
-#include <WebCore/MediaConstraintsImpl.h>
+#include <WebCore/MediaConstraints.h>
 #include <WebCore/RealtimeMediaSourceCenter.h>
 #include <WebCore/WebAudioBufferList.h>
 #include <WebCore/WebAudioSourceProviderAVFObjC.h>
@@ -279,12 +279,7 @@ void UserMediaCaptureManager::setEnabled(uint64_t id, bool enabled)
 
 void UserMediaCaptureManager::applyConstraints(uint64_t id, const WebCore::MediaConstraints& constraints)
 {
-    MediaConstraintsData constraintsData;
-    constraintsData.mandatoryConstraints = constraints.mandatoryConstraints();
-    constraintsData.advancedConstraints = constraints.advancedConstraints();
-    constraintsData.isValid = constraints.isValid();
-
-    m_process.send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints(id, constraintsData), 0);
+    m_process.send(Messages::UserMediaCaptureManagerProxy::ApplyConstraints(id, constraints), 0);
 }
 
 void UserMediaCaptureManager::applyConstraintsSucceeded(uint64_t id, const WebCore::RealtimeMediaSourceSettings& settings)