- Revision
- 236572
- Author
- [email protected]
- Date
- 2018-09-27 14:41:22 -0700 (Thu, 27 Sep 2018)
Log Message
MediaPlayer should have mediaPlayerWaitingForKeyChanged() / bool waitingForKey() accessor
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):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (236571 => 236572)
--- trunk/Source/WTF/ChangeLog 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WTF/ChangeLog 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1,3 +1,26 @@
+2018-09-27 Jer Noble <[email protected]>
+
+ 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 <[email protected]>
Change from HAVE(CFNETWORK_STORAGE_PARTITIONING) to ENABLE(RESOURCE_LOAD_STATISTICS)
Modified: trunk/Source/WTF/wtf/Algorithms.h (236571 => 236572)
--- trunk/Source/WTF/wtf/Algorithms.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WTF/wtf/Algorithms.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -28,7 +28,7 @@
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);
@@ -35,7 +35,7 @@
}
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 @@
}
template<typename ContainerType, typename AllOfFunction>
-bool allOf(ContainerType container, AllOfFunction allOfFunction)
+bool allOf(ContainerType&& container, AllOfFunction allOfFunction)
{
for (auto& value : container) {
if (!allOfFunction(value))
Modified: trunk/Source/WebCore/ChangeLog (236571 => 236572)
--- trunk/Source/WebCore/ChangeLog 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/ChangeLog 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1,3 +1,55 @@
+2018-09-27 Jer Noble <[email protected]>
+
+ 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 <[email protected]>
[MSE] Fix unwanted sample erase from the decode queue
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (236571 => 236572)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2018-09-27 21:41:22 UTC (rev 236572)
@@ -2787,8 +2787,28 @@
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 @@
// 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()
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (236571 => 236572)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -673,7 +673,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
void mediaPlayerInitializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&) final;
- void mediaPlayerWaitingForKey() final;
+ void mediaPlayerWaitingForKeyChanged() final;
void attemptToDecrypt();
void attemptToResumePlaybackIfNecessary();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1266,10 +1266,17 @@
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
String MediaPlayer::referrer() const
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -169,7 +169,7 @@
#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 @@
#if ENABLE(ENCRYPTED_MEDIA)
void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&);
- void waitingForKey();
+ void waitingForKeyChanged();
+ bool waitingForKey() const;
#endif
String referrer() const;
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -232,6 +232,7 @@
virtual void cdmInstanceAttached(CDMInstance&) { }
virtual void cdmInstanceDetached(CDMInstance&) { }
virtual void attemptToDecryptWithInstance(CDMInstance&) { }
+ virtual bool waitingForKey() const { return false; }
#endif
#if ENABLE(VIDEO_TRACK)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -147,6 +147,8 @@
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 @@
WeakPtr<CDMSessionAVFoundationObjC> m_session;
#endif
#if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
+ bool m_waitingForKey { false };
RefPtr<CDMInstanceFairPlayStreamingAVFObjC> m_cdmInstance;
#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1784,7 +1784,7 @@
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,7 +2503,17 @@
infoRequest.contentType = AVStreamingKeyDeliveryContentKeyType;
[request finishLoading];
}
+ setWaitingForKey(false);
}
+
+void MediaPlayerPrivateAVFoundationObjC::setWaitingForKey(bool waitingForKey)
+{
+ if (m_waitingForKey == waitingForKey)
+ return;
+
+ m_waitingForKey = waitingForKey;
+ player()->waitingForKeyChanged();
+}
#endif
#if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -120,6 +120,9 @@
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
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2018-09-27 21:41:22 UTC (rev 236572)
@@ -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 @@
{
}
+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
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -109,6 +109,8 @@
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 @@
bool m_parsingSucceeded { true };
bool m_parserStateWasReset { false };
bool m_discardSamplesUntilNextInitializationSegment { false };
+ bool m_waitingForKey { true };
int m_enabledVideoTrackID { -1 };
int m_protectedTrackID { -1 };
};
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2018-09-27 21:41:22 UTC (rev 236572)
@@ -664,6 +664,9 @@
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 @@
m_hasSessionSemaphore = nullptr;
}
}
+ m_waitingForKey = false;
+ m_mediaSource->player()->waitingForKeyChanged();
#else
UNUSED_PARAM(instance);
#endif
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1310,7 +1310,10 @@
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();
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2018-09-27 21:41:22 UTC (rev 236572)
@@ -1353,8 +1353,22 @@
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
bool MediaPlayerPrivateGStreamerBase::supportsKeySystem(const String& keySystem, const String& mimeType)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2018-09-27 21:41:22 UTC (rev 236572)
@@ -152,6 +152,8 @@
void attemptToDecryptWithInstance(CDMInstance&) override;
void dispatchCDMInstance();
void initializationDataEncountered(GstEvent*);
+ void setWaitingForKey(bool);
+ bool waitingForKey() const;
void reportWaitingForKey();
#endif
@@ -274,6 +276,7 @@
RefPtr<const CDMInstance> m_cdmInstance;
HashSet<uint32_t> m_handledProtectionEvents;
bool m_needToResendCredentials { false };
+ bool m_waitingForKey { false };
#endif
};
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp (236571 => 236572)
--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp 2018-09-27 21:27:53 UTC (rev 236571)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp 2018-09-27 21:41:22 UTC (rev 236572)
@@ -308,6 +308,7 @@
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")));