diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2022-10-21 16:23:08 +0300 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2022-10-26 19:44:57 +0300 |
commit | d186e195684548f13855ba5e9ef618a0a5b8951b (patch) | |
tree | c3016b0a57bb87a08259076923289d6f788d2fe6 | |
parent | 98bc763f2b306c6d5f40cc23e7127911d363dbba (diff) |
rtspsrc: Only EOS on timeout if all streams are timed out/EOS
Otherwise a stream that is just temporarily inactive might time out and
then can never become active again because the EOS event was sent
already.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3271>
-rw-r--r-- | subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c index d1e469ad0d..5bc37c6027 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c @@ -3620,8 +3620,39 @@ on_timeout_common (GObject * session, GObject * source, GstRTSPStream * stream) GST_WARNING_OBJECT (src, "source %08x, stream %08x in session %u timed out", ssrc, stream->ssrc, stream->id); - if (ssrc == stream->ssrc) - gst_rtspsrc_do_stream_eos (src, stream); + if (ssrc == stream->ssrc) { + GList *walk; + gboolean all_eos = TRUE; + + GST_DEBUG_OBJECT (src, "setting stream for session %u to EOS", stream->id); + stream->eos = TRUE; + + /* Only EOS all streams at once if they're all EOS. Otherwise it is + * possible for timed out streams to reappear at a later time time: they + * might just be inactive currently. + */ + + for (walk = src->streams; walk; walk = g_list_next (walk)) { + GstRTSPStream *stream = (GstRTSPStream *) walk->data; + + /* Skip streams that were not set up at all */ + if (!stream->setup) + continue; + + if (!stream->eos) { + all_eos = FALSE; + break; + } + } + + if (all_eos) { + GST_DEBUG_OBJECT (src, "sending EOS on all streams"); + for (walk = src->streams; walk; walk = g_list_next (walk)) { + GstRTSPStream *stream = (GstRTSPStream *) walk->data; + gst_rtspsrc_stream_push_event (src, stream, gst_event_new_eos ()); + } + } + } } static void @@ -3662,6 +3693,8 @@ on_ssrc_active (GObject * session, GObject * source, GstRTSPStream * stream) { GST_DEBUG_OBJECT (stream->parent, "source in session %u is active", stream->id); + + stream->eos = FALSE; } static void |