Title: [271820] branches/safari-611-branch/Source
Revision
271820
Author
alanc...@apple.com
Date
2021-01-25 14:10:52 -0800 (Mon, 25 Jan 2021)

Log Message

Cherry-pick r271405. rdar://problem/73466993

    [Cocoa] Support key rotation with HLS-backed encrypted media streams
    https://bugs.webkit.org/show_bug.cgi?id=220493
    <rdar://68227709>

    Reviewed by Eric Carlson.

    Source/WebCore:

    Support key rotation through AVContentKeySession by explicitly handling unexpected key requests
    submitted through the new -contentKeySession:didProvideContentKeyRequests:forInitializationData:.
    Rotation was previously handled in the delegate method -contentKeySession:didProvideContentKeyRequest,
    but that method is no longer called after the replacement delegate method was implemented, and
    that method never handled "skd://" style initialization data.

    Update the helper method, initTypeForRequest(), to detect "skd://" identifiers and correctly identify
    those sessions as "skd".

    Add a new helper method, initializationDataForRequest(), which will package the AVContentKeySession's
    identifier as initialization data.

    Drive-by Fix: Fixing this bug causes the default key group to update it's identifier, which causes an assert
    when the group in question isn't any of those associated with an existing MediaKeySession, so handle that case
    explicitly.

    Drive-by Fix 2: Sometimes, when GPUP is enabled for media, we will get spurious mediaPlayerEngineUpdated()
    calls which cause cdmInstanceAttached() to be called multiple times for the same player, triggering an ASSERT.
    If called twice with the same CDM, just return early rather than ASSERTing.

    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
    (WebCore::initTypeForRequest):
    (WebCore::initializationDataForRequest):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::takeUnexpectedKeyRequestForInitializationData):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests):
    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged):
    * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
    (WebCore::MediaSourcePrivateAVFObjC::cdmInstanceAttached):

    Source/WebCore/PAL:

    * pal/spi/cocoa/AVFoundationSPI.h:

    Source/WebKit:

    Support handling the "unexpectedInitializationDataReceived()" client callback from within the GPUP.

    * DerivedSources-input.xcfilelist:
    * DerivedSources-output.xcfilelist:
    * DerivedSources.make:
    * GPUProcess/media/RemoteCDMInstanceProxy.cpp:
    (WebKit::RemoteCDMInstanceProxy::create):
    (WebKit::RemoteCDMInstanceProxy::RemoteCDMInstanceProxy):
    (WebKit::RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy):
    (WebKit::RemoteCDMInstanceProxy::unrequestedInitializationDataReceived):
    * GPUProcess/media/RemoteCDMInstanceProxy.h:
    * GPUProcess/media/RemoteCDMProxy.cpp:
    (WebKit::RemoteCDMProxy::createInstance):
    * WebKit.xcodeproj/project.pbxproj:
    * WebProcess/GPU/media/RemoteCDMInstance.cpp:
    (WebKit::RemoteCDMInstance::RemoteCDMInstance):
    (WebKit::RemoteCDMInstance::~RemoteCDMInstance):
    (WebKit::RemoteCDMInstance::unrequestedInitializationDataReceived):
    * WebProcess/GPU/media/RemoteCDMInstance.h:
    * WebProcess/GPU/media/RemoteCDMInstance.messages.in: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-01-25 22:10:52 UTC (rev 271820)
@@ -1,5 +1,119 @@
 2021-01-25  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r271405. rdar://problem/73466993
