MediaPlayer should have mediaPlayerWaitingForKeyChanged() / bool waitingForKey()...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2018 21:41:22 +0000 (21:41 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2018 21:41:22 +0000 (21:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189951

Reviewed by Eric Carlson.

Source/WebCore:

In order to implement the "Resume Playback" section of EME, part 4, we need to be able
to query whether the MediaPlayer is still waiting for a key after attemptToDecrypt()
has been called. Currently this involves no behavioral changes, as all modern EME ports
will still just notify the media element that they no longer need keys after one has
been added, but future ports may be able to wait for multiple keys before reporting
that it is no longer waiting for keys.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerWaitingForKeyChanged):
(WebCore::HTMLMediaElement::attemptToResumePlaybackIfNecessary):
(WebCore::HTMLMediaElement::mediaPlayerWaitingForKey): Deleted.
* html/HTMLMediaElement.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::waitingForKeyChanged):
(WebCore::MediaPlayer::waitingForKey const):
(WebCore::MediaPlayer::waitingForKey): Deleted.
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerWaitingForKeyChanged):
(WebCore::MediaPlayerClient::mediaPlayerWaitingForKey): Deleted.
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::waitingForKey const):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
(WebCore::MediaPlayerPrivateAVFoundationObjC::attemptToDecryptWithInstance):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitingForKey const):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitingForKeyChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::initializationDataEncountered):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):
(WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::reportWaitingForKey):
(WebCore::MediaPlayerPrivateGStreamerBase::setWaitingForKey):
(WebCore::MediaPlayerPrivateGStreamerBase::waitingForKey const):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
(webkitMediaCommonEncryptionDecryptSinkEventHandler):

Source/WTF:

Templated functions should take r-value references, as they have perfect type deduction for
all parameter types; references, l-value references, and r-value references in template function
parameters have special type deduction semantics.
See: <https://en.cppreference.com/w/cpp/language/reference#Forwarding_references>

Previously, const reference parameters would be copied when passed into anyOf(), and containers
of Ref<> would generate compile errors when passed into anyOf, as they cannot be copied. Now,
with r-value reference types in template parameters, a const reference is mapped to a const reference,
a non-const reference is mapped to a non-const reference, and a r-value reference is mapped to
an r-value reference.

* wtf/Algorithms.h:
(WTF::forEach):
(WTF::anyOf):
(WTF::allOf):

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

18 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Algorithms.h
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp

index 953bafe..475b42d 100644 (file)
@@ -1,3 +1,26 @@
+2018-09-27  Jer Noble  <jer.noble@apple.com>
+
+        MediaPlayer should have mediaPlayerWaitingForKeyChanged() / bool waitingForKey() accessor
+        https://bugs.webkit.org/show_bug.cgi?id=189951
+
+        Reviewed by Eric Carlson.
+
+        Templated functions should take r-value references, as they have perfect type deduction for
+        all parameter types; references, l-value references, and r-value references in template function
+        parameters have special type deduction semantics.
+        See: <https://en.cppreference.com/w/cpp/language/reference#Forwarding_references>
+
+        Previously, const reference parameters would be copied when passed into anyOf(), and containers
+        of Ref<> would generate compile errors when passed into anyOf, as they cannot be copied. Now,
+        with r-value reference types in template parameters, a const reference is mapped to a const reference,
+        a non-const reference is mapped to a non-const reference, and a r-value reference is mapped to
+        an r-value reference.
+
+        * wtf/Algorithms.h:
+        (WTF::forEach):
+        (WTF::anyOf):
+        (WTF::allOf):
+
 2018-09-25  John Wilander  <wilander@apple.com>
 
         Change from HAVE(CFNETWORK_STORAGE_PARTITIONING) to ENABLE(RESOURCE_LOAD_STATISTICS)
