Title: [270872] trunk/Source
Revision
270872
Author
[email protected]
Date
2020-12-15 16:01:59 -0800 (Tue, 15 Dec 2020)

Log Message

[Cocoa] Adopt -externalContentProtectionStatus
https://bugs.webkit.org/show_bug.cgi?id=219911

Reviewed by Eric Carlson.

Source/WebCore:

Adopt a new AVContentKeyRequest API which provides a "pending" status (in addition to usable/unusable).

* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::keyStatuses const):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::keyRequestHasInsufficientProtectionForDisplayID const): Deleted.

Source/WebCore/PAL:

* pal/spi/cocoa/AVFoundationSPI.h:

Source/WTF:

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (270871 => 270872)


--- trunk/Source/WTF/ChangeLog	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WTF/ChangeLog	2020-12-16 00:01:59 UTC (rev 270872)
@@ -1,3 +1,12 @@
+2020-12-15  Jer Noble  <[email protected]>
+
+        [Cocoa] Adopt -externalContentProtectionStatus
+        https://bugs.webkit.org/show_bug.cgi?id=219911
+
+        Reviewed by Eric Carlson.
+
+        * wtf/PlatformHave.h:
+
 2020-12-15  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r270860.

Modified: trunk/Source/WTF/wtf/PlatformHave.h (270871 => 270872)


--- trunk/Source/WTF/wtf/PlatformHave.h	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2020-12-16 00:01:59 UTC (rev 270872)
@@ -808,3 +808,8 @@
 #define HAVE_MT_PLUGIN_SAMPLE_CURSOR_PLAYABLE_HORIZON 1
 #endif
 #endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 110200) \
+    || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140400)
+#define HAVE_AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS 1
+#endif

Modified: trunk/Source/WebCore/ChangeLog (270871 => 270872)


--- trunk/Source/WebCore/ChangeLog	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WebCore/ChangeLog	2020-12-16 00:01:59 UTC (rev 270872)
@@ -1,3 +1,18 @@
+2020-12-15  Jer Noble  <[email protected]>
+
+        [Cocoa] Adopt -externalContentProtectionStatus
+        https://bugs.webkit.org/show_bug.cgi?id=219911
+
+        Reviewed by Eric Carlson.
+
+        Adopt a new AVContentKeyRequest API which provides a "pending" status (in addition to usable/unusable).
+
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::keyStatuses const):
+        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID const):
+        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::keyRequestHasInsufficientProtectionForDisplayID const): Deleted.
+
 2020-12-15  Sihui Liu  <[email protected]>
 
         Add webkit- prefix to SpeechRecognition

Modified: trunk/Source/WebCore/PAL/ChangeLog (270871 => 270872)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-12-16 00:01:59 UTC (rev 270872)
@@ -1,3 +1,12 @@
+2020-12-15  Jer Noble  <[email protected]>
+
+        [Cocoa] Adopt -externalContentProtectionStatus
+        https://bugs.webkit.org/show_bug.cgi?id=219911
+
+        Reviewed by Eric Carlson.
+
+        * pal/spi/cocoa/AVFoundationSPI.h:
+
 2020-12-14  Chris Fleizach  <[email protected]>
 
         AX: implement prefers-contrast: more

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (270871 => 270872)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2020-12-16 00:01:59 UTC (rev 270872)
@@ -208,6 +208,19 @@
 - (BOOL)willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:(NSArray<NSNumber *> *)displays;
 NS_ASSUME_NONNULL_END
 @end
+
+#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
+typedef NS_ENUM(NSInteger, AVExternalContentProtectionStatus) {
+    AVExternalContentProtectionStatusPending      = 0,
+    AVExternalContentProtectionStatusSufficient   = 1,
+    AVExternalContentProtectionStatusInsufficient = 2,
+};
+
+@interface AVContentKeyRequest (AVContentKeyRequest_PendingProtectionStatus)
+- (AVExternalContentProtectionStatus)externalContentProtectionStatus;
+@end
+#endif
+
 #endif // HAVE(AVCONTENTKEYSESSION)
 
 #if ENABLE(MEDIA_SOURCE) && !USE(APPLE_INTERNAL_SDK)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h (270871 => 270872)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2020-12-16 00:01:59 UTC (rev 270872)
