Add support for MediaKeyEncryptionScheme
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2018 21:44:24 +0000 (21:44 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Oct 2018 21:44:24 +0000 (21:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190173

Reviewed by Eric Carlson.

Source/WebCore:

Added sub-tests to: media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html

Add support for the MediaKeyEncryptionScheme extension to EME, as detailed here:
<https://github.com/WICG/encrypted-media-encryption-scheme/blob/master/explainer.md>

As the strings "cenc" and "cbcs" are explicitly lower-case, add support to the bindings generator to keep
those strings as lower-case when converting from IDL.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/encryptedmedia/MediaKeyEncryptionScheme.h:
* Modules/encryptedmedia/MediaKeyEncryptionScheme.idl:
* Modules/encryptedmedia/MediaKeySystemMediaCapability.h:
* Modules/encryptedmedia/MediaKeySystemMediaCapability.idl:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/scripts/CodeGenerator.pm:
(WK_ucfirst):
* platform/encryptedmedia/CDMEncryptionScheme.h: Copied from Source/WebCore/testing/MockCDMFactory.idl.
* platform/encryptedmedia/CDMMediaCapability.h:
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::CDMPrivateFairPlayStreaming::supportsConfiguration const):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::supportsMediaCapability):
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::initializeWithConfiguration):
* testing/MockCDMFactory.cpp:
(WebCore::m_supportedEncryptionSchemes):
(WebCore::MockCDM::supportsConfiguration const):
* testing/MockCDMFactory.h:
(WebCore::MockCDMFactory::supportedEncryptionSchemes const):
(WebCore::MockCDMFactory::setSupportedEncryptionSchemes):
* testing/MockCDMFactory.idl:

LayoutTests:

* media/encrypted-media/mock-navigator-requestMediaKeySystemAccess-expected.txt:
* media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html:

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess-expected.txt
LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.h [new file with mode: 0644]
Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.idl [new file with mode: 0644]
Source/WebCore/Modules/encryptedmedia/MediaKeySystemMediaCapability.h
Source/WebCore/Modules/encryptedmedia/MediaKeySystemMediaCapability.idl
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/platform/encryptedmedia/CDMEncryptionScheme.h [new file with mode: 0644]
Source/WebCore/platform/encryptedmedia/CDMMediaCapability.h
Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp
Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
Source/WebCore/testing/MockCDMFactory.cpp
Source/WebCore/testing/MockCDMFactory.h
Source/WebCore/testing/MockCDMFactory.idl

index a173b6b..252d58d 100644 (file)
@@ -1,3 +1,13 @@
+2018-10-18  Jer Noble  <jer.noble@apple.com>
+
+        Add support for MediaKeyEncryptionScheme
+        https://bugs.webkit.org/show_bug.cgi?id=190173
+
+        Reviewed by Eric Carlson.
+
+        * media/encrypted-media/mock-navigator-requestMediaKeySystemAccess-expected.txt:
+        * media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html:
+
 2018-10-18  Youenn Fablet  <youenn@apple.com>
 
         Handle MDNS resolution of candidates through libwebrtc directly
index 7ad82c1..35cd36c 100644 (file)
@@ -85,5 +85,24 @@ RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilit
 Promise resolved OK
 EXPECTED (access.getConfiguration().label == 'persistent-state-not-required') OK
 EXPECTED (access.getConfiguration().persistentState == 'not-allowed') OK
+
+RUN(mock.supportedEncryptionSchemes = ["cenc"])
+SET capabilities = '[ { "label": "encryption-scheme-cenc", "initDataTypes": [ "mock" ], "videoCapabilities": [ { "contentType": "video/mock; codecs=\"mock\"", "encryptionScheme": "cenc" } ] } ]'
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities))
+Promise resolved OK
+EXPECTED (access.getConfiguration().label == 'encryption-scheme-cenc') OK
+EXPECTED (access.getConfiguration().videoCapabilities[0].encryptionScheme == 'cenc') OK
+
+SET capabilities = '[ { "initDataTypes": [ "mock" ], "videoCapabilities": [ { "contentType": "video/mock; codecs=\"mock\"", "encryptionScheme": "cbcs" } ] } ]'
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities))
+Promise rejected correctly OK
+EXPECTED (exceptionCode.name == 'NotSupportedError') OK
+
+RUN(mock.supportedEncryptionSchemes = ["cenc", "cbcs"])
+SET capabilities = '[ { "label": "encryption-scheme-cbcs", "initDataTypes": [ "mock" ], "videoCapabilities": [ { "contentType": "video/mock; codecs=\"mock\"", "encryptionScheme": "cbcs" } ] } ]'
+RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities))
+Promise resolved OK
+EXPECTED (access.getConfiguration().label == 'encryption-scheme-cbcs') OK
+EXPECTED (access.getConfiguration().videoCapabilities[0].encryptionScheme == 'cbcs') OK
 END OF TEST
 