index 48b644e..160cf5a 100644 (file)
 namespace WTF {
 
 template<typename ContainerType, typename ForEachFunction>
-void forEach(ContainerType container, ForEachFunction forEachFunction)
+void forEach(ContainerType&& container, ForEachFunction forEachFunction)
 {
     for (auto& value : container)
         forEachFunction(value);
 }
 
 template<typename ContainerType, typename AnyOfFunction>
-bool anyOf(ContainerType container, AnyOfFunction anyOfFunction)
+bool anyOf(ContainerType&& container, AnyOfFunction anyOfFunction)
 {
     for (auto& value : container) {
         if (anyOfFunction(value))
@@ -45,7 +45,7 @@ bool anyOf(ContainerType container, AnyOfFunction anyOfFunction)
 }
 
 template<typename ContainerType, typename AllOfFunction>
-bool allOf(ContainerType container, AllOfFunction allOfFunction)
+bool allOf(ContainerType&& container, AllOfFunction allOfFunction)
 {
     for (auto& value : container) {
         if (!allOfFunction(value))
index f0e58bb..026db65 100644 (file)
@@ -1,3 +1,55 @@
+2018-09-27  Jer Noble  <jer.noble@apple.com>
+
+        MediaPlayer should have mediaPlayerWaitingForKeyChanged() / bool waitingForKey() accessor
+        https://bugs.webkit.org/show_bug.cgi?id=189951
+
+        Reviewed by Eric Carlson.
+
+        In order to implement the "Resume Playback" section of EME, part 4, we need to be able
+        to query whether the MediaPlayer is still waiting for a key after attemptToDecrypt()
+        has been called. Currently this involves no behavioral changes, as all modern EME ports
+        will still just notify the media element that they no longer need keys after one has
+        been added, but future ports may be able to wait for multiple keys before reporting
+        that it is no longer waiting for keys.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerWaitingForKeyChanged):
+        (WebCore::HTMLMediaElement::attemptToResumePlaybackIfNecessary):
+        (WebCore::HTMLMediaElement::mediaPlayerWaitingForKey): Deleted.
+        * html/HTMLMediaElement.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::waitingForKeyChanged):
+        (WebCore::MediaPlayer::waitingForKey const):
+        (WebCore::MediaPlayer::waitingForKey): Deleted.
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerWaitingForKeyChanged):
+        (WebCore::MediaPlayerClient::mediaPlayerWaitingForKey): Deleted.
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::waitingForKey const):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::attemptToDecryptWithInstance):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitingForKey const):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::waitingForKeyChanged):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::initializationDataEncountered):
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):
+        (WebCore::SourceBufferPrivateAVFObjC::attemptToDecrypt):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::reportWaitingForKey):
+        (WebCore::MediaPlayerPrivateGStreamerBase::setWaitingForKey):
+        (WebCore::MediaPlayerPrivateGStreamerBase::waitingForKey const):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+        * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
+        (webkitMediaCommonEncryptionDecryptSinkEventHandler):
+
 2018-09-27  Alicia Boya GarcĂ­a  <aboya@igalia.com>
 
         [MSE] Fix unwanted sample erase from the decode queue
index 41ea239..a652cee 100644 (file)
@@ -2787,8 +2787,28 @@ void HTMLMediaElement::mediaPlayerInitializationDataEncountered(const String& in
     m_asyncEventQueue.enqueueEvent(MediaEncryptedEvent::create(eventNames().encryptedEvent, initializer, Event::IsTrusted::Yes));
 }
 
