[MediaCapabilities] Implement MediaEngineConfigurationFactory registration
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 23:18:15 +0000 (23:18 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Sep 2018 23:18:15 +0000 (23:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189438

Reviewed by Eric Carlson.

Source/WebCore:

Implement a mechanism to register platform-specific MediaEngineConfigurationFactory methods, and a mechanism to iterate
over those registered factories when createDecodingConfiguration() and createEncodingConfiguration() are called.

The Factory has been radically simplified; the concept of MediaEngineDecodingConfiguration
and MediaEngineEncodingConfiguration and its subclasess have been removed. Since the primary
objects representing video and audio configurations are IDLDictionaries, the native objects
are just structs full of POD types (and Strings). Since these have no dependencies on
higher-level HTML concepts, they can be moved into platform/ and accessed from there. This
patch also converts MediaCapabilitiesInfo to an Interface, so its implementation also can
become a struct and live in platform/. The MediaEngineDecodingConfigurationMock and
MediaEngineEncodingConfigurationMock have been consolidated in a single class which simply
parses MediaDecodingConfiguration and MediaEncodingConifguration objects (now that they live
in Platform) and return a MediaCapabilitiesInfo object (now that it does too).

* Modules/mediacapabilities/MediaCapabilities.cpp:
(WebCore::isValidVideoConfiguration):
(WebCore::MediaCapabilities::decodingInfo):
(WebCore::MediaCapabilities::encodingInfo):
* Modules/mediacapabilities/MediaCapabilitiesInfo.h: Removed.
* Modules/mediacapabilities/MediaCapabilitiesInfo.idl:
* Modules/mediacapabilities/VideoConfiguration.idl:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/MediaCapabilitiesInfo.h: Copied from Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h.
* platform/mediacapabilities/AudioConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h.
* platform/mediacapabilities/MediaConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h.
* platform/mediacapabilities/MediaDecodingConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h.
* platform/mediacapabilities/MediaDecodingType.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h.
* platform/mediacapabilities/MediaEncodingConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h.
* platform/mediacapabilities/MediaEncodingType.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h.
* platform/mediacapabilities/MediaEngineConfiguration.cpp: Removed.
* platform/mediacapabilities/MediaEngineConfiguration.h: Removed.
* platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
(WebCore::factories):
(WebCore::MediaEngineConfigurationFactory::createDecodingConfiguration):
(WebCore::MediaEngineConfigurationFactory::createEncodingConfiguration):
* platform/mediacapabilities/MediaEngineConfigurationFactory.h:
* platform/mediacapabilities/MediaEngineEncodingConfiguration.h: Removed.
* platform/mediacapabilities/VideoConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h.
* platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
* platform/mock/MediaEngineConfigurationFactoryMock.cpp: Added.
(WebCore::canDecodeMedia):
(WebCore::canSmoothlyDecodeMedia):
(WebCore::canPowerEfficientlyDecodeMedia):
(WebCore::canEncodeMedia):
(WebCore::canSmoothlyEncodeMedia):
(WebCore::canPowerEfficientlyEncodeMedia):
(WebCore::MediaEngineConfigurationFactoryMock::createDecodingConfiguration):
(WebCore::MediaEngineConfigurationFactoryMock::createEncodingConfiguration):
* platform/mock/MediaEngineConfigurationFactoryMock.h: Renamed from Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h.
* platform/mock/MediaEngineDecodingConfigurationMock.cpp: Removed.
* platform/mock/MediaEngineDecodingConfigurationMock.h: Removed.
* platform/mock/MediaEngineEncodingConfigurationMock.cpp: Removed.
* platform/mock/MediaEngineEncodingConfigurationMock.h: Removed.

LayoutTests:

* media/mediacapabilities/mediacapabilities-types-expected.txt:

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/media/mediacapabilities/mediacapabilities-types-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp
Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h [deleted file]
Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.idl
Source/WebCore/Modules/mediacapabilities/VideoConfiguration.idl
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/MediaCapabilitiesInfo.h [new file with mode: 0644]
Source/WebCore/platform/mediacapabilities/AudioConfiguration.h [moved from Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h with 95% similarity]
Source/WebCore/platform/mediacapabilities/MediaConfiguration.h [moved from Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h with 100% similarity]
Source/WebCore/platform/mediacapabilities/MediaDecodingConfiguration.h [moved from Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h with 100% similarity]
Source/WebCore/platform/mediacapabilities/MediaDecodingType.h [moved from Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h with 100% similarity]
Source/WebCore/platform/mediacapabilities/MediaEncodingConfiguration.h [moved from Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h with 100% similarity]
Source/WebCore/platform/mediacapabilities/MediaEncodingType.h [moved from Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h with 100% similarity]
Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp [deleted file]
Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h [deleted file]
Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp
Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h
Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h [deleted file]
Source/WebCore/platform/mediacapabilities/VideoConfiguration.h [moved from Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h with 98% similarity]
Source/WebCore/platform/mediastream/mac/DisplayCaptureSourceCocoa.h
Source/WebCore/platform/mock/MediaEngineConfigurationFactoryMock.cpp [new file with mode: 0644]
Source/WebCore/platform/mock/MediaEngineConfigurationFactoryMock.h [moved from Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h with 64% similarity]
Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp [deleted file]
Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h [deleted file]
Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp [deleted file]
Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h [deleted file]

index fb32d91..ae4ede2 100644 (file)
@@ -1,3 +1,12 @@
+2018-09-11  Jer Noble  <jer.noble@apple.com>
+
+        [MediaCapabilities] Implement MediaEngineConfigurationFactory registration
+        https://bugs.webkit.org/show_bug.cgi?id=189438
+
+        Reviewed by Eric Carlson.
+
+        * media/mediacapabilities/mediacapabilities-types-expected.txt:
+
 2018-09-08  Ryosuke Niwa  <rniwa@webkit.org>
 
         :first-child, :last-child, :nth-child, and :nth-of-type don't work on shadow root's children
index 6eadfaf..88c8ca2 100644 (file)
@@ -35,10 +35,10 @@ PASS () => {
     } rejected promise  with TypeError: Type error.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
-    } rejected promise  with TypeError: Type error.
+    } rejected promise  with TypeError: The provided value is non-finite.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/0" } });
-    } rejected promise  with TypeError: Type error.
+    } rejected promise  with TypeError: The provided value is non-finite.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
     } rejected promise  with TypeError: Type error.
@@ -74,10 +74,10 @@ PASS () => {
     } rejected promise  with TypeError: Type error.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
-    } rejected promise  with TypeError: Type error.
+    } rejected promise  with TypeError: The provided value is non-finite.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/-1" } });
-    } rejected promise  with TypeError: Type error.
+    } rejected promise  with TypeError: The provided value is non-finite.
 PASS () => {
         return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
     } rejected promise  with TypeError: Type error.
