From 1a300eb50967e88ad73ffeeb44a84e268d4705b8 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Tue, 21 Jan 2014 13:42:38 +0100 Subject: [PATCH] rtprtxsend: ensure that no rtx buffers are sent after EOS To do that, enqueue the EOS event to be sent from the srcpad task thread and flush the queue right afterwards, so that no more rtx buffers can be sent, even if there are more requests coming in. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=722370 --- gst/rtpmanager/gstrtprtxsend.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gst/rtpmanager/gstrtprtxsend.c b/gst/rtpmanager/gstrtprtxsend.c index e20a0be916..ab246f8311 100644 --- a/gst/rtpmanager/gstrtprtxsend.c +++ b/gst/rtpmanager/gstrtprtxsend.c @@ -577,6 +577,10 @@ gst_rtp_rtx_send_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) gst_pad_start_task (rtx->srcpad, (GstTaskFunction) gst_rtp_rtx_send_src_loop, rtx, NULL); return TRUE; + case GST_EVENT_EOS: + GST_INFO_OBJECT (rtx, "Got EOS - enqueueing it"); + gst_rtp_rtx_send_push_out (rtx, event); + return TRUE; case GST_EVENT_CAPS: { GstCaps *caps; @@ -698,11 +702,23 @@ gst_rtp_rtx_send_src_loop (GstRtpRtxSend * rtx) if (gst_data_queue_pop (rtx->queue, &data)) { GST_LOG_OBJECT (rtx, "pushing rtx buffer %p", data->object); - gst_pad_push (rtx->srcpad, GST_BUFFER (data->object)); + if (G_LIKELY (GST_IS_BUFFER (data->object))) { + gst_pad_push (rtx->srcpad, GST_BUFFER (data->object)); - GST_OBJECT_LOCK (rtx); - rtx->num_rtx_packets++; - GST_OBJECT_UNLOCK (rtx); + GST_OBJECT_LOCK (rtx); + rtx->num_rtx_packets++; + GST_OBJECT_UNLOCK (rtx); + } else if (GST_IS_EVENT (data->object)) { + gst_pad_push_event (rtx->srcpad, GST_EVENT (data->object)); + + /* after EOS, we should not send any more buffers, + * even if there are more requests coming in */ + if (GST_EVENT_TYPE (data->object) == GST_EVENT_EOS) { + gst_rtp_rtx_send_set_flushing (rtx, TRUE); + } + } else { + g_assert_not_reached (); + } data->object = NULL; /* we no longer own that object */ data->destroy (data);