WebKit Bugzilla
Attachment 346480 Details for
Bug 187850
: [MediaCapabilities] Platform integration
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187850-20180803160939.patch (text/plain), 72.00 KB, created by
Philippe Normand
on 2018-08-03 07:09:41 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Philippe Normand
Created:
2018-08-03 07:09:41 PDT
Size:
72.00 KB
patch
obsolete
>Subversion Revision: 234539 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 11982cf5aeaf9aac86f9620b841407fb3db56490..dfae3e478a38b668b48890b54d9df999e43139d0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,77 @@ >+2018-08-03 Philippe Normand <pnormand@igalia.com> >+ >+ [MediaCapabilities] Platform integration >+ https://bugs.webkit.org/show_bug.cgi?id=187850 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Mock platform support for the MediaCapabilities specification. >+ >+ Test: media/mediacapabilities/mock-decodingInfo.html >+ media/mediacapabilities/mock-encodingInfo.html >+ >+ * Modules/mediacapabilities/MediaCapabilities.cpp: >+ (WebCore::MediaCapabilities::decodingInfo): >+ (WebCore::MediaCapabilities::encodingInfo): >+ * Modules/mediacapabilities/MediaCapabilitiesInfo.h: >+ (WebCore::MediaCapabilitiesInfo::create): >+ * PlatformGTK.cmake: >+ * PlatformMac.cmake: >+ * PlatformWPE.cmake: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * platform/mediacapabilities/MediaEngineConfiguration.cpp: Added. >+ (WebCore::MediaEngineVideoConfiguration::MediaEngineVideoConfiguration): >+ (WebCore::MediaEngineAudioConfiguration::MediaEngineAudioConfiguration): >+ (WebCore::MediaEngineConfiguration::MediaEngineConfiguration): >+ * platform/mediacapabilities/MediaEngineConfiguration.h: Added. >+ (WebCore::MediaEngineVideoConfiguration::create): >+ (WebCore::MediaEngineVideoConfiguration::contentType const): >+ (WebCore::MediaEngineVideoConfiguration::size const): >+ (WebCore::MediaEngineVideoConfiguration::bitrate const): >+ (WebCore::MediaEngineVideoConfiguration::framerate const): >+ (WebCore::MediaEngineAudioConfiguration::create): >+ (WebCore::MediaEngineAudioConfiguration::contentType const): >+ (WebCore::MediaEngineAudioConfiguration::channels const): >+ (WebCore::MediaEngineAudioConfiguration::bitrate const): >+ (WebCore::MediaEngineAudioConfiguration::samplerate const): >+ (WebCore::MediaEngineConfiguration::audioConfiguration const): >+ (WebCore::MediaEngineConfiguration::videoConfiguration const): >+ * platform/mediacapabilities/MediaEngineConfigurationFactory.cpp: Added. >+ (WebCore::mockEnabled): >+ (WebCore::MediaEngineConfigurationFactory::createDecodingConfiguration): >+ (WebCore::MediaEngineConfigurationFactory::createEncodingConfiguration): >+ (WebCore::MediaEngineConfigurationFactory::enableMock): >+ (WebCore::MediaEngineConfigurationFactory::disableMock): >+ * platform/mediacapabilities/MediaEngineConfigurationFactory.h: Added. >+ * platform/mediacapabilities/MediaEngineDecodingConfiguration.h: Added. >+ (WebCore::MediaEngineDecodingConfiguration::MediaEngineDecodingConfiguration): >+ (WebCore::MediaEngineDecodingConfiguration::canDecodeMedia): >+ (WebCore::MediaEngineDecodingConfiguration::canSmoothlyDecodeMedia): >+ (WebCore::MediaEngineDecodingConfiguration::canPowerEfficientlyDecodeMedia): >+ (WebCore::MediaEngineDecodingConfiguration::decodingType const): >+ * platform/mediacapabilities/MediaEngineEncodingConfiguration.h: Added. >+ (WebCore::MediaEngineEncodingConfiguration::MediaEngineEncodingConfiguration): >+ (WebCore::MediaEngineEncodingConfiguration::canEncodeMedia): >+ (WebCore::MediaEngineEncodingConfiguration::canSmoothlyEncodeMedia): >+ (WebCore::MediaEngineEncodingConfiguration::canPowerEfficientlyEncodeMedia): >+ (WebCore::MediaEngineEncodingConfiguration::encodingType const): >+ * platform/mock/MediaEngineDecodingConfigurationMock.cpp: Added. >+ (WebCore::MediaEngineDecodingConfigurationMock::canDecodeMedia): >+ (WebCore::MediaEngineDecodingConfigurationMock::canSmoothlyDecodeMedia): >+ (WebCore::MediaEngineDecodingConfigurationMock::canPowerEfficientlyDecodeMedia): >+ * platform/mock/MediaEngineDecodingConfigurationMock.h: Added. >+ * platform/mock/MediaEngineEncodingConfigurationMock.cpp: Added. >+ (WebCore::MediaEngineEncodingConfigurationMock::canEncodeMedia): >+ (WebCore::MediaEngineEncodingConfigurationMock::canSmoothlyEncodeMedia): >+ (WebCore::MediaEngineEncodingConfigurationMock::canPowerEfficientlyEncodeMedia): >+ * platform/mock/MediaEngineEncodingConfigurationMock.h: Added. >+ * testing/Internals.cpp: >+ (WebCore::Internals::resetToConsistentState): >+ (WebCore::Internals::enableMockMediaCapabilities): >+ * testing/Internals.h: >+ * testing/Internals.idl: >+ > 2018-08-02 Ryosuke Niwa <rniwa@webkit.org> > > Release assert when throwing exceptions in custom element reactions >diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp b/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp >index fdfb6df76b99b2035e05272777928403ab438ca4..88b3383da73742d82a3cf8a0bbd2f98257d75341 100644 >--- a/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp >+++ b/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp >@@ -27,8 +27,10 @@ > #include "MediaCapabilities.h" > > #include "ContentType.h" >+#include "JSMediaCapabilitiesInfo.h" > #include "MediaDecodingConfiguration.h" > #include "MediaEncodingConfiguration.h" >+#include "MediaEngineConfigurationFactory.h" > #include <wtf/HashSet.h> > > namespace WebCore { >@@ -195,8 +197,36 @@ void MediaCapabilities::decodingInfo(MediaDecodingConfiguration&& configuration, > // 5. In parallel, run the create a MediaCapabilitiesInfo algorithm with configuration and resolve p with its result. > // 6. Return p. > m_taskQueue.enqueueTask([configuration = WTFMove(configuration), promise = WTFMove(promise)] () mutable { >- UNUSED_PARAM(configuration); >- UNUSED_PARAM(promise); >+ >+ // 2.2.3 If configuration is of type MediaDecodingConfiguration, run the following substeps: >+ MediaEngineConfigurationFactory::DecodingConfigurationCallback callback = [promise = WTFMove(promise)] (RefPtr<MediaEngineDecodingConfiguration> 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::createDecodingConfiguration(configuration, callback); > }); > } > >@@ -217,8 +247,40 @@ void MediaCapabilities::encodingInfo(MediaEncodingConfiguration&& configuration, > // 5. In parallel, run the create a MediaCapabilitiesInfo algorithm with configuration and resolve p with its result. > // 6. Return p. > m_taskQueue.enqueueTask([configuration = WTFMove(configuration), promise = WTFMove(promise)] () mutable { >- UNUSED_PARAM(configuration); >- UNUSED_PARAM(promise); >+ >+ // 2.2.4. If configuration is of type MediaEncodingConfiguration, run the following substeps: >+ MediaEngineConfigurationFactory::EncodingConfigurationCallback callback = [promise = WTFMove(promise)] (RefPtr<MediaEngineEncodingConfiguration> 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::createEncodingConfiguration(configuration, callback); >+ > }); > } > >diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h b/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h >index 119a127a5590465fa2fd7ace124f5e3fc741fa4e..af7adb8fc878ea2b7f8d672081be7ce06019a78b 100644 >--- a/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h >+++ b/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h >@@ -31,6 +31,14 @@ 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; } > >@@ -41,6 +49,8 @@ public: > void setPowerEfficient(bool powerEfficient) { m_powerEfficient = powerEfficient; } > > private: >+ MediaCapabilitiesInfo() = default; >+ > bool m_supported { false }; > bool m_smooth { false }; > bool m_powerEfficient { false }; >diff --git a/Source/WebCore/PlatformGTK.cmake b/Source/WebCore/PlatformGTK.cmake >index ee5f1bb73939d95d2e0a17fe018cb217a63bce9c..e14ed4adcec092cd8830745f432c737c1e40dfd8 100644 >--- a/Source/WebCore/PlatformGTK.cmake >+++ b/Source/WebCore/PlatformGTK.cmake >@@ -30,6 +30,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES > "${WEBCORE_DIR}/platform/graphics/opentype" > "${WEBCORE_DIR}/platform/graphics/wayland" > "${WEBCORE_DIR}/platform/graphics/x11" >+ "${WEBCORE_DIR}/platform/mediacapabilities" > "${WEBCORE_DIR}/platform/mediastream/gtk" > "${WEBCORE_DIR}/platform/mediastream/gstreamer" > "${WEBCORE_DIR}/platform/mock/mediasource" >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index 5dfe74c79b523100d4ec7b8b4bdf5d835f86f291..e2f95b42635b1be82a89d6955c75946c892aa2e9 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -99,6 +99,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES > "${WEBCORE_DIR}/platform/graphics/opengl" > "${WEBCORE_DIR}/platform/graphics/mac" > "${WEBCORE_DIR}/platform/mac" >+ "${WEBCORE_DIR}/platform/mediacapabilities" > "${WEBCORE_DIR}/platform/mediastream/mac" > "${WEBCORE_DIR}/platform/network/cocoa" > "${WEBCORE_DIR}/platform/network/cf" >diff --git a/Source/WebCore/PlatformWPE.cmake b/Source/WebCore/PlatformWPE.cmake >index eaa89124fedab571cc5f78f86efabbcaa8694778..1e388f2c046d9550363aaefe0cf1ae4dcaa4e62c 100644 >--- a/Source/WebCore/PlatformWPE.cmake >+++ b/Source/WebCore/PlatformWPE.cmake >@@ -27,6 +27,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES > "${WEBCORE_DIR}/platform/graphics/wpe" > "${WEBCORE_DIR}/platform/graphics/wayland" > "${WEBCORE_DIR}/platform/mock/mediasource" >+ "${WEBCORE_DIR}/platform/mediacapabilities" > "${WEBCORE_DIR}/platform/mediastream/gstreamer" > "${WEBCORE_DIR}/platform/network/soup" > "${WEBCORE_DIR}/platform/text/icu" >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index f996d273967a5685c50995be84f17381df04b577..8502ec6953151b95c25d5a522c245dea457eedb2 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1721,6 +1721,9 @@ 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 > platform/mediastream/MediaConstraints.cpp > platform/mediastream/MediaEndpointConfiguration.cpp >@@ -1741,6 +1744,8 @@ platform/mediastream/libwebrtc/LibWebRTCProvider.cpp > > platform/mock/DeviceOrientationClientMock.cpp > platform/mock/GeolocationClientMock.cpp >+platform/mock/MediaEngineDecodingConfigurationMock.cpp >+platform/mock/MediaEngineEncodingConfigurationMock.cpp > platform/mock/MockRealtimeAudioSource.cpp > platform/mock/MockRealtimeMediaSource.cpp > platform/mock/MockRealtimeMediaSourceCenter.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 85288cd4748bbfe477a16f6b888408e1fb384f44..0c787ef495cd5fc2491fa8b1f2bdc6938c2682d9 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -10819,6 +10819,16 @@ > 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>"; }; > 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>"; }; >@@ -18805,6 +18815,10 @@ > 59C77F101054591C00506104 /* mock */ = { > isa = PBXGroup; > children = ( >+ 9AC6F02D21148F9F00CBDA06 /* MediaEngineDecodingConfigurationMock.cpp */, >+ 9AC6F02F21148FA200CBDA06 /* MediaEngineDecodingConfigurationMock.h */, >+ 9AC6F02E21148FA100CBDA06 /* MediaEngineEncodingConfigurationMock.cpp */, >+ 9AC6F03021148FA400CBDA06 /* MediaEngineEncodingConfigurationMock.h */, > CDF2B005182053DF00F2B424 /* mediasource */, > 59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */, > 59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */, >@@ -21288,6 +21302,19 @@ > path = replay; > sourceTree = "<group>"; > }; >+ 9AC6F02021148F1E00CBDA06 /* mediacapabilities */ = { >+ isa = PBXGroup; >+ children = ( >+ 9AC6F02121148F5000CBDA06 /* MediaEngineConfiguration.cpp */, >+ 9AC6F02321148F5200CBDA06 /* MediaEngineConfiguration.h */, >+ 9AC6F02221148F5100CBDA06 /* MediaEngineConfigurationFactory.cpp */, >+ 9AC6F02521148F5400CBDA06 /* MediaEngineConfigurationFactory.h */, >+ 9AC6F02421148F5300CBDA06 /* MediaEngineDecodingConfiguration.h */, >+ 9AC6F02621148F5500CBDA06 /* MediaEngineEncodingConfiguration.h */, >+ ); >+ name = mediacapabilities; >+ sourceTree = "<group>"; >+ }; > A148328B187F506800DA63A6 /* wak */ = { > isa = PBXGroup; > children = ( >@@ -24412,6 +24439,7 @@ > BCF1A5BA097832090061A123 /* platform */ = { > isa = PBXGroup; > children = ( >+ 9AC6F02021148F1E00CBDA06 /* mediacapabilities */, > 49E912A40EFAC8E6009D0CAF /* animation */, > FD31604012B026A300C1A359 /* audio */, > 1AE42F670AA4B8CB00C8612D /* cf */, >diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp b/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..57f4c5de6a92a7f79d4a04633541c1741a77afd6 >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp >@@ -0,0 +1,87 @@ >+/* >+ * 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) >+ return; >+ >+ double denominator = frameratePieces[1].toDouble(&ok); >+ if (!ok) >+ 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 >new file mode 100644 >index 0000000000000000000000000000000000000000..aa3477e62d8908573904b0730d912c0602b01a9c >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h >@@ -0,0 +1,109 @@ >+/* >+ * 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() >diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp b/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..b15388573d4ad8d0724ec299e18a18ec0c287aa0 >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp >@@ -0,0 +1,73 @@ >+/* >+ * 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 "MediaEngineConfigurationFactory.h" >+ >+#include "DeprecatedGlobalSettings.h" >+#include "MediaEngineDecodingConfiguration.h" >+#include "MediaEngineDecodingConfigurationMock.h" >+#include "MediaEngineEncodingConfiguration.h" >+#include "MediaEngineEncodingConfigurationMock.h" >+ >+namespace WebCore { >+ >+static bool& mockEnabled() >+{ >+ static bool enabled; >+ return enabled; >+} >+ >+void MediaEngineConfigurationFactory::createDecodingConfiguration(MediaDecodingConfiguration& config, MediaEngineConfigurationFactory::DecodingConfigurationCallback& callback) >+{ >+ if (mockEnabled()) { >+ MediaEngineDecodingConfigurationMock::create(config, callback); >+ return; >+ } >+ callback(nullptr); >+} >+ >+void MediaEngineConfigurationFactory::createEncodingConfiguration(MediaEncodingConfiguration& config, MediaEngineConfigurationFactory::EncodingConfigurationCallback& callback) >+{ >+ if (mockEnabled()) { >+ MediaEngineEncodingConfigurationMock::create(config, callback); >+ return; >+ } >+ callback(nullptr); >+} >+ >+void MediaEngineConfigurationFactory::enableMock() >+{ >+ mockEnabled() = true; >+} >+ >+void MediaEngineConfigurationFactory::disableMock() >+{ >+ mockEnabled() = false; >+} >+ >+} >diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h b/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7eecb6365c50f8f77827692517326cb06fefca95 >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h >@@ -0,0 +1,50 @@ >+/* >+ * 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 "MediaCapabilities.h" >+#include "MediaDecodingConfiguration.h" >+#include "MediaEngineDecodingConfiguration.h" >+#include "MediaEngineEncodingConfiguration.h" >+#include <wtf/Forward.h> >+ >+namespace WebCore { >+ >+class MediaEngineConfigurationFactory { >+public: >+ using DecodingConfigurationCallback = WTF::Function<void(RefPtr<MediaEngineDecodingConfiguration>)>; >+ using EncodingConfigurationCallback = WTF::Function<void(RefPtr<MediaEngineEncodingConfiguration>)>; >+ >+ static void createDecodingConfiguration(MediaDecodingConfiguration&, DecodingConfigurationCallback&); >+ static void createEncodingConfiguration(MediaEncodingConfiguration&, EncodingConfigurationCallback&); >+ >+ WEBCORE_EXPORT static void enableMock(); >+ WEBCORE_EXPORT static void disableMock(); >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h b/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..cdac105401ae2fc6aeac357ae49cdb59e08e9e44 >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 "MediaEngineConfiguration.h" >+ >+#include <wtf/Forward.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; }; >+ >+ MediaDecodingType decodingType() const { return m_decodingType; }; >+ >+private: >+ MediaDecodingType m_decodingType; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h b/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h >new file mode 100644 >index 0000000000000000000000000000000000000000..2f763aa75f1761fac87d6d8c07e7db0c4a27f4d5 >--- /dev/null >+++ b/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h >@@ -0,0 +1,57 @@ >+/* >+ * 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 >diff --git a/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp b/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..c6615fbe6cdb69ac9d46a42ee501b241186dab4b >--- /dev/null >+++ b/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp >@@ -0,0 +1,88 @@ >+/* >+ * 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. >+ RefPtr<MediaEngineVideoConfiguration> videoConfig = videoConfiguration(); >+ if (videoConfig) { >+ IntSize size = videoConfig->size(); >+ if (size.width() > 1280 && size.height() > 720) >+ return false; >+ } >+ >+ // Audio decoding support limited to audio/mp4. >+ RefPtr<MediaEngineAudioConfiguration> audioConfig = audioConfiguration(); >+ if (audioConfig) >+ return audioConfig->contentType().containerType() == "audio/mp4"; >+ >+ return true; >+} >+ >+bool MediaEngineDecodingConfigurationMock::canSmoothlyDecodeMedia() >+{ >+ RefPtr<MediaEngineVideoConfiguration> 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() >+{ >+ RefPtr<MediaEngineVideoConfiguration> videoConfig = videoConfiguration(); >+ if (videoConfig) { >+ if (videoConfig->contentType().containerType() != "video/mp4") >+ return false; >+ } >+ >+ RefPtr<MediaEngineAudioConfiguration> 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 >new file mode 100644 >index 0000000000000000000000000000000000000000..61f38298fc00e257335bdd6bf24bb1313ef4456c >--- /dev/null >+++ b/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h >@@ -0,0 +1,58 @@ >+/* >+ * 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 >new file mode 100644 >index 0000000000000000000000000000000000000000..86d76da321d815edc6a3f2a0a9bc88e4aa6997a9 >--- /dev/null >+++ b/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp >@@ -0,0 +1,88 @@ >+/* >+ * 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. >+ RefPtr<MediaEngineVideoConfiguration> videoConfig = videoConfiguration(); >+ if (videoConfig) { >+ IntSize size = videoConfig->size(); >+ if (size.width() > 1280 && size.height() > 720) >+ return false; >+ } >+ >+ // Audio encoding support limited to audio/mp4. >+ RefPtr<MediaEngineAudioConfiguration> audioConfig = audioConfiguration(); >+ if (audioConfig) >+ return audioConfig->contentType().containerType() == "audio/mp4"; >+ >+ return true; >+} >+ >+bool MediaEngineEncodingConfigurationMock::canSmoothlyEncodeMedia() >+{ >+ RefPtr<MediaEngineVideoConfiguration> videoConfig = videoConfiguration(); >+ if (videoConfig) { >+ if (videoConfig->framerate() > 30) >+ return false; >+ } >+ >+ RefPtr<MediaEngineAudioConfiguration> audioConfig = audioConfiguration(); >+ if (audioConfig) >+ return audioConfig->channels() == "2"; >+ >+ return true; >+} >+ >+bool MediaEngineEncodingConfigurationMock::canPowerEfficientlyEncodeMedia() >+{ >+ RefPtr<MediaEngineVideoConfiguration> videoConfig = videoConfiguration(); >+ if (videoConfig) { >+ if (videoConfig->contentType().containerType() != "video/mp4") >+ return false; >+ } >+ >+ RefPtr<MediaEngineAudioConfiguration> audioConfig = audioConfiguration(); >+ if (audioConfig) >+ return audioConfig->bitrate() <= 1000; >+ >+ return true; >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h b/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h >new file mode 100644 >index 0000000000000000000000000000000000000000..8c405aff78d651e3d7242253f60b2b30a122a37d >--- /dev/null >+++ b/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h >@@ -0,0 +1,58 @@ >+/* >+ * 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); >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index a3e96ed9651dda7baa559ed139f76de335a9b8d5..0b348e80199a68ab89d307c0fe9e462dfd9433b9 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -100,6 +100,7 @@ > #include "LibWebRTCProvider.h" > #include "LoaderStrategy.h" > #include "MallocStatistics.h" >+#include "MediaEngineConfigurationFactory.h" > #include "MediaPlayer.h" > #include "MediaProducer.h" > #include "MediaResourceLoader.h" >@@ -505,6 +506,8 @@ void Internals::resetToConsistentState(Page& page) > page.setFullscreenAutoHideDuration(0_s); > page.setFullscreenInsets({ }); > page.setFullscreenControlsHidden(false); >+ >+ MediaEngineConfigurationFactory::disableMock(); > } > > Internals::Internals(Document& document) >@@ -3464,6 +3467,11 @@ void Internals::setShouldGenerateTimestamps(SourceBuffer& buffer, bool flag) > > #endif > >+void Internals::enableMockMediaCapabilities() >+{ >+ MediaEngineConfigurationFactory::enableMock(); >+} >+ > #if ENABLE(VIDEO) > > ExceptionOr<void> Internals::beginMediaSessionInterruption(const String& interruptionString) >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 0ab570ba439a18d2fc44189fbd77f00576ae483e..3884efde17cdbd26af07f96f58a134145db5d004 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -474,6 +474,8 @@ public: > Ref<MockCDMFactory> registerMockCDM(); > #endif > >+ void enableMockMediaCapabilities(); >+ > #if ENABLE(SPEECH_SYNTHESIS) > void enableMockSpeechSynthesizer(); > #endif >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index 23aa929536888fc008613d9270342c64efed4abc..750c6f9519dafbf9177bd567f2133bef6ee28842 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -478,6 +478,7 @@ enum CompositingPolicy { > > [Conditional=LEGACY_ENCRYPTED_MEDIA] void initializeMockCDM(); > [Conditional=ENCRYPTED_MEDIA] MockCDMFactory registerMockCDM(); >+ void enableMockMediaCapabilities(); > > [Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer(); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index fea830e6f1668b1557654c43af5bcc608598c332..fb29df64cde7999e9e5f212ae2bbfdba65c06bc2 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-03 Philippe Normand <pnormand@igalia.com> >+ >+ [MediaCapabilities] Platform integration >+ https://bugs.webkit.org/show_bug.cgi?id=187850 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Mock tests for the MediaCapabilities specification. >+ >+ * media/mediacapabilities/mock-decodingInfo-expected.txt: Added. >+ * media/mediacapabilities/mock-decodingInfo.html: Added. >+ * media/mediacapabilities/mock-encodingInfo-expected.txt: Added. >+ * media/mediacapabilities/mock-encodingInfo.html: Added. >+ * media/video-test.js: >+ (checkMediaCapabilitiesInfo): >+ > 2018-08-02 Ryosuke Niwa <rniwa@webkit.org> > > Release assert when throwing exceptions in custom element reactions >diff --git a/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt b/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..6f5b7ae95ef8d992ef9f260e3580b74c3a4dcd1e >--- /dev/null >+++ b/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt >@@ -0,0 +1,66 @@ >+RUN(internals.enableMockMediaCapabilities()) >+ >+Smooth and power efficient 720P MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 24.5 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == true OK >+ >+Not smooth (too high framerate) but power efficient 720P MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 60.4/2 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == true OK >+ >+Unsupported protocol: MSE >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'media-source', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 24 } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Unsupported video resolution: 1080P >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 1080, bitrate: 1000, width: 1920, framerate: 24 } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Smooth and power efficient audio MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '2', bitrate: 1000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == true OK >+ >+Smooth but power inefficient audio MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '2', bitrate: 2000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == false OK >+ >+Not smooth but power efficient audio MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '5.1', bitrate: 1000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == true OK >+ >+Not smooth and power inefficient audio MP4 decoding >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '5.1', bitrate: 2000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Unsupported audio codec: ogg vorbis >+RUN(promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/ogg; codecs="vorbis"', channels: '2' } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+END OF TEST >+ >diff --git a/LayoutTests/media/mediacapabilities/mock-decodingInfo.html b/LayoutTests/media/mediacapabilities/mock-decodingInfo.html >new file mode 100644 >index 0000000000000000000000000000000000000000..27439001942af57253ae6e65a6f0d26db149621e >--- /dev/null >+++ b/LayoutTests/media/mediacapabilities/mock-decodingInfo.html >@@ -0,0 +1,107 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <script src=../video-test.js></script> >+ <script type="text/javascript"> >+ var promise; >+ >+ function doTest() >+ { >+ if (!window.internals) { >+ failTest("Internals is required for this test.") >+ return; >+ } >+ >+ run('internals.enableMockMediaCapabilities()'); >+ next(); >+ } >+ >+ function next() { >+ if (!tests.length) { >+ endTest(); >+ return; >+ } >+ >+ var nextTest = tests.shift(); >+ consoleWrite(''); >+ nextTest(); >+ } >+ >+ tests = [ >+ function() { >+ consoleWrite('Smooth and power efficient 720P MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 24.5 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth (too high framerate) but power efficient 720P MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 60.4/2 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported protocol: MSE'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'media-source', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 24 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported video resolution: 1080P'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 1080, bitrate: 1000, width: 1920, framerate: 24 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Smooth and power efficient audio MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '2', bitrate: 1000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Smooth but power inefficient audio MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '2', bitrate: 2000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth but power efficient audio MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '5.1', bitrate: 1000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth and power inefficient audio MP4 decoding'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '5.1', bitrate: 2000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported audio codec: ogg vorbis'); >+ run("promise = navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'audio/ogg; codecs=\"vorbis\"', channels: '2' } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ ]; >+ </script> >+</head> >+<body onload="doTest()" /> >+</html> >diff --git a/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt b/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..35427418963d100c68a20b5dc2dd16369fd00eab >--- /dev/null >+++ b/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt >@@ -0,0 +1,66 @@ >+RUN(internals.enableMockMediaCapabilities()) >+ >+Smooth and power efficient 720P MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 24.5 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == true OK >+ >+Not smooth (too high framerate) but power efficient 720P MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 60.4/2 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == true OK >+ >+Unsupported protocol: Record >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', height: 720, bitrate: 1000, width: 1280, framerate: 24 } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Unsupported video resolution: 1080P >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs="avc1"', height: 1080, bitrate: 1000, width: 1920, framerate: 24 } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Smooth and power efficient audio MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '2', bitrate: 1000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == true OK >+ >+Smooth but power inefficient audio MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '2', bitrate: 2000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == true OK >+info.powerEfficient == false OK >+ >+Not smooth but power efficient audio MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '5.1', bitrate: 1000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == true OK >+ >+Not smooth and power inefficient audio MP4 encoding >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs="mp4a.40.2"', channels: '5.1', bitrate: 2000, samplerate: 44100 } });) >+Promise resolved OK >+info.supported == true OK >+info.smooth == false OK >+info.powerEfficient == false OK >+ >+Unsupported audio codec: ogg vorbis >+RUN(promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/ogg; codecs="vorbis"', channels: '2' } });) >+Promise resolved OK >+info.supported == false OK >+info.smooth == false OK >+info.powerEfficient == false OK >+END OF TEST >+ >diff --git a/LayoutTests/media/mediacapabilities/mock-encodingInfo.html b/LayoutTests/media/mediacapabilities/mock-encodingInfo.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b724af6d83adba3100e76807f74a468c146904df >--- /dev/null >+++ b/LayoutTests/media/mediacapabilities/mock-encodingInfo.html >@@ -0,0 +1,107 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <script src=../video-test.js></script> >+ <script type="text/javascript"> >+ var promise; >+ >+ function doTest() >+ { >+ if (!window.internals) { >+ failTest("Internals is required for this test.") >+ return; >+ } >+ >+ run('internals.enableMockMediaCapabilities()'); >+ next(); >+ } >+ >+ function next() { >+ if (!tests.length) { >+ endTest(); >+ return; >+ } >+ >+ var nextTest = tests.shift(); >+ consoleWrite(''); >+ nextTest(); >+ } >+ >+ tests = [ >+ function() { >+ consoleWrite('Smooth and power efficient 720P MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 24.5 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth (too high framerate) but power efficient 720P MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 60.4/2 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported protocol: Record'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 720, bitrate: 1000, width: 1280, framerate: 24 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported video resolution: 1080P'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', video: { contentType: 'video/mp4; codecs=\"avc1\"', height: 1080, bitrate: 1000, width: 1920, framerate: 24 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Smooth and power efficient audio MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '2', bitrate: 1000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Smooth but power inefficient audio MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '2', bitrate: 2000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, true, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth but power efficient audio MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '5.1', bitrate: 1000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, true); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Not smooth and power inefficient audio MP4 encoding'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/mp4; codecs=\"mp4a.40.2\"', channels: '5.1', bitrate: 2000, samplerate: 44100 } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, true, false, false); >+ next(); >+ }, next); >+ }, >+ function() { >+ consoleWrite('Unsupported audio codec: ogg vorbis'); >+ run("promise = navigator.mediaCapabilities.encodingInfo({ type: 'transmission', audio: { contentType: 'audio/ogg; codecs=\"vorbis\"', channels: '2' } });"); >+ shouldResolve(promise).then((info) => { >+ checkMediaCapabilitiesInfo(info, false, false, false); >+ next(); >+ }, next); >+ }, >+ ]; >+ </script> >+</head> >+<body onload="doTest()" /> >+</html> >diff --git a/LayoutTests/media/video-test.js b/LayoutTests/media/video-test.js >index db8e4198d60270d03fafc2a793fef5d8c45827d5..2c3acc5fc654f356105b2e836a46fafb11c424b5 100644 >--- a/LayoutTests/media/video-test.js >+++ b/LayoutTests/media/video-test.js >@@ -487,3 +487,9 @@ function handlePromise(promise) { > function handle() { } > return promise.then(handle, handle); > } >+ >+function checkMediaCapabilitiesInfo(info, expectedSupported, expectedSmooth, expectedPowerEfficient) { >+ logResult(info.supported == expectedSupported, "info.supported == " + expectedSupported); >+ logResult(info.smooth == expectedSmooth, "info.smooth == " + expectedSmooth); >+ logResult(info.powerEfficient == expectedPowerEfficient, "info.powerEfficient == " + expectedPowerEfficient); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187850
:
345754
|
346480
|
346481
|
346484
|
346492
|
346498