-void HTMLMediaElement::mediaPlayerWaitingForKey()
+void HTMLMediaElement::mediaPlayerWaitingForKeyChanged()
 {
+    if (!m_player)
+        return;
+
+    if (!m_player->waitingForKey() && m_playbackBlockedWaitingForKey) {
+        // https://w3c.github.io/encrypted-media/#resume-playback
+        // W3C Editor's Draft 23 June 2017
+
+        // NOTE: continued from HTMLMediaElement::attemptToDecrypt().
+        // 4. If the user agent can advance the current playback position in the direction of playback:
+        //   4.1. Set the media element's decryption blocked waiting for key value to false.
+        // FIXME: ^
+        //   4.2. Set the media element's playback blocked waiting for key value to false.
+        m_playbackBlockedWaitingForKey = false;
+
+        //   4.3. Set the media element's readyState value to HAVE_CURRENT_DATA, HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA as appropriate.
+        setReadyState(m_player->readyState());
+
+        return;
+    }
+
     // https://www.w3.org/TR/encrypted-media/#wait-for-key
     // W3C Recommendation 18 September 2017
 
@@ -2890,14 +2910,7 @@ void HTMLMediaElement::attemptToResumePlaybackIfNecessary()
     // 3. Run the Attempt to Decrypt algorithm on the media element.
     attemptToDecrypt();
 
-    // 4. If the user agent can advance the current playback position in the direction of playback:
-    //   4.1. Set the media element's decryption blocked waiting for key value to false.
-    // FIXME: ^
-    //   4.2. Set the media element's playback blocked waiting for key value to false.
-    m_playbackBlockedWaitingForKey = false;
-
-    //   4.3. Set the media element's readyState value to HAVE_CURRENT_DATA, HAVE_FUTURE_DATA or HAVE_ENOUGH_DATA as appropriate.
-    setReadyState(m_player->readyState());
+    // NOTE: continued in HTMLMediaElement::waitingForKeyChanged()
 }
 
 void HTMLMediaElement::cdmClientAttemptToResumePlaybackIfNecessary()
index 9c8d541..6fb2cb8 100644 (file)
@@ -673,7 +673,7 @@ private:
 
 #if ENABLE(ENCRYPTED_MEDIA)
     void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) final;
-    void mediaPlayerWaitingForKey() final;
+    void mediaPlayerWaitingForKeyChanged() final;
 
     void attemptToDecrypt();
     void attemptToResumePlaybackIfNecessary();
index c2e80d6..105a80f 100644 (file)
@@ -1266,9 +1266,16 @@ void MediaPlayer::initializationDataEncountered(const String& initDataType, RefP
     client().mediaPlayerInitializationDataEncountered(initDataType, WTFMove(initData));
 }
 
-void MediaPlayer::waitingForKey()
+void MediaPlayer::waitingForKeyChanged()
 {
-    client().mediaPlayerWaitingForKey();
+    client().mediaPlayerWaitingForKeyChanged();
+}
+
+bool MediaPlayer::waitingForKey() const
+{
+    if (!m_private)
+        return false;
+    return m_private->waitingForKey();
 }
 #endif
 
index 760f0e4..462a726 100644 (file)
@@ -169,7 +169,7 @@ public:
 
 #if ENABLE(ENCRYPTED_MEDIA)
     virtual void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) { }
-    virtual void mediaPlayerWaitingForKey() { }
+    virtual void mediaPlayerWaitingForKeyChanged() { }
 #endif
     
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -488,7 +488,8 @@ public:
 
 #if ENABLE(ENCRYPTED_MEDIA)
     void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&);
-    void waitingForKey();
+    void waitingForKeyChanged();
+    bool waitingForKey() const;
 #endif
 
     String referrer() const;
index 54547f9..2413da5 100644 (file)
@@ -232,6 +232,7 @@ public:
     virtual void cdmInstanceAttached(CDMInstance&) { }
     virtual void cdmInstanceDetached(CDMInstance&) { }
     virtual void attemptToDecryptWithInstance(CDMInstance&) { }
+    virtual bool waitingForKey() const { return false; }
 #endif
 
 #if ENABLE(VIDEO_TRACK)
index c545ae1..2927aca 100644 (file)
@@ -147,6 +147,8 @@ public:
     void cdmInstanceAttached(CDMInstance&) final;
     void cdmInstanceDetached(CDMInstance&) final;
     void attemptToDecryptWithInstance(CDMInstance&) final;
