Title: [254288] trunk/Source/WebCore
Revision
254288
Author
[email protected]
Date
2020-01-09 12:18:40 -0800 (Thu, 09 Jan 2020)

Log Message

[Cocoa] persistent-usage-record message fails first time; succeeds subsequent times
https://bugs.webkit.org/show_bug.cgi?id=205970
<rdar://problem/57785647>

Reviewed by Eric Carlson.

The AVContentKeySession is created too early; before the CDM has a chance to provide the storage path
for persistent usage records. Delay creation of the AVCKS until it's actually needed during the first
license request.

Drive-by fix: fix the exceptional case where a PUR session is closed but PUR data isn't available; send
a null message rather than an empty array.

* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::CDMInstanceFairPlayStreamingAVFObjC): Deleted.
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::ensureSession): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254287 => 254288)


--- trunk/Source/WebCore/ChangeLog	2020-01-09 20:08:23 UTC (rev 254287)
+++ trunk/Source/WebCore/ChangeLog	2020-01-09 20:18:40 UTC (rev 254288)
@@ -1,3 +1,25 @@
+2020-01-09  Jer Noble  <[email protected]>
+
+        [Cocoa] persistent-usage-record message fails first time; succeeds subsequent times
+        https://bugs.webkit.org/show_bug.cgi?id=205970
+        <rdar://problem/57785647>
+
+        Reviewed by Eric Carlson.
+
+        The AVContentKeySession is created too early; before the CDM has a chance to provide the storage path
+        for persistent usage records. Delay creation of the AVCKS until it's actually needed during the first
+        license request.
+
+        Drive-by fix: fix the exceptional case where a PUR session is closed but PUR data isn't available; send
+        a null message rather than an empty array.
+
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::contentKeySession):
+        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::CDMInstanceFairPlayStreamingAVFObjC): Deleted.
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::ensureSession): Deleted.
+
 2020-01-09  Zalan Bujtas  <[email protected]>
 
         Fix iOS build.

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2020-01-09 20:08:23 UTC (rev 254287)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2020-01-09 20:18:40 UTC (rev 254288)
@@ -87,7 +87,7 @@
     NSURL *storageURL() const { return m_storageURL.get(); }
     bool persistentStateAllowed() const { return m_persistentStateAllowed; }
     SharedBuffer* serverCertificate() const { return m_serverCertificate.get(); }
-    AVContentKeySession* contentKeySession() { return m_session.get(); }
+    AVContentKeySession* contentKeySession();
 
     // AVContentKeySessionDelegateClient
     void didProvideRequest(AVContentKeyRequest*) final;
@@ -106,8 +106,6 @@
     CDMInstanceSessionFairPlayStreamingAVFObjC* sessionForGroup(AVContentKeyReportGroup*) const;
 
 private:
-    void ensureSession();
-
     RetainPtr<AVContentKeySession> m_session;
     RetainPtr<WebCoreFPSContentKeySessionDelegate> m_delegate;
     RefPtr<SharedBuffer> m_serverCertificate;

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-01-09 20:08:23 UTC (rev 254287)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-01-09 20:18:40 UTC (rev 254288)
@@ -159,20 +159,19 @@
 
 namespace WebCore {
 
-CDMInstanceFairPlayStreamingAVFObjC::CDMInstanceFairPlayStreamingAVFObjC()
-{
-    if (PAL::getAVContentKeyReportGroupClass())
-        ensureSession();
-}
+CDMInstanceFairPlayStreamingAVFObjC::CDMInstanceFairPlayStreamingAVFObjC() = default;
 
-void CDMInstanceFairPlayStreamingAVFObjC::ensureSession()
+AVContentKeySession* CDMInstanceFairPlayStreamingAVFObjC::contentKeySession()
 {
     if (m_session)
-        return;
+        return m_session.get();
 
     if (!PAL::canLoad_AVFoundation_AVContentKeySystemFairPlayStreaming())
-        return;
+        return nullptr;
 
+    if (!PAL::getAVContentKeyReportGroupClass())
+        return nullptr;
+
     auto storageURL = this->storageURL();
     if (!persistentStateAllowed() || !storageURL)
         m_session = [PAL::getAVContentKeySessionClass() contentKeySessionWithKeySystem:AVContentKeySystemFairPlayStreaming];
@@ -180,12 +179,13 @@
         m_session = [PAL::getAVContentKeySessionClass() contentKeySessionWithKeySystem:AVContentKeySystemFairPlayStreaming storageDirectoryAtURL:storageURL];
 
     if (!m_session)
-        return;
+        return nullptr;
 
     if (!m_delegate)
         m_delegate = adoptNS([[WebCoreFPSContentKeySessionDelegate alloc] initWithParent:this]);
 
     [m_session setDelegate:m_delegate.get() queue:dispatch_get_main_queue()];
+    return m_session.get();
 }
 
 class CDMInstanceSessionFairPlayStreamingAVFObjC::UpdateResponseCollector {
@@ -816,6 +816,11 @@
             }
         }
 
+        if (!expiredSessionsArray.get().count) {
+            callback(WTFMove(changedKeys), WTF::nullopt, Succeeded);
+            return;
+        }
+
         RetainPtr<NSData> expiredSessionsData = [NSPropertyListSerialization dataWithPropertyList:expiredSessionsArray.get() format:NSPropertyListBinaryFormat_v1_0 options:kCFPropertyListImmutable error:nullptr];
 
         callback(WTFMove(changedKeys), SharedBuffer::create(expiredSessionsData.get()), Succeeded);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to