Add initial DOM support for Media Capabilities
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Dec 2017 18:28:21 +0000 (18:28 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Dec 2017 18:28:21 +0000 (18:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181064

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/mediacapabilities/mediacapabilities-types.html

Add basic, cross-platform, DOM facing type and API support for Media Capabilities API.

* bindings/scripts/CodeGenerator.pm:
(WK_ucfirst):
* CMakeLists.txt:
* DerivedSources.make:
* Modules/mediacapabilities/AudioConfiguration.h: Added.
* Modules/mediacapabilities/AudioConfiguration.idl: Added.
* Modules/mediacapabilities/MediaCapabilities.cpp: Added.
(WebCore::bucketMIMETypes):
(WebCore::isValidMIMEType):
(WebCore::isValidVideoConfiguration):
(WebCore::isValidAudioConfiguration):
(WebCore::isValidMediaConfiguration):
(WebCore::MediaCapabilities::decodingInfo):
(WebCore::MediaCapabilities::encodingInfo):
* Modules/mediacapabilities/MediaCapabilities.h: Added.
* Modules/mediacapabilities/MediaCapabilities.idl: Added.
* Modules/mediacapabilities/MediaCapabilitiesInfo.h: Added.
(WebCore::MediaCapabilitiesInfo::supported const):
(WebCore::MediaCapabilitiesInfo::setSupported):
(WebCore::MediaCapabilitiesInfo::smooth const):
(WebCore::MediaCapabilitiesInfo::setSmooth):
(WebCore::MediaCapabilitiesInfo::powerEfficient const):
(WebCore::MediaCapabilitiesInfo::setPowerEfficient):
* Modules/mediacapabilities/MediaCapabilitiesInfo.idl: Added.
* Modules/mediacapabilities/MediaConfiguration.h: Added.
* Modules/mediacapabilities/MediaConfiguration.idl: Added.
* Modules/mediacapabilities/MediaDecodingConfiguration.h: Added.
* Modules/mediacapabilities/MediaDecodingConfiguration.idl: Added.
* Modules/mediacapabilities/MediaDecodingType.h: Added.
* Modules/mediacapabilities/MediaDecodingType.idl: Added.
* Modules/mediacapabilities/MediaEncodingConfiguration.h: Added.
* Modules/mediacapabilities/MediaEncodingConfiguration.idl: Added.
* Modules/mediacapabilities/MediaEncodingType.h: Added.
* Modules/mediacapabilities/MediaEncodingType.idl: Added.
* Modules/mediacapabilities/NavigatorMediaCapabilities.cpp: Added.
(WebCore::NavigatorMediaCapabilities::NavigatorMediaCapabilities):
(WebCore::NavigatorMediaCapabilities::supplementName):
(WebCore::NavigatorMediaCapabilities::from):
(WebCore::NavigatorMediaCapabilities::mediaCapabilities):
(WebCore::NavigatorMediaCapabilities::mediaCapabilities const):
* Modules/mediacapabilities/NavigatorMediaCapabilities.h: Added.
* Modules/mediacapabilities/NavigatorMediaCapabilities.idl: Added.
* Modules/mediacapabilities/ScreenColorGamut.h: Added.
* Modules/mediacapabilities/ScreenColorGamut.idl: Added.
* Modules/mediacapabilities/ScreenLuminance.h: Added.
(WebCore::ScreenLuminance::min const):
(WebCore::ScreenLuminance::setMin):
(WebCore::ScreenLuminance::max const):
(WebCore::ScreenLuminance::setMax):
(WebCore::ScreenLuminance::maxAverage const):
(WebCore::ScreenLuminance::setMaxAverage):
* Modules/mediacapabilities/ScreenLuminance.idl: Added.
* Modules/mediacapabilities/VideoConfiguration.h: Added.
* Modules/mediacapabilities/VideoConfiguration.idl: Added.
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:
* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setMediaCapabilitiesEnabled):
(WebCore::RuntimeEnabledFeatures::mediaCapabilitiesEnabled const):
* page/Settings.yaml:

Source/WebKit:

Add a new preference to enable the (disabled-by-default) Media Capabilities API.

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetMediaCapabilitiesEnabled):
(WKPreferencesGetMediaCapabilitiesEnabled):
* UIProcess/API/C/WKPreferencesRef.h:

Source/WebKitLegacy/mac:

Add a new preference to enable the (disabled-by-default) Media Capabilities API.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences mediaCapabilitiesEnabled]):
(-[WebPreferences setMediaCapabilitiesEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

LayoutTests:

* fast/dom/navigator-detached-no-crash-expected.txt:
* media/mediacapabilities/mediacapabilities-types-expected.txt: Added.
* media/mediacapabilities/mediacapabilities-types.html: Added.
* platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt:
* platform/win/fast/dom/navigator-detached-no-crash-expected.txt:

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

55 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/media/mediacapabilities/mediacapabilities-types-expected.txt [new file with mode: 0644]
LayoutTests/media/mediacapabilities/mediacapabilities-types.html [new file with mode: 0644]
LayoutTests/platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt
LayoutTests/platform/win/fast/dom/navigator-detached-no-crash-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/AudioConfiguration.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaCapabilities.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaConfiguration.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaDecodingType.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/MediaEncodingType.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/ScreenLuminance.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/ScreenLuminance.idl [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h [new file with mode: 0644]
Source/WebCore/Modules/mediacapabilities/VideoConfiguration.idl [new file with mode: 0644]
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/page/Settings.yaml
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRef.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKitLegacy/mac/WebView/WebPreferences.mm
Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/TestController.cpp

index 5b1212e..678ed67 100644 (file)
@@ -1,3 +1,18 @@
+2017-12-21  Jer Noble  <jer.noble@apple.com>
+
+        Add initial DOM support for Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=181064
+
+        Reviewed by Eric Carlson.
+
+        * fast/dom/navigator-detached-no-crash-expected.txt:
+        * media/mediacapabilities/mediacapabilities-types-expected.txt: Added.
+        * media/mediacapabilities/mediacapabilities-types.html: Added.
+        * platform/gtk/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/mac-elcapitan-wk2/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/mac-wk1/fast/dom/navigator-detached-no-crash-expected.txt:
+        * platform/win/fast/dom/navigator-detached-no-crash-expected.txt:
+
 2017-12-21  Ryan Haddad  <ryanhaddad@apple.com>
 
         Correct a TestExpectations entry after r226074.
index 9da05af..0e933ce 100644 (file)
@@ -9,6 +9,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
@@ -30,6 +31,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
diff --git a/LayoutTests/media/mediacapabilities/mediacapabilities-types-expected.txt b/LayoutTests/media/mediacapabilities/mediacapabilities-types-expected.txt
new file mode 100644 (file)
index 0000000..6eadfaf
--- /dev/null
@@ -0,0 +1,87 @@
+Test basic dictionary and enum types of Media Capabilities API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'media-source' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/0" } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record' });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { } });
+    } rejected promise  with TypeError: Member AudioConfiguration.contentType is required and must be an instance of DOMString.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { } });
+    } rejected promise  with TypeError: Member VideoConfiguration.bitrate is required and must be an instance of unsigned long long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Member VideoConfiguration.width is required and must be an instance of unsigned long.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/-1" } });
+    } rejected promise  with TypeError: Type error.
+PASS () => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    } rejected promise  with TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/media/mediacapabilities/mediacapabilities-types.html b/LayoutTests/media/mediacapabilities/mediacapabilities-types.html
new file mode 100644 (file)
index 0000000..acc6cb4
--- /dev/null
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>mediacapabilities-types</title>
+</head>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description('Test basic dictionary and enum types of Media Capabilities API');
+jsTestIsAsync = true;
+
+(async function() {
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file' });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'media-source' });
+    })
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'file', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/0" } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record' });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.encodingInfo({ type: 'record', audio: { } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', audio: { contentType: 'video/mp4; codecs="avc1"' } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'audio/mp3', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1,vp9"', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4', width:640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 0 } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/a" } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'record', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: "24/-1" } });
+    });
+    await shouldReject(() => {
+        return navigator.mediaCapabilities.decodingInfo({ type: 'invalid', video: { contentType: 'video/mp4; codecs="avc1"', width: 640, height: 480, bitrate: 1000, framerate: 24 } });
+    });
+    finishJSTest();
+})()
+
+</script>
+<script src="../../resources/js-test.js"></script>
+</body>
+</html>
index 342d6e1..fa3ff16 100644 (file)
@@ -8,6 +8,7 @@ navigator.cookieEnabled is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
@@ -25,6 +26,7 @@ navigator.cookieEnabled is OK
 navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
index e5a4c3b..56bdc9f 100644 (file)
@@ -9,6 +9,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
@@ -29,6 +30,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
index 542aa8e..aecf6ac 100644 (file)
@@ -9,6 +9,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
@@ -28,6 +29,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
index 8ad847e..0974460 100644 (file)
@@ -9,6 +9,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
@@ -27,6 +28,7 @@ navigator.getStorageUpdates() is OK
 navigator.javaEnabled() is OK
 navigator.language is OK
 navigator.languages is OK
+navigator.mediaCapabilities is OK
 navigator.mimeTypes is OK
 navigator.onLine is OK
 navigator.platform is OK
index 00a89b0..8227a7b 100644 (file)
@@ -33,6 +33,7 @@ set(WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/Modules/indexeddb/client"
     "${WEBCORE_DIR}/Modules/indexeddb/server"
     "${WEBCORE_DIR}/Modules/indexeddb/shared"
+    "${WEBCORE_DIR}/Modules/mediacapabilities"
     "${WEBCORE_DIR}/Modules/mediacontrols/"
     "${WEBCORE_DIR}/Modules/mediasession"
     "${WEBCORE_DIR}/Modules/mediasource"
@@ -172,6 +173,7 @@ set(WebCore_IDL_INCLUDES
     Modules/fetch
     Modules/geolocation
     Modules/indexeddb
+    Modules/mediacapabilities
     Modules/mediasession
     Modules/mediastream
     Modules/notifications
@@ -266,6 +268,19 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/indexeddb/IDBVersionChangeEvent.idl
     Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.idl
 
+    Modules/mediacapabilities/AudioConfiguration.idl
+    Modules/mediacapabilities/MediaCapabilities.idl
+    Modules/mediacapabilities/MediaCapabilitiesInfo.idl
+    Modules/mediacapabilities/MediaConfiguration.idl
+    Modules/mediacapabilities/MediaDecodingConfiguration.idl
+    Modules/mediacapabilities/MediaDecodingType.idl
+    Modules/mediacapabilities/MediaEncodingConfiguration.idl
+    Modules/mediacapabilities/MediaEncodingType.idl
+    Modules/mediacapabilities/NavigatorMediaCapabilities.idl
+    Modules/mediacapabilities/ScreenColorGamut.idl
+    Modules/mediacapabilities/ScreenLuminance.idl
+    Modules/mediacapabilities/VideoConfiguration.idl
+
     Modules/mediacontrols/MediaControlsHost.idl
 
     Modules/mediasession/HTMLMediaElementMediaSession.idl
index 353be7a..1523777 100644 (file)
@@ -1,3 +1,76 @@
+2017-12-21  Jer Noble  <jer.noble@apple.com>
+
+        Add initial DOM support for Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=181064
+
+        Reviewed by Eric Carlson.
+
+        Test: media/mediacapabilities/mediacapabilities-types.html
+
+        Add basic, cross-platform, DOM facing type and API support for Media Capabilities API.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (WK_ucfirst):
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/mediacapabilities/AudioConfiguration.h: Added.
+        * Modules/mediacapabilities/AudioConfiguration.idl: Added.
+        * Modules/mediacapabilities/MediaCapabilities.cpp: Added.
+        (WebCore::bucketMIMETypes):
+        (WebCore::isValidMIMEType):
+        (WebCore::isValidVideoConfiguration):
+        (WebCore::isValidAudioConfiguration):
+        (WebCore::isValidMediaConfiguration):
+        (WebCore::MediaCapabilities::decodingInfo):
+        (WebCore::MediaCapabilities::encodingInfo):
+        * Modules/mediacapabilities/MediaCapabilities.h: Added.
+        * Modules/mediacapabilities/MediaCapabilities.idl: Added.
+        * Modules/mediacapabilities/MediaCapabilitiesInfo.h: Added.
+        (WebCore::MediaCapabilitiesInfo::supported const):
+        (WebCore::MediaCapabilitiesInfo::setSupported):
+        (WebCore::MediaCapabilitiesInfo::smooth const):
+        (WebCore::MediaCapabilitiesInfo::setSmooth):
+        (WebCore::MediaCapabilitiesInfo::powerEfficient const):
+        (WebCore::MediaCapabilitiesInfo::setPowerEfficient):
+        * Modules/mediacapabilities/MediaCapabilitiesInfo.idl: Added.
+        * Modules/mediacapabilities/MediaConfiguration.h: Added.
+        * Modules/mediacapabilities/MediaConfiguration.idl: Added.
+        * Modules/mediacapabilities/MediaDecodingConfiguration.h: Added.
+        * Modules/mediacapabilities/MediaDecodingConfiguration.idl: Added.
+        * Modules/mediacapabilities/MediaDecodingType.h: Added.
+        * Modules/mediacapabilities/MediaDecodingType.idl: Added.
+        * Modules/mediacapabilities/MediaEncodingConfiguration.h: Added.
+        * Modules/mediacapabilities/MediaEncodingConfiguration.idl: Added.
+        * Modules/mediacapabilities/MediaEncodingType.h: Added.
+        * Modules/mediacapabilities/MediaEncodingType.idl: Added.
+        * Modules/mediacapabilities/NavigatorMediaCapabilities.cpp: Added.
+        (WebCore::NavigatorMediaCapabilities::NavigatorMediaCapabilities):
+        (WebCore::NavigatorMediaCapabilities::supplementName):
+        (WebCore::NavigatorMediaCapabilities::from):
+        (WebCore::NavigatorMediaCapabilities::mediaCapabilities):
+        (WebCore::NavigatorMediaCapabilities::mediaCapabilities const):
+        * Modules/mediacapabilities/NavigatorMediaCapabilities.h: Added.
+        * Modules/mediacapabilities/NavigatorMediaCapabilities.idl: Added.
+        * Modules/mediacapabilities/ScreenColorGamut.h: Added.
+        * Modules/mediacapabilities/ScreenColorGamut.idl: Added.
+        * Modules/mediacapabilities/ScreenLuminance.h: Added.
+        (WebCore::ScreenLuminance::min const):
+        (WebCore::ScreenLuminance::setMin):
+        (WebCore::ScreenLuminance::max const):
+        (WebCore::ScreenLuminance::setMax):
+        (WebCore::ScreenLuminance::maxAverage const):
+        (WebCore::ScreenLuminance::setMaxAverage):
+        * Modules/mediacapabilities/ScreenLuminance.idl: Added.
+        * Modules/mediacapabilities/VideoConfiguration.h: Added.
+        * Modules/mediacapabilities/VideoConfiguration.idl: Added.
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setMediaCapabilitiesEnabled):
+        (WebCore::RuntimeEnabledFeatures::mediaCapabilitiesEnabled const):
+        * page/Settings.yaml:
+
 2017-12-21  Keith Rollin  <krollin@apple.com>
 
         Add optional logging of per-resource cookie information
index b445beb..31e9079 100644 (file)
@@ -42,6 +42,7 @@ VPATH = \
     $(WebCore)/Modules/geolocation \
     $(WebCore)/Modules/indexeddb \
     $(WebCore)/Modules/indieui \
+    $(WebCore)/Modules/mediacapabilities \
     $(WebCore)/Modules/mediacontrols \
     $(WebCore)/Modules/mediasession \
     $(WebCore)/Modules/mediasource \
@@ -193,6 +194,18 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/indexeddb/IDBTransactionMode.idl \
     $(WebCore)/Modules/indexeddb/IDBVersionChangeEvent.idl \
     $(WebCore)/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.idl \
+    $(WebCore)/Modules/mediacapabilities/AudioConfiguration.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaCapabilities.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaCapabilitiesInfo.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaConfiguration.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaDecodingConfiguration.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaDecodingType.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaEncodingConfiguration.idl \
+    $(WebCore)/Modules/mediacapabilities/MediaEncodingType.idl \
+    $(WebCore)/Modules/mediacapabilities/NavigatorMediaCapabilities.idl \
+    $(WebCore)/Modules/mediacapabilities/ScreenColorGamut.idl \
+    $(WebCore)/Modules/mediacapabilities/ScreenLuminance.idl \
+    $(WebCore)/Modules/mediacapabilities/VideoConfiguration.idl \
     $(WebCore)/Modules/mediacontrols/MediaControlsHost.idl \
     $(WebCore)/Modules/mediasession/HTMLMediaElementMediaSession.idl \
     $(WebCore)/Modules/mediasession/MediaRemoteControls.idl \
diff --git a/Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h b/Source/WebCore/Modules/mediacapabilities/AudioConfiguration.h
new file mode 100644 (file)
index 0000000..5eff359
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct AudioConfiguration {
+    String contentType;
+    String channels;
+    std::optional<uint64_t> bitrate;
+    std::optional<uint32_t> samplerate;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediacapabilities/AudioConfiguration.idl b/Source/WebCore/Modules/mediacapabilities/AudioConfiguration.idl
new file mode 100644 (file)
index 0000000..0a9798e
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary AudioConfiguration {
+  required DOMString contentType;
+  DOMString channels;
+  unsigned long long bitrate;
+  unsigned long samplerate;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp b/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp
new file mode 100644 (file)
index 0000000..b9847d8
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaCapabilities.h"
+
+#include "ContentType.h"
+#include "MediaDecodingConfiguration.h"
+#include "MediaEncodingConfiguration.h"
+#include <wtf/HashSet.h>
+
+namespace WebCore {
+
+static const HashSet<String>& bucketMIMETypes()
+{
+    // A "bucket" MIME types is one whose container type does not uniquely specify a codec.
+    // See: https://tools.ietf.org/html/rfc6381
+    static NeverDestroyed<HashSet<String>> bucketMIMETypes = HashSet<String>({
+        "audio/3gpp",
+        "video/3gpp",
+        "audio/3gpp2",
+        "video/3gpp2",
+        "audio/mp4",
+        "video/mp4",
+        "application/mp4",
+        "video/quicktime",
+        "application/mp21",
+        "audio/vnd.apple.mpegurl",
+        "video/vnd.apple.mpegurl",
+        "audio/ogg",
+        "video/ogg",
+        "video/webm",
+        "audio/webm",
+    });
+    return bucketMIMETypes;
+}
+
+static bool isValidMediaMIMEType(const ContentType& contentType)
+{
+    // 2.1.4. MIME types
+    // https://wicg.github.io/media-capabilities/#valid-media-mime-type
+    // A valid media MIME type is a string that is a valid MIME type per [mimesniff]. If the MIME type does
+    // not imply a codec, the string MUST also have one and only one parameter that is named codecs with a
+    // value describing a single media codec. Otherwise, it MUST contain no parameters.
+    if (contentType.isEmpty())
+        return false;
+
+    auto codecs = contentType.codecs();
+
+    // FIXME: The spec requires that the "codecs" parameter is the only parameter present.
+    if (bucketMIMETypes().contains(contentType.containerType()))
+        return codecs.size() == 1;
+    return !codecs.size();
+}
+
+static bool isValidVideoMIMEType(const ContentType& contentType)
+{
+    // 2.1.4 MIME Types
+    // https://wicg.github.io/media-capabilities/#valid-video-mime-type
+    // A valid video MIME type is a string that is a valid media MIME type and for which the type per [RFC7231]
+    // is either video or application.
+    if (!isValidMediaMIMEType(contentType))
+        return false;
+
+    auto containerType = contentType.containerType();
+    if (!startsWithLettersIgnoringASCIICase(containerType, "video/") && !startsWithLettersIgnoringASCIICase(containerType, "application/"))
+        return false;
+
+    return true;
+}
+
+static bool isValidAudioMIMEType(const ContentType& contentType)
+{
+    // 2.1.4 MIME Types
+    // https://wicg.github.io/media-capabilities/#valid-audio-mime-type
+    // A valid audio MIME type is a string that is a valid media MIME type and for which the type per [RFC7231]
+    // is either audio or application.
+    if (!isValidMediaMIMEType(contentType))
+        return false;
+
+    auto containerType = contentType.containerType();
+    if (!startsWithLettersIgnoringASCIICase(containerType, "audio/") && !startsWithLettersIgnoringASCIICase(containerType, "application/"))
+        return false;
+
+    return true;
+}
+
+static bool isValidVideoConfiguration(const VideoConfiguration& configuration)
+{
+    // 2.1.5. VideoConfiguration
+    // https://wicg.github.io/media-capabilities/#valid-video-configuration
+    // 1. If configuration’s contentType is not a valid video MIME type, return false and abort these steps.
+    if (!isValidVideoMIMEType(ContentType(configuration.contentType)))
+        return false;
+
+    // 2. If none of the following is true, return false and abort these steps:
+    //   o. Applying the rules for parsing floating-point number values to configuration’s framerate
+    //      results in a number that is finite and greater than 0.
+    bool ok = false;
+    double framerate = configuration.framerate.toDouble(&ok);
+    if (ok && std::isfinite(framerate) && framerate > 0)
+        return true;
+
+    //   o. Configuration’s framerate contains one occurence of U+002F SLASH character (/) and the substrings
+    //      before and after this character, when applying the rules for parsing floating-point number values
+    //      results in a number that is finite and greater than 0.
+    auto frameratePieces = configuration.framerate.split('/');
+    if (frameratePieces.size() != 2)
+        return false;
+
+    double numerator = frameratePieces[0].toDouble(&ok);
+    if (!ok)
+        return false;
+
+    double denominator = frameratePieces[1].toDouble(&ok);
+    if (!ok)
+        return false;
+
+    if (!std::isfinite(numerator) || !std::isfinite(denominator))
+        return false;
+
+    framerate = numerator / denominator;
+    if (!isfinite(framerate) || framerate <= 0)
+        return false;
+
+    // 3. Return true.
+    return true;
+}
+
+static bool isValidAudioConfiguration(const AudioConfiguration& configuration)
+{
+    // 2.1.6. AudioConfiguration
+    // https://wicg.github.io/media-capabilities/#audioconfiguration
+    // 1. If configuration’s contentType is not a valid audio MIME type, return false and abort these steps.
+    if (!isValidAudioMIMEType(ContentType(configuration.contentType)))
+        return false;
+
+    // 2. Return true.
+    return true;
+}
+
+static bool isValidMediaConfiguration(const MediaConfiguration& configuration)
+{
+    // 2.1.1. MediaConfiguration
+    // https://wicg.github.io/media-capabilities/#mediaconfiguration
+    // For a MediaConfiguration to be a valid MediaConfiguration, audio or video MUST be present.
+    if (!configuration.video && !configuration.audio)
+        return false;
+
+    if (configuration.video && !isValidVideoConfiguration(configuration.video.value()))
+        return false;
+
+    if (configuration.audio && !isValidAudioConfiguration(configuration.audio.value()))
+        return false;
+
+    return true;
+}
+
+void MediaCapabilities::decodingInfo(MediaDecodingConfiguration&& configuration, Ref<DeferredPromise>&& promise)
+{
+    // 2.4 Media Capabilities Interface
+    // https://wicg.github.io/media-capabilities/#media-capabilities-interface
+
+    // 1. If configuration is not a valid MediaConfiguration, return a Promise rejected with a TypeError.
+    // 2. If configuration.video is present and is not a valid video configuration, return a Promise rejected with a TypeError.
+    // 3. If configuration.audio is present and is not a valid audio configuration, return a Promise rejected with a TypeError.
+    if (!isValidMediaConfiguration(configuration)) {
+        promise->reject(TypeError);
+        return;
+    }
+
+    // 4. Let p be a new promise.
+    // 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);
+    });
+}
+
+void MediaCapabilities::encodingInfo(MediaEncodingConfiguration&& configuration, Ref<DeferredPromise>&& promise)
+{
+    // 2.4 Media Capabilities Interface
+    // https://wicg.github.io/media-capabilities/#media-capabilities-interface
+
+    // 1. If configuration is not a valid MediaConfiguration, return a Promise rejected with a TypeError.
+    // 2. If configuration.video is present and is not a valid video configuration, return a Promise rejected with a TypeError.
+    // 3. If configuration.audio is present and is not a valid audio configuration, return a Promise rejected with a TypeError.
+    if (!isValidMediaConfiguration(configuration)) {
+        promise->reject(TypeError);
+        return;
+    }
+
+    // 4. Let p be a new promise.
+    // 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);
+    });
+}
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.h b/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.h
new file mode 100644 (file)
index 0000000..b310e61
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "GenericTaskQueue.h"
+#include "JSDOMPromiseDeferred.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+struct MediaDecodingConfiguration;
+struct MediaEncodingConfiguration;
+
+class MediaCapabilities : public RefCounted<MediaCapabilities> {
+public:
+    void decodingInfo(MediaDecodingConfiguration&&, Ref<DeferredPromise>&&);
+    void encodingInfo(MediaEncodingConfiguration&&, Ref<DeferredPromise>&&);
+
+private:
+    GenericTaskQueue<Timer> m_taskQueue;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl b/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.idl
new file mode 100644 (file)
index 0000000..60281b5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=MediaCapabilities,
+    ImplementationLacksVTable
+]
+interface MediaCapabilities {
+  Promise<MediaCapabilitiesInfo> decodingInfo(MediaDecodingConfiguration configuration);
+  Promise<MediaCapabilitiesInfo> encodingInfo(MediaEncodingConfiguration configuration);
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h b/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.h
new file mode 100644 (file)
index 0000000..119a127
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class MediaCapabilitiesInfo : public RefCounted<MediaCapabilitiesInfo> {
+public:
+    bool supported() const { return m_supported; }
+    void setSupported(bool supported) { m_supported = supported; }
+
+    bool smooth() const { return m_smooth; }
+    void setSmooth(bool smooth) { m_smooth = smooth; }
+
+    bool powerEfficient() const { return m_powerEfficient; }
+    void setPowerEfficient(bool powerEfficient) { m_powerEfficient = powerEfficient; }
+
+private:
+    bool m_supported { false };
+    bool m_smooth { false };
+    bool m_powerEfficient { false };
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.idl b/Source/WebCore/Modules/mediacapabilities/MediaCapabilitiesInfo.idl
new file mode 100644 (file)
index 0000000..0940d79
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=MediaCapabilities,
+    ImplementationLacksVTable
+]
+interface MediaCapabilitiesInfo {
+  readonly attribute boolean supported;
+  readonly attribute boolean smooth;
+  readonly attribute boolean powerEfficient;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h b/Source/WebCore/Modules/mediacapabilities/MediaConfiguration.h
new file mode 100644 (file)
index 0000000..3bdc83f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "AudioConfiguration.h"
+#include "VideoConfiguration.h"
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+struct MediaConfiguration {
+    std::optional<VideoConfiguration> video;
+    std::optional<AudioConfiguration> audio;
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaConfiguration.idl b/Source/WebCore/Modules/mediacapabilities/MediaConfiguration.idl
new file mode 100644 (file)
index 0000000..a7b8f59
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+dictionary MediaConfiguration {
+  VideoConfiguration video;
+  AudioConfiguration audio;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h b/Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.h
new file mode 100644 (file)
index 0000000..55c0451
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "MediaConfiguration.h"
+#include "MediaDecodingType.h"
+
+namespace WebCore {
+
+struct MediaDecodingConfiguration : MediaConfiguration {
+    MediaDecodingType type;
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.idl b/Source/WebCore/Modules/mediacapabilities/MediaDecodingConfiguration.idl
new file mode 100644 (file)
index 0000000..a43774b
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary MediaDecodingConfiguration : MediaConfiguration {
+  required MediaDecodingType type;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h b/Source/WebCore/Modules/mediacapabilities/MediaDecodingType.h
new file mode 100644 (file)
index 0000000..890e7f8
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class MediaDecodingType {
+    File,
+    MediaSource,
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaDecodingType.idl b/Source/WebCore/Modules/mediacapabilities/MediaDecodingType.idl
new file mode 100644 (file)
index 0000000..d391440
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum MediaDecodingType {
+  "file",
+  "media-source"
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h b/Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.h
new file mode 100644 (file)
index 0000000..729b3a1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "MediaConfiguration.h"
+#include "MediaEncodingType.h"
+
+namespace WebCore {
+
+struct MediaEncodingConfiguration : MediaConfiguration {
+    MediaEncodingType type;
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.idl b/Source/WebCore/Modules/mediacapabilities/MediaEncodingConfiguration.idl
new file mode 100644 (file)
index 0000000..f905fed
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary MediaEncodingConfiguration : MediaConfiguration {
+  required MediaEncodingType type;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h b/Source/WebCore/Modules/mediacapabilities/MediaEncodingType.h
new file mode 100644 (file)
index 0000000..a87d0f2
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class MediaEncodingType {
+    Record,
+    Transmission,
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/MediaEncodingType.idl b/Source/WebCore/Modules/mediacapabilities/MediaEncodingType.idl
new file mode 100644 (file)
index 0000000..9a2a209
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum MediaEncodingType {
+  "record",
+  "transmission"
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.cpp b/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.cpp
new file mode 100644 (file)
index 0000000..f872574
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NavigatorMediaCapabilities.h"
+
+#include "MediaCapabilities.h"
+#include "Navigator.h"
+
+namespace WebCore {
+
+NavigatorMediaCapabilities::NavigatorMediaCapabilities()
+    : m_mediaCapabilities(adoptRef(*new MediaCapabilities()))
+{
+}
+
+NavigatorMediaCapabilities::~NavigatorMediaCapabilities() = default;
+
+const char* NavigatorMediaCapabilities::supplementName()
+{
+    return "NavigatorMediaCapabilities";
+}
+
+NavigatorMediaCapabilities& NavigatorMediaCapabilities::from(Navigator& navigator)
+{
+    NavigatorMediaCapabilities* supplement = static_cast<NavigatorMediaCapabilities*>(Supplement<Navigator>::from(&navigator, supplementName()));
+    if (!supplement) {
+        auto newSupplement = std::make_unique<NavigatorMediaCapabilities>();
+        supplement = newSupplement.get();
+        provideTo(&navigator, supplementName(), WTFMove(newSupplement));
+    }
+    return *supplement;
+}
+
+MediaCapabilities& NavigatorMediaCapabilities::mediaCapabilities(Navigator& navigator)
+{
+    return NavigatorMediaCapabilities::from(navigator).mediaCapabilities();
+}
+
+MediaCapabilities& NavigatorMediaCapabilities::mediaCapabilities() const
+{
+    return m_mediaCapabilities;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.h b/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.h
new file mode 100644 (file)
index 0000000..73b4c3e
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "Supplementable.h"
+
+namespace WebCore {
+
+class MediaCapabilities;
+class Navigator;
+
+class NavigatorMediaCapabilities final : public Supplement<Navigator> {
+public:
+    NavigatorMediaCapabilities();
+    ~NavigatorMediaCapabilities();
+
+    static MediaCapabilities& mediaCapabilities(Navigator&);
+    static NavigatorMediaCapabilities& from(Navigator&);
+
+    MediaCapabilities& mediaCapabilities() const;
+private:
+    static const char* supplementName();
+
+    mutable Ref<MediaCapabilities> m_mediaCapabilities;
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.idl b/Source/WebCore/Modules/mediacapabilities/NavigatorMediaCapabilities.idl
new file mode 100644 (file)
index 0000000..3d605ba
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[ EnabledAtRuntime=MediaCapabilities ]
+partial interface Navigator {
+    [SameObject] readonly attribute MediaCapabilities mediaCapabilities;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.h b/Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.h
new file mode 100644 (file)
index 0000000..a16329b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+enum class ScreenColorGamut {
+    SRGB,
+    P3,
+    Rec2020,
+};
+
+} // namespace WebCore
diff --git a/Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.idl b/Source/WebCore/Modules/mediacapabilities/ScreenColorGamut.idl
new file mode 100644 (file)
index 0000000..74b22cf
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum ScreenColorGamut {
+    "srgb",
+    "p3",
+    "rec2020"
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/ScreenLuminance.h b/Source/WebCore/Modules/mediacapabilities/ScreenLuminance.h
new file mode 100644 (file)
index 0000000..8a235a3
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class ScreenLuminance : public RefCounted<ScreenLuminance> {
+public:
+    double min() const { return m_min; }
+    void setMin(double min) { m_min = min; }
+
+    double max() const { return m_max; }
+    void setMax(double max) { m_max = max; }
+
+    double maxAverage() const { return m_maxAverage; }
+    void setMaxAverage(double maxAverage) { m_maxAverage = maxAverage; }
+
+private:
+    double m_min { 0 };
+    double m_max { 0 };
+    double m_maxAverage  { 0 };
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/ScreenLuminance.idl b/Source/WebCore/Modules/mediacapabilities/ScreenLuminance.idl
new file mode 100644 (file)
index 0000000..395bae0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    EnabledAtRuntime=MediaCapabilities,
+    ImplementationLacksVTable
+]
+interface ScreenLuminance {
+  readonly attribute double min;
+  readonly attribute double max;
+  readonly attribute double maxAverage;
+};
diff --git a/Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h b/Source/WebCore/Modules/mediacapabilities/VideoConfiguration.h
new file mode 100644 (file)
index 0000000..e2428b2
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct VideoConfiguration {
+    String contentType;
+    uint32_t width;
+    uint32_t height;
+    uint64_t bitrate;
+    String framerate;
+};
+
+}
diff --git a/Source/WebCore/Modules/mediacapabilities/VideoConfiguration.idl b/Source/WebCore/Modules/mediacapabilities/VideoConfiguration.idl
new file mode 100644 (file)
index 0000000..627e6c9
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary VideoConfiguration {
+  required DOMString contentType;
+  required unsigned long width;
+  required unsigned long height;
+  required unsigned long long bitrate;
+  required DOMString framerate;
+};
index f5106e7..a8f1757 100644 (file)
@@ -137,6 +137,9 @@ Modules/indexeddb/shared/IDBTransactionInfo.cpp
 Modules/indexeddb/shared/InProcessIDBServer.cpp
 Modules/indexeddb/shared/IndexKey.cpp
 
+Modules/mediacapabilities/MediaCapabilities.cpp
+Modules/mediacapabilities/NavigatorMediaCapabilities.cpp
+
 Modules/mediacontrols/MediaControlsHost.cpp
 
 Modules/mediasession/HTMLMediaElementMediaSession.cpp
@@ -2304,6 +2307,7 @@ JSAttr.cpp
 JSAudioBuffer.cpp
 JSAudioBufferCallback.cpp
 JSAudioBufferSourceNode.cpp
+JSAudioConfiguration.cpp
 JSAudioContext.cpp
 JSAudioDestinationNode.cpp
 JSAudioListener.cpp
@@ -2619,11 +2623,17 @@ JSKeyboardEvent.cpp
 JSKeyframeEffect.cpp
 JSLocation.cpp
 JSLongRange.cpp
+JSMediaCapabilities.cpp
+JSMediaCapabilitiesInfo.cpp
 JSMediaController.cpp
 JSMediaControlsHost.cpp
+JSMediaDecodingConfiguration.cpp
+JSMediaDecodingType.cpp
 JSMediaDeviceInfo.cpp
 JSMediaDevices.cpp
 JSMediaElementAudioSourceNode.cpp
+JSMediaEncodingConfiguration.cpp
+JSMediaEncodingType.cpp
 JSMediaError.cpp
 JSMediaList.cpp
 JSMediaQueryList.cpp
@@ -2656,6 +2666,7 @@ JSNavigatorCredentials.cpp
 JSNavigatorGeolocation.cpp
 JSNavigatorID.cpp
 JSNavigatorLanguage.cpp
+JSNavigatorMediaCapabilities.cpp
 JSNavigatorMediaDevices.cpp
 JSNavigatorOnLine.cpp
 JSNavigatorServiceWorker.cpp
@@ -2917,6 +2928,7 @@ JSSVGViewSpec.cpp
 JSSVGZoomAndPan.cpp
 JSSVGZoomEvent.cpp
 JSScreen.cpp
+JSScreenLuminance.cpp
 JSScriptProcessorNode.cpp
 JSScrollToOptions.cpp
 JSSecurityPolicyViolationEvent.cpp
@@ -2969,6 +2981,7 @@ JSVRLayerInit.cpp
 JSVRPose.cpp
 JSVRStageParameters.cpp
 JSValidityState.cpp
+JSVideoConfiguration.cpp
 JSVideoPlaybackQuality.cpp
 JSVisibilityState.cpp
 JSVisualViewport.cpp
index 43e5de5..f6c4d8d 100644 (file)
                CD9DE17E17AAD64E00EA386D /* DOMURLMediaSource.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMURLMediaSource.cpp; sourceTree = "<group>"; };
                CD9DE17F17AAD64E00EA386D /* DOMURLMediaSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMURLMediaSource.h; sourceTree = "<group>"; };
                CD9DE18017AAD64E00EA386D /* DOMURLMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMURLMediaSource.idl; sourceTree = "<group>"; };
+               CDA130BB1FEB332C00F53254 /* NavigatorMediaCapabilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorMediaCapabilities.cpp; sourceTree = "<group>"; };
+               CDA130BD1FEB332D00F53254 /* MediaCapabilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaCapabilities.cpp; sourceTree = "<group>"; };
                CDA29A081CBD99F400901CCF /* PlaybackSessionInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionInterface.h; sourceTree = "<group>"; };
                CDA29A0A1CBD9A7400901CCF /* PlaybackSessionModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionModel.h; sourceTree = "<group>"; };
                CDA29A0C1CBD9CFE00901CCF /* PlaybackSessionModelMediaElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlaybackSessionModelMediaElement.mm; sourceTree = "<group>"; };
                CDAE8C081746B95700532D78 /* PlatformMediaSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformMediaSessionManager.h; sourceTree = "<group>"; };
                CDB704581F7465A1003923DF /* CDMFairPlayStreaming.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDMFairPlayStreaming.h; sourceTree = "<group>"; };
                CDB704591F7465A1003923DF /* CDMFairPlayStreaming.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CDMFairPlayStreaming.cpp; sourceTree = "<group>"; };
+               CDBD3D281FE85CB80012C545 /* VideoConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VideoConfiguration.idl; sourceTree = "<group>"; };
+               CDBD3D291FE85CB90012C545 /* MediaConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaConfiguration.idl; sourceTree = "<group>"; };
+               CDBD3D2A1FE85CBA0012C545 /* MediaEncodingConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaEncodingConfiguration.idl; sourceTree = "<group>"; };
+               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D2C1FE85CBB0012C545 /* ScreenLuminance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenLuminance.h; sourceTree = "<group>"; };
+               CDBD3D2D1FE85CBC0012C545 /* MediaEncodingType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaEncodingType.idl; sourceTree = "<group>"; };
+               CDBD3D2E1FE85CBC0012C545 /* MediaDecodingType.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaDecodingType.idl; sourceTree = "<group>"; };
+               CDBD3D2F1FE85CBC0012C545 /* MediaCapabilities.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaCapabilities.idl; sourceTree = "<group>"; };
+               CDBD3D301FE85CBD0012C545 /* ScreenLuminance.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScreenLuminance.idl; sourceTree = "<group>"; };
+               CDBD3D311FE85CBE0012C545 /* NavigatorMediaCapabilities.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NavigatorMediaCapabilities.idl; sourceTree = "<group>"; };
+               CDBD3D321FE85CBE0012C545 /* MediaCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCapabilities.h; sourceTree = "<group>"; };
+               CDBD3D331FE85CBE0012C545 /* MediaCapabilitiesInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaCapabilitiesInfo.idl; sourceTree = "<group>"; };
+               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDecodingConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEncodingConfiguration.h; sourceTree = "<group>"; };
+               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaDecodingType.h; sourceTree = "<group>"; };
+               CDBD3D391FE85CC10012C545 /* NavigatorMediaCapabilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigatorMediaCapabilities.h; sourceTree = "<group>"; };
+               CDBD3D3A1FE85CC10012C545 /* ScreenColorGamut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScreenColorGamut.h; sourceTree = "<group>"; };
+               CDBD3D3B1FE85CC20012C545 /* MediaDecodingConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaDecodingConfiguration.idl; sourceTree = "<group>"; };
+               CDBD3D3C1FE85CC20012C545 /* AudioConfiguration.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AudioConfiguration.idl; sourceTree = "<group>"; };
+               CDBD3D3D1FE85CC30012C545 /* MediaCapabilitiesInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCapabilitiesInfo.h; sourceTree = "<group>"; };
+               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEncodingType.h; sourceTree = "<group>"; };
+               CDBD3D3F1FE85CC30012C545 /* ScreenColorGamut.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScreenColorGamut.idl; sourceTree = "<group>"; };
                CDBEAEAA19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSelectionGroupAVFObjC.mm; sourceTree = "<group>"; };
                CDBEAEAB19D92B6C00BEBA88 /* MediaSelectionGroupAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSelectionGroupAVFObjC.h; sourceTree = "<group>"; };
                CDC1DD4117CC2C48008CB55D /* mediaControlsApple.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = mediaControlsApple.css; sourceTree = "<group>"; };
                                518F4FE9194CA4B60081BAAE /* gamepad */,
                                971145FF14EF007900674FD9 /* geolocation */,
                                9712A55315004E3C0048AF10 /* indexeddb */,
+                               CDBD3D271FE85C920012C545 /* mediacapabilities */,
                                CD9A37F517C7D93600C5FA7A /* mediacontrols */,
                                0709D78B1AE5552E004E42F8 /* mediasession */,
                                B1A942DD15B5CE2200D525D1 /* mediasource */,
                        name = MediaControls;
                        sourceTree = "<group>";
                };
+               CDBD3D271FE85C920012C545 /* mediacapabilities */ = {
+                       isa = PBXGroup;
+                       children = (
+                               CDBD3D2B1FE85CBB0012C545 /* AudioConfiguration.h */,
+                               CDBD3D3C1FE85CC20012C545 /* AudioConfiguration.idl */,
+                               CDA130BD1FEB332D00F53254 /* MediaCapabilities.cpp */,
+                               CDBD3D321FE85CBE0012C545 /* MediaCapabilities.h */,
+                               CDBD3D2F1FE85CBC0012C545 /* MediaCapabilities.idl */,
+                               CDBD3D3D1FE85CC30012C545 /* MediaCapabilitiesInfo.h */,
+                               CDBD3D331FE85CBE0012C545 /* MediaCapabilitiesInfo.idl */,
+                               CDBD3D351FE85CBF0012C545 /* MediaConfiguration.h */,
+                               CDBD3D291FE85CB90012C545 /* MediaConfiguration.idl */,
+                               CDBD3D361FE85CC00012C545 /* MediaDecodingConfiguration.h */,
+                               CDBD3D3B1FE85CC20012C545 /* MediaDecodingConfiguration.idl */,
+                               CDBD3D381FE85CC00012C545 /* MediaDecodingType.h */,
+                               CDBD3D2E1FE85CBC0012C545 /* MediaDecodingType.idl */,
+                               CDBD3D371FE85CC00012C545 /* MediaEncodingConfiguration.h */,
+                               CDBD3D2A1FE85CBA0012C545 /* MediaEncodingConfiguration.idl */,
+                               CDBD3D3E1FE85CC30012C545 /* MediaEncodingType.h */,
+                               CDBD3D2D1FE85CBC0012C545 /* MediaEncodingType.idl */,
+                               CDA130BB1FEB332C00F53254 /* NavigatorMediaCapabilities.cpp */,
+                               CDBD3D391FE85CC10012C545 /* NavigatorMediaCapabilities.h */,
+                               CDBD3D311FE85CBE0012C545 /* NavigatorMediaCapabilities.idl */,
+                               CDBD3D3A1FE85CC10012C545 /* ScreenColorGamut.h */,
+                               CDBD3D3F1FE85CC30012C545 /* ScreenColorGamut.idl */,
+                               CDBD3D2C1FE85CBB0012C545 /* ScreenLuminance.h */,
+                               CDBD3D301FE85CBD0012C545 /* ScreenLuminance.idl */,
+                               CDBD3D341FE85CBF0012C545 /* VideoConfiguration.h */,
+                               CDBD3D281FE85CB80012C545 /* VideoConfiguration.idl */,
+                       );
+                       path = mediacapabilities;
+                       sourceTree = "<group>";
+               };
                CDC6751F1EAEA99600727C84 /* ios */ = {
                        isa = PBXGroup;
                        children = (
index 17dfe70..67ce8ef 100644 (file)
@@ -83,6 +83,8 @@ namespace WebCore {
     macro(IntersectionObserver) \
     macro(IntersectionObserverEntry) \
     macro(KeyframeEffect) \
+    macro(MediaCapabilities) \
+    macro(MediaCapabilitiesInfo) \
     macro(MediaEncryptedEvent) \
     macro(MediaKeyMessageEvent) \
     macro(MediaKeySession) \
@@ -132,6 +134,7 @@ namespace WebCore {
     macro(ReadableStreamDefaultReader) \
     macro(Request) \
     macro(Response) \
+    macro(ScreenLuminance) \
     macro(ServiceWorker) \
     macro(ServiceWorkerContainer) \
     macro(ServiceWorkerGlobalScope) \
index e212381..47af22d 100644 (file)
@@ -693,6 +693,7 @@ sub WK_ucfirst
     my $ret = ucfirst($param);
     $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
     $ret =~ s/Svg/SVG/ if $ret =~ /^Svg/;
+    $ret =~ s/Srgb/SRGB/ if $ret =~ /^Srgb/;
 
     return $ret;
 }
index 25a5121..1713b81 100644 (file)
@@ -233,6 +233,9 @@ public:
     void setAccessibilityObjectModelEnabled(bool isEnabled) { m_accessibilityObjectModelEnabled = isEnabled; }
     bool accessibilityObjectModelEnabled() const { return m_accessibilityObjectModelEnabled; }
 
+    void setMediaCapabilitiesEnabled(bool isEnabled) { m_mediaCapabilitiesEnabled = isEnabled; }
+    bool mediaCapabilitiesEnabled() const { return m_mediaCapabilitiesEnabled; }
+
     WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures();
 
 private:
@@ -358,6 +361,8 @@ private:
 
     bool m_accessibilityObjectModelEnabled { false };
 
+    bool m_mediaCapabilitiesEnabled { false };
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 
index 7afb6a2..b31718b 100644 (file)
@@ -700,3 +700,6 @@ touchEventEmulationEnabled:
   initial: false
   getter: isTouchEventEmulationEnabled
   conditional: TOUCH_EVENTS
+
+mediaCapabilitiesEnabled:
+  initial: false
index d178323..1471f72 100644 (file)
@@ -1,3 +1,18 @@
+2017-12-21  Jer Noble  <jer.noble@apple.com>
+
+        Add initial DOM support for Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=181064
+
+        Reviewed by Eric Carlson.
+
+        Add a new preference to enable the (disabled-by-default) Media Capabilities API.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetMediaCapabilitiesEnabled):
+        (WKPreferencesGetMediaCapabilitiesEnabled):
+        * UIProcess/API/C/WKPreferencesRef.h:
+
 2017-12-21  Keith Rollin  <krollin@apple.com>
 
         Add optional logging of per-resource cookie information
index 9b5f4f2..6d89394 100644 (file)
@@ -1044,6 +1044,10 @@ ShouldAllowUserInstalledFonts:
   type: bool
   defaultValue: true
 
+MediaCapabilitiesEnabled:
+    type: bool
+    defaultValue: false
+    webcoreBinding: RuntimeEnabledFeatures
 
 # For experimental features:
 # The type should be boolean.
index 37e6cb1..e689a62 100644 (file)
@@ -1929,3 +1929,14 @@ bool WKPreferencesGetShouldAllowUserInstalledFonts(WKPreferencesRef preferencesR
 {
     return toImpl(preferencesRef)->shouldAllowUserInstalledFonts();
 }
+
+void WKPreferencesSetMediaCapabilitiesEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setMediaCapabilitiesEnabled(enabled);
+}
+
+bool WKPreferencesGetMediaCapabilitiesEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->mediaCapabilitiesEnabled();
+}
+
index 9523f59..d31adb4 100644 (file)
@@ -304,6 +304,9 @@ WK_EXPORT void WKPreferencesSetLegacyEncryptedMediaAPIEnabled(WKPreferencesRef p
 WK_EXPORT bool WKPreferencesGetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef);
 WK_EXPORT void WKPreferencesSetAllowMediaContentTypesRequiringHardwareSupportAsFallback(WKPreferencesRef preferencesRef, bool allow);
 
+WK_EXPORT bool WKPreferencesGetMediaCapabilitiesEnabled(WKPreferencesRef preferencesRef);
+WK_EXPORT void WKPreferencesSetMediaCapabilitiesEnabled(WKPreferencesRef preferencesRef, bool enabled);
+
 #ifdef __cplusplus
 }
 #endif
index 56c4340..2248cd6 100644 (file)
@@ -1,3 +1,21 @@
+2017-12-21  Jer Noble  <jer.noble@apple.com>
+
+        Add initial DOM support for Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=181064
+
+        Reviewed by Eric Carlson.
+
+        Add a new preference to enable the (disabled-by-default) Media Capabilities API.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences mediaCapabilitiesEnabled]):
+        (-[WebPreferences setMediaCapabilitiesEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2017-12-21  Jeremy Jones  <jeremyj@apple.com>
 
         Enable picture-in-picture from inline element on suspend.
index 744887b..0b817fc 100644 (file)
 #define WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallbackKey @"WebKitAllowMediaContentTypesRequiringHardwareSupportAsFallback"
 #define WebKitInspectorAdditionsEnabledPreferenceKey @"WebKitInspectorAdditionsEnabled"
 #define WebKitAccessibilityObjectModelEnabledPreferenceKey @"WebKitAccessibilityObjectModelEnabled"
+#define WebKitMediaCapabilitiesEnabledPreferenceKey @"WebKitMediaCapabilitiesEnabled"
index 33bf0d9..166ecbe 100644 (file)
@@ -681,6 +681,7 @@ public:
         @NO, WebKitInspectorAdditionsEnabledPreferenceKey,
         (NSString *)Settings::defaultMediaContentTypesRequiringHardwareSupport(), WebKitMediaContentTypesRequiringHardwareSupportPreferenceKey,
         @NO, WebKitAccessibilityObjectModelEnabledPreferenceKey,
+        @NO, WebKitMediaCapabilitiesEnabledPreferenceKey,
         nil];
 
 #if !PLATFORM(IOS)
@@ -3276,6 +3277,15 @@ static NSString *classIBCreatorID = nil;
     [self _setBoolValue:flag forKey:WebKitAccessibilityObjectModelEnabledPreferenceKey];
 }
 
+- (BOOL)mediaCapabilitiesEnabled
+{
+    return [self _boolValueForKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
+}
+
+- (void)setMediaCapabilitiesEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitMediaCapabilitiesEnabledPreferenceKey];
+}
 
 @end
 
index c92af29..3320d75 100644 (file)
@@ -597,6 +597,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 @property (nonatomic) BOOL inspectorAdditionsEnabled;
 @property (nonatomic) BOOL allowMediaContentTypesRequiringHardwareSupportAsFallback;
 @property (nonatomic) BOOL accessibilityObjectModelEnabled;
+@property (nonatomic) BOOL mediaCapabilitiesEnabled;
 
 #if TARGET_OS_IPHONE
 @property (nonatomic) BOOL quickLookDocumentSavingEnabled;
index 482a0d5..05735e6 100644 (file)
@@ -3045,6 +3045,7 @@ static bool needsSelfRetainWhileLoadingQuirk()
     RuntimeEnabledFeatures::sharedFeatures().setDirectoryUploadEnabled([preferences directoryUploadEnabled]);
     RuntimeEnabledFeatures::sharedFeatures().setMenuItemElementEnabled([preferences menuItemElementEnabled]);
     RuntimeEnabledFeatures::sharedFeatures().setAccessibilityObjectModelEnabled([preferences accessibilityObjectModelEnabled]);
+    RuntimeEnabledFeatures::sharedFeatures().setMediaCapabilitiesEnabled([preferences mediaCapabilitiesEnabled]);
     
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     RuntimeEnabledFeatures::sharedFeatures().setLegacyEncryptedMediaAPIEnabled(preferences.legacyEncryptedMediaAPIEnabled);
index f32e73e..470295d 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-21  Jer Noble  <jer.noble@apple.com>
+
+        Add initial DOM support for Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=181064
+
+        Reviewed by Eric Carlson.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+
 2017-12-21  Guillaume Emont  <guijemont@igalia.com>
 
         build-jsc: allow to build out of tree
index 5452d2d..fe509fb 100644 (file)
@@ -974,6 +974,7 @@ static void resetWebPreferencesToConsistentValues()
     [preferences setUserTimingEnabled:YES];
 
     [preferences setCacheAPIEnabled:NO];
+    preferences.mediaCapabilitiesEnabled = YES;
 
     [WebPreferences _clearNetworkLoaderSession];
     [WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain];
index 9527149..19f9f3b 100644 (file)
@@ -744,6 +744,7 @@ void TestController::resetPreferencesToConsistentValues(const TestOptions& optio
     WKPreferencesSetStorageAccessAPIEnabled(preferences, true);
     
     WKPreferencesSetAccessibilityObjectModelEnabled(preferences, true);
+    WKPreferencesSetMediaCapabilitiesEnabled(preferences, true);
 
     platformResetPreferencesToConsistentValues();
 }