index 8a0864f..5ffee3f 100644 (file)
@@ -1,3 +1,65 @@
+2018-09-11  Jer Noble  <jer.noble@apple.com>
+
+        [MediaCapabilities] Implement MediaEngineConfigurationFactory registration
+        https://bugs.webkit.org/show_bug.cgi?id=189438
+
+        Reviewed by Eric Carlson.
+
+        Implement a mechanism to register platform-specific MediaEngineConfigurationFactory methods, and a mechanism to iterate
+        over those registered factories when createDecodingConfiguration() and createEncodingConfiguration() are called.
+
+        The Factory has been radically simplified; the concept of MediaEngineDecodingConfiguration
+        and MediaEngineEncodingConfiguration and its subclasess have been removed. Since the primary
+        objects representing video and audio configurations are IDLDictionaries, the native objects
+        are just structs full of POD types (and Strings). Since these have no dependencies on
+        higher-level HTML concepts, they can be moved into platform/ and accessed from there. This
+        patch also converts MediaCapabilitiesInfo to an Interface, so its implementation also can
+        become a struct and live in platform/. The MediaEngineDecodingConfigurationMock and
+        MediaEngineEncodingConfigurationMock have been consolidated in a single class which simply
+        parses MediaDecodingConfiguration and MediaEncodingConifguration objects (now that they live
+        in Platform) and return a MediaCapabilitiesInfo object (now that it does too).
+
+        * Modules/mediacapabilities/MediaCapabilities.cpp:
+        (WebCore::isValidVideoConfiguration):
+        (WebCore::MediaCapabilities::decodingInfo):
+        (WebCore::MediaCapabilities::encodingInfo):
+        * Modules/mediacapabilities/MediaCapabilitiesInfo.h: Removed.
+        * Modules/mediacapabilities/MediaCapabilitiesInfo.idl:
+        * Modules/mediacapabilities/VideoConfiguration.idl:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/MediaCapabilitiesInfo.h: Copied from Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h.
+        * platform/mediacapabilities/AudioConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h.
+        * platform/mediacapabilities/MediaConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h.
+        * platform/mediacapabilities/MediaDecodingConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h.
+        * platform/mediacapabilities/MediaDecodingType.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h.
+        * platform/mediacapabilities/MediaEncodingConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h.
+        * platform/mediacapabilities/MediaEncodingType.h: Renamed from Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h.
+        * platform/mediacapabilities/MediaEngineConfiguration.cpp: Removed.
+        * platform/mediacapabilities/MediaEngineConfiguration.h: Removed.
+        * platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
+        (WebCore::factories):
+        (WebCore::MediaEngineConfigurationFactory::createDecodingConfiguration):
+        (WebCore::MediaEngineConfigurationFactory::createEncodingConfiguration):
+        * platform/mediacapabilities/MediaEngineConfigurationFactory.h:
+        * platform/mediacapabilities/MediaEngineEncodingConfiguration.h: Removed.
+        * platform/mediacapabilities/VideoConfiguration.h: Renamed from Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h.
+        * platform/mediastream/mac/DisplayCaptureSourceCocoa.h:
+        * platform/mock/MediaEngineConfigurationFactoryMock.cpp: Added.
+        (WebCore::canDecodeMedia):
+        (WebCore::canSmoothlyDecodeMedia):
+        (WebCore::canPowerEfficientlyDecodeMedia):
+        (WebCore::canEncodeMedia):
+        (WebCore::canSmoothlyEncodeMedia):
+        (WebCore::canPowerEfficientlyEncodeMedia):
+        (WebCore::MediaEngineConfigurationFactoryMock::createDecodingConfiguration):
+        (WebCore::MediaEngineConfigurationFactoryMock::createEncodingConfiguration):
+        * platform/mock/MediaEngineConfigurationFactoryMock.h: Renamed from Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h.
+        * platform/mock/MediaEngineDecodingConfigurationMock.cpp: Removed.
+        * platform/mock/MediaEngineDecodingConfigurationMock.h: Removed.
+        * platform/mock/MediaEngineEncodingConfigurationMock.cpp: Removed.
+        * platform/mock/MediaEngineEncodingConfigurationMock.h: Removed.
+
 2018-09-08  Ryosuke Niwa  <rniwa@webkit.org>
 
         :first-child, :last-child, :nth-child, and :nth-of-type don't work on shadow root's children
index 51bf37d..2232b86 100644 (file)
@@ -120,31 +120,7 @@ static bool isValidVideoConfiguration(const VideoConfiguration& configuration)
     // 2. If none of the following is true, return false and abort these steps:
     //   o. Applying the rules for parsing floating-point number values to configuration’s framerate
     //      results in a number that is finite and greater than 0.
-    bool ok = false;
-    double framerate = configuration.framerate.toDouble(&ok);
-    if (ok && std::isfinite(framerate) && framerate > 0)
-        return true;
-
-    //   o. Configuration’s framerate contains one occurence of U+002F SLASH character (/) and the substrings
-    //      before and after this character, when applying the rules for parsing floating-point number values
-    //      results in a number that is finite and greater than 0.
-    auto frameratePieces = configuration.framerate.split('/');
-    if (frameratePieces.size() != 2)
-        return false;
-
-    double numerator = frameratePieces[0].toDouble(&ok);
-    if (!ok)
-        return false;
-
-    double denominator = frameratePieces[1].toDouble(&ok);
-    if (!ok)
-        return false;
-
-    if (!std::isfinite(numerator) || !std::isfinite(denominator))
-        return false;
-
-    framerate = numerator / denominator;
-    if (!std::isfinite(framerate) || framerate <= 0)
+    if (!std::isfinite(configuration.framerate) || configuration.framerate <= 0)
         return false;
 
     // 3. Return true.