index 6b0bbe4..6dfafcb 100644 (file)
                     testExpected('access.getConfiguration().persistentState', 'not-allowed');
                 });
         },
+
+        function() {
+            run('mock.supportedEncryptionSchemes = ["cenc"]');
+            passingTestWithCapabilities([{
+                    label: 'encryption-scheme-cenc',
+                    initDataTypes: ['mock'],
+                    videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cenc'}],
+                }],
+                mediaKeySystemAccess => {
+                    window.access = mediaKeySystemAccess;
+                    testExpected('access.getConfiguration().label', 'encryption-scheme-cenc');
+                    testExpected('access.getConfiguration().videoCapabilities[0].encryptionScheme', 'cenc');
+                });
+        },
+
+        function() {
+            failingTestWithCapabilities([{
+                    initDataTypes: ['mock'],
+                    videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cbcs'}],
+                }],
+                exceptionCode => {
+                    window.exceptionCode = exceptionCode;
+                    testExpected('exceptionCode.name', 'NotSupportedError');
+                });
+        },
+
+        function() {
+            run('mock.supportedEncryptionSchemes = ["cenc", "cbcs"]');
+            passingTestWithCapabilities([{
+                    label: 'encryption-scheme-cbcs',
+                    initDataTypes: ['mock'],
+                    videoCapabilities: [{ contentType: 'video/mock; codecs="mock"', encryptionScheme: 'cbcs'}],
+                }],
+                mediaKeySystemAccess => {
+                    window.access = mediaKeySystemAccess;
+                    testExpected('access.getConfiguration().label', 'encryption-scheme-cbcs');
+                    testExpected('access.getConfiguration().videoCapabilities[0].encryptionScheme', 'cbcs');
+                });
+        },
     ];
     </script>
 </head>
index 2c15fe4..8b02a52 100644 (file)
@@ -1177,6 +1177,7 @@ if (ENABLE_ENCRYPTED_MEDIA)
         html/MediaEncryptedEvent.cpp
     )
     list(APPEND WebCore_IDL_FILES
+        Modules/encryptedmedia/MediaKeyEncryptionScheme.idl
         Modules/encryptedmedia/MediaKeyMessageEvent.idl
         Modules/encryptedmedia/MediaKeySession.idl
         Modules/encryptedmedia/MediaKeySessionType.idl
index baf4194..501e9ba 100644 (file)
@@ -1,3 +1,44 @@
+2018-10-18  Jer Noble  <jer.noble@apple.com>
+
+        Add support for MediaKeyEncryptionScheme
+        https://bugs.webkit.org/show_bug.cgi?id=190173
+
+        Reviewed by Eric Carlson.
+
+        Added sub-tests to: media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html
+
+        Add support for the MediaKeyEncryptionScheme extension to EME, as detailed here:
+        <https://github.com/WICG/encrypted-media-encryption-scheme/blob/master/explainer.md>
+
+        As the strings "cenc" and "cbcs" are explicitly lower-case, add support to the bindings generator to keep
+        those strings as lower-case when converting from IDL.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/encryptedmedia/MediaKeyEncryptionScheme.h:
+        * Modules/encryptedmedia/MediaKeyEncryptionScheme.idl:
+        * Modules/encryptedmedia/MediaKeySystemMediaCapability.h:
+        * Modules/encryptedmedia/MediaKeySystemMediaCapability.idl:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/scripts/CodeGenerator.pm:
+        (WK_ucfirst):
+        * platform/encryptedmedia/CDMEncryptionScheme.h: Copied from Source/WebCore/testing/MockCDMFactory.idl.
+        * platform/encryptedmedia/CDMMediaCapability.h:
+        * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
+        (WebCore::CDMPrivateFairPlayStreaming::supportsConfiguration const):
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::supportsMediaCapability):
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::initializeWithConfiguration):
+        * testing/MockCDMFactory.cpp:
+        (WebCore::m_supportedEncryptionSchemes):
+        (WebCore::MockCDM::supportsConfiguration const):
+        * testing/MockCDMFactory.h:
+        (WebCore::MockCDMFactory::supportedEncryptionSchemes const):
+        (WebCore::MockCDMFactory::setSupportedEncryptionSchemes):
+        * testing/MockCDMFactory.idl:
+
 2018-10-18  Alexey Proskuryakov  <ap@apple.com>
 
         Switch from PLATFORM(IOS) to PLATFORM(IOS_FAMILY)
