[GStreamer][MSE][EME] Handle protection event also at decryptor level
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2017 15:14:13 +0000 (15:14 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Feb 2017 15:14:13 +0000 (15:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168316

Reviewed by Žan Doberšek.

So far in MSE pipeline we were handling the encryption events
only when they arrived at the demuxer but this won't work in any
kind of key renegotiation as the event will never arrive. Now we
connect to the element messages, check for the drm id and send it
to the private player for processing.

* platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::appendPipelineElementMessageCallback):
(WebCore::AppendPipeline::AppendPipeline):
(WebCore::AppendPipeline::handleElementMessage):
* platform/graphics/gstreamer/mse/AppendPipeline.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h

index ea8fc35..0f1a665 100644 (file)
@@ -1,3 +1,22 @@
+2017-02-15  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [GStreamer][MSE][EME] Handle protection event also at decryptor level
+        https://bugs.webkit.org/show_bug.cgi?id=168316
+
+        Reviewed by Žan Doberšek.
+
+        So far in MSE pipeline we were handling the encryption events
+        only when they arrived at the demuxer but this won't work in any
+        kind of key renegotiation as the event will never arrive. Now we
+        connect to the element messages, check for the drm id and send it
+        to the private player for processing.
+
+        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
+        (WebCore::appendPipelineElementMessageCallback):
+        (WebCore::AppendPipeline::AppendPipeline):
+        (WebCore::AppendPipeline::handleElementMessage):
+        * platform/graphics/gstreamer/mse/AppendPipeline.h:
+
 2017-02-15  Zan Dobersek  <zdobersek@igalia.com>
 
         [EME] MediaKeys::setServerCertificate() must resolve with 'false' when certificates aren't supported
index 150c38f..c4f2b06 100644 (file)
@@ -93,6 +93,13 @@ static void appendPipelineApplicationMessageCallback(GstBus*, GstMessage* messag
     appendPipeline->handleApplicationMessage(message);
 }
 
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+static void appendPipelineElementMessageCallback(GstBus*, GstMessage* message, AppendPipeline* appendPipeline)
+{
+    appendPipeline->handleElementMessage(message);
+}
+#endif
+
 AppendPipeline::AppendPipeline(Ref<MediaSourceClientGStreamerMSE> mediaSourceClient, Ref<SourceBufferPrivateGStreamer> sourceBufferPrivate, MediaPlayerPrivateGStreamerMSE& playerPrivate)
     : m_mediaSourceClient(mediaSourceClient.get())
     , m_sourceBufferPrivate(sourceBufferPrivate.get())
@@ -119,6 +126,9 @@ AppendPipeline::AppendPipeline(Ref<MediaSourceClientGStreamerMSE> mediaSourceCli
 
     g_signal_connect(m_bus.get(), "sync-message::need-context", G_CALLBACK(appendPipelineNeedContextMessageCallback), this);
     g_signal_connect(m_bus.get(), "message::application", G_CALLBACK(appendPipelineApplicationMessageCallback), this);
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+    g_signal_connect(m_bus.get(), "message::element", G_CALLBACK(appendPipelineElementMessageCallback), this);
+#endif
 
     // We assign the created instances here instead of adoptRef() because gst_bin_add_many()
     // below will already take the initial reference and we need an additional one for us.
@@ -284,6 +294,24 @@ void AppendPipeline::handleNeedContextSyncMessage(GstMessage* message)
         m_playerPrivate->handleSyncMessage(message);
 }
 
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+void AppendPipeline::handleElementMessage(GstMessage* message)
+{
+    ASSERT(WTF::isMainThread());
+
+    const GstStructure* structure = gst_message_get_structure(message);
+    GST_TRACE("%s message from %s", gst_structure_get_name(structure), GST_MESSAGE_SRC_NAME(message));
+    if (m_playerPrivate && gst_structure_has_name(structure, "drm-key-needed")) {
+        setAppendState(AppendPipeline::AppendState::KeyNegotiation);
+
+        GST_DEBUG("sending drm-key-needed message from %s to the player", GST_MESSAGE_SRC_NAME(message));
+        GRefPtr<GstEvent> event;
+        gst_structure_get(structure, "event", GST_TYPE_EVENT, &event.outPtr(), nullptr);
+        m_playerPrivate->handleProtectionEvent(event.get());
+    }
+}
+#endif
+
 void AppendPipeline::handleApplicationMessage(GstMessage* message)
 {
     ASSERT(WTF::isMainThread());
index 9e14079..301265e 100644 (file)
@@ -49,6 +49,9 @@ public:
 
     void handleNeedContextSyncMessage(GstMessage*);
     void handleApplicationMessage(GstMessage*);
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+    void handleElementMessage(GstMessage*);
+#endif
 
     gint id();
     AppendState appendState() { return m_appendState; }