+    void setWaitingForKey(bool);
+    bool waitingForKey() const final { return m_waitingForKey; }
 #endif
 
 private:
@@ -392,6 +394,7 @@ private:
     WeakPtr<CDMSessionAVFoundationObjC> m_session;
 #endif
 #if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
+    bool m_waitingForKey { false };
     RefPtr<CDMInstanceFairPlayStreamingAVFObjC> m_cdmInstance;
 #endif
 
index 37149b5..7d49d4e 100644 (file)
@@ -1784,7 +1784,7 @@ bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetR
         RetainPtr<NSData> keyURIData = [keyURI dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
         auto keyURIBuffer = SharedBuffer::create(keyURIData.get());
         player()->initializationDataEncountered("skd"_s, keyURIBuffer->tryCreateArrayBuffer());
-        player()->waitingForKey();
+        setWaitingForKey(true);
 #endif
         return true;
     }
@@ -2503,6 +2503,16 @@ void MediaPlayerPrivateAVFoundationObjC::attemptToDecryptWithInstance(CDMInstanc
             infoRequest.contentType = AVStreamingKeyDeliveryContentKeyType;
         [request finishLoading];
     }
+    setWaitingForKey(false);
+}
+
+void MediaPlayerPrivateAVFoundationObjC::setWaitingForKey(bool waitingForKey)
+{
+    if (m_waitingForKey == waitingForKey)
+        return;
+
+    m_waitingForKey = waitingForKey;
+    player()->waitingForKeyChanged();
 }
 #endif
 
index 4cb29cc..d781aa4 100644 (file)
@@ -120,6 +120,9 @@ public:
     void cdmInstanceAttached(CDMInstance&) final;
     void cdmInstanceDetached(CDMInstance&) final;
     void attemptToDecryptWithInstance(CDMInstance&) final;
+    bool waitingForKey() const final;
+
+    void waitingForKeyChanged();
     CDMInstance* cdmInstance() const { return m_cdmInstance.get(); }
 #endif
 
index 69c61b6..e423663 100644 (file)
@@ -50,6 +50,7 @@
 #import <objc_runtime.h>
 #import <pal/avfoundation/MediaTimeAVFoundation.h>
 #import <pal/spi/mac/AVFoundationSPI.h>
+#import <wtf/Algorithms.h>
 #import <wtf/Deque.h>
 #import <wtf/MainThread.h>
 #import <wtf/NeverDestroyed.h>
@@ -952,10 +953,21 @@ void MediaPlayerPrivateMediaSourceAVFObjC::attemptToDecryptWithInstance(CDMInsta
 {
 }
 
+bool MediaPlayerPrivateMediaSourceAVFObjC::waitingForKey() const
+{
+    return anyOf(m_mediaSourcePrivate->sourceBuffers(), [] (auto& sourceBuffer) {
+        return sourceBuffer->waitingForKey();
+    });
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::waitingForKeyChanged()
+{
+    m_player->waitingForKeyChanged();
+}
+
 void MediaPlayerPrivateMediaSourceAVFObjC::initializationDataEncountered(const String& initDataType, RefPtr<ArrayBuffer>&& initData)
 {
     m_player->initializationDataEncountered(initDataType, WTFMove(initData));
-    m_player->waitingForKey();
 }
 #endif
 
index 293c60b..52013a1 100644 (file)
@@ -109,6 +109,8 @@ public:
     AVStreamDataParser* parser() const { return m_parser.get(); }
     void setCDMSession(CDMSessionMediaSourceAVFObjC*);
     void setCDMInstance(CDMInstance*);
+    void attemptToDecrypt();
+    bool waitingForKey() const { return m_waitingForKey; }
 
     void flush();
 
@@ -189,6 +191,7 @@ private:
     bool m_parsingSucceeded { true };
     bool m_parserStateWasReset { false };
     bool m_discardSamplesUntilNextInitializationSegment { false };
+    bool m_waitingForKey { true };
     int m_enabledVideoTrackID { -1 };
     int m_protectedTrackID { -1 };
 };
index 528e3ba..b9ec56e 100644 (file)
@@ -664,6 +664,9 @@ void SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataFo
         auto initDataBuffer = SharedBuffer::create(initData);
         m_mediaSource->player()->initializationDataEncountered("sinf", initDataBuffer->tryCreateArrayBuffer());
     }