@@ -199,34 +175,22 @@ void MediaCapabilities::decodingInfo(MediaDecodingConfiguration&& configuration,
     m_taskQueue.enqueueTask([configuration = WTFMove(configuration), promise = WTFMove(promise)] () mutable {
 
         // 2.2.3 If configuration is of type MediaDecodingConfiguration, run the following substeps:
-        MediaEngineConfigurationFactory::DecodingConfigurationCallback callback = [promise = WTFMove(promise)] (auto engineConfiguration) mutable {
-            auto info = MediaCapabilitiesInfo::create();
-
-            if (engineConfiguration) {
-                // 2.2.3.1. If the user agent is able to decode the media represented by
-                // configuration, set supported to true. Otherwise set it to false.
-                info->setSupported(engineConfiguration->canDecodeMedia());
-
-                if (info->supported()) {
-                    // 2.2.3.2. If the user agent is able to decode the media represented by
-                    // configuration at a pace that allows a smooth playback, set smooth to
-                    // true. Otherwise set it to false.
-                    info->setSmooth(engineConfiguration->canSmoothlyDecodeMedia());
-
-                    // 2.2.3.3. If the user agent is able to decode the media represented by
-                    // configuration in a power efficient manner, set powerEfficient to
-                    // true. Otherwise set it to false. The user agent SHOULD NOT take into
-                    // consideration the current power source in order to determine the
-                    // decoding power efficiency unless the device’s power source has side
-                    // effects such as enabling different decoding modules.
-                    info->setPowerEfficient(engineConfiguration->canPowerEfficientlyDecodeMedia());
-                }
-            }
-
-            promise->resolveWithNewlyCreated<IDLInterface<MediaCapabilitiesInfo>>(WTFMove(info));
+        MediaEngineConfigurationFactory::DecodingConfigurationCallback callback = [promise = WTFMove(promise)] (auto info) mutable {
+            // 2.2.3.1. If the user agent is able to decode the media represented by
+            // configuration, set supported to true. Otherwise set it to false.
+            // 2.2.3.2. If the user agent is able to decode the media represented by
+            // configuration at a pace that allows a smooth playback, set smooth to
+            // true. Otherwise set it to false.
+            // 2.2.3.3. If the user agent is able to decode the media represented by
+            // configuration in a power efficient manner, set powerEfficient to
+            // true. Otherwise set it to false. The user agent SHOULD NOT take into
+            // consideration the current power source in order to determine the
+            // decoding power efficiency unless the device’s power source has side
+            // effects such as enabling different decoding modules.
+            promise->resolve<IDLDictionary<MediaCapabilitiesInfo>>(WTFMove(info));
         };
 
-        MediaEngineConfigurationFactory::createDecodingConfiguration(configuration, callback);
+        MediaEngineConfigurationFactory::createDecodingConfiguration(WTFMove(configuration), WTFMove(callback));
     });
 }
 
@@ -249,37 +213,25 @@ void MediaCapabilities::encodingInfo(MediaEncodingConfiguration&& configuration,
     m_taskQueue.enqueueTask([configuration = WTFMove(configuration), promise = WTFMove(promise)] () mutable {
 
         // 2.2.4. If configuration is of type MediaEncodingConfiguration, run the following substeps:
-        MediaEngineConfigurationFactory::EncodingConfigurationCallback callback = [promise = WTFMove(promise)] (auto engineConfiguration) mutable {
-            auto info = MediaCapabilitiesInfo::create();
-
-            if (engineConfiguration) {
-                // 2.2.4.1. If the user agent is able to encode the media
-                // represented by configuration, set supported to true. Otherwise
-                // set it to false.
-                info->setSupported(engineConfiguration->canEncodeMedia());
-
-                if (info->supported()) {
-                    // 2.2.4.2. If the user agent is able to encode the media
-                    // represented by configuration at a pace that allows encoding
-                    // frames at the same pace as they are sent to the encoder, set
-                    // smooth to true. Otherwise set it to false.
-                    info->setSmooth(engineConfiguration->canSmoothlyEncodeMedia());
-
-                    // 2.2.4.3. If the user agent is able to encode the media
-                    // represented by configuration in a power efficient manner, set
-                    // powerEfficient to true. Otherwise set it to false. The user agent
-                    // SHOULD NOT take into consideration the current power source in
-                    // order to determine the encoding power efficiency unless the
-                    // device’s power source has side effects such as enabling different
-                    // encoding modules.
-                    info->setPowerEfficient(engineConfiguration->canPowerEfficientlyEncodeMedia());
-                }
-            }
-
-            promise->resolveWithNewlyCreated<IDLInterface<MediaCapabilitiesInfo>>(WTFMove(info));
+        MediaEngineConfigurationFactory::EncodingConfigurationCallback callback = [promise = WTFMove(promise)] (auto info) mutable {
+            // 2.2.4.1. If the user agent is able to encode the media
+            // represented by configuration, set supported to true. Otherwise
+            // set it to false.
+            // 2.2.4.2. If the user agent is able to encode the media
+            // represented by configuration at a pace that allows encoding
+            // frames at the same pace as they are sent to the encoder, set
+            // smooth to true. Otherwise set it to false.
+            // 2.2.4.3. If the user agent is able to encode the media
+            // represented by configuration in a power efficient manner, set
+            // powerEfficient to true. Otherwise set it to false. The user agent
+            // SHOULD NOT take into consideration the current power source in
+            // order to determine the encoding power efficiency unless the
+            // device’s power source has side effects such as enabling different
+            // encoding modules.
+            promise->resolve<IDLDictionary<MediaCapabilitiesInfo>>(WTFMove(info));
         };
 
-        MediaEngineConfigurationFactory::createEncodingConfiguration(configuration, callback);
+        MediaEngineConfigurationFactory::createEncodingConfiguration(WTFMove(configuration), WTFMove(callback));
 
     });
 }
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h b/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h
deleted file mode 100644 (file)
index af7adb8..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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
-
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class MediaCapabilitiesInfo : public RefCounted<MediaCapabilitiesInfo> {
-public:
-
-    static Ref<MediaCapabilitiesInfo> create()
-    {
-        return adoptRef(*new MediaCapabilitiesInfo());
-    }
-
-    ~MediaCapabilitiesInfo() = default;
-
-    bool supported() const { return m_supported; }
-    void setSupported(bool supported) { m_supported = supported; }
-
-    bool smooth() const { return m_smooth; }
-    void setSmooth(bool smooth) { m_smooth = smooth; }
-
-    bool powerEfficient() const { return m_powerEfficient; }
-    void setPowerEfficient(bool powerEfficient) { m_powerEfficient = powerEfficient; }
-
-private:
-    MediaCapabilitiesInfo() = default;
-
-    bool m_supported { false };
-    bool m_smooth { false };
-    bool m_powerEfficient { false };
-};
-
-}
index b2525e5..7ad0aba 100644 (file)
 
 [
     EnabledBySetting=MediaCapabilities,
-    ImplementationLacksVTable
+    JSGenerateToJSObject,
 ]
-interface MediaCapabilitiesInfo {
-  readonly attribute boolean supported;
-  readonly attribute boolean smooth;
-  readonly attribute boolean powerEfficient;
+dictionary MediaCapabilitiesInfo {
+  required boolean supported;
+  required boolean smooth;
+  required boolean powerEfficient;
 };
index 627e6c9..01f244d 100644 (file)
@@ -28,5 +28,5 @@ dictionary VideoConfiguration {
   required unsigned long width;
   required unsigned long height;
   required unsigned long long bitrate;
-  required DOMString framerate;
+  required double framerate;
 };
index 7e6af49..df90dfc 100644 (file)
@@ -1729,7 +1729,6 @@ platform/graphics/transforms/TransformState.cpp
 platform/graphics/transforms/TransformationMatrix.cpp
 platform/graphics/transforms/TranslateTransformOperation.cpp
 
-platform/mediacapabilities/MediaEngineConfiguration.cpp
 platform/mediacapabilities/MediaEngineConfigurationFactory.cpp
 
 platform/mediastream/CaptureDeviceManager.cpp
@@ -1753,8 +1752,7 @@ platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
 
 platform/mock/DeviceOrientationClientMock.cpp
 platform/mock/GeolocationClientMock.cpp
-platform/mock/MediaEngineDecodingConfigurationMock.cpp
-platform/mock/MediaEngineEncodingConfigurationMock.cpp
+platform/mock/MediaEngineConfigurationFactoryMock.cpp
 platform/mock/MockRealtimeAudioSource.cpp
 platform/mock/MockRealtimeMediaSourceCenter.cpp
 platform/mock/MockRealtimeVideoSource.cpp
index 7293c6c..a3ee899 100644 (file)
                9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
                9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToLengthConversionData.h; sourceTree = "<group>"; };
                9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSToLengthConversionData.cpp; sourceTree = "<group>"; };
