[GStreamer][MSE] Add GstFlowCombiner to handle non-linked inactive branches
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 10:47:10 +0000 (10:47 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Jul 2018 10:47:10 +0000 (10:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187636

Reviewed by Carlos Garcia Campos.

When we have more than one source buffer, only one will be
rendered and the inactive branch will report linking errors that
we have to deal with.

* platform/graphics/gstreamer/GUniquePtrGStreamer.h: Added GstFlowCombiner.
* platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
(webkitMediaSrcChain): Combine the flow in the flow combiner.
(webkit_media_src_init): Initialize the flow combiner.
(webKitMediaSrcLinkStreamToSrcPad): Add the proxypad to the
combiner and set the chain function.
* platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h:
Declare the flow combiner.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/GUniquePtrGStreamer.h
Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h

index 80aaa8a..504734e 100644 (file)
@@ -1,3 +1,23 @@
+2018-07-13  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [GStreamer][MSE] Add GstFlowCombiner to handle non-linked inactive branches
+        https://bugs.webkit.org/show_bug.cgi?id=187636
+
+        Reviewed by Carlos Garcia Campos.
+
+        When we have more than one source buffer, only one will be
+        rendered and the inactive branch will report linking errors that
+        we have to deal with.
+
+        * platform/graphics/gstreamer/GUniquePtrGStreamer.h: Added GstFlowCombiner.
+        * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
+        (webkitMediaSrcChain): Combine the flow in the flow combiner.
+        (webkit_media_src_init): Initialize the flow combiner.
+        (webKitMediaSrcLinkStreamToSrcPad): Add the proxypad to the
+        combiner and set the chain function.
+        * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h:
+        Declare the flow combiner.
+
 2018-07-13  Charlie Turner  <cturner@igalia.com>
 
         [GStreamer] Add GstBufferMapped abstraction
index 2290abf..d3585ce 100644 (file)
@@ -21,6 +21,7 @@
 #define GUniquePtrGStreamer_h
 #if USE(GSTREAMER)
 
+#include <gst/base/gstflowcombiner.h>
 #include <gst/gstsegment.h>
 #include <gst/gststructure.h>
 #include <gst/pbutils/install-plugins.h>
@@ -31,6 +32,7 @@ namespace WTF {
 WTF_DEFINE_GPTR_DELETER(GstStructure, gst_structure_free)
 WTF_DEFINE_GPTR_DELETER(GstInstallPluginsContext, gst_install_plugins_context_free)
 WTF_DEFINE_GPTR_DELETER(GstSegment, gst_segment_free)
+WTF_DEFINE_GPTR_DELETER(GstFlowCombiner, gst_flow_combiner_free)
 
 }
 
index f63cea2..ee49e57 100644 (file)
@@ -48,7 +48,6 @@
 #include <gst/video/video.h>
 #include <wtf/Condition.h>
 #include <wtf/MainThread.h>
-#include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>
 
 GST_DEBUG_CATEGORY_STATIC(webkit_media_src_debug);
@@ -249,6 +248,13 @@ static void webkit_media_src_class_init(WebKitMediaSrcClass* klass)
     g_type_class_add_private(klass, sizeof(WebKitMediaSrcPrivate));
 }
 
+static GstFlowReturn webkitMediaSrcChain(GstPad* pad, GstObject* parent, GstBuffer* buffer)
+{
+    GRefPtr<WebKitMediaSrc> self = adoptGRef(WEBKIT_MEDIA_SRC(gst_object_get_parent(parent)));
+
+    return gst_flow_combiner_update_pad_flow(self->priv->flowCombiner.get(), pad, gst_proxy_pad_chain_default(pad, GST_OBJECT(self.get()), buffer));
+}
+
 static void webkit_media_src_init(WebKitMediaSrc* source)
 {
     source->priv = WEBKIT_MEDIA_SRC_GET_PRIVATE(source);
@@ -257,6 +263,7 @@ static void webkit_media_src_init(WebKitMediaSrc* source)
     source->priv->appsrcSeekDataCount = 0;
     source->priv->appsrcNeedDataCount = 0;
     source->priv->appsrcSeekDataNextAction = Nothing;
+    source->priv->flowCombiner = GUniquePtr<GstFlowCombiner>(gst_flow_combiner_new());
 
     // No need to reset Stream.appsrcNeedDataFlag because there are no Streams at this point yet.
 }
@@ -474,6 +481,9 @@ void webKitMediaSrcLinkStreamToSrcPad(GstPad* sourcePad, Stream* stream)
     GUniquePtr<gchar> padName(g_strdup_printf("src_%u", padId));
     GstPad* ghostpad = WebCore::webkitGstGhostPadFromStaticTemplate(&srcTemplate, padName.get(), sourcePad);
 
+    auto proxypad = adoptGRef(GST_PAD(gst_proxy_pad_get_internal(GST_PROXY_PAD(ghostpad))));
+    gst_flow_combiner_add_pad(stream->parent->priv->flowCombiner.get(), proxypad.get());
+    gst_pad_set_chain_function(proxypad.get(), static_cast<GstPadChainFunction>(webkitMediaSrcChain));
     gst_pad_set_query_function(ghostpad, webKitMediaSrcQueryWithParent);
 
     gst_pad_set_active(ghostpad, TRUE);
index 980cec3..9d7eab9 100644 (file)
@@ -23,6 +23,7 @@
 #if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE)
 
 #include "AudioTrackPrivateGStreamer.h"
+#include "GUniquePtrGStreamer.h"
 #include "SourceBufferPrivateGStreamer.h"
 #include "VideoTrackPrivateGStreamer.h"
 #include "WebKitMediaSourceGStreamer.h"
@@ -121,6 +122,8 @@ struct _WebKitMediaSrcPrivate {
 
     GRefPtr<GstBus> bus;
     WebCore::MediaPlayerPrivateGStreamerMSE* mediaPlayerPrivate;
+
+    GUniquePtr<GstFlowCombiner> flowCombiner;
 };
 
 extern guint webKitMediaSrcSignals[LAST_SIGNAL];