index 1912f1e..15a5d6b 100644 (file)
@@ -128,6 +128,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/credentialmanagement/CredentialRequestOptions.idl \
     $(WebCore)/Modules/credentialmanagement/CredentialsContainer.idl \
     $(WebCore)/Modules/credentialmanagement/NavigatorCredentials.idl \
+    $(WebCore)/Modules/encryptedmedia/MediaKeyEncryptionScheme.idl \
     $(WebCore)/Modules/encryptedmedia/MediaKeyMessageEvent.idl \
     $(WebCore)/Modules/encryptedmedia/MediaKeySession.idl \
     $(WebCore)/Modules/encryptedmedia/MediaKeySessionType.idl \
diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.h b/Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.h
new file mode 100644 (file)
index 0000000..d7b8193
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 ENABLE(ENCRYPTED_MEDIA)
+
+#include "CDMEncryptionScheme.h"
+
+namespace WebCore {
+
+using MediaKeyEncryptionScheme = CDMEncryptionScheme;
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.idl b/Source/WebCore/Modules/encryptedmedia/MediaKeyEncryptionScheme.idl
new file mode 100644 (file)
index 0000000..64357dd
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+[
+    Conditional=ENCRYPTED_MEDIA,
+    ImplementedAs=MediaKeyEncryptionScheme,
+    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT
+]
+enum MediaKeyEncryptionScheme {
+    "cenc",
+    "cbcs"
+};
index 3204794..3c86815 100644 (file)
@@ -32,4 +32,5 @@
 ] dictionary MediaKeySystemMediaCapability {
     DOMString contentType = "";
     DOMString robustness = "";
+    MediaKeyEncryptionScheme? encryptionScheme = null;
 };
index d193d9e..8c1a3b7 100644 (file)
@@ -3248,6 +3248,7 @@ JSWebKitMediaKeyError.cpp
 
 #if ENABLE_ENCRYPTED_MEDIA
 
+JSMediaKeyEncryptionScheme.cpp
 JSMediaKeyMessageEvent.cpp
 JSMediaKeySession.cpp
 JSMediaKeySessionType.cpp
