REGRESSION(244439): platform/mac/media/encrypted-media/fps-* tests are crashing
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 20:10:29 +0000 (20:10 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jun 2019 20:10:29 +0000 (20:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198612
<rdar://problem/51078978>

Reviewed by Eric Carlson.

There are two implementations of a 'cenc' initialiation data factory; an ASSERT fires when
the second one is added to the registry. Unify them.

* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsCenc):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::CDMPrivateFairPlayStreaming::validFairPlayStreamingSchemes):
(WebCore::CDMPrivateFairPlayStreaming::fairPlaySystemID):
(WebCore::validInitDataTypes):
(WebCore::CDMFactory::platformRegisterFactories):
(WebCore::validFairPlayStreamingSchemes): Deleted.
(WebCore::CDMPrivateFairPlayStreaming::cencName): Deleted.
(WebCore::fairPlaySystemID): Deleted.
(WebCore::extractSchemeAndKeyIdFromCenc): Deleted.
(WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsCenc): Deleted.
(WebCore::CDMPrivateFairPlayStreaming::sanitizeCenc): Deleted.
* platform/graphics/avfoundation/CDMFairPlayStreaming.h:

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp
Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp
Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h

index 0aa6d08..c9ab851 100644 (file)
@@ -1,3 +1,29 @@
+2019-06-14  Jer Noble  <jer.noble@apple.com>
+
+        REGRESSION(244439): platform/mac/media/encrypted-media/fps-* tests are crashing
+        https://bugs.webkit.org/show_bug.cgi?id=198612
+        <rdar://problem/51078978>
+
+        Reviewed by Eric Carlson.
+
+        There are two implementations of a 'cenc' initialiation data factory; an ASSERT fires when
+        the second one is added to the registry. Unify them.
+
+        * Modules/encryptedmedia/InitDataRegistry.cpp:
+        (WebCore::extractKeyIDsCenc):
+        * platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
+        (WebCore::CDMPrivateFairPlayStreaming::validFairPlayStreamingSchemes):
+        (WebCore::CDMPrivateFairPlayStreaming::fairPlaySystemID):
+        (WebCore::validInitDataTypes):
+        (WebCore::CDMFactory::platformRegisterFactories):
+        (WebCore::validFairPlayStreamingSchemes): Deleted.
+        (WebCore::CDMPrivateFairPlayStreaming::cencName): Deleted.
+        (WebCore::fairPlaySystemID): Deleted.
+        (WebCore::extractSchemeAndKeyIdFromCenc): Deleted.
+        (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsCenc): Deleted.
+        (WebCore::CDMPrivateFairPlayStreaming::sanitizeCenc): Deleted.
+        * platform/graphics/avfoundation/CDMFairPlayStreaming.h:
+
 2019-06-14  Saam Barati  <sbarati@apple.com>
 
         Unreviewed. Follow up to r246438. This removes a debug assert until
index 9f8b5e0..3b2f81d 100644 (file)
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/Base64.h>
 
