Title: [290169] branches/safari-614.1.4-branch/Source/WebCore
Revision
290169
Author
[email protected]
Date
2022-02-18 14:19:43 -0800 (Fri, 18 Feb 2022)

Log Message

Cherry-pick r290153. rdar://problem/89142268

    [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.

    Source/WebCore:

    Wrap call-sites in #if HAVE() macros.

    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):

    Source/WebCore/PAL:

    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:

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

Modified Paths

Diff

Modified: branches/safari-614.1.4-branch/Source/WebCore/ChangeLog (290168 => 290169)


--- branches/safari-614.1.4-branch/Source/WebCore/ChangeLog	2022-02-18 22:01:40 UTC (rev 290168)
+++ branches/safari-614.1.4-branch/Source/WebCore/ChangeLog	2022-02-18 22:19:43 UTC (rev 290169)
@@ -1,3 +1,65 @@
+2022-02-18  Russell Epstein  <[email protected]>
+
+        Cherry-pick r290153. rdar://problem/89142268
+
+    [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.
+    
+    Source/WebCore:
+    
+    Wrap call-sites in #if HAVE() macros.
+    
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):
+    
+    Source/WebCore/PAL:
+    
+    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:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-18  Jer Noble  <[email protected]>
+
+            [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.
+
+            Wrap call-sites in #if HAVE() macros.
+
+            * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
+            (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
+            (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
+            (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
+            (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
+            (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):
+
 2022-02-13  Lauro Moura  <[email protected]>
 
         Unreviewed, non-unified build fixes

Modified: branches/safari-614.1.4-branch/Source/WebCore/PAL/ChangeLog (290168 => 290169)


--- branches/safari-614.1.4-branch/Source/WebCore/PAL/ChangeLog	2022-02-18 22:01:40 UTC (rev 290168)
+++ branches/safari-614.1.4-branch/Source/WebCore/PAL/ChangeLog	2022-02-18 22:19:43 UTC (rev 290169)
@@ -1,3 +1,69 @@
+2022-02-18  Russell Epstein  <[email protected]>
+
+        Cherry-pick r290153. rdar://problem/89142268
+
+    [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.
+    
+    Source/WebCore:
+    
+    Wrap call-sites in #if HAVE() macros.
+    
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::sessionForRequest const):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::requestLicense):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
+    (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup):
+    
+    Source/WebCore/PAL:
+    
+    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:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-18  Jer Noble  <[email protected]>
+
+            [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-17  Alan Coon  <[email protected]>
 
         Cherry-pick r290076. rdar://problem/89076606

Modified: branches/safari-614.1.4-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (290168 => 290169)


--- branches/safari-614.1.4-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2022-02-18 22:01:40 UTC (rev 290168)
+++ branches/safari-614.1.4-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2022-02-18 22:19:43 UTC (rev 290169)
@@ -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: branches/safari-614.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (290168 => 290169)


--- branches/safari-614.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2022-02-18 22:01:40 UTC (rev 290168)
+++ branches/safari-614.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2022-02-18 22:19:43 UTC (rev 290169)
@@ -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
 
 CDMInstanceSessionFairPlayStreamingAVFObjC::CDMInstanceSessionFairPlayStreamingAVFObjC(Ref<CDMInstanceFairPlayStreamingAVFObjC>&& instance)
     : m_instance(WTFMove(instance))
@@ -694,11 +713,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;
@@ -726,13 +747,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)
@@ -982,9 +1006,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) {
@@ -1103,7 +1129,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);
                 }
 
@@ -1386,7 +1418,11 @@
 
 void CDMInstanceSessionFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData *sessionIdentifier)
 {
+#if HAVE(AVCONTENTKEYREPORTGROUP)
     sessionIdentifierChanged(sessionIdentifier);
+#else
+    UNUSED_PARAM(sessionIdentifier);
+#endif
 }
 
 static auto requestStatusToCDMStatus(AVContentKeyRequestStatus status)
@@ -1462,6 +1498,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
@@ -1480,6 +1517,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.
@@ -1499,13 +1537,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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to