index 68f71d4..223ca33 100644 (file)
                CDF65CC8145B1E7500C4C7AA /* MediaController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD27F6E4145767870078207D /* MediaController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CDF65CCA145B448800C4C7AA /* MediaControllerInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF65CC9145B43A700C4C7AA /* MediaControllerInterface.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CDF7483F18FEBCEC0006ECC0 /* GridPositionsResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF7483D18FEBCEC0006ECC0 /* GridPositionsResolver.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               CDF756A3215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h in Headers */ = {isa = PBXBuildFile; fileRef = CDF756A1215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h */; };
                CDFC360618CA61C20026E56F /* RemoteCommandListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CDFC360418CA61C20026E56F /* RemoteCommandListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE057FA61220731100A476D5 /* DocumentMarkerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE057FA41220731100A476D5 /* DocumentMarkerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE08C3D0152B599A0021B8C2 /* AlternativeTextController.h */; settings = {ATTRIBUTES = (); }; };
                CDF65CC9145B43A700C4C7AA /* MediaControllerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControllerInterface.h; sourceTree = "<group>"; };
                CDF7483C18FEBCEC0006ECC0 /* GridPositionsResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GridPositionsResolver.cpp; sourceTree = "<group>"; };
                CDF7483D18FEBCEC0006ECC0 /* GridPositionsResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GridPositionsResolver.h; sourceTree = "<group>"; };
+               CDF7569B215C23A400EFCB50 /* CDMEncryptionScheme.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDMEncryptionScheme.h; sourceTree = "<group>"; };
+               CDF7569D215C244400EFCB50 /* MediaKeyEncryptionScheme.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaKeyEncryptionScheme.h; sourceTree = "<group>"; };
+               CDF7569E215C285E00EFCB50 /* MediaKeyEncryptionScheme.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaKeyEncryptionScheme.idl; sourceTree = "<group>"; };
+               CDF756A0215C29E800EFCB50 /* JSMediaKeyEncryptionScheme.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaKeyEncryptionScheme.cpp; sourceTree = "<group>"; };
+               CDF756A1215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaKeyEncryptionScheme.h; sourceTree = "<group>"; };
                CDFC360118CA61630026E56F /* RemoteCommandListenerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListenerIOS.h; sourceTree = "<group>"; };
                CDFC360218CA61630026E56F /* RemoteCommandListenerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerIOS.mm; sourceTree = "<group>"; };
                CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCommandListener.cpp; sourceTree = "<group>"; };
                                A5071E841C56D079009951BE /* ResourceUsageThread.h */,
                                7C52229B1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.cpp */,
                                7C52229C1E1DAE47002CB8F7 /* RuntimeEnabledFeatures.h */,
+                               CD9A87F2215D43A6006F17B5 /* Quirks.cpp */,
+                               CD9A87F1215D43A6006F17B5 /* Quirks.h */,
                                BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
                                BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
                                BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
                        isa = PBXGroup;
                        children = (
                                CD94A5D91F71CB9F00F525C5 /* clearkey */,
+                               CDF7569B215C23A400EFCB50 /* CDMEncryptionScheme.h */,
                                CD94A5D11F71CB6B00F525C5 /* CDMFactory.cpp */,
                                CD94A5D21F71CB6B00F525C5 /* CDMFactory.h */,
                                CD94A5CE1F71CB6A00F525C5 /* CDMInstance.h */,
                                2D9BF7331DBFDC0F007A7D99 /* MediaKeys.cpp */,
                                2D9BF7341DBFDC0F007A7D99 /* MediaKeys.h */,
                                2D9BF6F61DBFB71F007A7D99 /* MediaKeys.idl */,
+                               CDF7569D215C244400EFCB50 /* MediaKeyEncryptionScheme.h */,
+                               CDF7569E215C285E00EFCB50 /* MediaKeyEncryptionScheme.idl */,
                                2D9BF7351DBFDC0F007A7D99 /* MediaKeySession.cpp */,
                                2D9BF7361DBFDC0F007A7D99 /* MediaKeySession.h */,
                                2D9BF6F71DBFB71F007A7D99 /* MediaKeySession.idl */,
                CDA98DCD1601515C00FEA3B1 /* EncryptedMedia */ = {
                        isa = PBXGroup;
                        children = (
+                               CDF756A0215C29E800EFCB50 /* JSMediaKeyEncryptionScheme.cpp */,
+                               CDF756A1215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h */,
                                2D9BF7131DBFDAB1007A7D99 /* JSMediaKeyMessageEvent.cpp */,
                                2D9BF7141DBFDAB1007A7D99 /* JSMediaKeyMessageEvent.h */,
                                2D9BF7151DBFDAB1007A7D99 /* JSMediaKeys.cpp */,
                                51058AE01D67C229009A538C /* MockGamepad.h in Headers */,
                                51058AE21D67C229009A538C /* MockGamepadProvider.h in Headers */,
                                413CCD4A20DE034F0065A21A /* MockMediaDevice.h in Headers */,
+                               CDF756A3215C29E900EFCB50 /* JSMediaKeyEncryptionScheme.h in Headers */,
                                CDF2B0131820540600F2B424 /* MockMediaPlayerMediaSource.h in Headers */,
                                CDF2B0151820540600F2B424 /* MockMediaSourcePrivate.h in Headers */,
                                A1BB85A92159B02C0067E07D /* MockPaymentError.h in Headers */,
index 2fcfee3..75c19ec 100644 (file)
@@ -694,6 +694,8 @@ sub WK_ucfirst
     $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
     $ret =~ s/Svg/SVG/ if $ret =~ /^Svg/;
     $ret =~ s/Srgb/SRGB/ if $ret =~ /^Srgb/;
+    $ret =~ s/Cenc/cenc/ if $ret =~ /^Cenc/;
+    $ret =~ s/Cbcs/cbcs/ if $ret =~ /^Cbcs/;
 
     return $ret;
 }
diff --git a/Source/WebCore/platform/encryptedmedia/CDMEncryptionScheme.h b/Source/WebCore/platform/encryptedmedia/CDMEncryptionScheme.h
new file mode 100644 (file)
index 0000000..74b3aa7
--- /dev/null
@@ -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 ENABLE(ENCRYPTED_MEDIA)
+
+namespace WebCore {
+
+enum class CDMEncryptionScheme {
+    cenc,
+    cbcs,
+};
+
+}
+
+#endif
index 13ded25..66d0211 100644 (file)
@@ -30,6 +30,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA)
 
+#include "CDMEncryptionScheme.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -37,6 +38,7 @@ namespace WebCore {
 struct CDMMediaCapability {
     String contentType;
     String robustness;
+    std::optional<CDMEncryptionScheme> encryptionScheme;
 };
 
 } // namespace WebCore
