Changeset 279285 in webkit


Ignore:
Timestamp:
Jun 25, 2021, 8:39:12 AM (4 years ago)
Author:
Philippe Normand
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):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r279284 r279285  
     12021-06-25  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] TextCombiner has unlinked internal encoders
     4        https://bugs.webkit.org/show_bug.cgi?id=227362
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Each combiner pad can receive multiple caps events for the same stream, so we can't really
     9        rely on those to modify the internal topology of the combiner. Instead we can check the
     10        sticky events from the pad chain function, this is done at most once per pad. In case a caps
     11        event was sticked to the pad, the combiner now reacts properly.
     12
     13        This issue was detected while running
     14        media/track/in-band/track-in-band-kate-ogg-cues-added-once.html with playbin3 enabled. 6
     15        different encoders where added to the combiner while only 2 are needed actually.
     16
     17        * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
     18        (webKitTextCombinerHandleCaps):
     19        * platform/graphics/gstreamer/TextCombinerGStreamer.h:
     20        * platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp:
     21        (webkitTextCombinerPadChain):
     22        (webkitTextCombinerPadConstructed):
     23
    1242021-06-17  Sergio Villar Senin  <svillar@igalia.com>
    225
  • trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp

    r277947 r279285  
    5151using namespace WebCore;
    5252
    53 void webKitTextCombinerHandleCapsEvent(WebKitTextCombiner* combiner, GstPad* pad, GstEvent* event)
    54 {
    55     GstCaps* caps;
    56     gst_event_parse_caps(event, &caps);
     53void webKitTextCombinerHandleCaps(WebKitTextCombiner* combiner, GstPad* pad, const GstCaps* caps)
     54{
    5755    ASSERT(caps);
    5856    GST_DEBUG_OBJECT(combiner, "Handling caps %" GST_PTR_FORMAT, caps);
  • trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.h

    r271512 r279285  
    5757GstElement* webkitTextCombinerNew();
    5858
    59 void webKitTextCombinerHandleCapsEvent(WebKitTextCombiner*, GstPad*, GstEvent*);
     59void webKitTextCombinerHandleCaps(WebKitTextCombiner*, GstPad*, const GstCaps*);
    6060
    6161#endif // ENABLE(VIDEO) && USE(GSTREAMER)
  • trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerPadGStreamer.cpp

    r278655 r279285  
    3737    GRefPtr<GstTagList> tags;
    3838    GRefPtr<GstPad> innerCombinerPad;
     39    bool shouldProcessStickyEvents { true };
    3940};
    4041
     
    5455{
    5556    switch (GST_EVENT_TYPE(event)) {
    56     case GST_EVENT_CAPS:
    57         webKitTextCombinerHandleCapsEvent(WEBKIT_TEXT_COMBINER(parent), pad, event);
    58         break;
    5957    case GST_EVENT_TAG: {
    6058        auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
     
    7876    }
    7977    return gst_pad_event_default(pad, parent, event);
     78}
     79
     80static GstFlowReturn webkitTextCombinerPadChain(GstPad* pad, GstObject* parent, GstBuffer* buffer)
     81{
     82    auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
     83
     84    if (combinerPad->priv->shouldProcessStickyEvents) {
     85        gst_pad_sticky_events_foreach(pad, [](GstPad* pad, GstEvent** event, gpointer) -> gboolean {
     86            if (GST_EVENT_TYPE(*event) != GST_EVENT_CAPS)
     87                return TRUE;
     88
     89            auto* combinerPad = WEBKIT_TEXT_COMBINER_PAD(pad);
     90            auto parent = adoptGRef(gst_pad_get_parent(pad));
     91            GstCaps* caps;
     92            gst_event_parse_caps(*event, &caps);
     93            combinerPad->priv->shouldProcessStickyEvents = false;
     94            webKitTextCombinerHandleCaps(WEBKIT_TEXT_COMBINER(parent.get()), pad, caps);
     95            return FALSE;
     96        }, nullptr);
     97    }
     98
     99    return gst_proxy_pad_chain_default(pad, parent, buffer);
    80100}
    81101
     
    121141    gst_ghost_pad_construct(GST_GHOST_PAD(object));
    122142    gst_pad_set_event_function(GST_PAD_CAST(object), webkitTextCombinerPadEvent);
     143    gst_pad_set_chain_function(GST_PAD_CAST(object), webkitTextCombinerPadChain);
    123144}
    124145
Note: See TracChangeset for help on using the changeset viewer.