Skip to content

Commit d89d709

Browse files
emutavchieocanha
authored andcommitted
[MSE][GStreamer] always reset appsink/parser state when recycling the track
https://bugs.webkit.org/show_bug.cgi?id=263532 Reviewed by Alicia Boya Garcia. After applying [1], appsink can receive EOS event that was sent by qtdemux before removing an "old" streamd. This marks the sink as "received_eos" and makes it reject any events from subsequent appends. Resulting in append failing with ParsingFailed error. See: #1208 Original author: Eugene Mutavchi <Ievgen_Mutavchi@comcast.com> [1] https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4535 * Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp: (WebCore::AppendPipeline::recycleTrackForPad): Unconditionally change the parser and appsink to NULL and PLAYING. Canonical link: https://commits.webkit.org/269761@main
1 parent c6df424 commit d89d709

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -864,16 +864,21 @@ bool AppendPipeline::recycleTrackForPad(GstPad* demuxerSrcPad)
864864
return false;
865865
}
866866

867+
// The https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4535 merge request in qtdemux is causing EOS on
868+
// a "to be removed" stream before the no-more-pads message is triggered. That message makes AppendPipeline realize that
869+
// the stream is actually going to be removed. AppendPipeline may therefore be trying to reuse a former EOSed parser and
870+
// appsink elements from the old terminated stream, so "restarting" them (by stopping them now and restarting them at the
871+
// end) is required.
872+
// Note that what happens before qtdemux is irrelevant. Qtdemux itself is never receiving EOS in this case.
873+
if (matchingTrack->parser)
874+
gst_element_set_state(matchingTrack->parser.get(), GST_STATE_NULL);
875+
gst_element_set_state(matchingTrack->appsink.get(), GST_STATE_NULL);
876+
867877
GRefPtr<GstCaps> matchingTrackCaps = adoptGRef(gst_pad_get_current_caps(matchingTrack->entryPad.get()));
868878
if (!matchingTrack->isLinked() && (!matchingTrackCaps || gst_caps_can_intersect(parsedCaps.get(), matchingTrackCaps.get())))
869879
linkPadWithTrack(demuxerSrcPad, *matchingTrack);
870880
else {
871-
// Unlink from old track and link to new track, by 1. stopping parser/sink, 2. unlinking
872-
// demuxer from track, 3. restarting parser/sink.
873-
if (matchingTrack->parser)
874-
gst_element_set_state(matchingTrack->parser.get(), GST_STATE_NULL);
875-
gst_element_set_state(matchingTrack->appsink.get(), GST_STATE_NULL);
876-
881+
// Unlink from old track and link to new track.
877882
auto peer = adoptGRef(gst_pad_get_peer(matchingTrack->entryPad.get()));
878883
if (peer.get() != demuxerSrcPad) {
879884
if (peer) {
@@ -892,10 +897,12 @@ bool AppendPipeline::recycleTrackForPad(GstPad* demuxerSrcPad)
892897
} else
893898
GST_DEBUG_OBJECT(pipeline(), "%s track pads match, nothing to re-link", matchingTrack->trackId.string().ascii().data());
894899

895-
gst_element_set_state(matchingTrack->appsink.get(), GST_STATE_PLAYING);
896-
if (matchingTrack->parser)
897-
gst_element_set_state(matchingTrack->parser.get(), GST_STATE_PLAYING);
898900
}
901+
902+
gst_element_set_state(matchingTrack->appsink.get(), GST_STATE_PLAYING);
903+
if (matchingTrack->parser)
904+
gst_element_set_state(matchingTrack->parser.get(), GST_STATE_PLAYING);
905+
899906
return true;
900907
}
901908

0 commit comments

Comments
 (0)