+
+    [Cocoa] Support key rotation with HLS-backed encrypted media streams
+    https://bugs.webkit.org/show_bug.cgi?id=220493
+    <rdar://68227709>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Support key rotation through AVContentKeySession by explicitly handling unexpected key requests
+    submitted through the new -contentKeySession:didProvideContentKeyRequests:forInitializationData:.
+    Rotation was previously handled in the delegate method -contentKeySession:didProvideContentKeyRequest,
+    but that method is no longer called after the replacement delegate method was implemented, and
+    that method never handled "skd://" style initialization data.
+    
+    Update the helper method, initTypeForRequest(), to detect "skd://" identifiers and correctly identify
+    those sessions as "skd".
+    
+    Add a new helper method, initializationDataForRequest(), which will package the AVContentKeySession's
+    identifier as initialization data.
+    
+    Drive-by Fix: Fixing this bug causes the default key group to update it's identifier, which causes an assert
+    when the group in question isn't any of those associated with an existing MediaKeySession, so handle that case
+    explicitly.
+    
+    Drive-by Fix 2: Sometimes, when GPUP is enabled for media, we will get spurious mediaPlayerEngineUpdated()
+    calls which cause cdmInstanceAttached() to be called multiple times for the same player, triggering an ASSERT.
+    If called twice with the same CDM, just return early rather than ASSERTing.
+    
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+    (WebCore::initTypeForRequest):
+    (WebCore::initializationDataForRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::takeUnexpectedKeyRequestForInitializationData):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged):
+    * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+    (WebCore::MediaSourcePrivateAVFObjC::cdmInstanceAttached):
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    
+    Source/WebKit:
+    
+    Support handling the "unexpectedInitializationDataReceived()" client callback from within the GPUP.
+    
+    * DerivedSources-input.xcfilelist:
+    * DerivedSources-output.xcfilelist:
+    * DerivedSources.make:
+    * GPUProcess/media/RemoteCDMInstanceProxy.cpp:
+    (WebKit::RemoteCDMInstanceProxy::create):
+    (WebKit::RemoteCDMInstanceProxy::RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::unrequestedInitializationDataReceived):
+    * GPUProcess/media/RemoteCDMInstanceProxy.h:
+    * GPUProcess/media/RemoteCDMProxy.cpp:
+    (WebKit::RemoteCDMProxy::createInstance):
+    * WebKit.xcodeproj/project.pbxproj:
+    * WebProcess/GPU/media/RemoteCDMInstance.cpp:
+    (WebKit::RemoteCDMInstance::RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::~RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::unrequestedInitializationDataReceived):
+    * WebProcess/GPU/media/RemoteCDMInstance.h:
+    * WebProcess/GPU/media/RemoteCDMInstance.messages.in: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Jer Noble  <jer.no...@apple.com>
+
+            [Cocoa] Support key rotation with HLS-backed encrypted media streams
+            https://bugs.webkit.org/show_bug.cgi?id=220493
+            <rdar://68227709>
+
+            Reviewed by Eric Carlson.
+
+            Support key rotation through AVContentKeySession by explicitly handling unexpected key requests
+            submitted through the new -contentKeySession:didProvideContentKeyRequests:forInitializationData:.
+            Rotation was previously handled in the delegate method -contentKeySession:didProvideContentKeyRequest,
+            but that method is no longer called after the replacement delegate method was implemented, and
+            that method never handled "skd://" style initialization data.
+
+            Update the helper method, initTypeForRequest(), to detect "skd://" identifiers and correctly identify
+            those sessions as "skd".
+
+            Add a new helper method, initializationDataForRequest(), which will package the AVContentKeySession's
+            identifier as initialization data.
+
+            Drive-by Fix: Fixing this bug causes the default key group to update it's identifier, which causes an assert
+            when the group in question isn't any of those associated with an existing MediaKeySession, so handle that case
+            explicitly.
+
+            Drive-by Fix 2: Sometimes, when GPUP is enabled for media, we will get spurious mediaPlayerEngineUpdated()
+            calls which cause cdmInstanceAttached() to be called multiple times for the same player, triggering an ASSERT.
+            If called twice with the same CDM, just return early rather than ASSERTing.
+
+            * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+            * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+            (WebCore::initTypeForRequest):
+            (WebCore::initializationDataForRequest):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::takeUnexpectedKeyRequestForInitializationData):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests):
+            (WebCore::CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged):
+            * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+            (WebCore::MediaSourcePrivateAVFObjC::cdmInstanceAttached):
+
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r271394. rdar://problem/73425595
 
     [Multicol] set the childrenInline flag on the RenderBlockFlow properly

Modified: branches/safari-611-branch/Source/WebCore/PAL/ChangeLog (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/PAL/ChangeLog	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/PAL/ChangeLog	2021-01-25 22:10:52 UTC (rev 271820)
@@ -1,3 +1,87 @@
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r271405. rdar://problem/73466993
+
+    [Cocoa] Support key rotation with HLS-backed encrypted media streams
+    https://bugs.webkit.org/show_bug.cgi?id=220493
+    <rdar://68227709>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Support key rotation through AVContentKeySession by explicitly handling unexpected key requests
+    submitted through the new -contentKeySession:didProvideContentKeyRequests:forInitializationData:.
+    Rotation was previously handled in the delegate method -contentKeySession:didProvideContentKeyRequest,
+    but that method is no longer called after the replacement delegate method was implemented, and
+    that method never handled "skd://" style initialization data.
+    
+    Update the helper method, initTypeForRequest(), to detect "skd://" identifiers and correctly identify
+    those sessions as "skd".
+    
+    Add a new helper method, initializationDataForRequest(), which will package the AVContentKeySession's
+    identifier as initialization data.
+    
+    Drive-by Fix: Fixing this bug causes the default key group to update it's identifier, which causes an assert
+    when the group in question isn't any of those associated with an existing MediaKeySession, so handle that case
+    explicitly.
+    
+    Drive-by Fix 2: Sometimes, when GPUP is enabled for media, we will get spurious mediaPlayerEngineUpdated()
+    calls which cause cdmInstanceAttached() to be called multiple times for the same player, triggering an ASSERT.
+    If called twice with the same CDM, just return early rather than ASSERTing.
+    
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+    (WebCore::initTypeForRequest):
+    (WebCore::initializationDataForRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::takeUnexpectedKeyRequestForInitializationData):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged):
+    * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+    (WebCore::MediaSourcePrivateAVFObjC::cdmInstanceAttached):
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    
+    Source/WebKit:
+    
+    Support handling the "unexpectedInitializationDataReceived()" client callback from within the GPUP.
+    
+    * DerivedSources-input.xcfilelist:
+    * DerivedSources-output.xcfilelist:
+    * DerivedSources.make:
+    * GPUProcess/media/RemoteCDMInstanceProxy.cpp:
+    (WebKit::RemoteCDMInstanceProxy::create):
+    (WebKit::RemoteCDMInstanceProxy::RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::unrequestedInitializationDataReceived):
+    * GPUProcess/media/RemoteCDMInstanceProxy.h:
+    * GPUProcess/media/RemoteCDMProxy.cpp:
+    (WebKit::RemoteCDMProxy::createInstance):
+    * WebKit.xcodeproj/project.pbxproj:
+    * WebProcess/GPU/media/RemoteCDMInstance.cpp:
+    (WebKit::RemoteCDMInstance::RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::~RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::unrequestedInitializationDataReceived):
+    * WebProcess/GPU/media/RemoteCDMInstance.h:
+    * WebProcess/GPU/media/RemoteCDMInstance.messages.in: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Jer Noble  <jer.no...@apple.com>
+
+            [Cocoa] Support key rotation with HLS-backed encrypted media streams
+            https://bugs.webkit.org/show_bug.cgi?id=220493
+            <rdar://68227709>
+
+            Reviewed by Eric Carlson.
+
+            * pal/spi/cocoa/AVFoundationSPI.h:
+
 2021-01-08  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r271331.

