Modified: trunk/Source/WebCore/PAL/ChangeLog (290152 => 290153)
--- trunk/Source/WebCore/PAL/ChangeLog 2022-02-18 20:27:21 UTC (rev 290152)
+++ trunk/Source/WebCore/PAL/ChangeLog 2022-02-18 20:30:09 UTC (rev 290153)
@@ -1,3 +1,26 @@
+2022-02-18 Jer Noble <jer.no...@apple.com>
+
+ [Cocoa] Make AVFoundationSPI.h robust against changes in system headers
+ https://bugs.webkit.org/show_bug.cgi?id=236787
+ <rdar://89076606>
+
+ Reviewed by Eric Carlson.
+
+ Follow-up: build problems still persist on certain platforms, so the "robustness"
+ changes made previously were not robust enough. The guards in AVFoundationSPI.h were
+ intended to ensure the definitions were present even on builds where the official API
+ is not supported. However, just because the API is not supported does not mean it's not
+ present, which leads to duplicate-interface build errors.
+
+ Fix the AVFoundationSPI.h pragmas to only define the classes and methods where those
+ objects are supported, and in parallel, wrap implementations which use those objects
+ in those same guards (making these checks compile-time in addition to runtime).
+
+ Move the declarations inside the #else (IOW, !USE(APPLE_INTERNAL_SDK)) block above,
+ and wrap each declaration in the correct HAVE() macro.
+
+ * pal/spi/cocoa/AVFoundationSPI.h:
+
2022-02-18 Brandon Stewart <brandonstew...@apple.com>
Generate compile_commands.json on macOS Builds
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (290152 => 290153)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h 2022-02-18 20:27:21 UTC (rev 290152)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h 2022-02-18 20:30:09 UTC (rev 290153)
@@ -220,13 +220,9 @@
@end
NS_ASSUME_NONNULL_END
-#endif // USE(APPLE_INTERNAL_SDK)
-
-#import <AVFoundation/AVPlayerLayer.h>
-
#if HAVE(AVCONTENTKEYSESSION)
-#if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYREPORTGROUP)
+#if HAVE(AVCONTENTKEYREPORTGROUP)
@interface AVContentKeyReportGroup : NSObject
@property (readonly, nullable) NSData *contentProtectionSessionIdentifier;
- (void)expire;
@@ -240,7 +236,7 @@
@end
#endif
-#if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
+#if HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
@interface AVContentKeyRequest (OutputObscured)
NS_ASSUME_NONNULL_BEGIN
- (BOOL)willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:(NSArray<NSNumber *> *)displays;
@@ -248,7 +244,7 @@
@end
#endif
-#if !USE(APPLE_INTERNAL_SDK) || !HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
+#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
typedef NS_ENUM(NSInteger, AVExternalContentProtectionStatus) {
AVExternalContentProtectionStatusPending = 0,
AVExternalContentProtectionStatusSufficient = 1,
@@ -262,6 +258,10 @@
#endif // HAVE(AVCONTENTKEYSESSION)
+#endif // USE(APPLE_INTERNAL_SDK)
+
+#import <AVFoundation/AVPlayerLayer.h>
+
#if ENABLE(MEDIA_SOURCE) && !USE(APPLE_INTERNAL_SDK)
NS_ASSUME_NONNULL_BEGIN
@interface AVStreamDataParser (AVStreamDataParserPrivate)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (290152 => 290153)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2022-02-18 20:27:21 UTC (rev 290152)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm 2022-02-18 20:30:09 UTC (rev 290153)
@@ -50,7 +50,9 @@
#import <pal/cocoa/AVFoundationSoftLink.h>
static NSString * const InitializationDataTypeKey = @"InitializationDataType";
+#if HAVE(AVCONTENTKEYREPORTGROUP)
static NSString * const ContentKeyReportGroupKey = @"ContentKeyReportGroup";
+#endif
static const NSInteger SecurityLevelError = -42811;
@interface WebCoreFPSContentKeySessionDelegate : NSObject<AVContentKeySessionDelegate> {
@@ -146,6 +148,7 @@
_parent->sessionIdentifierChanged(session.contentProtectionSessionIdentifier);
}
+#if HAVE(AVCONTENTKEYREPORTGROUP)
- (void)contentKeySession:(AVContentKeySession *)session contentProtectionSessionIdentifierDidChangeForKeyGroup:(nullable AVContentKeyReportGroup *)reportGroup
{
// FIXME: Remove after rdar://57430747 is fixed
@@ -158,6 +161,7 @@
if (_parent)
_parent->groupSessionIdentifierChanged(reportGroup, reportGroup.contentProtectionSessionIdentifier);
}
+#endif
- (void)contentKeySession:(AVContentKeySession *)session externalProtectionStatusDidChangeForContentKeyRequest:(AVContentKeyRequest *)keyRequest
{
@@ -247,8 +251,10 @@
if (!PAL::canLoad_AVFoundation_AVContentKeySystemFairPlayStreaming())
return nullptr;
+#if HAVE(AVCONTENTKEYREPORTGROUP)
if (!PAL::getAVContentKeyReportGroupClass())
return nullptr;
+#endif
auto storageURL = this->storageURL();
if (!persistentStateAllowed() || !storageURL)
@@ -440,6 +446,7 @@
return keySystem;
}
+#if HAVE(AVCONTENTKEYREPORTGROUP)
static AVContentKeyReportGroup* groupForRequest(AVContentKeyRequest* request)
{
ASSERT([request respondsToSelector:@selector(options)]);
@@ -448,6 +455,7 @@
ALLOW_NEW_API_WITHOUT_GUARDS_END
return group;
}
+#endif
void CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest(AVContentKeyRequest *request)
{
@@ -544,6 +552,7 @@
void CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup* group, NSData *sessionIdentifier)
{
+#if HAVE(AVCONTENTKEYREPORTGROUP)
if (group == [m_session defaultContentKeyGroup]) {
INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- default unused group identifier changed; dropping");
return;
@@ -556,6 +565,10 @@
ASSERT_NOT_REACHED();
ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- no responsible session; dropping");
+#else
+ UNUSED_PARAM(group);
+ UNUSED_PARAM(sessionIdentifier);
+#endif
}
void CDMInstanceFairPlayStreamingAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged(bool obscured)
@@ -603,9 +616,14 @@
if (index != notFound)
return m_sessions[index].get();
+#if HAVE(AVCONTENTKEYREPORTGROUP)
return sessionForGroup(groupForRequest(request));
+#else
+ return nullptr;
+#endif
}
+#if HAVE(AVCONTENTKEYREPORTGROUP)
CDMInstanceSessionFairPlayStreamingAVFObjC* CDMInstanceFairPlayStreamingAVFObjC::sessionForGroup(AVContentKeyReportGroup* group) const
{
auto index = m_sessions.findIf([group] (auto session) {
@@ -616,6 +634,7 @@
return m_sessions[index].get();
return nullptr;
}
+#endif
bool CDMInstanceFairPlayStreamingAVFObjC::isAnyKeyUsable(const Keys& keys) const
{
@@ -725,11 +744,13 @@
if (auto unexpectedRequest = m_instance->takeUnexpectedKeyRequestForInitializationData(initDataType, initData)) {
DEBUG_LOG_IF_POSSIBLE(LOGIDENTIFIER, " found unexpectedRequest matching initData");
+#if HAVE(AVCONTENTKEYREPORTGROUP)
if (m_group) {
ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN
[m_group associateContentKeyRequest:unexpectedRequest.get()];
ALLOW_NEW_API_WITHOUT_GUARDS_END
}
+#endif
m_requestLicenseCallback = WTFMove(callback);
didProvideRequest(unexpectedRequest.get());
return;
@@ -757,13 +778,16 @@
DEBUG_LOG_IF_POSSIBLE(LOGIDENTIFIER, " processing request");
m_requestLicenseCallback = WTFMove(callback);
+#if HAVE(AVCONTENTKEYREPORTGROUP)
if (m_group) {
auto* options = @{ ContentKeyReportGroupKey: m_group.get(), InitializationDataTypeKey: (NSString*)initDataType };
[m_group processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
- } else {
- auto* options = @{ InitializationDataTypeKey: (NSString*)initDataType };
- [m_session processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
+ return;
}
+#endif
+
+ auto* options = @{ InitializationDataTypeKey: (NSString*)initDataType };
+ [m_session processContentKeyRequestWithIdentifier:identifier.get() initializationData:initializationData.get() options:options];
}
static bool isEqual(const FragmentedSharedBuffer& data, const String& value)
@@ -1011,9 +1035,11 @@
void CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData(const String& sessionId, LicenseType licenseType, RemoveSessionDataCallback&& callback)
{
+#if HAVE(AVCONTENTKEYREPORTGROUP)
if (m_group)
[m_group expire];
else
+#endif
[m_session expire];
if (licenseType == LicenseType::PersistentUsageRecord) {
@@ -1132,7 +1158,13 @@
return;
if (m_sessionId.isEmpty()) {
- auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier;
+ NSData *sessionID = nullptr;
+#if HAVE(AVCONTENTKEYREPORTGROUP)
+ if (m_group)
+ sessionID = m_group.get().contentProtectionSessionIdentifier;
+ else
+#endif
+ sessionID = m_session.get().contentProtectionSessionIdentifier;
sessionIdentifierChanged(sessionID);
}
@@ -1417,7 +1449,11 @@
void CDMInstanceSessionFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData *sessionIdentifier)
{
+#if HAVE(AVCONTENTKEYREPORTGROUP)
sessionIdentifierChanged(sessionIdentifier);
+#else
+ UNUSED_PARAM(sessionIdentifier);
+#endif
}
static auto requestStatusToCDMStatus(AVContentKeyRequestStatus status)
@@ -1507,6 +1543,7 @@
}
#endif
+#if HAVE(AVCONTENTKEYSESSIONWILLOUTPUTBEOBSCURED)
// FIXME: AVFoundation requires a connection to the WindowServer in order to query the HDCP status of individual
// displays. Passing in an empty NSArray will cause AVFoundation to fall back to a "minimum supported HDCP level"
// across all displays. Replace the below with explicit APIs to query the per-display HDCP status in the UIProcess
@@ -1525,6 +1562,7 @@
ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, "request { ", keyIDsForRequest(request), " } willOutputBeObscured...forDisplays:[ nil ] = ", obscured ? "true" : "false");
return obscured ? CDMKeyStatus::OutputRestricted : CDMKeyStatus::Usable;
}
+#endif
// Only use the non-request-specific "outputObscuredDueToInsufficientExternalProtection" status if
// AVContentKeyRequests do not support the finer grained "-willOutputBeObscured..." API.
@@ -1548,13 +1586,18 @@
bool CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup()
{
- if (m_session || m_group)
+ if (m_session)
return true;
+#if HAVE(AVCONTENTKEYREPORTGROUP)
+ if (m_group)
+ return true;
+
if (auto* session = m_instance->contentKeySession()) {
m_group = [session makeContentKeyGroup];
return true;
}
+#endif
auto storageURL = m_instance->storageURL();
if (!m_instance->persistentStateAllowed() || !storageURL)