Modified: trunk/Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp (246440 => 246441)
--- trunk/Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp 2019-06-14 20:10:23 UTC (rev 246440)
+++ trunk/Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp 2019-06-14 20:10:29 UTC (rev 246441)
@@ -36,7 +36,12 @@
#include <wtf/NeverDestroyed.h>
#include <wtf/text/Base64.h>
+#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
+#include "CDMFairPlayStreaming.h"
+#include "ISOFairPlayStreamingPsshBox.h"
+#endif
+
namespace WebCore {
namespace {
@@ -129,6 +134,23 @@
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)));
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp (246440 => 246441)
--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp 2019-06-14 20:10:23 UTC (rev 246440)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp 2019-06-14 20:10:29 UTC (rev 246441)
@@ -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,14 +74,8 @@
return skd;
}
-const AtomicString& CDMPrivateFairPlayStreaming::cencName()
+const Vector<uint8_t>& CDMPrivateFairPlayStreaming::fairPlaySystemID()
{
- static NeverDestroyed<AtomicString> cenc { MAKE_STATIC_STRING_IMPL("cenc") };
- return cenc;
-}
-
-static const Vector<uint8_t>& 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 @@
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 @@
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 NeverDestroyed<HashSet<AtomicString>> validTypes = HashSet<AtomicString>({
CDMPrivateFairPlayStreaming::sinfName(),
CDMPrivateFairPlayStreaming::skdName(),
-#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
- CDMPrivateFairPlayStreaming::cencName(),
-#endif
});
return validTypes;
}
@@ -281,9 +216,6 @@
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()
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h (246440 => 246441)
--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h 2019-06-14 20:10:23 UTC (rev 246440)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.h 2019-06-14 20:10:29 UTC (rev 246441)
@@ -32,6 +32,8 @@
namespace WebCore {
+struct FourCC;
+
class CDMFactoryFairPlayStreaming final : public CDMFactory {
public:
static CDMFactoryFairPlayStreaming& singleton();
@@ -75,9 +77,8 @@
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();
};
}