Modified: branches/safari-611-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-01-25 22:10:52 UTC (rev 271820)
@@ -200,6 +200,7 @@
 @end
 
 @interface AVContentKeySession (AVContentKeyGroup_Support)
+@property (readonly, nullable) AVContentKeyReportGroup *defaultContentKeyGroup;
 - (nonnull AVContentKeyReportGroup *)makeContentKeyGroup;
 @end
 

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h	2021-01-25 22:10:52 UTC (rev 271820)
@@ -120,6 +120,8 @@
     CDMInstanceSessionFairPlayStreamingAVFObjC* sessionForRequest(AVContentKeyRequest*) const;
 
 private:
+    void handleUnexpectedRequests(Vector<RetainPtr<AVContentKeyRequest>>&&);
+
 #if !RELEASE_LOG_DISABLED
     WTF::Logger* loggerPtr() const { return m_logger.get(); };
     const void* logIdentifier() const { return m_logIdentifier; }

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2021-01-25 22:10:52 UTC (rev 271820)
@@ -196,6 +196,9 @@
 
 static AtomString initTypeForRequest(AVContentKeyRequest* request)
 {
+    if ([request.identifier isKindOfClass:NSString.class] && [request.identifier hasPrefix:@"skd://"])
+        return CDMPrivateFairPlayStreaming::skdName();
+
     if (![request respondsToSelector:@selector(options)]) {
         // AVContentKeyRequest.options was added in 10.14.4; if we are running on a previous version
         // we don't have support for 'cenc' anyway, so just assume 'sinf'.
@@ -215,6 +218,17 @@
     return AtomString(nsInitType);
 }
 
+static Ref<SharedBuffer> initializationDataForRequest(AVContentKeyRequest* request)
+{
+    if (!request)
+        return SharedBuffer::create();
+
+    if (initTypeForRequest(request) == CDMPrivateFairPlayStreaming::skdName())
+        return SharedBuffer::create([request.identifier dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]);
+
+    return SharedBuffer::create(request.initializationData);
+}
+
 CDMInstanceFairPlayStreamingAVFObjC::CDMInstanceFairPlayStreamingAVFObjC() = default;
 
 #if !RELEASE_LOG_DISABLED
@@ -257,8 +271,8 @@
     for (auto requestIter = m_unexpectedKeyRequests.begin(); requestIter != m_unexpectedKeyRequests.end(); ++requestIter) {
         auto& request = *requestIter;
         auto requestType = initTypeForRequest(request.get());
-        auto* requestInitData  = request.get().initializationData;
-        if (initDataType != requestType || initData != SharedBuffer::create(requestInitData))
+        auto requestInitData = initializationDataForRequest(request.get());
+        if (initDataType != requestType || initData != requestInitData)
             continue;
 
         return m_unexpectedKeyRequests.take(requestIter);
@@ -444,10 +458,7 @@
 
     DEBUG_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- Unexpected request");
 
-    m_unexpectedKeyRequests.add(request);
-
-    if (m_client)
-        m_client->unrequestedInitializationDataReceived(initTypeForRequest(request), SharedBuffer::create(request.initializationData));
+    handleUnexpectedRequests({{ request }});
 }
 
 void CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests(Vector<RetainPtr<AVContentKeyRequest>>&& requests)
@@ -457,10 +468,20 @@
         return;
     }
 
-    ASSERT_NOT_REACHED();
-    ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- no responsible session; dropping");
+    handleUnexpectedRequests(WTFMove(requests));
 }
 