-               9AC6F02121148F5000CBDA06 /* MediaEngineConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MediaEngineConfiguration.cpp; path = mediacapabilities/MediaEngineConfiguration.cpp; sourceTree = "<group>"; };
                9AC6F02221148F5100CBDA06 /* MediaEngineConfigurationFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MediaEngineConfigurationFactory.cpp; path = mediacapabilities/MediaEngineConfigurationFactory.cpp; sourceTree = "<group>"; };
-               9AC6F02321148F5200CBDA06 /* MediaEngineConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEngineConfiguration.h; path = mediacapabilities/MediaEngineConfiguration.h; sourceTree = "<group>"; };
-               9AC6F02421148F5300CBDA06 /* MediaEngineDecodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEngineDecodingConfiguration.h; path = mediacapabilities/MediaEngineDecodingConfiguration.h; sourceTree = "<group>"; };
                9AC6F02521148F5400CBDA06 /* MediaEngineConfigurationFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEngineConfigurationFactory.h; path = mediacapabilities/MediaEngineConfigurationFactory.h; sourceTree = "<group>"; };
-               9AC6F02621148F5500CBDA06 /* MediaEngineEncodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEngineEncodingConfiguration.h; path = mediacapabilities/MediaEngineEncodingConfiguration.h; sourceTree = "<group>"; };
-               9AC6F02D21148F9F00CBDA06 /* MediaEngineDecodingConfigurationMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEngineDecodingConfigurationMock.cpp; sourceTree = "<group>"; };
-               9AC6F02E21148FA100CBDA06 /* MediaEngineEncodingConfigurationMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEngineEncodingConfigurationMock.cpp; sourceTree = "<group>"; };
-               9AC6F02F21148FA200CBDA06 /* MediaEngineDecodingConfigurationMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEngineDecodingConfigurationMock.h; sourceTree = "<group>"; };
-               9AC6F03021148FA400CBDA06 /* MediaEngineEncodingConfigurationMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEngineEncodingConfigurationMock.h; sourceTree = "<group>"; };
+               9AC6F02D21148F9F00CBDA06 /* MediaEngineConfigurationFactoryMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEngineConfigurationFactoryMock.cpp; sourceTree = "<group>"; };
+               9AC6F02F21148FA200CBDA06 /* MediaEngineConfigurationFactoryMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEngineConfigurationFactoryMock.h; sourceTree = "<group>"; };
                9B03D8061BB3110D00B73F64 /* ReadableByteStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableByteStreamInternalsBuiltins.h; sourceTree = "<group>"; };
                9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltins.h; sourceTree = "<group>"; };
                9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltins.h; sourceTree = "<group>"; };
                CCC2B51215F613060048CDD6 /* DeviceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceController.h; sourceTree = "<group>"; };
                CD063F801E23FA8900812BE3 /* InitDataRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitDataRegistry.cpp; sourceTree = "<group>"; };
                CD063F811E23FA8900812BE3 /* InitDataRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InitDataRegistry.h; sourceTree = "<group>"; };
+               CD0C8B582141C8CA0062F59D /* MediaCapabilitiesInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaCapabilitiesInfo.h; sourceTree = "<group>"; };
                CD0EEE0A14743E34003EAFA2 /* AudioDestinationIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioDestinationIOS.h; sourceTree = "<group>"; };
                CD0EEE0B14743E35003EAFA2 /* AudioDestinationIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioDestinationIOS.cpp; sourceTree = "<group>"; };
                CD127DEA14F3097900E84779 /* WebCoreFullScreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenWindow.h; sourceTree = "<group>"; };
                CDBD3D281FE85CB80012C545 /* VideoConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VideoConfiguration.idl; sourceTree = "<group>"; };
                CDBD3D291FE85CB90012C545 /* MediaConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaConfiguration.idl; sourceTree = "<group>"; };
                CDBD3D2A1FE85CBA0012C545 /* MediaEncodingConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaEncodingConfiguration.idl; sourceTree = "<group>"; };
-               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioConfiguration.h; path = mediacapabilities/AudioConfiguration.h; sourceTree = "<group>"; };
                CDBD3D2C1FE85CBB0012C545 /* ScreenLuminance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenLuminance.h; sourceTree = "<group>"; };
                CDBD3D2D1FE85CBC0012C545 /* MediaEncodingType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaEncodingType.idl; sourceTree = "<group>"; };
                CDBD3D2E1FE85CBC0012C545 /* MediaDecodingType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaDecodingType.idl; sourceTree = "<group>"; };
                CDBD3D311FE85CBE0012C545 /* NavigatorMediaCapabilities.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorMediaCapabilities.idl; sourceTree = "<group>"; };
                CDBD3D321FE85CBE0012C545 /* MediaCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCapabilities.h; sourceTree = "<group>"; };
                CDBD3D331FE85CBE0012C545 /* MediaCapabilitiesInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaCapabilitiesInfo.idl; sourceTree = "<group>"; };
-               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoConfiguration.h; sourceTree = "<group>"; };
-               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaConfiguration.h; sourceTree = "<group>"; };
-               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDecodingConfiguration.h; sourceTree = "<group>"; };
-               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEncodingConfiguration.h; sourceTree = "<group>"; };
-               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDecodingType.h; sourceTree = "<group>"; };
+               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoConfiguration.h; path = mediacapabilities/VideoConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaConfiguration.h; path = mediacapabilities/MediaConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaDecodingConfiguration.h; path = mediacapabilities/MediaDecodingConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEncodingConfiguration.h; path = mediacapabilities/MediaEncodingConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaDecodingType.h; path = mediacapabilities/MediaDecodingType.h; sourceTree = "<group>"; };
                CDBD3D391FE85CC10012C545 /* NavigatorMediaCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorMediaCapabilities.h; sourceTree = "<group>"; };
                CDBD3D3A1FE85CC10012C545 /* ScreenColorGamut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenColorGamut.h; sourceTree = "<group>"; };
                CDBD3D3B1FE85CC20012C545 /* MediaDecodingConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaDecodingConfiguration.idl; sourceTree = "<group>"; };
                CDBD3D3C1FE85CC20012C545 /* AudioConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AudioConfiguration.idl; sourceTree = "<group>"; };
-               CDBD3D3D1FE85CC30012C545 /* MediaCapabilitiesInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCapabilitiesInfo.h; sourceTree = "<group>"; };
-               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEncodingType.h; sourceTree = "<group>"; };
+               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaEncodingType.h; path = mediacapabilities/MediaEncodingType.h; sourceTree = "<group>"; };
                CDBD3D3F1FE85CC30012C545 /* ScreenColorGamut.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScreenColorGamut.idl; sourceTree = "<group>"; };
                CDBEAEAA19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSelectionGroupAVFObjC.mm; sourceTree = "<group>"; };
                CDBEAEAB19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSelectionGroupAVFObjC.h; sourceTree = "<group>"; };
                                CDF2B005182053DF00F2B424 /* mediasource */,
                                59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */,
                                59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */,
