Skip to content

Commit

Permalink
Cherry-pick 262144@main (9bc4d3c). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=228820

    [MSE][GStreamer] Missing support for aborts not followed by an initialization segment
    https://bugs.webkit.org/show_bug.cgi?id=228820

    This patch performs a flush on the AppendPipeline on SourceBuffer::abort().
    Such action drains the AppendPipeline but leaves the demuxer still configured with
    the context provided by the last init segment. This is in compliance with the spec,
    which mandates that there's no need to append an init segment after an abort,
    because the last one should be reused.

    For this patch to work, the following GStreamer merge requests, scheduled to be
    landed on 1.23.1, must be present:
    https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4101.
    https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4199.

    If the GStreamer version is lower than the required one, the old reset technique,
    consisting of setting the pipeline to READY and then PLAYING, is applied.

    In the current circumstances, the layout tests still don't pass, so this patch
    isn't unskipping them yet. media-mp4-h264-partial-abort.html should be unskipped
    when we start using a GStreamer version that includes the MRs.
    media-webm-opus-partial-abort.html should be unskipped when
    #11807 lands.

    See: WebPlatformForEmbedded/WPEWebKit#1016

    Reviewed by Alicia Boya Garcia.

    * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:
    (WebCore::AppendPipeline::resetParserState): If supported by GStreamer, perform a flush instead of setting the pipeline state to READY and then again to PLAYING.

    Canonical link: https://commits.webkit.org/262144@main
  • Loading branch information
eocanha authored and aperezdc committed Apr 27, 2023
1 parent cabee89 commit a42f850
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
Expand Up @@ -566,22 +566,33 @@ void AppendPipeline::consumeAppsinksAvailableSamples()
void AppendPipeline::resetParserState()
{
ASSERT(isMainThread());
GST_DEBUG_OBJECT(pipeline(), "Handling resetParserState() in AppendPipeline by resetting the pipeline");

// FIXME: Implement a flush event-based resetParserState() implementation would allow the initialization segment to
// survive, in accordance with the spec.

// This function restores the GStreamer pipeline to the same state it was when the AppendPipeline constructor
// finished. All previously enqueued data is lost and the demuxer is reset, losing all pads and track data.
// finished. All previously enqueued data is lost and the demuxer is flushed, but retains the configuration from the
// last received init segment, in accordance to the spec.

// Unlock the streaming thread.
m_taskQueue.startAborting();

// Reset the state of all elements in the pipeline.
assertedElementSetState(m_pipeline.get(), GST_STATE_READY);
// Flush approach requires these GStreamer patches, scheduled to land on 1.23.1:
// https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4101.
// https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4199.
if (webkitGstCheckVersion(1, 23, 1)) {
GST_DEBUG_OBJECT(pipeline(), "Handling resetParserState() in AppendPipeline by flushing the pipeline");
gst_element_send_event(m_appsrc.get(), gst_event_new_flush_start());
gst_element_send_event(m_appsrc.get(), gst_event_new_flush_stop(true));

// Set the pipeline to PLAYING so that it can be used again.
assertedElementSetState(m_pipeline.get(), GST_STATE_PLAYING);
GstSegment segment;
gst_segment_init(&segment, GST_FORMAT_BYTES);
gst_element_send_event(m_appsrc.get(), gst_event_new_segment(&segment));
} else {
GST_DEBUG_OBJECT(pipeline(), "Handling resetParserState() in AppendPipeline by resetting the pipeline");
// Reset the state of all elements in the pipeline.
assertedElementSetState(m_pipeline.get(), GST_STATE_READY);

// Set the pipeline to PLAYING so that it can be used again.
assertedElementSetState(m_pipeline.get(), GST_STATE_PLAYING);
}

// All processing related to the previous append has been aborted and the pipeline is idle.
// We can listen again to new requests coming from the streaming thread.
Expand Down

0 comments on commit a42f850

Please sign in to comment.