Skip to content

Commit

Permalink
Revert "Cherry-pick 12dd6bd. rdar://122030589"
Browse files Browse the repository at this point in the history
This reverts commit 3c3f438.

Identifier: 272448.546@safari-7618.1.15.10-branch
  • Loading branch information
MyahCobbs committed Feb 10, 2024
1 parent c41f7a4 commit fc1461c
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 223 deletions.
Binary file not shown.

This file was deleted.

48 changes: 0 additions & 48 deletions LayoutTests/http/tests/media/fairplay/fps-mse-unmuxed-mpts.html

This file was deleted.

13 changes: 0 additions & 13 deletions LayoutTests/platform/mac/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2580,16 +2580,3 @@ webkit.org/b/265957 fullscreen/full-screen-layer-dump.html [ Failure ]
# SVG Animations Failures on WPT Import
imported/w3c/web-platform-tests/svg/animations/reinserting-svg-into-document.html [ Failure ]
imported/w3c/web-platform-tests/svg/animations/use-animate-display-none-symbol-2.html [ Pass Failure ]

webkit.org/b/266996 imported/w3c/web-platform-tests/css/css-writing-modes/mongolian-orientation-002.html [ ImageOnlyFailure ]

fast/gradients/conic-stop-with-offset-zero-in-middle.html [ ImageOnlyFailure ]

webkit.org/b/267352 [ Monterey ] imported/w3c/web-platform-tests/mathml/relations/css-styling/padding-border-margin/margin-003.html [ Failure ]

webkit.org/b/267612 [ Ventura+ Release x86_64 ] fast/canvas/image-buffer-backend-variants.html [ Pass Failure ]

webkit.org/b/268947 [ Ventura+ ] imported/w3c/web-platform-tests/mathml/relations/css-styling/floats/not-floating-001.html [ Failure ]

# Enable after rdar://120859525 is available on bots
http/tests/media/fairplay/fps-mse-unmuxed-mpts.html [ Skip ]
20 changes: 0 additions & 20 deletions Source/WTF/wtf/PlatformHave.h
Original file line number Diff line number Diff line change
Expand Up @@ -1701,23 +1701,3 @@
&& (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400)
#define HAVE_MARKETPLACE_KIT 1
#endif

#if !defined(HAVE_XPC_API) \
&& (PLATFORM(MAC) \
|| ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400))
#define HAVE_XPC_API 1
#endif

#if !defined(HAVE_BROWSER_ENGINE_SUPPORTING_API) \
&& ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140400) \
|| ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400) \
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MAX_ALLOWED >= 170400))
#define HAVE_BROWSER_ENGINE_SUPPORTING_API 1
#endif

#if !defined(HAVE_FAIRPLAYSTREAMING_MTPS_INITDATA) \
&& ((PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 170400) \
|| (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 140400) \
|| (PLATFORM(VISION) && __VISION_OS_VERSION_MAX_ALLOWED >= 10100))
#define HAVE_FAIRPLAYSTREAMING_MTPS_INITDATA 1
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ std::optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKey
{
Vector<Ref<SharedBuffer>> keyIDs;
auto results = extractSchemeAndKeyIdFromSinf(buffer);
if (results.isEmpty())
return std::nullopt;

for (auto& result : results) {
if (validFairPlayStreamingSchemes().contains(result.first))
Expand Down Expand Up @@ -202,70 +200,13 @@ std::optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKey
return Vector { buffer.makeContiguous() };
}

#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
const AtomString& CDMPrivateFairPlayStreaming::mptsName()
{
static MainThreadNeverDestroyed<const AtomString> mpts { MAKE_STATIC_STRING_IMPL("mpts") };
return mpts;
}

std::optional<Vector<Ref<SharedBuffer>>> CDMPrivateFairPlayStreaming::extractKeyIDsMpts(const SharedBuffer& buffer)
{
// JSON of the format: "{ "codc" : [integer], "mtyp" : [integer], "cont" : "mpts"} }"
if (buffer.size() > std::numeric_limits<unsigned>::max())
return { };
String json { buffer.makeContiguous()->data(), static_cast<unsigned>(buffer.size()) };

auto value = JSON::Value::parseJSON(json);
if (!value)
return { };

auto object = value->asObject();
if (!object)
return { };

auto contValue = object->getString("cont"_s);
if (contValue != "mpts"_s)
return { };

auto codcValue = object->getInteger("codc"_s);
if (!codcValue)
return { };

auto mtypValue = object->getInteger("mtyp"_s);
if (!mtypValue)
return { };

return mptsKeyIDs();
}

RefPtr<SharedBuffer> CDMPrivateFairPlayStreaming::sanitizeMpts(const SharedBuffer& buffer)
{
UNUSED_PARAM(buffer);
notImplemented();
return buffer.makeContiguous();
}

const Vector<Ref<SharedBuffer>>& CDMPrivateFairPlayStreaming::mptsKeyIDs() {
static NeverDestroyed<Vector<Ref<SharedBuffer>>> mptsKeyID = [] {
Vector<uint8_t> keyData { std::initializer_list<uint8_t> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 } };
Ref<SharedBuffer> keyBuffer = SharedBuffer::create(WTFMove(keyData));
return Vector { 1, WTFMove(keyBuffer) };
}();
return mptsKeyID;
}
#endif