-                               9AC6F02D21148F9F00CBDA06 /* MediaEngineDecodingConfigurationMock.cpp */,
-                               9AC6F02F21148FA200CBDA06 /* MediaEngineDecodingConfigurationMock.h */,
-                               9AC6F02E21148FA100CBDA06 /* MediaEngineEncodingConfigurationMock.cpp */,
-                               9AC6F03021148FA400CBDA06 /* MediaEngineEncodingConfigurationMock.h */,
+                               9AC6F02D21148F9F00CBDA06 /* MediaEngineConfigurationFactoryMock.cpp */,
+                               9AC6F02F21148FA200CBDA06 /* MediaEngineConfigurationFactoryMock.h */,
                                077B64141B95F703003E9AD5 /* MediaPlaybackTargetMock.cpp */,
                                077B64151B95F703003E9AD5 /* MediaPlaybackTargetMock.h */,
                                077B64101B94F12E003E9AD5 /* MediaPlaybackTargetPickerMock.cpp */,
                9AC6F02021148F1E00CBDA06 /* mediacapabilities */ = {
                        isa = PBXGroup;
                        children = (
-                               9AC6F02121148F5000CBDA06 /* MediaEngineConfiguration.cpp */,
-                               9AC6F02321148F5200CBDA06 /* MediaEngineConfiguration.h */,
+                               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */,
+                               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */,
+                               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */,
+                               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */,
+                               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */,
+                               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */,
+                               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */,
                                9AC6F02221148F5100CBDA06 /* MediaEngineConfigurationFactory.cpp */,
                                9AC6F02521148F5400CBDA06 /* MediaEngineConfigurationFactory.h */,
-                               9AC6F02421148F5300CBDA06 /* MediaEngineDecodingConfiguration.h */,
-                               9AC6F02621148F5500CBDA06 /* MediaEngineEncodingConfiguration.h */,
+                               CD0C8B582141C8CA0062F59D /* MediaCapabilitiesInfo.h */,
                        );
                        name = mediacapabilities;
                        sourceTree = "<group>";
                CDBD3D271FE85C920012C545 /* mediacapabilities */ = {
                        isa = PBXGroup;
                        children = (
-                               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */,
                                CDBD3D3C1FE85CC20012C545 /* AudioConfiguration.idl */,
                                CDA130BD1FEB332D00F53254 /* MediaCapabilities.cpp */,
                                CDBD3D321FE85CBE0012C545 /* MediaCapabilities.h */,
                                CDBD3D2F1FE85CBC0012C545 /* MediaCapabilities.idl */,
-                               CDBD3D3D1FE85CC30012C545 /* MediaCapabilitiesInfo.h */,
                                CDBD3D331FE85CBE0012C545 /* MediaCapabilitiesInfo.idl */,
-                               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */,
                                CDBD3D291FE85CB90012C545 /* MediaConfiguration.idl */,
-                               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */,
                                CDBD3D3B1FE85CC20012C545 /* MediaDecodingConfiguration.idl */,
-                               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */,
                                CDBD3D2E1FE85CBC0012C545 /* MediaDecodingType.idl */,
-                               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */,
                                CDBD3D2A1FE85CBA0012C545 /* MediaEncodingConfiguration.idl */,
-                               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */,
                                CDBD3D2D1FE85CBC0012C545 /* MediaEncodingType.idl */,
                                CDA130BB1FEB332C00F53254 /* NavigatorMediaCapabilities.cpp */,
                                CDBD3D391FE85CC10012C545 /* NavigatorMediaCapabilities.h */,
                                CDBD3D3F1FE85CC30012C545 /* ScreenColorGamut.idl */,
                                CDBD3D2C1FE85CBB0012C545 /* ScreenLuminance.h */,
                                CDBD3D301FE85CBD0012C545 /* ScreenLuminance.idl */,
-                               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */,
                                CDBD3D281FE85CB80012C545 /* VideoConfiguration.idl */,
                        );
                        path = mediacapabilities;
diff --git a/Source/WebCore/platform/MediaCapabilitiesInfo.h b/Source/WebCore/platform/MediaCapabilitiesInfo.h
new file mode 100644 (file)
index 0000000..2dde787
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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
+
+namespace WebCore {
+    
+struct MediaCapabilitiesInfo {
+    bool supported { false };
+    bool smooth { false };
+    bool powerEfficient { false };
+};
+    
+}
@@ -33,8 +33,8 @@ namespace WebCore {
 struct AudioConfiguration {
     String contentType;
     String channels;
-    std::optional<uint64_t> bitrate;
-    std::optional<uint32_t> samplerate;
+    uint64_t bitrate;
+    uint32_t samplerate;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp b/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp
deleted file mode 100644 (file)
index 30957ff..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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"
-#include "MediaEngineConfiguration.h"
-
-namespace WebCore {
-
-MediaEngineVideoConfiguration::MediaEngineVideoConfiguration(VideoConfiguration&& config)
-    : m_type(config.contentType)
-    , m_width(config.width)
-    , m_height(config.height)
-    , m_bitrate(config.bitrate)
-    , m_frameRateNumerator(0)
-    , m_frameRateDenominator(1)
-{
-    bool ok = false;
-    m_frameRateNumerator = config.framerate.toDouble(&ok);
-    if (ok)
-        return;
-
-    auto frameratePieces = config.framerate.split('/');
-    if (frameratePieces.size() != 2)
-        return;
-
-    double numerator = frameratePieces[0].toDouble(&ok);
-    if (!ok || !numerator)
-        return;
-
-    double denominator = frameratePieces[1].toDouble(&ok);
-    if (!ok || !denominator)
-        return;
-
-    if (!std::isfinite(numerator) || !std::isfinite(denominator))
-        return;
-
-    m_frameRateNumerator = numerator;
-    m_frameRateDenominator = denominator;
-}
-
-MediaEngineAudioConfiguration::MediaEngineAudioConfiguration(AudioConfiguration&& config)
-    : m_type(config.contentType)
-    , m_channels(config.channels)
-    , m_bitrate(0)
-    , m_samplerate(0)
-{
-    if (config.bitrate)
-        m_bitrate = config.bitrate.value();
-
-    if (config.samplerate)
-        m_samplerate = config.samplerate.value();
-}
-
-MediaEngineConfiguration::MediaEngineConfiguration(MediaConfiguration&& config)
-{
-    if (config.audio)
-        m_audioConfiguration = MediaEngineAudioConfiguration::create(config.audio.value());
-
-    if (config.video)
-        m_videoConfiguration = MediaEngineVideoConfiguration::create(config.video.value());
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h b/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h
deleted file mode 100644 (file)
index aa3477e..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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
-
-#include "AudioConfiguration.h"
-#include "ContentType.h"
-#include "IntSize.h"
-#include "MediaConfiguration.h"
-#include "VideoConfiguration.h"
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-class MediaEngineConfiguration;
-
-class MediaEngineVideoConfiguration : public RefCounted<MediaEngineVideoConfiguration> {
-public:
-    static Ref<MediaEngineVideoConfiguration> create(VideoConfiguration& config)
-    {
-        return adoptRef(*new MediaEngineVideoConfiguration(WTFMove(config)));
-    };
-
-    ContentType contentType() const { return m_type; };
-    IntSize size() const { return IntSize(m_width, m_height); };
-    uint64_t bitrate() const { return m_bitrate; };
-    double framerate() const { return m_frameRateNumerator / m_frameRateDenominator; };
-
-private:
-    MediaEngineVideoConfiguration(VideoConfiguration&&);
-
-    ContentType m_type;
-    uint32_t m_width;
-    uint32_t m_height;
-    uint64_t m_bitrate;
-    double m_frameRateNumerator;
-    double m_frameRateDenominator;
-};
-
-class MediaEngineAudioConfiguration : public RefCounted<MediaEngineAudioConfiguration> {
-public:
-    static Ref<MediaEngineAudioConfiguration> create(AudioConfiguration& config)
-    {
-        return adoptRef(*new MediaEngineAudioConfiguration(WTFMove(config)));
-    };
-
-    ContentType contentType() const { return m_type; };
-    String channels() const { return m_channels; };
-    uint64_t bitrate() const { return m_bitrate; };
-    uint32_t samplerate() const { return m_samplerate; };
-
-private:
-    MediaEngineAudioConfiguration(AudioConfiguration&&);
-
-    ContentType m_type;
-    String m_channels;
-    uint64_t m_bitrate;
-    uint32_t m_samplerate;
-};
-
-class MediaEngineConfiguration : public RefCounted<MediaEngineConfiguration> {
-public:
-    MediaEngineConfiguration(MediaConfiguration&&);
-    virtual ~MediaEngineConfiguration() = default;
-
-    enum class ImplementationType {
-        Mock,
-    };
-
-    virtual ImplementationType implementationType() const = 0;
-
-    RefPtr<MediaEngineAudioConfiguration> audioConfiguration() const { return m_audioConfiguration; };
-    RefPtr<MediaEngineVideoConfiguration> videoConfiguration() const { return m_videoConfiguration; };
-
-private:
-    RefPtr<MediaEngineAudioConfiguration> m_audioConfiguration;
-    RefPtr<MediaEngineVideoConfiguration> m_videoConfiguration;
-};
-
-} // namespace WebCore
-
-#define SPECIALIZE_TYPE_TRAITS_MEDIA_ENGINE_CONFIGURATION(ToValueTypeName, ImplementationTypeName) \
-    SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName)                       \
-    static bool isType(const WebCore::MediaEngineConfiguration& config) { return config.implementationType() == ImplementationTypeName; } \
-    SPECIALIZE_TYPE_TRAITS_END()
index b153885..c0a1c0d 100644 (file)
 #include "config.h"
 #include "MediaEngineConfigurationFactory.h"
 
-#include "DeprecatedGlobalSettings.h"
-#include "MediaEngineDecodingConfiguration.h"
-#include "MediaEngineDecodingConfigurationMock.h"
-#include "MediaEngineEncodingConfiguration.h"
-#include "MediaEngineEncodingConfigurationMock.h"
+#include "MediaCapabilitiesInfo.h"
+#include "MediaDecodingConfiguration.h"
+#include "MediaEncodingConfiguration.h"
+#include "MediaEngineConfigurationFactoryMock.h"
+#include <wtf/NeverDestroyed.h>
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
@@ -42,22 +43,68 @@ static bool& mockEnabled()
     return enabled;
 }
 
-void MediaEngineConfigurationFactory::createDecodingConfiguration(MediaDecodingConfiguration& config, MediaEngineConfigurationFactory::DecodingConfigurationCallback& callback)
+struct MediaEngineFactory {
+    void(*createDecodingConfiguration)(MediaDecodingConfiguration&, MediaEngineConfigurationFactory::DecodingConfigurationCallback&&);
+    void(*createEncodingConfiguration)(MediaEncodingConfiguration&, MediaEngineConfigurationFactory::EncodingConfigurationCallback&&);
+};
+
+using FactoryVector = Vector<MediaEngineFactory>;
+static const FactoryVector& factories()
+{
+    static NeverDestroyed<FactoryVector> factories = makeNeverDestroyed(FactoryVector({ }));
+    return factories;
+}
+
+void MediaEngineConfigurationFactory::createDecodingConfiguration(MediaDecodingConfiguration&& config, MediaEngineConfigurationFactory::DecodingConfigurationCallback&& callback)
 {
     if (mockEnabled()) {
-        MediaEngineDecodingConfigurationMock::create(config, callback);
+        MediaEngineConfigurationFactoryMock::createDecodingConfiguration(config, WTFMove(callback));
         return;
     }
-    callback(nullptr);
+
+    auto factoryCallback = [] (auto factoryCallback, auto nextFactory, auto config, auto&& callback) mutable {
+        if (nextFactory == factories().end()) {
+            callback({ });
+            return;
+        }
+
+        auto& factory = *nextFactory;
+        factory.createDecodingConfiguration(config, [factoryCallback, nextFactory, config, callback = WTFMove(callback)] (auto&& info) mutable {
+            if (info.supported) {
+                callback(WTFMove(info));
+                return;
+            }
+
+            factoryCallback(factoryCallback, ++nextFactory, config, WTFMove(callback));
+        });
+    };
+    factoryCallback(factoryCallback, factories().begin(), config, WTFMove(callback));
 }
 
-void MediaEngineConfigurationFactory::createEncodingConfiguration(MediaEncodingConfiguration& config, MediaEngineConfigurationFactory::EncodingConfigurationCallback& callback)
+void MediaEngineConfigurationFactory::createEncodingConfiguration(MediaEncodingConfiguration&& config, MediaEngineConfigurationFactory::EncodingConfigurationCallback&& callback)
 {
     if (mockEnabled()) {
-        MediaEngineEncodingConfigurationMock::create(config, callback);
+        MediaEngineConfigurationFactoryMock::createEncodingConfiguration(config, WTFMove(callback));
         return;
     }
-    callback(nullptr);
+
+    auto factoryCallback = [] (auto factoryCallback, auto nextFactory, auto config, auto&& callback) mutable {
+        if (nextFactory == factories().end()) {
+            callback({ });
+            return;
+        }
+
+        auto& factory = *nextFactory;
+        factory.createEncodingConfiguration(config, [factoryCallback, nextFactory, config, callback = WTFMove(callback)] (auto&& info) mutable {
+            if (info.supported) {
+                callback(WTFMove(info));
+                return;
+            }
+
+            factoryCallback(factoryCallback, ++nextFactory, config, WTFMove(callback));
+        });
+    };
+    factoryCallback(factoryCallback, factories().begin(), config, WTFMove(callback));
 }
 
 void MediaEngineConfigurationFactory::enableMock()
index 7eecb63..4b51e95 100644 (file)
 
 #pragma once
 
-#include "MediaCapabilities.h"
-#include "MediaDecodingConfiguration.h"
-#include "MediaEngineDecodingConfiguration.h"
-#include "MediaEngineEncodingConfiguration.h"
-#include <wtf/Forward.h>
+#include <wtf/Function.h>
 
 namespace WebCore {
 
+struct MediaCapabilitiesInfo;
+struct MediaDecodingConfiguration;
+struct MediaEncodingConfiguration;
+
 class MediaEngineConfigurationFactory {
 public:
-    using DecodingConfigurationCallback = WTF::Function<void(RefPtr<MediaEngineDecodingConfiguration>)>;
-    using EncodingConfigurationCallback = WTF::Function<void(RefPtr<MediaEngineEncodingConfiguration>)>;
+    using DecodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesInfo&&)>;
+    using EncodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesInfo&&)>;
 
-    static void createDecodingConfiguration(MediaDecodingConfiguration&, DecodingConfigurationCallback&);
-    static void createEncodingConfiguration(MediaEncodingConfiguration&, EncodingConfigurationCallback&);
+    static void createDecodingConfiguration(MediaDecodingConfiguration&&, DecodingConfigurationCallback&&);
+    static void createEncodingConfiguration(MediaEncodingConfiguration&&, EncodingConfigurationCallback&&);
 
     WEBCORE_EXPORT static void enableMock();
     WEBCORE_EXPORT static void disableMock();
diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h b/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h
deleted file mode 100644 (file)
index 2f763aa..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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
-
-#include "MediaEncodingConfiguration.h"
-#include "MediaEngineConfiguration.h"
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class MediaEngineEncodingConfiguration : public MediaEngineConfiguration {
-public:
-    MediaEngineEncodingConfiguration(MediaEncodingConfiguration&& config)
-        : MediaEngineConfiguration(reinterpret_cast<MediaConfiguration&&>(config))
-        , m_encodingType(config.type)
-    {
-    }
-
-    virtual ~MediaEngineEncodingConfiguration() = default;
-
-    virtual bool canEncodeMedia() { return false; };
-    virtual bool canSmoothlyEncodeMedia() { return false; };
-    virtual bool canPowerEfficientlyEncodeMedia() { return false; };
-
-    MediaEncodingType encodingType() const { return m_encodingType; };
-
-private:
-    MediaEncodingType m_encodingType;
-};
-
-} // namespace WebCore
@@ -34,7 +34,7 @@ struct VideoConfiguration {
     uint32_t width;
     uint32_t height;
     uint64_t bitrate;
-    String framerate;
+    double framerate;
 };
 
 }
index 484c1b0..d8263d5 100644 (file)
@@ -34,6 +34,9 @@
 #include <wtf/RunLoop.h>
 #include <wtf/text/WTFString.h>
 
+typedef struct __CVBuffer *CVPixelBufferRef;
+typedef struct __IOSurface *IOSurfaceRef;
+
 namespace WTF {
 class MediaTime;
 }
diff --git a/Source/WebCore/platform/mock/MediaEngineConfigurationFactoryMock.cpp b/Source/WebCore/platform/mock/MediaEngineConfigurationFactoryMock.cpp
new file mode 100644 (file)
index 0000000..3ca1e4e
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2018 Igalia S.L.
+ *
+ * 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.
+ *
+ * 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
+ * HOLDER 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"
+#include "MediaEngineConfigurationFactoryMock.h"
+
+#include "ContentType.h"
+#include "MediaCapabilitiesInfo.h"
+#include "MediaDecodingConfiguration.h"
+#include "MediaEncodingConfiguration.h"
+
+namespace WebCore {
+
+static bool canDecodeMedia(const MediaDecodingConfiguration& configuration)
+{
+    // The mock implementation supports only local file playback.
+    if (configuration.type == MediaDecodingType::MediaSource)
+        return false;
+
+    // Maxing out video decoding support at 720P.
+    auto videoConfig = configuration.video;
+    if (videoConfig && videoConfig->width > 1280 && videoConfig->height > 720)
+        return false;
+
+    // Audio decoding support limited to audio/mp4.
+    auto audioConfig = configuration.audio;
+    if (audioConfig)
+        return ContentType(audioConfig->contentType).containerType() == "audio/mp4";
+
+    return true;
+}
+
+static bool canSmoothlyDecodeMedia(const MediaDecodingConfiguration& configuration)
+{
+    auto videoConfig = configuration.video;
+    if (videoConfig && videoConfig->framerate > 30)
+        return false;
+
+    auto audioConfig = configuration.audio;
+    if (audioConfig)
+        return audioConfig->channels == "2";
+
+    return true;
+}
+
+static bool canPowerEfficientlyDecodeMedia(const MediaDecodingConfiguration& configuration)
+{
+    auto videoConfig = configuration.video;
+    if (videoConfig && ContentType(videoConfig->contentType).containerType() != "video/mp4")
+        return false;
+
+    auto audioConfig = configuration.audio;
+    if (audioConfig)
+        return audioConfig->bitrate <= 1000;
+
+    return true;
+}
+
+static bool canEncodeMedia(const MediaEncodingConfiguration& configuration)
+{
+    // The mock implementation supports only local file playback.
+    if (configuration.type == MediaEncodingType::Record)
+        return false;
+
+    // Maxing out video encoding support at 720P.
+    auto videoConfig = configuration.video;
+    if (videoConfig && videoConfig->width > 1280 && videoConfig->height > 720)
+        return false;
+
+    // Audio encoding support limited to audio/mp4.
+    auto audioConfig = configuration.audio;
+    if (audioConfig && ContentType(audioConfig->contentType).containerType() != "audio/mp4")
+        return false;
+
+    return true;
+}
+
+static bool canSmoothlyEncodeMedia(const MediaEncodingConfiguration& configuration)
+{
+    auto videoConfig = configuration.video;
+    if (videoConfig && videoConfig->framerate > 30)
+        return false;
+
+    auto audioConfig = configuration.audio;
+    if (audioConfig && audioConfig->channels != "2")
+        return false;
+
+    return true;
+}
+
+static bool canPowerEfficientlyEncodeMedia(const MediaEncodingConfiguration& configuration)
+{
+    auto videoConfig = configuration.video;
+    if (videoConfig && ContentType(videoConfig->contentType).containerType() != "video/mp4")
+        return false;
+
+    auto audioConfig = configuration.audio;
+    if (audioConfig && audioConfig->bitrate > 1000)
+        return false;
+
+    return true;
+}
+
+void MediaEngineConfigurationFactoryMock::createDecodingConfiguration(MediaDecodingConfiguration& configuration, DecodingConfigurationCallback&& callback)
+{
+    if (!canDecodeMedia(configuration)) {
+        callback({ });
+        return;
+    }
+    callback({ true, canSmoothlyDecodeMedia(configuration), canPowerEfficientlyDecodeMedia(configuration) });
+}
+
+void MediaEngineConfigurationFactoryMock::createEncodingConfiguration(MediaEncodingConfiguration& configuration, EncodingConfigurationCallback&& callback)
+{
+    if (!canEncodeMedia(configuration)) {
+        callback({ });
+        return;
+    }
+    callback({ true, canSmoothlyEncodeMedia(configuration), canPowerEfficientlyEncodeMedia(configuration) });
+}
+
+} // namespace WebCore
 
 #pragma once
 
-#include "MediaDecodingConfiguration.h"
-#include "MediaEngineConfiguration.h"
-
-#include <wtf/Forward.h>
+#include <wtf/Function.h>
 
 namespace WebCore {
 
-class MediaEngineDecodingConfiguration : public MediaEngineConfiguration {
-public:
-    MediaEngineDecodingConfiguration(MediaDecodingConfiguration&& config)
-        : MediaEngineConfiguration(reinterpret_cast<MediaConfiguration&&>(config))
-        , m_decodingType(config.type)
-    {
-    }
-
-    virtual ~MediaEngineDecodingConfiguration() = default;
-
-    virtual bool canDecodeMedia() { return false; };
-    virtual bool canSmoothlyDecodeMedia() { return false; };
-    virtual bool canPowerEfficientlyDecodeMedia() { return false; };
+struct MediaCapabilitiesInfo;
+struct MediaDecodingConfiguration;
+struct MediaEncodingConfiguration;
 
-    MediaDecodingType decodingType() const { return m_decodingType; };
+struct MediaEngineConfigurationFactoryMock {
+    using DecodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesInfo&&)>;
+    using EncodingConfigurationCallback = WTF::Function<void(MediaCapabilitiesInfo&&)>;
 
-private:
-    MediaDecodingType m_decodingType;
+    static void createDecodingConfiguration(MediaDecodingConfiguration&, DecodingConfigurationCallback&&);
+    static void createEncodingConfiguration(MediaEncodingConfiguration&, EncodingConfigurationCallback&&);
 };
 
-} // namespace WebCore
+}
diff --git a/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp b/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp
deleted file mode 100644 (file)
index 301ce19..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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"
-#include "MediaEngineDecodingConfigurationMock.h"
-
-#include "ContentType.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-bool MediaEngineDecodingConfigurationMock::canDecodeMedia()
-{
-    // The mock implementation supports only local file playback.
-    if (decodingType() == MediaDecodingType::MediaSource)
-        return false;
-
-    // Maxing out video decoding support at 720P.
-    auto videoConfig = videoConfiguration();
-    if (videoConfig) {
-        IntSize size = videoConfig->size();
-        if (size.width() > 1280 && size.height() > 720)
-            return false;
-    }
-
-    // Audio decoding support limited to audio/mp4.
-    auto audioConfig = audioConfiguration();
-    if (audioConfig)
-        return audioConfig->contentType().containerType() == "audio/mp4";
-
-    return true;
-}
-
-bool MediaEngineDecodingConfigurationMock::canSmoothlyDecodeMedia()
-{
-    auto videoConfig = videoConfiguration();
-    if (videoConfig) {
-        if (videoConfig->framerate() > 30)
-            return false;
-    }
-
-    RefPtr<MediaEngineAudioConfiguration> audioConfig = audioConfiguration();
-    if (audioConfig)
-        return audioConfig->channels() == "2";
-
-    return true;
-}
-
-bool MediaEngineDecodingConfigurationMock::canPowerEfficientlyDecodeMedia()
-{
-    auto videoConfig = videoConfiguration();
-    if (videoConfig) {
-        if (videoConfig->contentType().containerType() != "video/mp4")
-            return false;
-    }
-
-    auto audioConfig = audioConfiguration();
-    if (audioConfig)
-        return audioConfig->bitrate() <= 1000;
-
-    return true;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h b/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h
deleted file mode 100644 (file)
index 61f3829..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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
-
-#include "MediaDecodingConfiguration.h"
-#include "MediaEngineConfigurationFactory.h"
-#include "MediaEngineDecodingConfiguration.h"
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class MediaEngineDecodingConfigurationMock final : public MediaEngineDecodingConfiguration {
-public:
-    static void create(MediaDecodingConfiguration& config, MediaEngineConfigurationFactory::DecodingConfigurationCallback& callback)
-    {
-        auto mockConfig = adoptRef(new MediaEngineDecodingConfigurationMock(WTFMove(config)));
-        callback(mockConfig);
-    };
-
-    ImplementationType implementationType() const final { return ImplementationType::Mock; }
-    bool canDecodeMedia() final;
-    bool canSmoothlyDecodeMedia() final;
-    bool canPowerEfficientlyDecodeMedia() final;
-
-private:
-    explicit MediaEngineDecodingConfigurationMock(MediaDecodingConfiguration&& config)
-        : MediaEngineDecodingConfiguration(WTFMove(config)) { };
-};
-
-}
-
-SPECIALIZE_TYPE_TRAITS_MEDIA_ENGINE_CONFIGURATION(WebCore::MediaEngineDecodingConfigurationMock, WebCore::MediaEngineDecodingConfiguration::ImplementationType::Mock);
diff --git a/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp b/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp
deleted file mode 100644 (file)
index 6802491..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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"
-#include "MediaEngineEncodingConfigurationMock.h"
-
-#include "ContentType.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-bool MediaEngineEncodingConfigurationMock::canEncodeMedia()
-{
-    // The mock implementation supports only local file playback.
-    if (encodingType() == MediaEncodingType::Record)
-        return false;
-
-    // Maxing out video encoding support at 720P.
-    auto videoConfig = videoConfiguration();
-    if (videoConfig) {
-        IntSize size = videoConfig->size();
-        if (size.width() > 1280 && size.height() > 720)
-            return false;
-    }
-
-    // Audio encoding support limited to audio/mp4.
-    auto audioConfig = audioConfiguration();
-    if (audioConfig && (audioConfig->contentType().containerType() != "audio/mp4"))
-        return false;
-
-    return true;
-}
-
-bool MediaEngineEncodingConfigurationMock::canSmoothlyEncodeMedia()
-{
-    auto videoConfig = videoConfiguration();
-    if (videoConfig) {
-        if (videoConfig->framerate() > 30)
-            return false;
-    }
-
-    auto audioConfig = audioConfiguration();
-    if (audioConfig && audioConfig->channels() != "2")
-        return false;
-
-    return true;
-}
-
-bool MediaEngineEncodingConfigurationMock::canPowerEfficientlyEncodeMedia()
-{
-    auto videoConfig = videoConfiguration();
-    if (videoConfig && (videoConfig->contentType().containerType() != "video/mp4"))
-        return false;
-
-    auto audioConfig = audioConfiguration();
-    if (audioConfig && (audioConfig->bitrate() > 1000))
-        return false;
-
-    return true;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h b/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h
deleted file mode 100644 (file)
index 8c405af..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2018 Igalia S.L.
- *
- * 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.
- *
- * 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
- * HOLDER 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
-
-#include "MediaEncodingConfiguration.h"
-#include "MediaEngineConfigurationFactory.h"
-#include "MediaEngineEncodingConfiguration.h"
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class MediaEngineEncodingConfigurationMock final : public MediaEngineEncodingConfiguration {
-public:
-    static void create(MediaEncodingConfiguration& config, MediaEngineConfigurationFactory::EncodingConfigurationCallback& callback)
-    {
-        auto mockConfig = adoptRef(new MediaEngineEncodingConfigurationMock(WTFMove(config)));
-        callback(mockConfig);
-    };
-
-    ImplementationType implementationType() const final { return ImplementationType::Mock; }
-    bool canEncodeMedia() final;
-    bool canSmoothlyEncodeMedia() final;
-    bool canPowerEfficientlyEncodeMedia() final;
-
-private:
-    explicit MediaEngineEncodingConfigurationMock(MediaEncodingConfiguration&& config)
-        : MediaEngineEncodingConfiguration(WTFMove(config)) { };
-};
-
-}
-
-SPECIALIZE_TYPE_TRAITS_MEDIA_ENGINE_CONFIGURATION(WebCore::MediaEngineEncodingConfigurationMock, WebCore::MediaEngineEncodingConfiguration::ImplementationType::Mock);