Diff
Modified: trunk/LayoutTests/ChangeLog (234581 => 234582)
--- trunk/LayoutTests/ChangeLog 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/LayoutTests/ChangeLog 2018-08-05 09:26:00 UTC (rev 234582)
@@ -1,3 +1,19 @@
+2018-08-05 Philippe Normand <[email protected]>
+
+ [MediaCapabilities] Platform integration
+ https://bugs.webkit.org/show_bug.cgi?id=187850
+
+ Reviewed by Eric Carlson.
+
+ 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-03 Ryosuke Niwa <[email protected]>
Properties set on window.customElements can disappear due to GC
Added: trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt (0 => 234582)
--- trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt (rev 0)
+++ trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo-expected.txt 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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
+
Added: trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo.html (0 => 234582)
--- trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo.html (rev 0)
+++ trunk/LayoutTests/media/mediacapabilities/mock-decodingInfo.html 2018-08-05 09:26:00 UTC (rev 234582)
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <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>
Added: trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt (0 => 234582)
--- trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt (rev 0)
+++ trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo-expected.txt 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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
+
Added: trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo.html (0 => 234582)
--- trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo.html (rev 0)
+++ trunk/LayoutTests/media/mediacapabilities/mock-encodingInfo.html 2018-08-05 09:26:00 UTC (rev 234582)
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+ <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>
Modified: trunk/LayoutTests/media/video-test.js (234581 => 234582)
--- trunk/LayoutTests/media/video-test.js 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/LayoutTests/media/video-test.js 2018-08-05 09:26:00 UTC (rev 234582)
@@ -487,3 +487,9 @@
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);
+}
Modified: trunk/Source/WebCore/ChangeLog (234581 => 234582)
--- trunk/Source/WebCore/ChangeLog 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/ChangeLog 2018-08-05 09:26:00 UTC (rev 234582)
@@ -1,3 +1,77 @@
+2018-08-05 Philippe Normand <[email protected]>
+
+ [MediaCapabilities] Platform integration
+ https://bugs.webkit.org/show_bug.cgi?id=187850
+
+ Reviewed by Eric Carlson.
+
+ 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-04 Simon Fraser <[email protected]>
Make WebCore::Timer more space-efficient
Modified: trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp (234581 => 234582)
--- trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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 @@
// 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)] (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::createDecodingConfiguration(configuration, callback);
});
}
@@ -217,8 +247,40 @@
// 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)] (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::createEncodingConfiguration(configuration, callback);
+
});
}
Modified: trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h (234581 => 234582)
--- trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -31,6 +31,14 @@
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 @@
void setPowerEfficient(bool powerEfficient) { m_powerEfficient = powerEfficient; }
private:
+ MediaCapabilitiesInfo() = default;
+
bool m_supported { false };
bool m_smooth { false };
bool m_powerEfficient { false };
Modified: trunk/Source/WebCore/PlatformGTK.cmake (234581 => 234582)
--- trunk/Source/WebCore/PlatformGTK.cmake 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2018-08-05 09:26:00 UTC (rev 234582)
@@ -30,6 +30,7 @@
"${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"
Modified: trunk/Source/WebCore/PlatformMac.cmake (234581 => 234582)
--- trunk/Source/WebCore/PlatformMac.cmake 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/PlatformMac.cmake 2018-08-05 09:26:00 UTC (rev 234582)
@@ -99,6 +99,7 @@
"${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"
Modified: trunk/Source/WebCore/PlatformWPE.cmake (234581 => 234582)
--- trunk/Source/WebCore/PlatformWPE.cmake 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/PlatformWPE.cmake 2018-08-05 09:26:00 UTC (rev 234582)
@@ -27,6 +27,7 @@
"${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"
Modified: trunk/Source/WebCore/PlatformWin.cmake (234581 => 234582)
--- trunk/Source/WebCore/PlatformWin.cmake 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/PlatformWin.cmake 2018-08-05 09:26:00 UTC (rev 234582)
@@ -10,6 +10,7 @@
"${WEBCORE_DIR}/platform/graphics/opengl"
"${WEBCORE_DIR}/platform/graphics/opentype"
"${WEBCORE_DIR}/platform/graphics/win"
+ "${WEBCORE_DIR}/platform/mediacapabilities"
"${WEBCORE_DIR}/platform/network/win"
"${WEBCORE_DIR}/platform/win"
"${THIRDPARTY_DIR}/ANGLE/include"
@@ -193,6 +194,7 @@
platform/animation
platform/audio
platform/graphics
+ platform/mediacapabilities
platform/mock
platform/network
platform/sql
@@ -232,6 +234,7 @@
inspector/agents
+ platform/mediacapabilities
platform/mediastream
workers/service/context
Modified: trunk/Source/WebCore/PlatformWinCairo.cmake (234581 => 234582)
--- trunk/Source/WebCore/PlatformWinCairo.cmake 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/PlatformWinCairo.cmake 2018-08-05 09:26:00 UTC (rev 234582)
@@ -55,7 +55,7 @@
)
list(APPEND WebCore_FORWARDING_HEADERS_DIRECTORIES
+ platform/mediacapabilities
platform/graphics/cairo
-
platform/network/curl
)
Modified: trunk/Source/WebCore/Sources.txt (234581 => 234582)
--- trunk/Source/WebCore/Sources.txt 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/Sources.txt 2018-08-05 09:26:00 UTC (rev 234582)
@@ -1720,6 +1720,9 @@
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
@@ -1740,6 +1743,8 @@
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
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (234581 => 234582)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-05 09:26:00 UTC (rev 234582)
@@ -10817,6 +10817,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>"; };
@@ -18804,6 +18814,10 @@
CDF2B005182053DF00F2B424 /* mediasource */,
59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */,
59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */,
+ 9AC6F02D21148F9F00CBDA06 /* MediaEngineDecodingConfigurationMock.cpp */,
+ 9AC6F02F21148FA200CBDA06 /* MediaEngineDecodingConfigurationMock.h */,
+ 9AC6F02E21148FA100CBDA06 /* MediaEngineEncodingConfigurationMock.cpp */,
+ 9AC6F03021148FA400CBDA06 /* MediaEngineEncodingConfigurationMock.h */,
077B64141B95F703003E9AD5 /* MediaPlaybackTargetMock.cpp */,
077B64151B95F703003E9AD5 /* MediaPlaybackTargetMock.h */,
077B64101B94F12E003E9AD5 /* MediaPlaybackTargetPickerMock.cpp */,
@@ -21284,6 +21298,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 = (
@@ -24417,6 +24444,7 @@
B2A015910AF6CD53006BCE0E /* graphics */,
A59E3C1B11580F340072928E /* ios */,
6582A14809999D6C00BEEB6D /* mac */,
+ 9AC6F02021148F1E00CBDA06 /* mediacapabilities */,
C96F5EBF1B5872260091EA9D /* mediasession */,
07221B9217CF0AD400848E51 /* mediastream */,
59C77F101054591C00506104 /* mock */,
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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 || !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
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfiguration.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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()
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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;
+}
+
+}
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineDecodingConfiguration.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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
Added: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h (0 => 234582)
--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h (rev 0)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineEncodingConfiguration.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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
Added: trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp (0 => 234582)
--- trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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.
+ 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
Added: trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h (0 => 234582)
--- trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h (rev 0)
+++ trunk/Source/WebCore/platform/mock/MediaEngineDecodingConfigurationMock.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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);
Added: trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp (0 => 234582)
--- trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp (rev 0)
+++ trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -0,0 +1,86 @@
+/*
+ * 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
Added: trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h (0 => 234582)
--- trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h (rev 0)
+++ trunk/Source/WebCore/platform/mock/MediaEngineEncodingConfigurationMock.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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);
Modified: trunk/Source/WebCore/testing/Internals.cpp (234581 => 234582)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-08-05 09:26:00 UTC (rev 234582)
@@ -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 @@
page.setFullscreenAutoHideDuration(0_s);
page.setFullscreenInsets({ });
page.setFullscreenControlsHidden(false);
+
+ MediaEngineConfigurationFactory::disableMock();
}
Internals::Internals(Document& document)
@@ -3464,6 +3467,11 @@
#endif
+void Internals::enableMockMediaCapabilities()
+{
+ MediaEngineConfigurationFactory::enableMock();
+}
+
#if ENABLE(VIDEO)
ExceptionOr<void> Internals::beginMediaSessionInterruption(const String& interruptionString)
Modified: trunk/Source/WebCore/testing/Internals.h (234581 => 234582)
--- trunk/Source/WebCore/testing/Internals.h 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/testing/Internals.h 2018-08-05 09:26:00 UTC (rev 234582)
@@ -474,6 +474,8 @@
Ref<MockCDMFactory> registerMockCDM();
#endif
+ void enableMockMediaCapabilities();
+
#if ENABLE(SPEECH_SYNTHESIS)
void enableMockSpeechSynthesizer();
#endif
Modified: trunk/Source/WebCore/testing/Internals.idl (234581 => 234582)
--- trunk/Source/WebCore/testing/Internals.idl 2018-08-04 22:57:13 UTC (rev 234581)
+++ trunk/Source/WebCore/testing/Internals.idl 2018-08-05 09:26:00 UTC (rev 234582)
@@ -478,6 +478,7 @@
[Conditional=LEGACY_ENCRYPTED_MEDIA] void initializeMockCDM();
[Conditional=ENCRYPTED_MEDIA] MockCDMFactory registerMockCDM();
+ void enableMockMediaCapabilities();
[Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer();