Title: [236094] trunk
Revision
236094
Author
jer.no...@apple.com
Date
2018-09-17 16:24:21 -0700 (Mon, 17 Sep 2018)

Log Message

Add support for HEVC codec types in Media Capabilities
https://bugs.webkit.org/show_bug.cgi?id=189565

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/hevc-codec-parameters.html

Add some utility methods for parsing HEVC codec strings, and using those parsed
values to query the platform for detailed support for HEVC decoding.

Drive-by fix: Modify MediaEngineConfigurationFactory to allow for null function
pointers in the encode/decode factory pair.

* Sources.txt:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/cocoa/VideoToolboxSoftLink.cpp:
* platform/cocoa/VideoToolboxSoftLink.h:
* platform/graphics/HEVCUtilities.cpp: Added.
(WebCore::parseHEVCCodecParameters):
* platform/graphics/HEVCUtilities.h: Added.
* platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp: Added.
(WebCore::validateHEVCParameters):
* platform/graphics/cocoa/HEVCUtilitiesCocoa.h: Added.
* platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp: Added.
(WebCore::videoCodecTypeFromRFC4281Type):
(WebCore::createMediaPlayerDecodingConfigurationCocoa):
* platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.h: Added.
* platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
(WebCore::factories):
(WebCore::MediaEngineConfigurationFactory::createDecodingConfiguration):
(WebCore::MediaEngineConfigurationFactory::createEncodingConfiguration):
* testing/Internals.cpp:
(WebCore::Internals::parseHEVCCodecParameters):
* testing/Internals.h:
* testing/Internals.idl:

Source/WTF:

Extract the toIntegralType template into its own header.

* wtf/CMakeLists.txt:
* wtf/text/StringConversion.h: Added.
(isCharacterAllowedInBase):
(toIntegralType):
* wtf/text/WTFString.cpp:

LayoutTests:

* media/hevc-codec-parameters-expected.txt: Added.
* media/hevc-codec-parameters.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (236093 => 236094)


--- trunk/LayoutTests/ChangeLog	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/LayoutTests/ChangeLog	2018-09-17 23:24:21 UTC (rev 236094)
@@ -1,3 +1,13 @@
+2018-09-17  Jer Noble  <jer.no...@apple.com>
+
+        Add support for HEVC codec types in Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=189565
+
+        Reviewed by Eric Carlson.
+
+        * media/hevc-codec-parameters-expected.txt: Added.
+        * media/hevc-codec-parameters.html: Added.
+
 2018-09-17  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: generate CSSKeywordCompletions from backend values

Added: trunk/LayoutTests/media/hevc-codec-parameters-expected.txt (0 => 236094)


--- trunk/LayoutTests/media/hevc-codec-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/hevc-codec-parameters-expected.txt	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,9 @@
+EXPECTED (internals.parseHEVCCodecParameters("bad-parameter") == 'null') OK
+EXPECTED (internals.parseHEVCCodecParameters("hvc1") == 'null') OK
+EXPECTED (internals.parseHEVCCodecParameters("hev1.1.6.L93") === '{ 0, 1, 6, false, 93 }') OK
+EXPECTED (internals.parseHEVCCodecParameters("hev1.A4.41.H120") === '{ 1, 4, 65, true, 120 }') OK
+EXPECTED (internals.parseHEVCCodecParameters("hev1.B1.4.L63") === '{ 2, 1, 4, false, 63 }') OK
+EXPECTED (internals.parseHEVCCodecParameters("hev1.D1.4.L63") == 'null') OK
+EXPECTED (internals.parseHEVCCodecParameters("hev1.B1.4.L68000") == 'null') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/hevc-codec-parameters.html (0 => 236094)


--- trunk/LayoutTests/media/hevc-codec-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/media/hevc-codec-parameters.html	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script>
+    function HEVCParameterSetToString(set) {
+        return `{ ${set.generalProfileSpace }, ${set.generalProfileIDC }, ${set.generalProfileCompatibilityFlags }, ${set.generalTierFlag }, ${set.generalLevelIDC } }`;
+    }
+    function isEqualHEVCParameterSet(setA, setB) {
+        return setA.generalProfileSpace === setB.generalProfileSpace
+            && setA.generalProfileIDC === setB.generalProfileIDC
+            && setA.generalProfileCompatibilityFlags === setB.generalProfileCompatibilityFlags
+            && setA.generalTierFlag === setB.generalTierFlag
+            && setA.generalLevelIDC === setB.generalLevelIDC
+    }
+    function makeHEVCParameterSet(generalProfileSpace, generalProfileIDC, generalProfileCompatibilityFlags, generalTierFlag, generalLevelIDC)
+    {
+        return {
+            generalProfileSpace: generalProfileSpace,
+            generalProfileIDC: generalProfileIDC,
+            generalProfileCompatibilityFlags: generalProfileCompatibilityFlags,
+            generalTierFlag: generalTierFlag,
+            generalLevelIDC: generalLevelIDC,
+        };
+    }
+    function testExpectedHEVCParameterSet(testFuncString, expected)
+    {
+        let observed = eval(testFuncString);
+        let success = isEqualHEVCParameterSet(observed, expected);
+        reportExpected(success, testFuncString, '===', HEVCParameterSetToString(expected), HEVCParameterSetToString(observed));
+    }
+    window.addEventListener('load', event => {
+        testExpected('internals.parseHEVCCodecParameters("bad-parameter")', null);
+        testExpected('internals.parseHEVCCodecParameters("hvc1")', null);
+        testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.1.6.L93")', makeHEVCParameterSet(0, 1, 6, false, 93));
+        testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.A4.41.H120")', makeHEVCParameterSet(1, 4, 65, true, 120));
+        testExpectedHEVCParameterSet('internals.parseHEVCCodecParameters("hev1.B1.4.L63")', makeHEVCParameterSet(2, 1, 4, false, 63));
+        testExpected('internals.parseHEVCCodecParameters("hev1.D1.4.L63")', null);
+        testExpected('internals.parseHEVCCodecParameters("hev1.B1.4.L68000")', null);
+        endTest();
+    }, { once: true });
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/Source/WTF/ChangeLog (236093 => 236094)


--- trunk/Source/WTF/ChangeLog	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WTF/ChangeLog	2018-09-17 23:24:21 UTC (rev 236094)
@@ -1,5 +1,20 @@
 2018-09-17  Jer Noble  <jer.no...@apple.com>
 
+        Add support for HEVC codec types in Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=189565
+
+        Reviewed by Eric Carlson.
+
+        Extract the toIntegralType template into its own header.
+
+        * wtf/CMakeLists.txt:
+        * wtf/text/StringConversion.h: Added.
+        (isCharacterAllowedInBase):
+        (toIntegralType):
+        * wtf/text/WTFString.cpp:
+
+2018-09-17  Jer Noble  <jer.no...@apple.com>
+
         Enable USE_MEDIAREMOTE on iOS
         https://bugs.webkit.org/show_bug.cgi?id=189096
 

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (236093 => 236094)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2018-09-17 23:24:21 UTC (rev 236094)
@@ -329,6 +329,7 @@
 		2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopCF.cpp; sourceTree = "<group>"; };
 		2CDED0F118115C85004DBA70 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; };
 		2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; };
+		304CA4E41375437EBE931D03 /* Markable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Markable.h; sourceTree = "<group>"; };
 		3137E1D7DBD84AC38FAE4D34 /* IndexSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexSet.h; sourceTree = "<group>"; };
 		313EDEC9778E49C9BEA91CFC /* StackTrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackTrace.cpp; sourceTree = "<group>"; };
 		37C7CC291EA40A73007BD956 /* WeakLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakLinking.h; sourceTree = "<group>"; };
@@ -604,6 +605,7 @@
 		C4F8A93619C65EB400B2B15D /* Stopwatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Stopwatch.h; sourceTree = "<group>"; };
 		C6F050790D9C432A99085E75 /* ASCIILiteral.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ASCIILiteral.cpp; sourceTree = "<group>"; };
 		C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomDevice.cpp; sourceTree = "<group>"; };
+		CD00360D21501F7800F4ED4C /* StringToIntegerConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StringToIntegerConversion.h; sourceTree = "<group>"; };
 		CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
 		CD5497AB15857D0300B5BC30 /* MediaTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTime.h; sourceTree = "<group>"; };
 		CD6D9FCD1EEF3AD4008B0671 /* Algorithms.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Algorithms.h; sourceTree = "<group>"; };
@@ -632,7 +634,6 @@
 		E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilderJSON.cpp; sourceTree = "<group>"; };
 		E3A32BC21FC830E2007D7E76 /* JSValueMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSValueMalloc.cpp; sourceTree = "<group>"; };
 		E3A32BC31FC830E2007D7E76 /* JSValueMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueMalloc.h; sourceTree = "<group>"; };
-		304CA4E41375437EBE931D03 /* Markable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Markable.h; sourceTree = "<group>"; };
 		E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; };
 		E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; };
 		E431CC4A21187ADB000C8A07 /* DispatchSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DispatchSPI.h; sourceTree = "<group>"; };
@@ -1226,6 +1227,7 @@
 				A8A47328151A825B004123FF /* StringImpl.cpp */,
 				A8A47329151A825B004123FF /* StringImpl.h */,
 				A8A4732A151A825B004123FF /* StringOperators.h */,
+				CD00360D21501F7800F4ED4C /* StringToIntegerConversion.h */,
 				93F1993D19D7958D00C2390B /* StringView.cpp */,
 				1A6EB1DF187D0BD30030126F /* StringView.h */,
 				F72BBDB107FA424886178B9E /* SymbolImpl.cpp */,

Modified: trunk/Source/WTF/wtf/CMakeLists.txt (236093 => 236094)


--- trunk/Source/WTF/wtf/CMakeLists.txt	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WTF/wtf/CMakeLists.txt	2018-09-17 23:24:21 UTC (rev 236094)
@@ -301,6 +301,7 @@
     text/StringHasher.h
     text/StringImpl.h
     text/StringOperators.h
+    text/StringToIntegerConversion.h
     text/StringView.h
     text/SymbolImpl.h
     text/SymbolRegistry.h

Added: trunk/Source/WTF/wtf/text/StringToIntegerConversion.h (0 => 236094)


--- trunk/Source/WTF/wtf/text/StringToIntegerConversion.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/text/StringToIntegerConversion.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WTF {
+
+inline bool isCharacterAllowedInBase(UChar c, int base)
+{
+    if (c > 0x7F)
+        return false;
+    if (isASCIIDigit(c))
+        return c - '0' < base;
+    if (isASCIIAlpha(c)) {
+        if (base > 36)
+            base = 36;
+        return (c >= 'a' && c < 'a' + base - 10)
+            || (c >= 'A' && c < 'A' + base - 10);
+    }
+    return false;
+}
+
+template<typename IntegralType, typename CharacterType>
+inline IntegralType toIntegralType(const CharacterType* data, size_t length, bool* ok = nullptr, int base = 10)
+{
+    static const IntegralType integralMax = std::numeric_limits<IntegralType>::max();
+    static const bool isSigned = std::numeric_limits<IntegralType>::is_signed;
+    const IntegralType maxMultiplier = integralMax / base;
+
+    IntegralType value = 0;
+    bool isOk = false;
+    bool isNegative = false;
+
+    if (!data)
+        goto bye;
+
+    // skip leading whitespace
+    while (length && isSpaceOrNewline(*data)) {
+        --length;
+        ++data;
+    }
+
+    if (isSigned && length && *data == '-') {
+        --length;
+        ++data;
+        isNegative = true;
+    } else if (length && *data == '+') {
+        --length;
+        ++data;
+    }
+
+    if (!length || !isCharacterAllowedInBase(*data, base))
+        goto bye;
+
+    while (length && isCharacterAllowedInBase(*data, base)) {
+        --length;
+        IntegralType digitValue;
+        auto c = *data;
+        if (isASCIIDigit(c))
+            digitValue = c - '0';
+        else if (c >= 'a')
+            digitValue = c - 'a' + 10;
+        else
+            digitValue = c - 'A' + 10;
+
+        if (value > maxMultiplier || (value == maxMultiplier && digitValue > (integralMax % base) + isNegative))
+            goto bye;
+
+        value = base * value + digitValue;
+        ++data;
+    }
+
+#if COMPILER(MSVC)
+#pragma warning(push, 0)
+#pragma warning(disable:4146)
+#endif
+
+    if (isNegative)
+        value = -value;
+
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+
+    // skip trailing space
+    while (length && isSpaceOrNewline(*data)) {
+        --length;
+        ++data;
+    }
+
+    if (!length)
+        isOk = true;
+bye:
+    if (ok)
+        *ok = isOk;
+    return isOk ? value : 0;
+}
+
+template<typename IntegralType, typename StringOrStringView>
+inline IntegralType toIntegralType(const StringOrStringView& stringView, bool* ok = nullptr, int base = 10)
+{
+    if (stringView.is8Bit())
+        return toIntegralType<IntegralType, LChar>(stringView.characters8(), stringView.length(), ok, base);
+    return toIntegralType<IntegralType, UChar>(stringView.characters16(), stringView.length(), ok, base);
+}
+
+}
+
+using WTF::toIntegralType;

Modified: trunk/Source/WTF/wtf/text/WTFString.cpp (236093 => 236094)


--- trunk/Source/WTF/wtf/text/WTFString.cpp	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WTF/wtf/text/WTFString.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -29,9 +29,10 @@
 #include <wtf/HexNumber.h>
 #include <wtf/MathExtras.h>
 #include <wtf/NeverDestroyed.h>
-#include <wtf/text/CString.h>
 #include <wtf/Vector.h>
 #include <wtf/dtoa.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringToIntegerConversion.h>
 #include <wtf/unicode/CharacterNames.h>
 #include <wtf/unicode/UTF8.h>
 
@@ -930,98 +931,6 @@
 }
 
 // String Operations
-
-static bool isCharacterAllowedInBase(UChar c, int base)
-{
-    if (c > 0x7F)
-        return false;
-    if (isASCIIDigit(c))
-        return c - '0' < base;
-    if (isASCIIAlpha(c)) {
-        if (base > 36)
-            base = 36;
-        return (c >= 'a' && c < 'a' + base - 10)
-            || (c >= 'A' && c < 'A' + base - 10);
-    }
-    return false;
-}
-
-template<typename IntegralType, typename CharacterType>
-static inline IntegralType toIntegralType(const CharacterType* data, size_t length, bool* ok, int base)
-{
-    static const IntegralType integralMax = std::numeric_limits<IntegralType>::max();
-    static const bool isSigned = std::numeric_limits<IntegralType>::is_signed;
-    const IntegralType maxMultiplier = integralMax / base;
-
-    IntegralType value = 0;
-    bool isOk = false;
-    bool isNegative = false;
-
-    if (!data)
-        goto bye;
-
-    // skip leading whitespace
-    while (length && isSpaceOrNewline(*data)) {
-        --length;
-        ++data;
-    }
-
-    if (isSigned && length && *data == '-') {
-        --length;
-        ++data;
-        isNegative = true;
-    } else if (length && *data == '+') {
-        --length;
-        ++data;
-    }
-
-    if (!length || !isCharacterAllowedInBase(*data, base))
-        goto bye;
-
-    while (length && isCharacterAllowedInBase(*data, base)) {
-        --length;
-        IntegralType digitValue;
-        auto c = *data;
-        if (isASCIIDigit(c))
-            digitValue = c - '0';
-        else if (c >= 'a')
-            digitValue = c - 'a' + 10;
-        else
-            digitValue = c - 'A' + 10;
-
-        if (value > maxMultiplier || (value == maxMultiplier && digitValue > (integralMax % base) + isNegative))
-            goto bye;
-
-        value = base * value + digitValue;
-        ++data;
-    }
-
-#if COMPILER(MSVC)
-#pragma warning(push, 0)
-#pragma warning(disable:4146)
-#endif
-
-    if (isNegative)
-        value = -value;
-
-#if COMPILER(MSVC)
-#pragma warning(pop)
-#endif
-
-    // skip trailing space
-    while (length && isSpaceOrNewline(*data)) {
-        --length;
-        ++data;
-    }
-
-    if (!length)
-        isOk = true;
-bye:
-    if (ok)
-        *ok = isOk;
-    return isOk ? value : 0;
-}
-
 template<typename CharacterType>
 static unsigned lengthOfCharactersAsInteger(const CharacterType* data, size_t length)
 {

Modified: trunk/Source/WebCore/ChangeLog (236093 => 236094)


--- trunk/Source/WebCore/ChangeLog	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/ChangeLog	2018-09-17 23:24:21 UTC (rev 236094)
@@ -1,3 +1,42 @@
+2018-09-17  Jer Noble  <jer.no...@apple.com>
+
+        Add support for HEVC codec types in Media Capabilities
+        https://bugs.webkit.org/show_bug.cgi?id=189565
+
+        Reviewed by Eric Carlson.
+
+        Test: media/hevc-codec-parameters.html
+
+        Add some utility methods for parsing HEVC codec strings, and using those parsed
+        values to query the platform for detailed support for HEVC decoding.
+
+        Drive-by fix: Modify MediaEngineConfigurationFactory to allow for null function
+        pointers in the encode/decode factory pair.
+
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/cocoa/VideoToolboxSoftLink.cpp:
+        * platform/cocoa/VideoToolboxSoftLink.h:
+        * platform/graphics/HEVCUtilities.cpp: Added.
+        (WebCore::parseHEVCCodecParameters):
+        * platform/graphics/HEVCUtilities.h: Added.
+        * platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp: Added.
+        (WebCore::validateHEVCParameters):
+        * platform/graphics/cocoa/HEVCUtilitiesCocoa.h: Added.
+        * platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp: Added.
+        (WebCore::videoCodecTypeFromRFC4281Type):
+        (WebCore::createMediaPlayerDecodingConfigurationCocoa):
+        * platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.h: Added.
+        * platform/mediacapabilities/MediaEngineConfigurationFactory.cpp:
+        (WebCore::factories):
+        (WebCore::MediaEngineConfigurationFactory::createDecodingConfiguration):
+        (WebCore::MediaEngineConfigurationFactory::createEncodingConfiguration):
+        * testing/Internals.cpp:
+        (WebCore::Internals::parseHEVCCodecParameters):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-09-17  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: generate CSSKeywordCompletions from backend values

Modified: trunk/Source/WebCore/Sources.txt (236093 => 236094)


--- trunk/Source/WebCore/Sources.txt	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/Sources.txt	2018-09-17 23:24:21 UTC (rev 236094)
@@ -1622,6 +1622,7 @@
 platform/graphics/GraphicsLayerTransform.cpp
 platform/graphics/GraphicsLayerUpdater.cpp
 platform/graphics/GraphicsTypes.cpp
+platform/graphics/HEVCUtilities.cpp
 platform/graphics/Image.cpp
 platform/graphics/ImageBuffer.cpp
 platform/graphics/ImageDecoder.cpp

Modified: trunk/Source/WebCore/SourcesCocoa.txt (236093 => 236094)


--- trunk/Source/WebCore/SourcesCocoa.txt	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/SourcesCocoa.txt	2018-09-17 23:24:21 UTC (rev 236094)
@@ -301,8 +301,10 @@
 platform/graphics/cocoa/FontDescriptionCocoa.cpp
 platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
 platform/graphics/cocoa/FontPlatformDataCocoa.mm
+platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp
 platform/graphics/cocoa/IOSurface.mm
 platform/graphics/cocoa/IOSurfacePoolCocoa.mm
+platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp
 platform/graphics/cocoa/WebActionDisablingCALayerDelegate.mm
 platform/graphics/cocoa/WebCoreCALayerExtras.mm
 platform/graphics/cocoa/WebCoreDecompressionSession.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (236093 => 236094)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-17 23:24:21 UTC (rev 236094)
@@ -4033,6 +4033,8 @@
 		CDA29A171CBDA56C00901CCF /* PlaybackSessionInterfaceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A151CBDA56C00901CCF /* PlaybackSessionInterfaceMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CDA29A301CBF74D400901CCF /* PlaybackSessionInterfaceAVKit.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A2F1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.mm */; };
 		CDA29A321CC01A9500901CCF /* PlaybackSessionInterfaceAVKit.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A2E1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		CDA595932146DEC300A84185 /* HEVCUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA595912146DEC300A84185 /* HEVCUtilities.h */; };
+		CDA595982146DF7800A84185 /* HEVCUtilitiesCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA595962146DF7800A84185 /* HEVCUtilitiesCocoa.h */; };
 		CDA79827170A279100D45C55 /* AudioSessionIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA79825170A279000D45C55 /* AudioSessionIOS.mm */; };
 		CDA7982A170A3D0000D45C55 /* AudioSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA79821170A22DC00D45C55 /* AudioSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA98E091603CD5900FEA3B1 /* LegacyCDM.cpp */; };
@@ -4046,6 +4048,7 @@
 		CDC224281F756966005F077B /* CDMInstanceFairPlayStreamingAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78A2EC1F75648600DE371B /* CDMInstanceFairPlayStreamingAVFObjC.mm */; };
 		CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDC26B3C160A62B00026757B /* LegacyMockCDM.cpp */; };
 		CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC26B3D160A62B00026757B /* LegacyMockCDM.h */; };
+		CDC48AC92149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC48AC72149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h */; };
 		CDC675221EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC675201EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.mm */; };
 		CDC675231EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC675211EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h */; };
 		CDC675271EAEA9D400727C84 /* AVAudioSessionCaptureDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC675251EAEA9D400727C84 /* AVAudioSessionCaptureDevice.h */; };
@@ -13333,6 +13336,10 @@
 		CDA29A2D1CBF73FC00901CCF /* WebAVPlayerController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAVPlayerController.mm; sourceTree = "<group>"; };
 		CDA29A2E1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaybackSessionInterfaceAVKit.h; sourceTree = "<group>"; };
 		CDA29A2F1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlaybackSessionInterfaceAVKit.mm; sourceTree = "<group>"; };
+		CDA595912146DEC300A84185 /* HEVCUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HEVCUtilities.h; sourceTree = "<group>"; };
+		CDA595922146DEC300A84185 /* HEVCUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HEVCUtilities.cpp; sourceTree = "<group>"; };
+		CDA595962146DF7800A84185 /* HEVCUtilitiesCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HEVCUtilitiesCocoa.h; sourceTree = "<group>"; };
+		CDA595972146DF7800A84185 /* HEVCUtilitiesCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HEVCUtilitiesCocoa.cpp; sourceTree = "<group>"; };
 		CDA79821170A22DC00D45C55 /* AudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioSession.h; sourceTree = "<group>"; };
 		CDA79823170A258300D45C55 /* AudioSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSession.cpp; sourceTree = "<group>"; };
 		CDA79825170A279000D45C55 /* AudioSessionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioSessionIOS.mm; sourceTree = "<group>"; };
@@ -13389,6 +13396,8 @@
 		CDC1DD4117CC2C48008CB55D /* mediaControlsApple.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = mediaControlsApple.css; sourceTree = "<group>"; };
 		CDC26B3C160A62B00026757B /* LegacyMockCDM.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LegacyMockCDM.cpp; sourceTree = "<group>"; };
 		CDC26B3D160A62B00026757B /* LegacyMockCDM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LegacyMockCDM.h; sourceTree = "<group>"; };
+		CDC48AC72149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaEngineConfigurationFactoryCocoa.h; sourceTree = "<group>"; };
+		CDC48AC82149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEngineConfigurationFactoryCocoa.cpp; sourceTree = "<group>"; };
 		CDC675201EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AVAudioSessionCaptureDeviceManager.mm; sourceTree = "<group>"; };
 		CDC675211EAEA9B700727C84 /* AVAudioSessionCaptureDeviceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AVAudioSessionCaptureDeviceManager.h; sourceTree = "<group>"; };
 		CDC675241EAEA9D400727C84 /* AVAudioSessionCaptureDevice.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = AVAudioSessionCaptureDevice.mm; sourceTree = "<group>"; };
@@ -23715,6 +23724,8 @@
 				B2A015940AF6CD53006BCE0E /* GraphicsTypes.cpp */,
 				B2A015950AF6CD53006BCE0E /* GraphicsTypes.h */,
 				77A17A7A12F2890B004E02F6 /* GraphicsTypes3D.h */,
+				CDA595922146DEC300A84185 /* HEVCUtilities.cpp */,
+				CDA595912146DEC300A84185 /* HEVCUtilities.h */,
 				B27535400B053814002CE64F /* Icon.h */,
 				B27535410B053814002CE64F /* Image.cpp */,
 				B27535420B053814002CE64F /* Image.h */,
@@ -23927,9 +23938,13 @@
 				B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
 				49FFBF1C11C8550E006A7118 /* GraphicsContext3DCocoa.mm */,
 				B277B4030B22F37C0004BEC6 /* GraphicsContextCocoa.mm */,
+				CDA595972146DF7800A84185 /* HEVCUtilitiesCocoa.cpp */,
+				CDA595962146DF7800A84185 /* HEVCUtilitiesCocoa.h */,
 				2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
 				2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
 				AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
+				CDC48AC72149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h */,
+				CDC48AC82149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.cpp */,
 				526724F21CB2FDF60075974D /* TextTrackRepresentationCocoa.h */,
 				526724F11CB2FDF60075974D /* TextTrackRepresentationCocoa.mm */,
 				2D3EF4441917915C00034184 /* WebActionDisablingCALayerDelegate.h */,
@@ -28146,6 +28161,8 @@
 				26EA89A71B4F2B75008C5FD2 /* HashableActionList.h in Headers */,
 				8482B7461198C35400BFB005 /* HashChangeEvent.h in Headers */,
 				A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */,
+				CDA595932146DEC300A84185 /* HEVCUtilities.h in Headers */,
+				CDA595982146DF7800A84185 /* HEVCUtilitiesCocoa.h in Headers */,
 				F55B3DC01251F12D003EF269 /* HiddenInputType.h in Headers */,
 				515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */,
 				515BE19E1D54F6C100DD7C68 /* HIDGamepadProvider.h in Headers */,
@@ -30261,6 +30278,7 @@
 				517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */,
 				517A53291F4B90B900DCDC0A /* ServiceWorkerRegistrationKey.h in Headers */,
 				51F175691F3EBC8300C74950 /* ServiceWorkerRegistrationOptions.h in Headers */,
+				CDC48AC92149CF2A0024FD59 /* MediaEngineConfigurationFactoryCocoa.h in Headers */,
 				51BCCE301F8F179E006BA0ED /* ServiceWorkerThread.h in Headers */,
 				4112B5431F9F9CA000E67875 /* ServiceWorkerThreadProxy.h in Headers */,
 				515E37F61FAA940200D7F22A /* ServiceWorkerTypes.h in Headers */,

Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp (236093 => 236094)


--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -45,6 +45,8 @@
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTIsHardwareDecodeSupported, Boolean, (CMVideoCodecType codecType), (codecType))
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTGetGVADecoderAvailability, OSStatus, (uint32_t* totalInstanceCountOut, uint32_t* freeInstanceCountOut), (totalInstanceCountOut, freeInstanceCountOut))
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut))
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTCopyHEVCDecoderCapabilitiesDictionary, CFDictionaryRef, (), ())
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, VTGetHEVCCapabilitesForFormatDescription, OSStatus, (CMVideoFormatDescriptionRef formatDescription, CFDictionaryRef decoderCapabilitiesDict, Boolean* isDecodable, Boolean* mayBePlayable), (formatDescription, decoderCapabilitiesDict, isDecodable, mayBePlayable))
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTDecompressionPropertyKey_PixelBufferPool, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTDecompressionPropertyKey_SuggestedQualityOfServiceTiers, CFStringRef)
@@ -57,3 +59,9 @@
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, VideoToolbox, VTSessionSetProperty, OSStatus, (VTSessionRef session, CFStringRef propertyKey, CFTypeRef propertyValue), (session, propertyKey, propertyValue))
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTPixelTransferPropertyKey_ScalingMode, CFStringRef)
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
+
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, kVTHEVCDecoderCapability_SupportedProfiles, CFStringRef)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, kVTHEVCDecoderCapability_PerProfileSupport, CFStringRef)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_IsHardwareAccelerated, CFStringRef)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_MaxDecodeLevel, CFStringRef)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_MaxPlaybackLevel, CFStringRef)

Modified: trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h (236093 => 236094)


--- trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/platform/cocoa/VideoToolboxSoftLink.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -57,6 +57,10 @@
 #define VTGetGVADecoderAvailability softLink_VideoToolbox_VTGetGVADecoderAvailability
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTCreateCGImageFromCVPixelBuffer, OSStatus, (CVPixelBufferRef pixelBuffer, CFDictionaryRef options, CGImageRef* imageOut), (pixelBuffer, options, imageOut))
 #define VTCreateCGImageFromCVPixelBuffer softLink_VideoToolbox_VTCreateCGImageFromCVPixelBuffer
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTCopyHEVCDecoderCapabilitiesDictionary, CFDictionaryRef, (), ())
+#define VTCopyHEVCDecoderCapabilitiesDictionary softLink_VideoToolbox_VTCopyHEVCDecoderCapabilitiesDictionary
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, VTGetHEVCCapabilitesForFormatDescription, OSStatus, (CMVideoFormatDescriptionRef formatDescription, CFDictionaryRef decoderCapabilitiesDict, Boolean* isDecodable, Boolean* mayBePlayable), (formatDescription, decoderCapabilitiesDict, isDecodable, mayBePlayable))
+#define VTGetHEVCCapabilitesForFormatDescription softLink_VideoToolbox_VTGetHEVCCapabilitesForFormatDescription
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder, CFStringRef)
 #define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder get_VideoToolbox_kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTDecompressionPropertyKey_PixelBufferPool, CFStringRef)
@@ -81,3 +85,14 @@
 #define kVTPixelTransferPropertyKey_ScalingMode get_VideoToolbox_kVTPixelTransferPropertyKey_ScalingMode()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, VideoToolbox, kVTScalingMode_Trim, CFStringRef)
 #define kVTScalingMode_Trim get_VideoToolbox_kVTScalingMode_Trim()
+
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, kVTHEVCDecoderCapability_SupportedProfiles, CFStringRef)
+#define kVTHEVCDecoderCapability_SupportedProfiles get_VideoToolbox_kVTHEVCDecoderCapability_SupportedProfiles()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, kVTHEVCDecoderCapability_PerProfileSupport, CFStringRef)
+#define kVTHEVCDecoderCapability_PerProfileSupport get_VideoToolbox_kVTHEVCDecoderCapability_PerProfileSupport()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_IsHardwareAccelerated, CFStringRef)
+#define kVTHEVCDecoderProfileCapability_IsHardwareAccelerated get_VideoToolbox_kVTHEVCDecoderProfileCapability_IsHardwareAccelerated()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_MaxDecodeLevel, CFStringRef)
+#define kVTHEVCDecoderProfileCapability_MaxDecodeLevel get_VideoToolbox_kVTHEVCDecoderProfileCapability_MaxDecodeLevel()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(WebCore, VideoToolbox, kVTHEVCDecoderProfileCapability_MaxPlaybackLevel, CFStringRef)
+#define kVTHEVCDecoderProfileCapability_MaxPlaybackLevel get_VideoToolbox_kVTHEVCDecoderProfileCapability_MaxPlaybackLevel()

Added: trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/HEVCUtilities.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HEVCUtilities.h"
+
+#include <wtf/text/StringToIntegerConversion.h>
+
+namespace WebCore {
+
+std::optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString)
+{
+    // The format of the 'hevc' codec string is specified in ISO/IEC 14496-15:2014, Annex E.3.
+    StringView codecView(codecString);
+    auto codecSplit = codecView.split('.');
+    auto nextElement = codecSplit.begin();
+    if (nextElement == codecSplit.end())
+        return std::nullopt;
+
+    HEVCParameterSet parameters;
+
+    // Codec identifier: legal values are specified in ISO/IEC 14496-15:2014, section 8:
+    parameters.codecName = (*nextElement).toString();
+    if (!equal(parameters.codecName, "hvc1") && !equal(parameters.codecName, "hev1"))
+        return std::nullopt;
+
+    if (++nextElement == codecSplit.end())
+        return std::nullopt;
+
+    // First element: Optional General Profile Space parameter ['A', 'B', 'C'], mapping to [1, 2, 3]
+    // and [0] for absent, then General Profile IDC as a 5-bit decimal number.
+    auto profileSpace = *nextElement;
+    if (!profileSpace.length())
+        return std::nullopt;
+
+    auto firstCharacter = profileSpace[0];
+    bool hasProfileSpace = firstCharacter >= 'A' && firstCharacter <= 'C';
+    if (hasProfileSpace) {
+        parameters.generalProfileSpace = 1 + (firstCharacter - 'A');
+        profileSpace = profileSpace.substring(1);
+    }
+
+    bool isValidProfileIDC = false;
+    parameters.generalProfileIDC = toIntegralType<uint8_t>(profileSpace, &isValidProfileIDC);
+    if (!isValidProfileIDC)
+        return std::nullopt;
+
+    if (++nextElement == codecSplit.end())
+        return std::nullopt;
+
+    // Second element: 32 bit of General Profile Compatibility Flags, in reverse bit order,
+    // in hex with leading zeros omitted.
+    auto compatibilityFlags = *nextElement;
+    bool isValidCompatibilityFlags = false;
+    parameters.generalProfileCompatibilityFlags = toIntegralType<uint32_t>(compatibilityFlags, &isValidCompatibilityFlags, 16);
+    if (!isValidCompatibilityFlags)
+        return std::nullopt;
+
+    if (++nextElement == codecSplit.end())
+        return std::nullopt;
+
+    // Third element: General Tier Flag ['L', 'H'], mapping to [false, true], followed by
+    // General Level IDC as a 8-bit decimal number.
+    auto generalTier = *nextElement;
+    firstCharacter = generalTier[0];
+    if (firstCharacter != 'L' && firstCharacter != 'H')
+        return std::nullopt;
+
+    parameters.generalTierFlag = firstCharacter == 'H';
+    bool isValidGeneralLevelIDC = false;
+    parameters.generalLevelIDC = toIntegralType<uint8_t>(generalTier.substring(1), &isValidGeneralLevelIDC);
+    if (!isValidGeneralLevelIDC)
+        return std::nullopt;
+
+    // Optional fourth and remaning elements: a sequence of 6 1-byte constraint flags, each byte encoded
+    // in hex, and separated by a period, with trailing zero bytes omitted.
+    parameters.constraintFlags.fill(0, 6);
+    for (auto& flag : parameters.constraintFlags) {
+        if (++nextElement == codecSplit.end())
+            break;
+
+        bool isValidFlag = false;
+        flag = toIntegralType<uint8_t>(*nextElement, &isValidFlag, 16);
+        if (!isValidFlag)
+            return std::nullopt;
+    }
+
+    return WTFMove(parameters);
+}
+
+}

Added: trunk/Source/WebCore/platform/graphics/HEVCUtilities.h (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/HEVCUtilities.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/HEVCUtilities.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct HEVCParameterSet {
+    String codecName;
+    unsigned short generalProfileSpace { 0 };
+    unsigned short generalProfileIDC { 0 };
+    uint32_t generalProfileCompatibilityFlags { 0 };
+    bool generalTierFlag { false };
+    unsigned short generalLevelIDC { 0 };
+    Vector<unsigned short> constraintFlags { 6, 0 };
+};
+
+WEBCORE_EXPORT std::optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString);
+
+}

Added: trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HEVCUtilitiesCocoa.h"
+
+#if PLATFORM(COCOA)
+
+#include "HEVCUtilities.h"
+#include "MediaCapabilitiesInfo.h"
+
+#include "VideoToolboxSoftLink.h"
+
+namespace WebCore {
+
+bool validateHEVCParameters(HEVCParameterSet& parameters, MediaCapabilitiesInfo& info)
+{
+    if (!canLoad_VideoToolbox_VTCopyHEVCDecoderCapabilitiesDictionary()
+        || !canLoad_VideoToolbox_kVTHEVCDecoderCapability_SupportedProfiles()
+        || !canLoad_VideoToolbox_kVTHEVCDecoderCapability_PerProfileSupport()
+        || !canLoad_VideoToolbox_kVTHEVCDecoderProfileCapability_IsHardwareAccelerated()
+        || !canLoad_VideoToolbox_kVTHEVCDecoderProfileCapability_MaxDecodeLevel()
+        || !canLoad_VideoToolbox_kVTHEVCDecoderProfileCapability_MaxPlaybackLevel())
+        return false;
+
+    RetainPtr<CFDictionaryRef> capabilities = adoptCF(VTCopyHEVCDecoderCapabilitiesDictionary());
+    if (!capabilities)
+        return false;
+
+    auto supportedProfiles = (CFArrayRef)CFDictionaryGetValue(capabilities.get(), kVTHEVCDecoderCapability_SupportedProfiles);
+    if (!supportedProfiles || CFGetTypeID(supportedProfiles) != CFArrayGetTypeID())
+        return false;
+
+    int16_t generalProfileIDC = parameters.generalProfileIDC;
+    auto cfGeneralProfileIDC = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt16Type, &generalProfileIDC));
+    auto searchRange = CFRangeMake(0, CFArrayGetCount(supportedProfiles));
+    if (!CFArrayContainsValue(supportedProfiles, searchRange, cfGeneralProfileIDC.get()))
+        return false;
+
+    auto perProfileSupport = (CFDictionaryRef)CFDictionaryGetValue(capabilities.get(), kVTHEVCDecoderCapability_PerProfileSupport);
+    if (!perProfileSupport || CFGetTypeID(perProfileSupport) != CFDictionaryGetTypeID())
+        return false;
+
+    auto generalProfileIDCString = String::number(generalProfileIDC).createCFString();
+    auto profileSupport = (CFDictionaryRef)CFDictionaryGetValue(perProfileSupport, generalProfileIDCString.get());
+    if (!profileSupport || CFGetTypeID(profileSupport) != CFDictionaryGetTypeID())
+        return false;
+
+    auto isHardwareAccelerated = (CFBooleanRef)CFDictionaryGetValue(profileSupport, kVTHEVCDecoderProfileCapability_IsHardwareAccelerated);
+    if (isHardwareAccelerated && CFGetTypeID(isHardwareAccelerated) == CFBooleanGetTypeID())
+        info.powerEfficient = CFBooleanGetValue(isHardwareAccelerated);
+
+    auto cfMaxDecodeLevel = (CFNumberRef)CFDictionaryGetValue(profileSupport, kVTHEVCDecoderProfileCapability_MaxDecodeLevel);
+    if (cfMaxDecodeLevel && CFGetTypeID(cfMaxDecodeLevel) == CFNumberGetTypeID()) {
+        int16_t maxDecodeLevel = 0;
+        if (!CFNumberGetValue(cfMaxDecodeLevel, kCFNumberSInt16Type, &maxDecodeLevel))
+            return false;
+
+        if (parameters.generalLevelIDC > maxDecodeLevel)
+            return false;
+
+        info.supported = true;
+    }
+
+    auto cfMaxPlaybackLevel = (CFNumberRef)CFDictionaryGetValue(profileSupport, kVTHEVCDecoderProfileCapability_MaxPlaybackLevel);
+    if (cfMaxPlaybackLevel && CFGetTypeID(cfMaxPlaybackLevel) == CFNumberGetTypeID()) {
+        int16_t maxPlaybackLevel = 0;
+        if (!CFNumberGetValue(cfMaxPlaybackLevel, kCFNumberSInt16Type, &maxPlaybackLevel))
+            return false;
+
+        info.smooth = parameters.generalLevelIDC <= maxPlaybackLevel;
+    }
+
+    return true;
+}
+
+}
+
+#endif // PLATFORM(COCOA)

