Title: [279285] trunk/Source/WebCore
Revision
279285
Author
[email protected]
Date
2021-06-25 08:39:12 -0700 (Fri, 25 Jun 2021)

Log Message

[GStreamer] TextCombiner has unlinked internal encoders
https://bugs.webkit.org/show_bug.cgi?id=227362

Reviewed by Xabier Rodriguez-Calvar.

Each combiner pad can receive multiple caps events for the same stream, so we can't really
rely on those to modify the internal topology of the combiner. Instead we can check the
sticky events from the pad chain function, this is done at most once per pad. In case a caps
event was sticked to the pad, the combiner now reacts properly.

This issue was detected while running
media/track/in-band/track-in-band-kate-ogg-cues-added-once.html with playbin3 enabled. 6
different encoders where added to the combiner while only 2 are needed actually.

* platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
(webKitTextCombinerHandleCaps):
* platform/graphics/gstreamer/TextCombinerGStreamer.h:
* platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp:
(webkitTextCombinerPadChain):
(webkitTextCombinerPadConstructed):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279284 => 279285)


--- trunk/Source/WebCore/ChangeLog	2021-06-25 15:28:43 UTC (rev 279284)
+++ trunk/Source/WebCore/ChangeLog	2021-06-25 15:39:12 UTC (rev 279285)
@@ -1,3 +1,26 @@
+2021-06-25  Philippe Normand  <[email protected]>
+
+        [GStreamer] TextCombiner has unlinked internal encoders
+        https://bugs.webkit.org/show_bug.cgi?id=227362
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Each combiner pad can receive multiple caps events for the same stream, so we can't really
+        rely on those to modify the internal topology of the combiner. Instead we can check the
+        sticky events from the pad chain function, this is done at most once per pad. In case a caps
+        event was sticked to the pad, the combiner now reacts properly.
+
+        This issue was detected while running
+        media/track/in-band/track-in-band-kate-ogg-cues-added-once.html with playbin3 enabled. 6
+        different encoders where added to the combiner while only 2 are needed actually.
+
+        * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
+        (webKitTextCombinerHandleCaps):
+        * platform/graphics/gstreamer/TextCombinerGStreamer.h:
+        * platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp:
+        (webkitTextCombinerPadChain):
+        (webkitTextCombinerPadConstructed):
+
 2021-06-17  Sergio Villar Senin  <[email protected]>
 
         Nullptr crash in StyledMarkupAccumulator::traverseNodesForSerialization

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp (279284 => 279285)


--- trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp	2021-06-25 15:28:43 UTC (rev 279284)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp	2021-06-25 15:39:12 UTC (rev 279285)
@@ -50,10 +50,8 @@
 
 using namespace WebCore;
 
-void webKitTextCombinerHandleCapsEvent(WebKitTextCombiner* combiner, GstPad* pad, GstEvent* event)
+void webKitTextCombinerHandleCaps(WebKitTextCombiner* combiner, GstPad* pad, const GstCaps* caps)
 {
-    GstCaps* caps;
-    gst_event_parse_caps(event, &caps);
     ASSERT(caps);
     GST_DEBUG_OBJECT(combiner, "Handling caps %" GST_PTR_FORMAT, caps);
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.h (279284 => 279285)


--- trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.h	2021-06-25 15:28:43 UTC (rev 279284)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.h	2021-06-25 15:39:12 UTC (rev 279285)
@@ -56,6 +56,6 @@
 
 GstElement* webkitTextCombinerNew();
 
-void webKitTextCombinerHandleCapsEvent(WebKitTextCombiner*, GstPad*, GstEvent*);
+void webKitTextCombinerHandleCaps(WebKitTextCombiner*, GstPad*, const GstCaps*);
 
 #endif // ENABLE(VIDEO) && USE(GSTREAMER)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp (279284 => 279285)


--- trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp	2021-06-25 15:28:43 UTC (rev 279284)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp	2021-06-25 15:39:12 UTC (rev 279285)
@@ -36,6 +36,7 @@
 struct _WebKitTextCombinerPadPrivate {
     GRefPtr<GstTagList> tags;
     GRefPtr<GstPad> innerCombinerPad;
+    bool shouldProcessStickyEvents { true };
 };
 
 enum {
@@ -53,9 +54,6 @@
 static gboolean webkitTextCombinerPadEvent(GstPad* pad, GstObject* parent, GstEvent* event)
 {
     switch (GST_EVENT_TYPE(event)) {
-    case GST_EVENT_CAPS:
-        webKitTextCombinerHandleCapsEvent(WEBKIT_TEXT_COMBINER(parent), pad, event);
-        break;
     case GST_EVENT_TAG: {
         auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
         GstTagList* tags;
@@ -79,6 +77,28 @@
     return gst_pad_event_default(pad, parent, event);
 }
 
+static GstFlowReturn webkitTextCombinerPadChain(GstPad* pad, GstObject* parent, GstBuffer* buffer)
+{
+    auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
+
+    if (combinerPad->priv->shouldProcessStickyEvents) {
+        gst_pad_sticky_events_foreach(pad, [](GstPad* pad, GstEvent** event, gpointer) -> gboolean {
+            if (GST_EVENT_TYPE(*event) != GST_EVENT_CAPS)
+                return TRUE;
+
+            auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
+            auto parent = adoptGRef(gst_pad_get_parent(pad));
+            GstCaps* caps;
+            gst_event_parse_caps(*event, &caps);
+            combinerPad->priv->shouldProcessStickyEvents = false;
+            webKitTextCombinerHandleCaps(WEBKIT_TEXT_COMBINER(parent.get()), pad, caps);
+            return FALSE;
+        }, nullptr);
+    }
+
+    return gst_proxy_pad_chain_default(pad, parent, buffer);
+}
+
 static void webkitTextCombinerPadGetProperty(GObject* object, unsigned propertyId, GValue* value, GParamSpec* pspec)
 {
     auto* pad = WEBKIT_TEXT_COMBINER_PAD(object);
@@ -120,6 +140,7 @@
     GST_CALL_PARENT(G_OBJECT_CLASS, constructed, (object));
     gst_ghost_pad_construct(GST_GHOST_PAD(object));
     gst_pad_set_event_function(GST_PAD_CAST(object), webkitTextCombinerPadEvent);
+    gst_pad_set_chain_function(GST_PAD_CAST(object), webkitTextCombinerPadChain);
 }
 
 static void webkit_text_combiner_pad_class_init(WebKitTextCombinerPadClass* klass)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to