+
+    m_waitingForKey = true;
+    m_mediaSource->player()->waitingForKeyChanged();
 #endif
 
     UNUSED_PARAM(initData);
@@ -922,6 +925,8 @@ void SourceBufferPrivateAVFObjC::setCDMInstance(CDMInstance* instance)
             m_hasSessionSemaphore = nullptr;
         }
     }
+    m_waitingForKey = false;
+    m_mediaSource->player()->waitingForKeyChanged();
 #else
     UNUSED_PARAM(instance);
 #endif
index 7c2a9eb..e7acaab 100644 (file)
@@ -1310,7 +1310,10 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
             handleProtectionEvent(event.get());
         } else if (gst_structure_has_name(structure, "drm-waiting-for-key")) {
             GST_DEBUG("drm-waiting-for-key message from %s", GST_MESSAGE_SRC_NAME(message));
-            reportWaitingForKey();
+            setWaitingForKey(true);
+        } else if (gst_structure_has_name(structure, "drm-key-received")) {
+            GST_DEBUG("drm-key-received message from %s", GST_MESSAGE_SRC_NAME(message));
+            setWaitingForKey(false);
         } else if (gst_structure_has_name(structure, "drm-cdm-instance-needed")) {
             GST_DEBUG("drm-cdm-instance-needed message from %s", GST_MESSAGE_SRC_NAME(message));
             dispatchCDMInstance();
index 26e6282..9bed1b0 100644 (file)
@@ -1353,7 +1353,21 @@ void MediaPlayerPrivateGStreamerBase::handleProtectionEvent(GstEvent* event)
 void MediaPlayerPrivateGStreamerBase::reportWaitingForKey()
 {
     GST_TRACE("waiting for key");
-    m_player->waitingForKey();
+    m_player->waitingForKeyChanged();
+}
+
+void MediaPlayerPrivateGStreamerBase::setWaitingForKey(bool waitingForKey)
+{
+    if (waitingForKey == m_waitingForKey)
+        return;
+
+    m_waitingForKey = waitingForKey;
+    reportWaitingForKey();
+}
+
+bool MediaPlayerPrivateGStreamerBase::waitingForKey() const
+{
+    return m_waitingForKey;
 }
 #endif
 
index 9021a09..4fa155a 100644 (file)
@@ -152,6 +152,8 @@ public:
     void attemptToDecryptWithInstance(CDMInstance&) override;
     void dispatchCDMInstance();
     void initializationDataEncountered(GstEvent*);
+    void setWaitingForKey(bool);
+    bool waitingForKey() const;
     void reportWaitingForKey();
 #endif
 
@@ -274,6 +276,7 @@ protected:
     RefPtr<const CDMInstance> m_cdmInstance;
     HashSet<uint32_t> m_handledProtectionEvents;
     bool m_needToResendCredentials { false };
+    bool m_waitingForKey { false };
 #endif
 };
 
index 4e35272..f3ee3fa 100644 (file)
@@ -308,6 +308,7 @@ static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransf
             priv->keyReceived = true;
             priv->waitingForKey = false;
             priv->condition.notifyOne();
+            gst_element_post_message(GST_ELEMENT(self), gst_message_new_element(GST_OBJECT(self), gst_structure_new_empty("drm-key-received")));
         } else if (priv->waitingForKey) {
             GST_DEBUG_OBJECT(self, "still waiting for key, reposting");
             gst_element_post_message(GST_ELEMENT(self), gst_message_new_element(GST_OBJECT(self), gst_structure_new_empty("drm-waiting-for-key")));