static const MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>& validInitDataTypes()
{
static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> validTypes(std::initializer_list<AtomString> {
CDMPrivateFairPlayStreaming::sinfName(),
CDMPrivateFairPlayStreaming::skdName(),
#if HAVE(FAIRPLAYSTREAMING_CENC_INITDATA)
InitDataRegistry::cencName(),
#endif
#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
CDMPrivateFairPlayStreaming::mptsName(),
#endif
});
return validTypes;
Expand All @@ -280,9 +221,6 @@ void CDMFactory::platformRegisterFactories(Vector<CDMFactory*>& factories)
std::call_once(onceFlag, [] {
InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::sinfName(), { CDMPrivateFairPlayStreaming::sanitizeSinf, CDMPrivateFairPlayStreaming::extractKeyIDsSinf });
InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::skdName(), { CDMPrivateFairPlayStreaming::sanitizeSkd, CDMPrivateFairPlayStreaming::extractKeyIDsSkd });
#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
InitDataRegistry::shared().registerInitDataType(CDMPrivateFairPlayStreaming::mptsName(), { CDMPrivateFairPlayStreaming::sanitizeMpts, CDMPrivateFairPlayStreaming::extractKeyIDsMpts });
#endif
});
}

Expand Down Expand Up @@ -477,11 +415,6 @@ bool CDMPrivateFairPlayStreaming::supportsInitData(const AtomString& initDataTyp
if (initDataType == skdName())
return true;

#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
if (initDataType == mptsName())
return true;
#endif

ASSERT_NOT_REACHED();
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ class CDMPrivateFairPlayStreaming final : public CDMPrivate {
static std::optional<Vector<Ref<SharedBuffer>>> extractKeyIDsSkd(const SharedBuffer&);
static RefPtr<SharedBuffer> sanitizeSkd(const SharedBuffer&);

#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
static const AtomString& mptsName();
static std::optional<Vector<Ref<SharedBuffer>>> extractKeyIDsMpts(const SharedBuffer&);
static RefPtr<SharedBuffer> sanitizeMpts(const SharedBuffer&);
static const Vector<Ref<SharedBuffer>>& mptsKeyIDs();
#endif

static const Vector<FourCC>& validFairPlayStreamingSchemes();

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,6 @@ static Keys keyIDsForRequest(AVContentKeyRequest* request)
if (request.initializationData) {
if (auto sinfKeyIDs = CDMPrivateFairPlayStreaming::extractKeyIDsSinf(SharedBuffer::create(request.initializationData)))
return WTFMove(sinfKeyIDs.value());
#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
if (auto mptsKeyIDs = CDMPrivateFairPlayStreaming::extractKeyIDsMpts(SharedBuffer::create(request.initializationData)))
return WTFMove(mptsKeyIDs.value());
#endif
}
return { };
}
Expand Down Expand Up @@ -817,10 +813,6 @@ static Keys keyIDsForRequest(const Request& requests)
auto psshString = base64EncodeToString(initData->makeContiguous()->data(), initData->size());
initializationData = [NSJSONSerialization dataWithJSONObject:@{ @"pssh": (NSString*)psshString } options:NSJSONWritingPrettyPrinted error:nil];
}
#endif
#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
else if (initDataType == CDMPrivateFairPlayStreaming::mptsName())
initializationData = initData->makeContiguous()->createNSData();
#endif
else {
ERROR_LOG(LOGIDENTIFIER, " false, initDataType not suppported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#import "config.h"
#import "MediaSampleAVFObjC.h"

#import "CDMFairPlayStreaming.h"
#import "CVUtilities.h"
#import "ISOTrackEncryptionBox.h"
#import "PixelBuffer.h"
Expand Down Expand Up @@ -77,10 +76,10 @@
if (CMTIME_IS_INVALID(presentationTime))
presentationTime = PAL::CMSampleBufferGetPresentationTimeStamp(m_sample.get());
m_presentationTime = PAL::toMediaTime(presentationTime);

auto decodeTime = PAL::CMSampleBufferGetDecodeTimeStamp(m_sample.get());
m_decodeTime = !CMTIME_IS_INVALID(decodeTime) ? PAL::toMediaTime(decodeTime) : m_presentationTime;

auto duration = PAL::CMSampleBufferGetOutputDuration(m_sample.get());
if (CMTIME_IS_INVALID(duration))
duration = PAL::CMSampleBufferGetDuration(m_sample.get());
Expand All @@ -90,33 +89,23 @@
auto getKeyIDs = [](CMFormatDescriptionRef description) -> Vector<Ref<SharedBuffer>> {
if (!description)
return { };
if (auto trackEncryptionData = static_cast<CFDataRef>(PAL::CMFormatDescriptionGetExtension(description, CFSTR("CommonEncryptionTrackEncryptionBox")))) {
// AVStreamDataParser will attach the 'tenc' box to each sample, not including the leading
// size and boxType data. Extract the 'tenc' box and use that box to derive the sample's
// keyID.
auto length = CFDataGetLength(trackEncryptionData);
auto ptr = (void*)(CFDataGetBytePtr(trackEncryptionData));
auto destructorFunction = createSharedTask<void(void*)>([data = WTFMove(trackEncryptionData)] (void*) { UNUSED_PARAM(data); });
auto trackEncryptionDataBuffer = ArrayBuffer::create(JSC::ArrayBufferContents(ptr, length, std::nullopt, WTFMove(destructorFunction)));

ISOTrackEncryptionBox trackEncryptionBox;
auto trackEncryptionView = JSC::DataView::create(WTFMove(trackEncryptionDataBuffer), 0, length);
if (!trackEncryptionBox.parseWithoutTypeAndSize(trackEncryptionView))
return { };
return { SharedBuffer::create(trackEncryptionBox.defaultKID()) };
}

#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
if (auto transportStreamData = static_cast<CFDataRef>(PAL::CMFormatDescriptionGetExtension(description, CFSTR("TransportStreamEncryptionInitData")))) {
// AVStreamDataParser will attach a JSON transport stream encryption
// description object to each sample. Use a static keyID in this case
// as MPEG2-TS encryption dose not specify a particular keyID in the
// stream.
return CDMPrivateFairPlayStreaming::mptsKeyIDs();
}
#endif
auto trackEncryptionData = static_cast<CFDataRef>(PAL::CMFormatDescriptionGetExtension(description, CFSTR("CommonEncryptionTrackEncryptionBox")));
if (!trackEncryptionData)
return { };

return { };
// AVStreamDataParser will attach the 'tenc' box to each sample, not including the leading
// size and boxType data. Extract the 'tenc' box and use that box to derive the sample's
// keyID.
auto length = CFDataGetLength(trackEncryptionData);
auto ptr = (void*)(CFDataGetBytePtr(trackEncryptionData));
auto destructorFunction = createSharedTask<void(void*)>([data = WTFMove(trackEncryptionData)] (void*) { UNUSED_PARAM(data); });
auto trackEncryptionDataBuffer = ArrayBuffer::create(JSC::ArrayBufferContents(ptr, length, std::nullopt, WTFMove(destructorFunction)));

ISOTrackEncryptionBox trackEncryptionBox;
auto trackEncryptionView = JSC::DataView::create(WTFMove(trackEncryptionDataBuffer), 0, length);
if (!trackEncryptionBox.parseWithoutTypeAndSize(trackEncryptionView))
return { };
return { SharedBuffer::create(trackEncryptionBox.defaultKID()) };
};
m_keyIDs = getKeyIDs(PAL::CMSampleBufferGetFormatDescription(m_sample.get()));
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,6 @@ static inline bool shouldAddContentKeyRecipients()

#if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
auto keyIDs = CDMPrivateFairPlayStreaming::extractKeyIDsSinf(*m_initData);
AtomString initDataType = CDMPrivateFairPlayStreaming::sinfName();
#if HAVE(FAIRPLAYSTREAMING_MTPS_INITDATA)
if (!keyIDs) {
keyIDs = CDMPrivateFairPlayStreaming::extractKeyIDsMpts(*m_initData);
initDataType = CDMPrivateFairPlayStreaming::mptsName();
}
#endif
if (!keyIDs)
return;

Expand All @@ -327,7 +320,7 @@ static inline bool shouldAddContentKeyRecipients()
}

m_keyIDs = WTFMove(keyIDs.value());
player->initializationDataEncountered(initDataType, m_initData->tryCreateArrayBuffer());
player->initializationDataEncountered("sinf"_s, m_initData->tryCreateArrayBuffer());
player->needsVideoLayerChanged();

m_waitingForKey = true;
Expand Down

0 comments on commit fc1461c

Please sign in to comment.