+void CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests(Vector<RetainPtr<AVContentKeyRequest>>&& requests)
+{
+    while (!requests.isEmpty()) {
+        auto request = requests.takeLast();
+        m_unexpectedKeyRequests.add(request);
+
+        if (m_client)
+            m_client->unrequestedInitializationDataReceived(initTypeForRequest(request.get()), initializationDataForRequest(request.get()));
+    }
+}
+
 void CDMInstanceFairPlayStreamingAVFObjC::didProvideRenewingRequest(AVContentKeyRequest *request)
 {
     if (auto* session = sessionForRequest(request)) {
@@ -524,6 +545,11 @@
 
 void CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged(AVContentKeyReportGroup* group, NSData *sessionIdentifier)
 {
+    if (group == [m_session defaultContentKeyGroup]) {
+        INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- default unused group identifier changed; dropping");
+        return;
+    }
+
     if (auto* session = sessionForGroup(group)) {
         session->groupSessionIdentifierChanged(group, sessionIdentifier);
         return;

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (271819 => 271820)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm	2021-01-25 22:10:52 UTC (rev 271820)
@@ -277,6 +277,9 @@
 #if ENABLE(ENCRYPTED_MEDIA)
 void MediaSourcePrivateAVFObjC::cdmInstanceAttached(CDMInstance& instance)
 {
+    if (m_cdmInstance.get() == &instance)
+        return;
+
     ASSERT(!m_cdmInstance);
     m_cdmInstance = &instance;
     for (auto& sourceBuffer : m_sourceBuffers)

Modified: branches/safari-611-branch/Source/WebKit/CMakeLists.txt (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/CMakeLists.txt	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/CMakeLists.txt	2021-01-25 22:10:52 UTC (rev 271820)
@@ -228,6 +228,7 @@
     WebProcess/GPU/media/MediaSourcePrivateRemote
     WebProcess/GPU/media/RemoteAudioSession
     WebProcess/GPU/media/RemoteAudioSourceProviderManager
+    WebProcess/GPU/media/RemoteCDMInstance
     WebProcess/GPU/media/RemoteCDMInstanceSession
     WebProcess/GPU/media/RemoteLegacyCDMSession
     WebProcess/GPU/media/SourceBufferPrivateRemote

Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog	2021-01-25 22:10:52 UTC (rev 271820)
@@ -1,5 +1,108 @@
 2021-01-25  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r271405. rdar://problem/73466993
+
+    [Cocoa] Support key rotation with HLS-backed encrypted media streams
+    https://bugs.webkit.org/show_bug.cgi?id=220493
+    <rdar://68227709>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    Support key rotation through AVContentKeySession by explicitly handling unexpected key requests
+    submitted through the new -contentKeySession:didProvideContentKeyRequests:forInitializationData:.
+    Rotation was previously handled in the delegate method -contentKeySession:didProvideContentKeyRequest,
+    but that method is no longer called after the replacement delegate method was implemented, and
+    that method never handled "skd://" style initialization data.
+    
+    Update the helper method, initTypeForRequest(), to detect "skd://" identifiers and correctly identify
+    those sessions as "skd".
+    
+    Add a new helper method, initializationDataForRequest(), which will package the AVContentKeySession's
+    identifier as initialization data.
+    
+    Drive-by Fix: Fixing this bug causes the default key group to update it's identifier, which causes an assert
+    when the group in question isn't any of those associated with an existing MediaKeySession, so handle that case
+    explicitly.
+    
+    Drive-by Fix 2: Sometimes, when GPUP is enabled for media, we will get spurious mediaPlayerEngineUpdated()
+    calls which cause cdmInstanceAttached() to be called multiple times for the same player, triggering an ASSERT.
+    If called twice with the same CDM, just return early rather than ASSERTing.
+    
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h:
+    * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+    (WebCore::initTypeForRequest):
+    (WebCore::initializationDataForRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::takeUnexpectedKeyRequestForInitializationData):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequest):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::didProvideRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::handleUnexpectedRequests):
+    (WebCore::CDMInstanceFairPlayStreamingAVFObjC::groupSessionIdentifierChanged):
+    * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+    (WebCore::MediaSourcePrivateAVFObjC::cdmInstanceAttached):
+    
+    Source/WebCore/PAL:
+    
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    
+    Source/WebKit:
+    
+    Support handling the "unexpectedInitializationDataReceived()" client callback from within the GPUP.
+    
+    * DerivedSources-input.xcfilelist:
+    * DerivedSources-output.xcfilelist:
+    * DerivedSources.make:
+    * GPUProcess/media/RemoteCDMInstanceProxy.cpp:
+    (WebKit::RemoteCDMInstanceProxy::create):
+    (WebKit::RemoteCDMInstanceProxy::RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy):
+    (WebKit::RemoteCDMInstanceProxy::unrequestedInitializationDataReceived):
+    * GPUProcess/media/RemoteCDMInstanceProxy.h:
+    * GPUProcess/media/RemoteCDMProxy.cpp:
+    (WebKit::RemoteCDMProxy::createInstance):
+    * WebKit.xcodeproj/project.pbxproj:
+    * WebProcess/GPU/media/RemoteCDMInstance.cpp:
+    (WebKit::RemoteCDMInstance::RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::~RemoteCDMInstance):
+    (WebKit::RemoteCDMInstance::unrequestedInitializationDataReceived):
+    * WebProcess/GPU/media/RemoteCDMInstance.h:
+    * WebProcess/GPU/media/RemoteCDMInstance.messages.in: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271405 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-01-12  Jer Noble  <jer.no...@apple.com>
+
+            [Cocoa] Support key rotation with HLS-backed encrypted media streams
+            https://bugs.webkit.org/show_bug.cgi?id=220493
+            <rdar://68227709>
+
+            Reviewed by Eric Carlson.
+
+            Support handling the "unexpectedInitializationDataReceived()" client callback from within the GPUP.
+
+            * DerivedSources-input.xcfilelist:
+            * DerivedSources-output.xcfilelist:
+            * DerivedSources.make:
+            * GPUProcess/media/RemoteCDMInstanceProxy.cpp:
+            (WebKit::RemoteCDMInstanceProxy::create):
+            (WebKit::RemoteCDMInstanceProxy::RemoteCDMInstanceProxy):
+            (WebKit::RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy):
+            (WebKit::RemoteCDMInstanceProxy::unrequestedInitializationDataReceived):
+            * GPUProcess/media/RemoteCDMInstanceProxy.h:
+            * GPUProcess/media/RemoteCDMProxy.cpp:
+            (WebKit::RemoteCDMProxy::createInstance):
+            * WebKit.xcodeproj/project.pbxproj:
+            * WebProcess/GPU/media/RemoteCDMInstance.cpp:
+            (WebKit::RemoteCDMInstance::RemoteCDMInstance):
+            (WebKit::RemoteCDMInstance::~RemoteCDMInstance):
+            (WebKit::RemoteCDMInstance::unrequestedInitializationDataReceived):
+            * WebProcess/GPU/media/RemoteCDMInstance.h:
+            * WebProcess/GPU/media/RemoteCDMInstance.messages.in: Added.
+
+2021-01-25  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r271387. rdar://problem/73469606
 
     Receiving two enter/exit fullscreen delegate callbacks on iPad when presenting fullscreen elements

Modified: branches/safari-611-branch/Source/WebKit/DerivedSources-input.xcfilelist (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/DerivedSources-input.xcfilelist	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/DerivedSources-input.xcfilelist	2021-01-25 22:10:52 UTC (rev 271820)
@@ -143,6 +143,7 @@
 $(PROJECT_DIR)/WebProcess/GPU/media/MediaSourcePrivateRemote.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioSession.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioSourceProviderManager.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteCDMInstance.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteCDMInstanceSession.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteLegacyCDMSession.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/SourceBufferPrivateRemote.messages.in

Modified: branches/safari-611-branch/Source/WebKit/DerivedSources-output.xcfilelist (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/DerivedSources-output.xcfilelist	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/DerivedSources-output.xcfilelist	2021-01-25 22:10:52 UTC (rev 271820)
@@ -162,6 +162,9 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceProxyMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceProxyMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMInstanceProxyMessagesReplies.h

Modified: branches/safari-611-branch/Source/WebKit/DerivedSources.make (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/DerivedSources.make	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/DerivedSources.make	2021-01-25 22:10:52 UTC (rev 271820)
@@ -180,6 +180,7 @@
 	WebProcess/GPU/media/MediaSourcePrivateRemote \
 	WebProcess/GPU/media/RemoteAudioSession \
 	WebProcess/GPU/media/RemoteAudioSourceProviderManager \
+	WebProcess/GPU/media/RemoteCDMInstance \
 	WebProcess/GPU/media/RemoteCDMInstanceSession \
 	WebProcess/GPU/media/RemoteLegacyCDMSession \
 	WebProcess/GPU/media/SourceBufferPrivateRemote \

Modified: branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.cpp (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.cpp	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.cpp	2021-01-25 22:10:52 UTC (rev 271820)
@@ -29,6 +29,7 @@
 #if ENABLE(GPU_PROCESS) && ENABLE(ENCRYPTED_MEDIA)
 
 #include "RemoteCDMInstanceConfiguration.h"
+#include "RemoteCDMInstanceMessages.h"
 #include "RemoteCDMInstanceSessionProxy.h"
 #include "SharedBufferCopy.h"
 #include <WebCore/CDMInstance.h>
@@ -37,23 +38,37 @@
 
 using namespace WebCore;
 
-std::unique_ptr<RemoteCDMInstanceProxy> RemoteCDMInstanceProxy::create(WeakPtr<RemoteCDMProxy>&& cdm, Ref<CDMInstance>&& priv)
+std::unique_ptr<RemoteCDMInstanceProxy> RemoteCDMInstanceProxy::create(WeakPtr<RemoteCDMProxy>&& cdm, Ref<CDMInstance>&& priv, RemoteCDMInstanceIdentifier identifier)
 {
     auto configuration = makeUniqueRefWithoutFastMallocCheck<RemoteCDMInstanceConfiguration, RemoteCDMInstanceConfiguration&&>({
         priv->keySystem(),
     });
-    return std::unique_ptr<RemoteCDMInstanceProxy>(new RemoteCDMInstanceProxy(WTFMove(cdm), WTFMove(priv), WTFMove(configuration)));
+    return std::unique_ptr<RemoteCDMInstanceProxy>(new RemoteCDMInstanceProxy(WTFMove(cdm), WTFMove(priv), WTFMove(configuration), identifier));
 }
 
-RemoteCDMInstanceProxy::RemoteCDMInstanceProxy(WeakPtr<RemoteCDMProxy>&& cdm, Ref<CDMInstance>&& priv, UniqueRef<RemoteCDMInstanceConfiguration>&& configuration)
+RemoteCDMInstanceProxy::RemoteCDMInstanceProxy(WeakPtr<RemoteCDMProxy>&& cdm, Ref<CDMInstance>&& priv, UniqueRef<RemoteCDMInstanceConfiguration>&& configuration, RemoteCDMInstanceIdentifier identifier)
     : m_cdm(WTFMove(cdm))
     , m_instance(WTFMove(priv))
     , m_configuration(WTFMove(configuration))
+    , m_identifier(identifier)
 {
+    m_instance->setClient(makeWeakPtr<CDMInstanceClient>(this));
 }
 
-RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy() = default;
+RemoteCDMInstanceProxy::~RemoteCDMInstanceProxy()
+{
+    m_instance->clearClient();
+}
 
+void RemoteCDMInstanceProxy::unrequestedInitializationDataReceived(const String& type, Ref<SharedBuffer>&& initData)
+{
+    if (!m_cdm)
+        return;
+
+    if (auto* factory = m_cdm->factory())
+        factory->gpuConnectionToWebProcess().connection().send(Messages::RemoteCDMInstance::UnrequestedInitializationDataReceived(type, WTFMove(initData)), m_identifier);
+}
+
 void RemoteCDMInstanceProxy::initializeWithConfiguration(const WebCore::CDMKeySystemConfiguration& configuration, AllowDistinctiveIdentifiers allowDistinctiveIdentifiers, AllowPersistentState allowPersistentState, CompletionHandler<void(SuccessValue)>&& completion)
 {
     m_instance->initializeWithConfiguration(configuration, allowDistinctiveIdentifiers, allowPersistentState, WTFMove(completion));

Modified: branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.h (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.h	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMInstanceProxy.h	2021-01-25 22:10:52 UTC (rev 271820)
@@ -50,9 +50,9 @@
 struct RemoteCDMInstanceConfiguration;
 class RemoteCDMInstanceSessionProxy;
 
-class RemoteCDMInstanceProxy : private IPC::MessageReceiver  {
+class RemoteCDMInstanceProxy : public WebCore::CDMInstanceClient, private IPC::MessageReceiver  {
 public:
-    static std::unique_ptr<RemoteCDMInstanceProxy> create(WeakPtr<RemoteCDMProxy>&&, Ref<WebCore::CDMInstance>&&);
+    static std::unique_ptr<RemoteCDMInstanceProxy> create(WeakPtr<RemoteCDMProxy>&&, Ref<WebCore::CDMInstance>&&, RemoteCDMInstanceIdentifier);
     ~RemoteCDMInstanceProxy();
 
     const RemoteCDMInstanceConfiguration& configuration() const { return m_configuration.get(); }
@@ -60,8 +60,11 @@
 
 private:
     friend class RemoteCDMFactoryProxy;
-    RemoteCDMInstanceProxy(WeakPtr<RemoteCDMProxy>&&, Ref<WebCore::CDMInstance>&&, UniqueRef<RemoteCDMInstanceConfiguration>&&);
+    RemoteCDMInstanceProxy(WeakPtr<RemoteCDMProxy>&&, Ref<WebCore::CDMInstance>&&, UniqueRef<RemoteCDMInstanceConfiguration>&&, RemoteCDMInstanceIdentifier);
 
+    // CDMInstanceClient
+    void unrequestedInitializationDataReceived(const String&, Ref<WebCore::SharedBuffer>&&) final;
+
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
     void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
@@ -79,6 +82,7 @@
     WeakPtr<RemoteCDMProxy> m_cdm;
     Ref<WebCore::CDMInstance> m_instance;
     UniqueRef<RemoteCDMInstanceConfiguration> m_configuration;
+    RemoteCDMInstanceIdentifier m_identifier;
     HashMap<RemoteCDMInstanceSessionIdentifier, std::unique_ptr<RemoteCDMInstanceSessionProxy>> m_sessions;
 };
 

Modified: branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/GPUProcess/media/RemoteCDMProxy.cpp	2021-01-25 22:10:52 UTC (rev 271820)
@@ -90,8 +90,8 @@
         completion({ }, { });
         return;
     }
-    auto instance = RemoteCDMInstanceProxy::create(makeWeakPtr(this), privateInstance.releaseNonNull());
     auto identifier = RemoteCDMInstanceIdentifier::generate();
+    auto instance = RemoteCDMInstanceProxy::create(makeWeakPtr(this), privateInstance.releaseNonNull(), identifier);
     RemoteCDMInstanceConfiguration configuration = instance->configuration();
     m_factory->addInstance(identifier, WTFMove(instance));
     completion(identifier, WTFMove(configuration));

Modified: branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-01-25 22:10:52 UTC (rev 271820)
@@ -1861,6 +1861,7 @@
 		CDA29A291CBEB67A00901CCF /* PlaybackSessionManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A251CBEB67A00901CCF /* PlaybackSessionManagerMessages.h */; };
 		CDA29A2A1CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A261CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp */; };
 		CDA29A2B1CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A271CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h */; };
+		CDA6D45125A989C7004B1DF6 /* RemoteCDMInstanceMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA6D45025A989AC004B1DF6 /* RemoteCDMInstanceMessageReceiver.cpp */; };
 		CDA93DB022F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA93DAE22F8BCF300490A69 /* FullscreenTouchSecheuristicParameters.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CDA93DB122F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA93DAF22F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp */; };
 		CDAC20B423FB58F20021DEE3 /* RemoteCDMInstanceProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAC20B223FB58F20021DEE3 /* RemoteCDMInstanceProxy.h */; };
@@ -5525,6 +5526,9 @@
 		CDA29A251CBEB67A00901CCF /* PlaybackSessionManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaybackSessionManagerMessages.h; path = DerivedSources/WebKit2/PlaybackSessionManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDA29A261CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlaybackSessionManagerProxyMessageReceiver.cpp; path = DerivedSources/WebKit2/PlaybackSessionManagerProxyMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDA29A271CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaybackSessionManagerProxyMessages.h; path = DerivedSources/WebKit2/PlaybackSessionManagerProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+		CDA6D44D25A97158004B1DF6 /* RemoteCDMInstance.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteCDMInstance.messages.in; sourceTree = "<group>"; };
+		CDA6D44F25A989AC004B1DF6 /* RemoteCDMInstanceMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCDMInstanceMessages.h; sourceTree = "<group>"; };
+		CDA6D45025A989AC004B1DF6 /* RemoteCDMInstanceMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCDMInstanceMessageReceiver.cpp; sourceTree = "<group>"; };
 		CDA93DAE22F8BCF300490A69 /* FullscreenTouchSecheuristicParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FullscreenTouchSecheuristicParameters.h; path = ios/fullscreen/FullscreenTouchSecheuristicParameters.h; sourceTree = "<group>"; };
 		CDA93DAF22F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = FullscreenTouchSecheuristicParameters.cpp; path = ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp; sourceTree = "<group>"; };
 		CDA9593A2412B17500910EEF /* RemoteMediaSessionHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteMediaSessionHelper.cpp; sourceTree = "<group>"; };
@@ -5962,6 +5966,7 @@
 				CDAC20C223FC2F750021DEE3 /* RemoteCDMIdentifier.h */,
 				CDAC20BB23FC2F740021DEE3 /* RemoteCDMInstance.cpp */,
 				CDAC20B723FC2F730021DEE3 /* RemoteCDMInstance.h */,
+				CDA6D44D25A97158004B1DF6 /* RemoteCDMInstance.messages.in */,
 				CDAC20C123FC2F750021DEE3 /* RemoteCDMInstanceConfiguration.h */,
 				CDAC20B623FC2F730021DEE3 /* RemoteCDMInstanceIdentifier.h */,
 				CDAC20BE23FC2F740021DEE3 /* RemoteCDMInstanceSession.cpp */,
@@ -10764,6 +10769,8 @@
 				CDAC20F223FC383A0021DEE3 /* RemoteCDMFactoryProxyMessageReceiver.cpp */,
 				CDAC20F323FC383A0021DEE3 /* RemoteCDMFactoryProxyMessages.h */,
 				CDAC20EE23FC38390021DEE3 /* RemoteCDMFactoryProxyMessagesReplies.h */,
+				CDA6D45025A989AC004B1DF6 /* RemoteCDMInstanceMessageReceiver.cpp */,
+				CDA6D44F25A989AC004B1DF6 /* RemoteCDMInstanceMessages.h */,
 				CDAC20F523FC383B0021DEE3 /* RemoteCDMInstanceProxyMessageReceiver.cpp */,
 				CDAC20EB23FC38380021DEE3 /* RemoteCDMInstanceProxyMessages.h */,
 				CDAC20F623FC383B0021DEE3 /* RemoteCDMInstanceProxyMessagesReplies.h */,
@@ -13774,6 +13781,7 @@
 				2D11B7642126A282006F8878 /* UnifiedSource10.cpp in Sources */,
 				2D11B7632126A282006F8878 /* UnifiedSource10-mm.mm in Sources */,
 				2D11B7652126A282006F8878 /* UnifiedSource11-mm.mm in Sources */,
+				CDA6D45125A989C7004B1DF6 /* RemoteCDMInstanceMessageReceiver.cpp in Sources */,
 				2D11B7662126A282006F8878 /* UnifiedSource11.cpp in Sources */,
 				2D11B7672126A282006F8878 /* UnifiedSource12-mm.mm in Sources */,
 				2D11B7682126A282006F8878 /* UnifiedSource12.cpp in Sources */,

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.cpp (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.cpp	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.cpp	2021-01-25 22:10:52 UTC (rev 271820)
@@ -29,6 +29,7 @@
 #if ENABLE(GPU_PROCESS) && ENABLE(ENCRYPTED_MEDIA)
 
 #include "GPUProcessConnection.h"
+#include "RemoteCDMInstanceMessages.h"
 #include "RemoteCDMInstanceProxyMessages.h"
 #include "RemoteCDMInstanceSession.h"
 #include "RemoteCDMInstanceSessionIdentifier.h"
@@ -51,8 +52,22 @@
     , m_identifier(WTFMove(identifier))
     , m_configuration(WTFMove(configuration))
 {
+    if (m_factory)
+        m_factory->gpuProcessConnection().messageReceiverMap().addMessageReceiver(Messages::RemoteCDMInstance::messageReceiverName(), m_identifier.toUInt64(), *this);
 }
 
+RemoteCDMInstance::~RemoteCDMInstance()
+{
+    if (m_factory)
+        m_factory->gpuProcessConnection().messageReceiverMap().removeMessageReceiver(Messages::RemoteCDMInstance::messageReceiverName(), m_identifier.toUInt64());
+}
+
+void RemoteCDMInstance::unrequestedInitializationDataReceived(const String& type, IPC::SharedBufferCopy&& initData)
+{
+    if (m_client && initData.buffer())
+        m_client->unrequestedInitializationDataReceived(type, initData.buffer().releaseNonNull());
+}
+
 void RemoteCDMInstance::initializeWithConfiguration(const WebCore::CDMKeySystemConfiguration& configuration, AllowDistinctiveIdentifiers distinctiveIdentifiers, AllowPersistentState persistentState, SuccessCallback&& callback)
 {
     if (!m_factory) {

Modified: branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.h (271819 => 271820)


--- branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.h	2021-01-25 22:10:45 UTC (rev 271819)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.h	2021-01-25 22:10:52 UTC (rev 271820)
@@ -27,16 +27,18 @@
 
 #if ENABLE(GPU_PROCESS) && ENABLE(ENCRYPTED_MEDIA)
 
+#include "MessageReceiver.h"
 #include "RemoteCDMFactory.h"
 #include "RemoteCDMInstanceConfiguration.h"
 #include "RemoteCDMInstanceIdentifier.h"
+#include "SharedBufferCopy.h"
 #include <WebCore/CDMInstance.h>
 
 namespace WebKit {
 
-class RemoteCDMInstance final : public WebCore::CDMInstance {
+class RemoteCDMInstance final : public WebCore::CDMInstance, private IPC::MessageReceiver {
 public:
-    virtual ~RemoteCDMInstance() = default;
+    virtual ~RemoteCDMInstance();
     static Ref<RemoteCDMInstance> create(WeakPtr<RemoteCDMFactory>&&, RemoteCDMInstanceIdentifier&&, RemoteCDMInstanceConfiguration&&);
 
     const RemoteCDMInstanceIdentifier& identifier() const { return m_identifier; }
@@ -44,6 +46,12 @@
 private:
     RemoteCDMInstance(WeakPtr<RemoteCDMFactory>&&, RemoteCDMInstanceIdentifier&&, RemoteCDMInstanceConfiguration&&);
 
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+    // Messages
+    void unrequestedInitializationDataReceived(const String&, IPC::SharedBufferCopy&&);
+
     ImplementationType implementationType() const final { return ImplementationType::Remote; }
     void initializeWithConfiguration(const WebCore::CDMKeySystemConfiguration&, AllowDistinctiveIdentifiers, AllowPersistentState, SuccessCallback&&) final;
     void setServerCertificate(Ref<WebCore::SharedBuffer>&&, SuccessCallback&&) final;
@@ -50,10 +58,13 @@
     void setStorageDirectory(const String&) final;
     const String& keySystem() const final { return m_configuration.keySystem; }
     RefPtr<WebCore::CDMInstanceSession> createSession() final;
+    void setClient(WeakPtr<WebCore::CDMInstanceClient>&& client) final { m_client = WTFMove(client); }
+    void clearClient() final { m_client.clear(); }
 
     WeakPtr<RemoteCDMFactory> m_factory;
     RemoteCDMInstanceIdentifier m_identifier;
     RemoteCDMInstanceConfiguration m_configuration;
+    WeakPtr<WebCore::CDMInstanceClient> m_client;
 };
 
 }

Added: branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.messages.in (0 => 271820)


--- branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.messages.in	                        (rev 0)
+++ branches/safari-611-branch/Source/WebKit/WebProcess/GPU/media/RemoteCDMInstance.messages.in	2021-01-25 22:10:52 UTC (rev 271820)
@@ -0,0 +1,30 @@
+# Copyright (C) 2020 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+# THE POSSIBILITY OF SUCH DAMAGE.
+
+#if ENABLE(GPU_PROCESS) && ENABLE(ENCRYPTED_MEDIA)
+
+messages -> RemoteCDMInstance NotRefCounted {
+    UnrequestedInitializationDataReceived(String type, IPC::SharedBufferCopy initData)
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to