@@ -194,7 +194,7 @@
     void nextRequest();
     AVContentKeyRequest* lastKeyRequest() const;
 
-    bool keyRequestHasInsufficientProtectionForDisplayID(AVContentKeyRequest *, PlatformDisplayID) const;
+    Optional<CDMKeyStatus> protectionStatusForDisplayID(AVContentKeyRequest *, Optional<PlatformDisplayID>) const;
 
 #if !RELEASE_LOG_DISABLED
     WTF::Logger* loggerPtr() const { return m_logger.get(); };

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (270871 => 270872)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-12-15 23:34:40 UTC (rev 270871)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-12-16 00:01:59 UTC (rev 270872)
@@ -1397,14 +1397,9 @@
             if (oneRequest.get().error.code == SecurityLevelError)
                 status = CDMKeyStatus::OutputRestricted;
 
-            // Only use the non-request-specific "outputObscuredDueToInsufficientExternalProtection" status if
-            // AVContentKeyRequests do not support the finer grained "-willOutputBeObscured..." API.
-            if (m_outputObscured && ![oneRequest respondsToSelector:@selector(willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:)])
-                status = CDMKeyStatus::OutputRestricted;
+            if (auto protectionStatus = protectionStatusForDisplayID(oneRequest.get(), *displayID))
+                status = *protectionStatus;
 
-            if (displayID && keyRequestHasInsufficientProtectionForDisplayID(oneRequest.get(), *displayID))
-                status = CDMKeyStatus::OutputRestricted;
-
             for (auto& keyID : keyIDs)
                 keyStatuses.append({ WTFMove(keyID), status });
         }
@@ -1434,14 +1429,17 @@
     updateProtectionStatusForDisplayID(m_client->displayID());
 }
 
-bool CDMInstanceSessionFairPlayStreamingAVFObjC::keyRequestHasInsufficientProtectionForDisplayID(AVContentKeyRequest *request, PlatformDisplayID displayID) const
+Optional<CDMKeyStatus> CDMInstanceSessionFairPlayStreamingAVFObjC::protectionStatusForDisplayID(AVContentKeyRequest *request, Optional<PlatformDisplayID> displayID) const
 {
-    // willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays will always return "YES" prior to
-    // receiving a response.
-    if (request.status != AVContentKeyRequestStatusReceivedResponse && request.status != AVContentKeyRequestStatusRenewed) {
-        ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, "request has insufficient status ", (int)request.status);
-        return false;
+#if HAVE(AVCONTENTKEYREQUEST_PENDING_PROTECTION_STATUS)
+    if ([request respondsToSelector:@selector(externalContentProtectionStatus)]) {
+        switch ([request externalContentProtectionStatus]) {
+        case AVExternalContentProtectionStatusPending: return CDMKeyStatus::StatusPending;
+        case AVExternalContentProtectionStatusSufficient: return CDMKeyStatus::Usable;
+        case AVExternalContentProtectionStatusInsufficient: return CDMKeyStatus::OutputRestricted;
+        }
     }
+#endif
 
     // 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"
@@ -1450,11 +1448,25 @@
     // WebProcess.
     UNUSED_PARAM(displayID);
     if ([request respondsToSelector:@selector(willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:)]) {
+
+        // willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays will always return "YES" prior to
+        // receiving a response.
+        if (request.status != AVContentKeyRequestStatusReceivedResponse && request.status != AVContentKeyRequestStatusRenewed) {
+            ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, "request has insufficient status ", (int)request.status);
+            return WTF::nullopt;
+        }
+
         auto obscured = [request willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:@[ ]];
         ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, "request { ", keyIDsForRequest(request), " } willOutputBeObscured...forDisplays:[ nil ] = ", obscured ? "true" : "false");
-        return obscured;
+        return obscured ? CDMKeyStatus::OutputRestricted : CDMKeyStatus::Usable;
     }
-    return false;
+
+    // Only use the non-request-specific "outputObscuredDueToInsufficientExternalProtection" status if
+    // AVContentKeyRequests do not support the finer grained "-willOutputBeObscured..." API.
+    if (m_outputObscured)
+        return CDMKeyStatus::OutputRestricted;
+
+    return WTF::nullopt;
 };
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to