+#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
+#include "CDMFairPlayStreaming.h"
+#include "ISOFairPlayStreamingPsshBox.h"
+#endif
+
 
 namespace WebCore {
 
@@ -129,6 +134,23 @@ static Optional<Vector<Ref<SharedBuffer>>> extractKeyIDsCenc(const SharedBuffer&
         if (!psshBox.read(view, offset))
             return WTF::nullopt;
 
+#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
+        if (psshBox.systemID() == CDMPrivateFairPlayStreaming::fairPlaySystemID()) {
+            ISOFairPlayStreamingPsshBox fpsPssh;
+            offset -= psshBox.size();
+            if (!fpsPssh.read(view, offset))
+                return WTF::nullopt;
+
+            FourCC scheme = fpsPssh.initDataBox().info().scheme();
+            if (CDMPrivateFairPlayStreaming::validFairPlayStreamingSchemes().contains(scheme)) {
+                for (auto request : fpsPssh.initDataBox().requests()) {
+                    auto& keyID = request.requestInfo().keyID();
+                    keyIDs.append(SharedBuffer::create(keyID.data(), keyID.size()));
+                }
+            }
+        }
+#endif
+
         for (auto& value : psshBox.keyIDs())
             keyIDs.append(SharedBuffer::create(WTFMove(value)));
     }
index 0b4df58..1b85354 100644 (file)
@@ -32,7 +32,6 @@
 #include "CDMKeySystemConfiguration.h"
 #include "CDMRestrictions.h"
 #include "CDMSessionType.h"
-#include "ISOFairPlayStreamingPsshBox.h"
 #include "ISOSchemeInformationBox.h"
 #include "ISOSchemeTypeBox.h"
 #include "ISOTrackEncryptionBox.h"
@@ -51,9 +50,9 @@
 
 namespace WebCore {
 
-static const Vector<FourCC>& validFairPlayStreamingSchemes()
+const Vector<FourCC>& CDMPrivateFairPlayStreaming::validFairPlayStreamingSchemes()
 {
-    static NeverDestroyed<Vector<FourCC>> validSchemes = Vector<FourCC>({ 
+    static NeverDestroyed<Vector<FourCC>> validSchemes = Vector<FourCC>({
         "cbcs",
         "cbc2",
         "cbc1",
@@ -75,13 +74,7 @@ const AtomicString& CDMPrivateFairPlayStreaming::skdName()
     return skd;
 }
 
-const AtomicString& CDMPrivateFairPlayStreaming::cencName()
-{
-    static NeverDestroyed<AtomicString> cenc { MAKE_STATIC_STRING_IMPL("cenc") };
-    return cenc;
-}
-
-static const Vector<uint8_t>& fairPlaySystemID()
+const Vector<uint8_t>& CDMPrivateFairPlayStreaming::fairPlaySystemID()
 {
     static NeverDestroyed<Vector<uint8_t>> systemID = Vector<uint8_t>({ 0x94, 0xCE, 0x86, 0xFB, 0x07, 0xFF, 0x4F, 0x43, 0xAD, 0xB8, 0x93, 0xD2, 0xFA, 0x96, 0x8C, 0xA2 });
     return systemID;
@@ -184,54 +177,6 @@ Optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsSi
     return keyIDs;
 }
 
-static SchemeAndKeyResult extractSchemeAndKeyIdFromCenc(const SharedBuffer& buffer)
-{
-    auto arrayBuffer = buffer.tryCreateArrayBuffer();
-    if (!arrayBuffer)
-        return { };
-
-    auto view = JSC::DataView::create(WTFMove(arrayBuffer), 0, buffer.size());
-    unsigned offset { 0 };
-
-    SchemeAndKeyResult result;
-    while (offset < buffer.size()) {
-        auto peekResult = ISOBox::peekBox(view, offset);
-        if (!peekResult || peekResult.value().first != ISOProtectionSystemSpecificHeaderBox::boxTypeName())
-            return { };
-
-        ISOProtectionSystemSpecificHeaderBox psshBox;
-        if (!psshBox.read(view, offset))
-            return { };
-
-        if (psshBox.systemID() != fairPlaySystemID())
-            continue;
-
-        ISOFairPlayStreamingPsshBox fpsPssh;
-        offset -= psshBox.size();
-        if (!fpsPssh.read(view, offset))
-            return { };
-
-        FourCC scheme = fpsPssh.initDataBox().info().scheme();
-        for (auto request : fpsPssh.initDataBox().requests())
-            result.append(std::make_pair(scheme, request.requestInfo().keyID()));
-    }
-
-    return result;
-}
-
-Optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsCenc(const SharedBuffer& buffer)
-{
-    Vector<Ref<SharedBuffer>> keyIDs;
-    auto results = extractSchemeAndKeyIdFromCenc(buffer);
-
-    for (auto& result : results) {
-        if (validFairPlayStreamingSchemes().contains(result.first))
-            keyIDs.append(SharedBuffer::create(result.second.data(), result.second.size()));
-    }
-
-    return keyIDs;
-}
-
 RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeSinf(const SharedBuffer& buffer)
 {
     // Common SINF Box Format
@@ -247,13 +192,6 @@ RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeSkd(const SharedBuffer
     return buffer.copy();
 }
 
-RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeCenc(const SharedBuffer& buffer)
-{
-    UNUSED_PARAM(buffer);
-    notImplemented();
-    return buffer.copy();
-}
-
 Optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsSkd(const SharedBuffer& buffer)
 {
     // In the 'skd' scheme, the init data is the key ID.
@@ -267,9 +205,6 @@ static const HashSet<AtomicString>& validInitDataTypes()
     static NeverDestroyed<HashSet<AtomicString>> validTypes = HashSet<AtomicString>({
         CDMPrivateFairPlayStreaming::sinfName(),
         CDMPrivateFairPlayStreaming::skdName(),
-#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
-        CDMPrivateFairPlayStreaming::cencName(),
-#endif
     });
     return validTypes;
 }
@@ -281,9 +216,6 @@ void CDMFactory::platformRegisterFactories(Vector<CDMFactory*>& factories)
 
     InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::sinfName(), { CDMPrivateFairPlayStreaming::sanitizeSinf, CDMPrivateFairPlayStreaming::extractKeyIDsSinf });
     InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::skdName(), { CDMPrivateFairPlayStreaming::sanitizeSkd, CDMPrivateFairPlayStreaming::extractKeyIDsSkd });
-#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
-    InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::cencName(), { CDMPrivateFairPlayStreaming::sanitizeCenc, CDMPrivateFairPlayStreaming::extractKeyIDsCenc });
-#endif
 }
 
 CDMFactoryFairPlayStreaming& CDMFactoryFairPlayStreaming::singleton()
index cb5aa02..9167b6e 100644 (file)
@@ -32,6 +32,8 @@
 
 namespace WebCore {
 
+struct FourCC;
+
 class CDMFactoryFairPlayStreaming final : public CDMFactory {
 public:
     static CDMFactoryFairPlayStreaming& singleton();
@@ -75,9 +77,8 @@ public:
     static Optional<Vector<Ref<SharedBuffer>>> extractKeyIDsSkd(const SharedBuffer&);
     static RefPtr<SharedBuffer> sanitizeSkd(const SharedBuffer&);
 
-    static const AtomicString& cencName();
-    static Optional<Vector<Ref<SharedBuffer>>> extractKeyIDsCenc(const SharedBuffer&);
-    static RefPtr<SharedBuffer> sanitizeCenc(const SharedBuffer&);
+    static const Vector<FourCC>& validFairPlayStreamingSchemes();
+    static const Vector<uint8_t>& fairPlaySystemID();
 };
 
 }