Added: trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.h (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/HEVCUtilitiesCocoa.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(COCOA)
+
+#include "HEVCUtilities.h"
+
+namespace WebCore {
+
+struct MediaCapabilitiesInfo;
+
+extern bool validateHEVCParameters(HEVCParameterSet&, MediaCapabilitiesInfo&);
+
+}
+
+#endif

Added: trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaEngineConfigurationFactoryCocoa.h"
+
+#if PLATFORM(COCOA)
+
+#include "HEVCUtilitiesCocoa.h"
+#include "MediaCapabilitiesInfo.h"
+#include "MediaDecodingConfiguration.h"
+#include "MediaPlayer.h"
+
+#include "VideoToolboxSoftLink.h"
+
+namespace WebCore {
+
+static CMVideoCodecType videoCodecTypeFromRFC4281Type(String type)
+{
+    if (type.startsWith("mp4v"))
+        return kCMVideoCodecType_MPEG4Video;
+    if (type.startsWith("avc1") || type.startsWith("avc3"))
+        return kCMVideoCodecType_H264;
+    if (type.startsWith("hvc1") || type.startsWith("hev1"))
+        return kCMVideoCodecType_HEVC;
+    return 0;
+}
+
+void createMediaPlayerDecodingConfigurationCocoa(MediaDecodingConfiguration& configuration, WTF::Function<void(MediaCapabilitiesInfo&&)>&& callback)
+{
+    MediaCapabilitiesInfo info;
+    if (configuration.video) {
+        auto& videoConfiguration = configuration.video.value();
+        MediaEngineSupportParameters parameters { };
+        parameters.type = ContentType(videoConfiguration.contentType);
+        parameters.isMediaSource = configuration.type == MediaDecodingType::MediaSource;
+        if (MediaPlayer::supportsType(parameters) != MediaPlayer::IsSupported) {
+            callback({ });
+            return;
+        }
+        info.supported = true;
+
+        auto codecs = parameters.type.codecs();
+        if (codecs.size() != 1) {
+            callback({ });
+            return;
+        }
+
+        info.supported = true;
+        auto& codec = codecs[0];
+        auto videoCodecType = videoCodecTypeFromRFC4281Type(codec);
+        if (!videoCodecType) {
+            callback({ });
+            return;
+        }
+
+        if (videoCodecType == kCMVideoCodecType_HEVC) {
+            auto parameters = parseHEVCCodecParameters(codec);
+            if (!parameters || !validateHEVCParameters(parameters.value(), info)) {
+                callback({ });
+                return;
+            }
+        } else if (canLoad_VideoToolbox_VTIsHardwareDecodeSupported())
+            info.powerEfficient = VTIsHardwareDecodeSupported(videoCodecType);
+    }
+
+    if (configuration.audio) {
+        MediaEngineSupportParameters parameters { };
+        parameters.type = ContentType(configuration.audio.value().contentType);
+        parameters.isMediaSource = configuration.type == MediaDecodingType::MediaSource;
+        if (MediaPlayer::supportsType(parameters) != MediaPlayer::IsSupported) {
+            callback({ });
+            return;
+        }
+        info.supported = true;
+    }
+
+    callback(WTFMove(info));
+}
+
+}
+#endif

Added: trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.h (0 => 236094)


--- trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/MediaEngineConfigurationFactoryCocoa.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(COCOA)
+
+namespace WebCore {
+
+struct MediaCapabilitiesInfo;
+struct MediaDecodingConfiguration;
+
+extern void createMediaPlayerDecodingConfigurationCocoa(MediaDecodingConfiguration&, WTF::Function<void(MediaCapabilitiesInfo&&)>&&);
+
+}
+
+#endif

Modified: trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp (236093 => 236094)


--- trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/platform/mediacapabilities/MediaEngineConfigurationFactory.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -35,6 +35,10 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Vector.h>
 
+#if PLATFORM(COCOA)
+#include "MediaEngineConfigurationFactoryCocoa.h"
+#endif
+
 namespace WebCore {
 
 static bool& mockEnabled()
@@ -51,7 +55,11 @@
 using FactoryVector = Vector<MediaEngineFactory>;
 static const FactoryVector& factories()
 {
-    static NeverDestroyed<FactoryVector> factories = makeNeverDestroyed(FactoryVector({ }));
+    static NeverDestroyed<FactoryVector> factories = makeNeverDestroyed(FactoryVector({
+#if PLATFORM(COCOA)
+        { &createMediaPlayerDecodingConfigurationCocoa, nullptr },
+#endif
+    }));
     return factories;
 }
 
@@ -69,6 +77,11 @@
         }
 
         auto& factory = *nextFactory;
+        if (!factory.createDecodingConfiguration) {
+            callback({ });
+            return;
+        }
+
         factory.createDecodingConfiguration(config, [factoryCallback, nextFactory, config, callback = WTFMove(callback)] (auto&& info) mutable {
             if (info.supported) {
                 callback(WTFMove(info));
@@ -95,6 +108,11 @@
         }
 
         auto& factory = *nextFactory;
+        if (!factory.createEncodingConfiguration) {
+            callback({ });
+            return;
+        }
+
         factory.createEncodingConfiguration(config, [factoryCallback, nextFactory, config, callback = WTFMove(callback)] (auto&& info) mutable {
             if (info.supported) {
                 callback(WTFMove(info));

Modified: trunk/Source/WebCore/testing/Internals.cpp (236093 => 236094)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-09-17 23:24:21 UTC (rev 236094)
@@ -74,6 +74,7 @@
 #include "FrameView.h"
 #include "GCObservation.h"
 #include "GridPosition.h"
+#include "HEVCUtilities.h"
 #include "HTMLAnchorElement.h"
 #include "HTMLCanvasElement.h"
 #include "HTMLIFrameElement.h"
@@ -4737,4 +4738,9 @@
 #endif
 }
 
+std::optional<HEVCParameterSet> Internals::parseHEVCCodecParameters(const String& codecString)
+{
+    return WebCore::parseHEVCCodecParameters(codecString);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (236093 => 236094)


--- trunk/Source/WebCore/testing/Internals.h	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/testing/Internals.h	2018-09-17 23:24:21 UTC (rev 236094)
@@ -29,6 +29,7 @@
 #include "CSSComputedStyleDeclaration.h"
 #include "ContextDestructionObserver.h"
 #include "ExceptionOr.h"
+#include "HEVCUtilities.h"
 #include "JSDOMPromiseDeferred.h"
 #include "OrientationNotifier.h"
 #include "PageConsoleClient.h"
@@ -738,6 +739,9 @@
 
     bool supportsVCPEncoder();
         
+    using HEVCParameterSet = WebCore::HEVCParameterSet;
+    std::optional<HEVCParameterSet> parseHEVCCodecParameters(const String& codecString);
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (236093 => 236094)


--- trunk/Source/WebCore/testing/Internals.idl	2018-09-17 23:21:49 UTC (rev 236093)
+++ trunk/Source/WebCore/testing/Internals.idl	2018-09-17 23:24:21 UTC (rev 236094)
@@ -124,6 +124,19 @@
 
 [
     ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
+    JSGenerateToJSObject,
+] dictionary HEVCParameterSet {
+    DOMString codecName;
+    unsigned short generalProfileSpace;
+    unsigned short generalProfileIDC;
+    unsigned long generalProfileCompatibilityFlags;
+    boolean generalTierFlag;
+    unsigned short generalLevelIDC;
+    sequence<unsigned short> constraintFlags;
+};
+
+[
+    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
     NoInterfaceObject,
 ] interface Internals {
     DOMString address(Node node);
@@ -672,4 +685,6 @@
     unsigned long primaryScreenDisplayID();
 
     boolean supportsVCPEncoder();
+
+    HEVCParameterSet? parseHEVCCodecParameters(DOMString codecParameters);
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to