WebKit Bugzilla
Attachment 357229 Details for
Bug 192229
: [GStreamer][EME][ClearKey] Request keys from CDMInstance rather than passing via bus messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192229-20181213144206.patch (text/plain), 31.93 KB, created by
Charlie Turner
on 2018-12-13 06:42:08 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Charlie Turner
Created:
2018-12-13 06:42:08 PST
Size:
31.93 KB
patch
obsolete
>Subversion Revision: 238793 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d1ac56ff4ac01acd15196428b65162054f0bb8b9..176cfc9d5bd9f542a73d3a9e0ab730ab57972335 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,62 @@ >+2018-12-13 Charlie Turner <cturner@igalia.com> >+ >+ [GStreamer][EME][ClearKey] Request keys from CDMInstance rather than passing via bus messages >+ https://bugs.webkit.org/show_bug.cgi?id=192229 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Refactoring, covered by existing tests. >+ >+ * platform/graphics/gstreamer/GStreamerCommon.h: >+ (WebCore::GstMappedBuffer::~GstMappedBuffer): Add extra check to >+ ensure that if GStreamer removes the buffer using its own >+ refcounts, we don't try and double delete. >+ (WebCore::GstMappedBuffer::sharedBuffer const): Add utility to >+ fabricate a SharedBuffer. >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp: >+ (WebCore::MediaPlayerPrivateGStreamerBase::dispatchDecryptionKey): >+ Deleted, not used anywhere. >+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h: Ditto. >+ * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp: >+ Much of the changes are just cleaning up the >+ namespaceInVariableNames stuff. >+ (webkit_media_clear_key_decrypt_class_init): Ditto. >+ (finalize): Ditto. >+ (handleKeyResponse): Downcast the CDMInstance received to >+ ClearKey. Now it seems we cannot modify CDMInstance in the base >+ class to help our use cases, we will need to keep the >+ multi-decryptor architecture. >+ (findAndSetKey): >+ (decrypt): >+ (webKitMediaClearKeyDecryptorFinalize): Deleted. >+ (webKitMediaClearKeyDecryptorHandleKeyResponse): Deleted. >+ (webKitMediaClearKeyDecryptorFindAndSetKey): Deleted. >+ (webKitMediaClearKeyDecryptorDecrypt): Deleted. >+ * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp: >+ (webkit_media_common_encryption_decrypt_class_init): >+ (finalize): >+ (transformCaps): >+ (transformInPlace): >+ (isCDMInstanceAvailable): >+ (sinkEventHandler): >+ (queryHandler): >+ (changeState): >+ (setContext): >+ (webKitMediaCommonEncryptionDecryptorFinalize): Deleted. >+ (webkitMediaCommonEncryptionDecryptTransformCaps): Deleted. >+ (webkitMediaCommonEncryptionDecryptTransformInPlace): Deleted. >+ (webkitMediaCommonEncryptionDecryptIsCDMInstanceAvailable): Deleted. >+ (webkitMediaCommonEncryptionDecryptSinkEventHandler): Deleted. >+ (webkitMediaCommonEncryptionDecryptorQueryHandler): Deleted. >+ (webKitMediaCommonEncryptionDecryptorChangeState): Deleted. >+ (webKitMediaCommonEncryptionDecryptorSetContext): Deleted. >+ * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h: >+ * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp: >+ Now that we are using the CDMClearKey::keys() method, no need for >+ this roundtripping anymore. >+ (WebCore::MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithLocalInstance): Deleted. >+ * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: >+ > 2018-12-02 Zalan Bujtas <zalan@apple.com> > > Add a runtime feature flag for LayoutFormattingContext. >diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h >index 5d44d47401bc718cede46290e609137190f2700f..b1d7d98e66504bf06de6e55821a7a68beab907b1 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h >+++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h >@@ -23,6 +23,7 @@ > #include "FloatSize.h" > #include "GRefPtrGStreamer.h" > #include "GUniquePtrGStreamer.h" >+#include "SharedBuffer.h" > #include <gst/gst.h> > #include <gst/video/video-format.h> > #include <gst/video/video-info.h> >@@ -102,16 +103,15 @@ public: > > ~GstMappedBuffer() > { >- if (m_isValid) >+ if (m_isValid && GST_IS_BUFFER(m_buffer)) > gst_buffer_unmap(m_buffer, &m_info); > m_isValid = false; > } > > uint8_t* data() { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); } > const uint8_t* data() const { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); } >- > size_t size() const { ASSERT(m_isValid); return static_cast<size_t>(m_info.size); } >- >+ Ref<SharedBuffer> sharedBuffer() const { return SharedBuffer::create(data(), size()); } > explicit operator bool() const { return m_isValid; } > > private: >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index 897f292025dd4aac265dd9bddf2b778386cb9b61..774fc3e01edad49cf0fa4279c9d43dbb7bd02a73 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -1254,13 +1254,6 @@ void MediaPlayerPrivateGStreamerBase::attemptToDecryptWithLocalInstance() > GST_DEBUG("attempting to decrypt, event handled %s", boolForPrinting(eventHandled)); > } > >-void MediaPlayerPrivateGStreamerBase::dispatchDecryptionKey(GstBuffer* buffer) >-{ >- bool eventHandled = gst_element_send_event(pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, >- gst_structure_new("drm-cipher", "key", GST_TYPE_BUFFER, buffer, nullptr))); >- GST_TRACE("emitted decryption cipher key on pipeline, event handled %s", boolForPrinting(eventHandled)); >-} >- > void MediaPlayerPrivateGStreamerBase::handleProtectionEvent(GstEvent* event) > { > if (m_handledProtectionEvents.contains(GST_EVENT_SEQNUM(event))) { >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index 42381d2f77b8c14c19d07aa0fc6d7f859c69faaa..76aa5ccfd8931f0c44095dfd0d70f4aa8f31e59c 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -148,7 +148,6 @@ public: > #if ENABLE(ENCRYPTED_MEDIA) > void cdmInstanceAttached(CDMInstance&) override; > void cdmInstanceDetached(CDMInstance&) override; >- void dispatchDecryptionKey(GstBuffer*); > void handleProtectionEvent(GstEvent*); > virtual void attemptToDecryptWithLocalInstance(); > void attemptToDecryptWithInstance(CDMInstance&) final; >diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp >index f941e528f47cbd069579bc5e633581e6b610c723..1ee1684d311f5e2708c756ad64f7f3ead0f64d8f 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp >@@ -24,12 +24,15 @@ > > #if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER) > >+#include "CDMClearKey.h" > #include "GStreamerCommon.h" > #include "GStreamerEMEUtilities.h" > #include <gcrypt.h> > #include <gst/base/gstbytereader.h> > #include <wtf/RunLoop.h> > >+using namespace WebCore; >+ > #define CLEARKEY_SIZE 16 > > struct Key { >@@ -39,13 +42,14 @@ struct Key { > > #define WEBKIT_MEDIA_CK_DECRYPT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_MEDIA_CK_DECRYPT, WebKitMediaClearKeyDecryptPrivate)) > struct _WebKitMediaClearKeyDecryptPrivate { >+ RefPtr<CDMInstanceClearKey> cdmInstance; > Vector<Key> keys; > gcry_cipher_hd_t handle; > }; > >-static void webKitMediaClearKeyDecryptorFinalize(GObject*); >-static gboolean webKitMediaClearKeyDecryptorHandleKeyResponse(WebKitMediaCommonEncryptionDecrypt* self, GstEvent*); >-static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* iv, GstBuffer* keyid, GstBuffer* sample, unsigned subSamplesCount, GstBuffer* subSamples); >+static void finalize(GObject*); >+static bool handleKeyResponse(WebKitMediaCommonEncryptionDecrypt* self, RefPtr<CDMInstance>); >+static bool decrypt(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* iv, GstBuffer* keyid, GstBuffer* sample, unsigned subSamplesCount, GstBuffer* subSamples); > > GST_DEBUG_CATEGORY_STATIC(webkit_media_clear_key_decrypt_debug_category); > #define GST_CAT_DEFAULT webkit_media_clear_key_decrypt_debug_category >@@ -69,7 +73,7 @@ G_DEFINE_TYPE(WebKitMediaClearKeyDecrypt, webkit_media_clear_key_decrypt, WEBKIT > static void webkit_media_clear_key_decrypt_class_init(WebKitMediaClearKeyDecryptClass* klass) > { > GObjectClass* gobjectClass = G_OBJECT_CLASS(klass); >- gobjectClass->finalize = webKitMediaClearKeyDecryptorFinalize; >+ gobjectClass->finalize = finalize; > > GstElementClass* elementClass = GST_ELEMENT_CLASS(klass); > gst_element_class_add_pad_template(elementClass, gst_static_pad_template_get(&sinkTemplate)); >@@ -85,9 +89,9 @@ static void webkit_media_clear_key_decrypt_class_init(WebKitMediaClearKeyDecrypt > "webkitclearkey", 0, "ClearKey decryptor"); > > WebKitMediaCommonEncryptionDecryptClass* cencClass = WEBKIT_MEDIA_CENC_DECRYPT_CLASS(klass); >- cencClass->protectionSystemId = WebCore::GStreamerEMEUtilities::s_ClearKeyUUID; >- cencClass->handleKeyResponse = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorHandleKeyResponse); >- cencClass->decrypt = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorDecrypt); >+ cencClass->protectionSystemId = GStreamerEMEUtilities::s_ClearKeyUUID; >+ cencClass->handleKeyResponse = GST_DEBUG_FUNCPTR(handleKeyResponse); >+ cencClass->decrypt = GST_DEBUG_FUNCPTR(decrypt); > > g_type_class_add_private(klass, sizeof(WebKitMediaClearKeyDecryptPrivate)); > } >@@ -104,7 +108,7 @@ static void webkit_media_clear_key_decrypt_init(WebKitMediaClearKeyDecrypt* self > } > } > >-static void webKitMediaClearKeyDecryptorFinalize(GObject* object) >+static void finalize(GObject* object) > { > WebKitMediaClearKeyDecrypt* self = WEBKIT_MEDIA_CK_DECRYPT(object); > WebKitMediaClearKeyDecryptPrivate* priv = self->priv; >@@ -114,65 +118,30 @@ static void webKitMediaClearKeyDecryptorFinalize(GObject* object) > GST_CALL_PARENT(G_OBJECT_CLASS, finalize, (object)); > } > >-static gboolean webKitMediaClearKeyDecryptorHandleKeyResponse(WebKitMediaCommonEncryptionDecrypt* self, GstEvent* event) >+static bool handleKeyResponse(WebKitMediaCommonEncryptionDecrypt* self, RefPtr<CDMInstance> cdmInstance) > { > WebKitMediaClearKeyDecryptPrivate* priv = WEBKIT_MEDIA_CK_DECRYPT_GET_PRIVATE(WEBKIT_MEDIA_CK_DECRYPT(self)); >- const GstStructure* structure = gst_event_get_structure(event); >- >- // Demand the `drm-cipher-clearkey` GstStructure. >- if (!gst_structure_has_name(structure, "drm-cipher-clearkey")) >- return FALSE; >- >- // Retrieve the `key-ids` GStreamer value list. >- const GValue* keyIDsList = gst_structure_get_value(structure, "key-ids"); >- ASSERT(keyIDsList && GST_VALUE_HOLDS_LIST(keyIDsList)); >- unsigned keyIDsListSize = gst_value_list_get_size(keyIDsList); >- >- // Retrieve the `key-values` GStreamer value list. >- const GValue* keyValuesList = gst_structure_get_value(structure, "key-values"); >- ASSERT(keyValuesList && GST_VALUE_HOLDS_LIST(keyValuesList)); >- unsigned keyValuesListSize = gst_value_list_get_size(keyValuesList); >- >- // Bail if somehow the two lists don't match in size. >- if (keyIDsListSize != keyValuesListSize) >- return FALSE; >- >- // Clear out the previous list of keys. >- priv->keys.clear(); >- >- // Append the retrieved GstBuffer objects containing each key's ID and value to the list of Key objects. >- for (unsigned i = 0; i < keyIDsListSize; ++i) { >- GRefPtr<GstBuffer> keyIDBuffer(gst_value_get_buffer(gst_value_list_get_value(keyIDsList, i))); >- GRefPtr<GstBuffer> keyValueBuffer(gst_value_get_buffer(gst_value_list_get_value(keyValuesList, i))); >- priv->keys.append(Key { WTFMove(keyIDBuffer), WTFMove(keyValueBuffer) }); >- } >- >- return TRUE; >+ priv->cdmInstance = downcast<CDMInstanceClearKey>(cdmInstance.get()); >+ return priv->cdmInstance; > } > >-static gboolean webKitMediaClearKeyDecryptorFindAndSetKey(WebKitMediaClearKeyDecryptPrivate* priv, const WebCore::GstMappedBuffer& keyIDBuffer) >+static bool findAndSetKey(WebKitMediaClearKeyDecryptPrivate* priv, const Ref<SharedBuffer> keyID) > { >- GRefPtr<GstBuffer> keyBuffer; >- for (auto& key : priv->keys) { >- if (key.keyID.get() == keyIDBuffer) { >- keyBuffer = key.keyValue; >+ RefPtr<SharedBuffer> keyValue; >+ for (auto& key : priv->cdmInstance->keys()) { >+ if (*key.keyIDData == keyID) { >+ keyValue = key.keyValueData; > break; > } > } > >- if (!keyBuffer) { >- GST_ERROR_OBJECT(priv, "Failed to find an appropriate key buffer"); >- return false; >- } >- >- WebCore::GstMappedBuffer mappedKeyValueBuffer(keyBuffer.get(), GST_MAP_READ); >- if (!mappedKeyValueBuffer) { >- GST_ERROR_OBJECT(priv, "Failed to map decryption key"); >+ if (!keyValue) { >+ GST_ERROR_OBJECT(priv, "Failed to find an appropriate key"); > return false; > } > >- ASSERT(mappedKeyValueBuffer.size() == CLEARKEY_SIZE); >- if (gcry_error_t error = gcry_cipher_setkey(priv->handle, mappedKeyValueBuffer.data(), mappedKeyValueBuffer.size())) { >+ ASSERT(keyValue.size() == CLEARKEY_SIZE); >+ if (gcry_error_t error = gcry_cipher_setkey(priv->handle, keyValue->data(), keyValue->size())) { > GST_ERROR_OBJECT(priv, "gcry_cipher_setkey failed: %s", gpg_strerror(error)); > return false; > } >@@ -180,7 +149,7 @@ static gboolean webKitMediaClearKeyDecryptorFindAndSetKey(WebKitMediaClearKeyDec > return true; > } > >-static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionDecrypt* self, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSampleCount, GstBuffer* subSamplesBuffer) >+static bool decrypt(WebKitMediaCommonEncryptionDecrypt* self, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSampleCount, GstBuffer* subSamplesBuffer) > { > // Check ivBuffer isn't null. > if (!ivBuffer) { >@@ -188,7 +157,7 @@ static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionD > return false; > } > >- WebCore::GstMappedBuffer mappedIVBuffer(ivBuffer, GST_MAP_READ); >+ GstMappedBuffer mappedIVBuffer(ivBuffer, GST_MAP_READ); > if (!mappedIVBuffer) { > GST_ERROR_OBJECT(self, "Failed to map IV"); > return false; >@@ -216,19 +185,19 @@ static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionD > return false; > } > >- WebCore::GstMappedBuffer mappedKeyIdBuffer(keyIDBuffer, GST_MAP_READ); >+ GstMappedBuffer mappedKeyIdBuffer(keyIDBuffer, GST_MAP_READ); > if (!mappedKeyIdBuffer) { > GST_ERROR_OBJECT(self, "Failed to map key id buffer"); > return false; > } > >- WebCore::GstMappedBuffer mappedBuffer(buffer, GST_MAP_READWRITE); >+ GstMappedBuffer mappedBuffer(buffer, GST_MAP_READWRITE); > if (!mappedBuffer) { > GST_ERROR_OBJECT(self, "Failed to map buffer"); > return false; > } > >- webKitMediaClearKeyDecryptorFindAndSetKey(priv, mappedKeyIdBuffer); >+ findAndSetKey(priv, mappedKeyIdBuffer.sharedBuffer()); > > unsigned position = 0; > unsigned sampleIndex = 0; >@@ -248,14 +217,12 @@ static gboolean webKitMediaClearKeyDecryptorDecrypt(WebKitMediaCommonEncryptionD > return true; > } > >- // Check subSamplesBuffer isn't null. > if (!subSamplesBuffer) { > GST_ERROR_OBJECT(self, "Error, the subSampleBuffer is null"); > return false; > } > >- // Subsample encryption. >- WebCore::GstMappedBuffer mappedSubSamplesBuffer(subSamplesBuffer, GST_MAP_READ); >+ GstMappedBuffer mappedSubSamplesBuffer(subSamplesBuffer, GST_MAP_READ); > if (!mappedSubSamplesBuffer) { > GST_ERROR_OBJECT(self, "Failed to map subsample buffer"); > return false; >diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp >index 17fd48cc9591e814e6a39b4725f08f90980e5f61..fc6968582518f5efea232d65fc96e90323bb58dc 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp >@@ -26,7 +26,7 @@ > #if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER) > > #include "GStreamerCommon.h" >-#include <CDMInstance.h> >+#include "GStreamerEMEUtilities.h" > #include <wtf/Condition.h> > #include <wtf/PrintStream.h> > #include <wtf/RunLoop.h> >@@ -37,20 +37,21 @@ using WebCore::CDMInstance; > struct _WebKitMediaCommonEncryptionDecryptPrivate { > GRefPtr<GstEvent> protectionEvent; > RefPtr<CDMInstance> cdmInstance; >- bool keyReceived; >+ bool keyReceived { false }; > bool waitingForKey { false }; > Lock mutex; > Condition condition; > }; > >-static GstStateChangeReturn webKitMediaCommonEncryptionDecryptorChangeState(GstElement*, GstStateChange transition); >-static void webKitMediaCommonEncryptionDecryptorSetContext(GstElement*, GstContext*); >-static void webKitMediaCommonEncryptionDecryptorFinalize(GObject*); >-static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform*, GstPadDirection, GstCaps*, GstCaps*); >-static GstFlowReturn webkitMediaCommonEncryptionDecryptTransformInPlace(GstBaseTransform*, GstBuffer*); >-static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransform*, GstEvent*); >-static gboolean webkitMediaCommonEncryptionDecryptorQueryHandler(GstBaseTransform*, GstPadDirection, GstQuery*); >-static bool webkitMediaCommonEncryptionDecryptIsCDMInstanceAvailable(WebKitMediaCommonEncryptionDecrypt*); >+static GstStateChangeReturn changeState(GstElement*, GstStateChange transition); >+static void finalize(GObject*); >+static GstCaps* transformCaps(GstBaseTransform*, GstPadDirection, GstCaps*, GstCaps*); >+static GstFlowReturn transformInPlace(GstBaseTransform*, GstBuffer*); >+static gboolean sinkEventHandler(GstBaseTransform*, GstEvent*); >+static gboolean queryHandler(GstBaseTransform*, GstPadDirection, GstQuery*); >+static bool isCDMInstanceAvailable(WebKitMediaCommonEncryptionDecrypt*); >+static void setContext(GstElement*, GstContext*); >+ > > GST_DEBUG_CATEGORY_STATIC(webkit_media_common_encryption_decrypt_debug_category); > #define GST_CAT_DEFAULT webkit_media_common_encryption_decrypt_debug_category >@@ -61,21 +62,21 @@ G_DEFINE_TYPE(WebKitMediaCommonEncryptionDecrypt, webkit_media_common_encryption > static void webkit_media_common_encryption_decrypt_class_init(WebKitMediaCommonEncryptionDecryptClass* klass) > { > GObjectClass* gobjectClass = G_OBJECT_CLASS(klass); >- gobjectClass->finalize = webKitMediaCommonEncryptionDecryptorFinalize; >+ gobjectClass->finalize = finalize; > > GST_DEBUG_CATEGORY_INIT(webkit_media_common_encryption_decrypt_debug_category, > "webkitcenc", 0, "Common Encryption base class"); > > GstElementClass* elementClass = GST_ELEMENT_CLASS(klass); >- elementClass->change_state = GST_DEBUG_FUNCPTR(webKitMediaCommonEncryptionDecryptorChangeState); >- elementClass->set_context = GST_DEBUG_FUNCPTR(webKitMediaCommonEncryptionDecryptorSetContext); >+ elementClass->change_state = GST_DEBUG_FUNCPTR(changeState); >+ elementClass->set_context = GST_DEBUG_FUNCPTR(setContext); > > GstBaseTransformClass* baseTransformClass = GST_BASE_TRANSFORM_CLASS(klass); >- baseTransformClass->transform_ip = GST_DEBUG_FUNCPTR(webkitMediaCommonEncryptionDecryptTransformInPlace); >- baseTransformClass->transform_caps = GST_DEBUG_FUNCPTR(webkitMediaCommonEncryptionDecryptTransformCaps); >+ baseTransformClass->transform_ip = GST_DEBUG_FUNCPTR(transformInPlace); >+ baseTransformClass->transform_caps = GST_DEBUG_FUNCPTR(transformCaps); > baseTransformClass->transform_ip_on_passthrough = FALSE; >- baseTransformClass->sink_event = GST_DEBUG_FUNCPTR(webkitMediaCommonEncryptionDecryptSinkEventHandler); >- baseTransformClass->query = GST_DEBUG_FUNCPTR(webkitMediaCommonEncryptionDecryptorQueryHandler); >+ baseTransformClass->sink_event = GST_DEBUG_FUNCPTR(sinkEventHandler); >+ baseTransformClass->query = GST_DEBUG_FUNCPTR(queryHandler); > > g_type_class_add_private(klass, sizeof(WebKitMediaCommonEncryptionDecryptPrivate)); > } >@@ -93,7 +94,7 @@ static void webkit_media_common_encryption_decrypt_init(WebKitMediaCommonEncrypt > gst_base_transform_set_gap_aware(base, FALSE); > } > >-static void webKitMediaCommonEncryptionDecryptorFinalize(GObject* object) >+static void finalize(GObject* object) > { > WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(object); > WebKitMediaCommonEncryptionDecryptPrivate* priv = self->priv; >@@ -102,7 +103,7 @@ static void webKitMediaCommonEncryptionDecryptorFinalize(GObject* object) > GST_CALL_PARENT(G_OBJECT_CLASS, finalize, (object)); > } > >-static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform* base, GstPadDirection direction, GstCaps* caps, GstCaps* filter) >+static GstCaps* transformCaps(GstBaseTransform* base, GstPadDirection direction, GstCaps* caps, GstCaps* filter) > { > if (direction == GST_PAD_UNKNOWN) > return nullptr; >@@ -197,7 +198,7 @@ static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform > return transformedCaps; > } > >-static GstFlowReturn webkitMediaCommonEncryptionDecryptTransformInPlace(GstBaseTransform* base, GstBuffer* buffer) >+static GstFlowReturn transformInPlace(GstBaseTransform* base, GstBuffer* buffer) > { > WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(base); > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(self); >@@ -302,7 +303,7 @@ static GstFlowReturn webkitMediaCommonEncryptionDecryptTransformInPlace(GstBaseT > return GST_FLOW_OK; > } > >-static bool webkitMediaCommonEncryptionDecryptIsCDMInstanceAvailable(WebKitMediaCommonEncryptionDecrypt* self) >+static bool isCDMInstanceAvailable(WebKitMediaCommonEncryptionDecrypt* self) > { > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(self); > >@@ -317,19 +318,22 @@ static bool webkitMediaCommonEncryptionDecryptIsCDMInstanceAvailable(WebKitMedia > // requests are useful here. > if (context) { > const GValue* value = gst_structure_get_value(gst_context_get_structure(context.get()), "cdm-instance"); >- priv->cdmInstance = value ? reinterpret_cast<CDMInstance*>(g_value_get_pointer(value)) : nullptr; >+ // Capture the CDMInstance into a separate variable to avoid missing a refcount. >+ CDMInstance* instance = value ? reinterpret_cast<CDMInstance*>(g_value_get_pointer(value)) : nullptr; >+ // ... And force a refcount bump using operator=. >+ priv->cdmInstance = instance; > if (priv->cdmInstance) >- GST_DEBUG_OBJECT(self, "received new CDMInstance %p", priv->cdmInstance.get()); >+ GST_DEBUG_OBJECT(self, "received a new CDM instance %p, refcount %u", priv->cdmInstance.get(), priv->cdmInstance->refCount()); > else >- GST_TRACE_OBJECT(self, "former instance was detached"); >+ GST_TRACE_OBJECT(self, "CDM instance was detached"); > } > } > >- GST_TRACE_OBJECT(self, "CDMInstance available %s", boolForPrinting(priv->cdmInstance.get())); >+ GST_TRACE_OBJECT(self, "CDM instance available %s", boolForPrinting(priv->cdmInstance.get())); > return priv->cdmInstance; > } > >-static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransform* trans, GstEvent* event) >+static gboolean sinkEventHandler(GstBaseTransform* trans, GstEvent* event) > { > WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(trans); > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(self); >@@ -345,13 +349,13 @@ static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransf > // events will not be handled by the demuxer, so the must be > // handled in here. > LockHolder locker(priv->mutex); >- if (!webkitMediaCommonEncryptionDecryptIsCDMInstanceAvailable(self)) { >+ if (!isCDMInstanceAvailable(self)) { > GST_ERROR_OBJECT(self, "No CDM instance available"); > result = FALSE; > break; > } > >- if (klass->handleKeyResponse(self, event)) { >+ if (klass->handleKeyResponse(self, priv->cdmInstance)) { > GST_DEBUG_OBJECT(self, "key received"); > priv->keyReceived = true; > priv->condition.notifyOne(); >@@ -369,7 +373,7 @@ static gboolean webkitMediaCommonEncryptionDecryptSinkEventHandler(GstBaseTransf > return result; > } > >-static gboolean webkitMediaCommonEncryptionDecryptorQueryHandler(GstBaseTransform* trans, GstPadDirection direction, GstQuery* query) >+static gboolean queryHandler(GstBaseTransform* trans, GstPadDirection direction, GstQuery* query) > { > if (gst_structure_has_name(gst_query_get_structure(query), "any-decryptor-waiting-for-key")) { > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(trans); >@@ -379,7 +383,7 @@ static gboolean webkitMediaCommonEncryptionDecryptorQueryHandler(GstBaseTransfor > return GST_BASE_TRANSFORM_CLASS(parent_class)->query(trans, direction, query); > } > >-static GstStateChangeReturn webKitMediaCommonEncryptionDecryptorChangeState(GstElement* element, GstStateChange transition) >+static GstStateChangeReturn changeState(GstElement* element, GstStateChange transition) > { > WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(element); > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(self); >@@ -400,7 +404,7 @@ static GstStateChangeReturn webKitMediaCommonEncryptionDecryptorChangeState(GstE > return result; > } > >-static void webKitMediaCommonEncryptionDecryptorSetContext(GstElement* element, GstContext* context) >+static void setContext(GstElement* element, GstContext* context) > { > WebKitMediaCommonEncryptionDecrypt* self = WEBKIT_MEDIA_CENC_DECRYPT(element); > WebKitMediaCommonEncryptionDecryptPrivate* priv = WEBKIT_MEDIA_CENC_DECRYPT_GET_PRIVATE(self); >diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h >index 22211254eb7d9ef5466057fd7d5434219ecef2dd..8299d39d2ec06012b8e21ceb1aecc679276e8567 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h >+++ b/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.h >@@ -24,6 +24,7 @@ > > #if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER) > >+#include <CDMInstance.h> > #include <gst/base/gstbasetransform.h> > #include <gst/gst.h> > >@@ -53,8 +54,8 @@ struct _WebKitMediaCommonEncryptionDecryptClass { > GstBaseTransformClass parentClass; > > const char* protectionSystemId; >- gboolean (*handleKeyResponse)(WebKitMediaCommonEncryptionDecrypt*, GstEvent* event); >- gboolean (*decrypt)(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSamplesCount, GstBuffer* subSamplesBuffer); >+ bool (*handleKeyResponse)(WebKitMediaCommonEncryptionDecrypt*, RefPtr<WebCore::CDMInstance>); >+ bool (*decrypt)(WebKitMediaCommonEncryptionDecrypt*, GstBuffer* ivBuffer, GstBuffer* keyIDBuffer, GstBuffer* buffer, unsigned subSamplesCount, GstBuffer* subSamplesBuffer); > }; > > G_END_DECLS >diff --git a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp >index b63e5deee72c95c49d856dc5470baab3f6149e8c..aa91a9969e9cb087b26d8e80a35dfc9a41eaa550 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp >@@ -55,11 +55,6 @@ > #include <wtf/text/AtomicString.h> > #include <wtf/text/AtomicStringHash.h> > >-#if ENABLE(ENCRYPTED_MEDIA) >-#include "CDMClearKey.h" >-#include "SharedBuffer.h" >-#endif >- > static const char* dumpReadyState(WebCore::MediaPlayer::ReadyState readyState) > { > switch (readyState) { >@@ -908,42 +903,6 @@ MediaTime MediaPlayerPrivateGStreamerMSE::maxMediaTimeSeekable() const > return result; > } > >-#if ENABLE(ENCRYPTED_MEDIA) >-void MediaPlayerPrivateGStreamerMSE::attemptToDecryptWithLocalInstance() >-{ >- if (is<CDMInstanceClearKey>(*m_cdmInstance)) { >- auto& clearkeyCDMInstance = downcast<CDMInstanceClearKey>(*m_cdmInstance); >- if (clearkeyCDMInstance.keys().isEmpty()) >- return; >- >- GValue keyIDList = G_VALUE_INIT, keyValueList = G_VALUE_INIT; >- g_value_init(&keyIDList, GST_TYPE_LIST); >- g_value_init(&keyValueList, GST_TYPE_LIST); >- >- auto appendBuffer = >- [](GValue* valueList, const SharedBuffer& buffer) >- { >- GValue* bufferValue = g_new0(GValue, 1); >- g_value_init(bufferValue, GST_TYPE_BUFFER); >- gst_value_take_buffer(bufferValue, >- gst_buffer_new_wrapped(g_memdup(buffer.data(), buffer.size()), buffer.size())); >- gst_value_list_append_and_take_value(valueList, bufferValue); >- }; >- >- for (auto& key : clearkeyCDMInstance.keys()) { >- appendBuffer(&keyIDList, *key.keyIDData); >- appendBuffer(&keyValueList, *key.keyValueData); >- } >- >- GUniquePtr<GstStructure> structure(gst_structure_new_empty("drm-cipher-clearkey")); >- gst_structure_set_value(structure.get(), "key-ids", &keyIDList); >- gst_structure_set_value(structure.get(), "key-values", &keyValueList); >- >- gst_element_send_event(m_playbackPipeline->pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, structure.release())); >- } >-} >-#endif >- > } // namespace WebCore. > > #endif // USE(GSTREAMER) >diff --git a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h >index 5b5682f64b5d35494e839b7a3944ba7e409efc18..2dfa732fcbf26ba687f1a9814ab7663eef985474 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h >+++ b/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h >@@ -85,10 +85,6 @@ public: > static bool supportsCodec(String codec); > static bool supportsAllCodecs(const Vector<String>& codecs); > >-#if ENABLE(ENCRYPTED_MEDIA) >- void attemptToDecryptWithLocalInstance() final; >-#endif >- > private: > static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&); > static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index c1ea44ce11c08b7c6b3ad35f0ee099642e38c529..d5d007b83af506bc26ba0ed64e0f823542d6a312 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,13 @@ >+2018-12-13 Charlie Turner <cturner@igalia.com> >+ >+ [GStreamer][EME][ClearKey] Request keys from CDMInstance rather than passing via bus messages >+ https://bugs.webkit.org/show_bug.cgi?id=192229 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * MiniBrowser/wpe/main.cpp: >+ (main): Enable encrypted-media by default. >+ > 2018-12-01 Don Olmstead <don.olmstead@sony.com> > > Cleanup WebKit Features >diff --git a/Tools/MiniBrowser/wpe/main.cpp b/Tools/MiniBrowser/wpe/main.cpp >index e0c29b2129934371274a6f25451eae9821c4689f..5c448a8e07126189f3411ce71010fbfd62911ee0 100644 >--- a/Tools/MiniBrowser/wpe/main.cpp >+++ b/Tools/MiniBrowser/wpe/main.cpp >@@ -177,6 +177,7 @@ int main(int argc, char *argv[]) > "enable-developer-extras", TRUE, > "enable-webgl", TRUE, > "enable-media-stream", TRUE, >+ "enable-encrypted-media", TRUE, > nullptr); > > auto* webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192229
:
356374
|
356384
|
357229
|
359479
|
359480