index 8c64de1..500f33a 100644 (file)
@@ -260,13 +260,13 @@ bool CDMPrivateFairPlayStreaming::supportsConfiguration(const CDMKeySystemConfig
 
     if (!configuration.audioCapabilities.isEmpty()
         && !WTF::anyOf(configuration.audioCapabilities, [](auto& capability) {
-            return CDMInstanceFairPlayStreamingAVFObjC::mimeTypeIsPlayable(capability.contentType);
+            return CDMInstanceFairPlayStreamingAVFObjC::supportsMediaCapability(capability);
         }))
         return false;
 
     if (!configuration.videoCapabilities.isEmpty()
         && !WTF::anyOf(configuration.videoCapabilities, [](auto& capability) {
-            return CDMInstanceFairPlayStreamingAVFObjC::mimeTypeIsPlayable(capability.contentType);
+            return CDMInstanceFairPlayStreamingAVFObjC::supportsMediaCapability(capability);
         }))
         return false;
 
index 377b430..5ef841d 100644 (file)
@@ -44,6 +44,7 @@ OBJC_CLASS WebCoreFPSContentKeySessionDelegate;
 namespace WebCore {
 
 class CDMInstanceSessionFairPlayStreamingAVFObjC;
+struct CDMMediaCapability;
 
 class CDMInstanceFairPlayStreamingAVFObjC final : public CDMInstance, public CanMakeWeakPtr<CDMInstanceFairPlayStreamingAVFObjC> {
 public:
@@ -52,6 +53,7 @@ public:
 
     static bool supportsPersistableState();
     static bool supportsPersistentKeys();
+    static bool supportsMediaCapability(const CDMMediaCapability&);
     static bool mimeTypeIsPlayable(const String&);
 
     ImplementationType implementationType() const final { return ImplementationType::FairPlayStreaming; }
index b270848..5ac24e4 100644 (file)
@@ -30,6 +30,7 @@
 
 #import "CDMFairPlayStreaming.h"
 #import "CDMKeySystemConfiguration.h"
+#import "CDMMediaCapability.h"
 #import "NotImplemented.h"
 #import "SharedBuffer.h"
 #import "TextDecoder.h"
@@ -158,9 +159,16 @@ bool CDMInstanceFairPlayStreamingAVFObjC::supportsPersistentKeys()
 #endif
 }
 
-bool CDMInstanceFairPlayStreamingAVFObjC::mimeTypeIsPlayable(const String& contentType)
+bool CDMInstanceFairPlayStreamingAVFObjC::supportsMediaCapability(const CDMMediaCapability& capability)
 {
-    return [getAVURLAssetClass() isPlayableExtendedMIMEType:contentType];
+    if (![getAVURLAssetClass() isPlayableExtendedMIMEType:capability.contentType])
+        return false;
+
+    // FairPlay only supports 'cbcs' encryption:
+    if (capability.encryptionScheme && capability.encryptionScheme.value() != CDMEncryptionScheme::cbcs)
+        return false;
+
+    return true;
 }
 
 CDMInstance::SuccessValue CDMInstanceFairPlayStreamingAVFObjC::initializeWithConfiguration(const CDMKeySystemConfiguration& configuration)
index d043771..34283f1 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "InitDataRegistry.h"
 #include <JavaScriptCore/ArrayBuffer.h>
+#include <wtf/Algorithms.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/UUID.h>
 #include <wtf/text/StringHash.h>
@@ -39,6 +40,7 @@ namespace WebCore {
 
 MockCDMFactory::MockCDMFactory()
     : m_supportedSessionTypes({ MediaKeySessionType::Temporary, MediaKeySessionType::PersistentUsageRecord, MediaKeySessionType::PersistentLicense })
+    , m_supportedEncryptionSchemes({ MediaKeyEncryptionScheme::cenc })
 {
     CDMFactory::registerFactory(*this);
 }
@@ -113,9 +115,20 @@ bool MockCDM::supportsInitDataType(const AtomicString& initDataType) const
     return false;
 }
 
-bool MockCDM::supportsConfiguration(const MediaKeySystemConfiguration&) const
+bool MockCDM::supportsConfiguration(const MediaKeySystemConfiguration& configuration) const
 {
-    // NOTE: Implement;
+    auto capabilityHasSupportedEncryptionScheme = [&] (auto& capability) {
+        if (capability.encryptionScheme)
+            return m_factory->supportedEncryptionSchemes().contains(capability.encryptionScheme.value());
+        return true;
+    };
+
+    if (!configuration.audioCapabilities.isEmpty() && !anyOf(configuration.audioCapabilities, capabilityHasSupportedEncryptionScheme))
+        return false;
+
+    if (!configuration.videoCapabilities.isEmpty() && !anyOf(configuration.videoCapabilities, capabilityHasSupportedEncryptionScheme))
+        return false;
+
     return true;
 
 }
index a822731..843a08a 100644 (file)
@@ -32,6 +32,7 @@
 #include "CDMInstance.h"
 #include "CDMInstanceSession.h"
 #include "CDMPrivate.h"
+#include "MediaKeyEncryptionScheme.h"
 #include "MediaKeysRequirement.h"
 #include <wtf/HashMap.h>
 #include <wtf/RefCounted.h>
@@ -69,6 +70,9 @@ public:
     bool supportsSessions() const { return m_supportsSessions; }
     void setSupportsSessions(bool flag) { m_supportsSessions = flag; }
 
+    const Vector<MediaKeyEncryptionScheme>& supportedEncryptionSchemes() const { return m_supportedEncryptionSchemes; }
+    void setSupportedEncryptionSchemes(Vector<MediaKeyEncryptionScheme>&& schemes) { m_supportedEncryptionSchemes = WTFMove(schemes); }
+
     void unregister();
 
     bool hasSessionWithID(const String& id) { return m_sessions.contains(id); }
@@ -87,6 +91,7 @@ private:
     Vector<AtomicString> m_supportedDataTypes;
     Vector<MediaKeySessionType> m_supportedSessionTypes;
     Vector<String> m_supportedRobustness;
+    Vector<MediaKeyEncryptionScheme> m_supportedEncryptionSchemes;
     bool m_registered { true };
     bool m_canCreateInstances { true };
     bool m_supportsServerCertificates { true };
index 90d382e..6bb5605 100644 (file)
@@ -36,6 +36,7 @@
     attribute boolean canCreateInstances;
     attribute boolean supportsServerCertificates;
     attribute boolean supportsSessions;
+    attribute sequence<MediaKeyEncryptionScheme> supportedEncryptionSchemes;
 
     void unregister();
 };