summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-08-21 03:02:40 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-09-09 17:46:40 +0000
commit5699ada939bec5a1317d4a7d1fb6e0afd70fad7e (patch)
treed3898eff92e574faf17f98a9f688db9aa50ddae5
parent883ddc72bb5bc57c95a9e167814d1ac53fe1b443 (diff)
rtsp-stream: preroll on gap events
This allows negotiating a SDP with all streams present, but only start sending packets at some later point in time Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/-/merge_requests/146>
-rw-r--r--gst/rtsp-server/rtsp-stream.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c
index 7ef3511..fecb183 100644
--- a/gst/rtsp-server/rtsp-stream.c
+++ b/gst/rtsp-server/rtsp-stream.c
@@ -5179,35 +5179,47 @@ pad_blocking (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
GstRTSPStreamPrivate *priv;
GstRTSPStream *stream;
GstBuffer *buffer = NULL;
+ GstPadProbeReturn ret = GST_PAD_PROBE_OK;
stream = user_data;
priv = stream->priv;
- GST_DEBUG_OBJECT (pad, "now blocking");
-
g_mutex_lock (&priv->lock);
- priv->blocking = TRUE;
if ((info->type & GST_PAD_PROBE_TYPE_BUFFER)) {
buffer = gst_pad_probe_info_get_buffer (info);
+ priv->position = GST_BUFFER_TIMESTAMP (buffer);
} else if ((info->type & GST_PAD_PROBE_TYPE_BUFFER_LIST)) {
GstBufferList *list = gst_pad_probe_info_get_buffer_list (info);
buffer = gst_buffer_list_get (list, 0);
+ priv->position = GST_BUFFER_TIMESTAMP (buffer);
+ } else if ((info->type & GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM)) {
+ if (GST_EVENT_TYPE (info->data) == GST_EVENT_GAP) {
+ gst_event_parse_gap (info->data, &priv->position, NULL);
+ } else {
+ ret = GST_PAD_PROBE_PASS;
+ g_mutex_unlock (&priv->lock);
+ goto done;
+ }
} else {
g_assert_not_reached ();
}
- g_assert (buffer);
- priv->position = GST_BUFFER_TIMESTAMP (buffer);
- GST_DEBUG_OBJECT (stream, "buffer position: %" GST_TIME_FORMAT,
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
+ priv->blocking = TRUE;
+
+ GST_DEBUG_OBJECT (pad, "Now blocking");
+
+ GST_DEBUG_OBJECT (stream, "position: %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (priv->position));
+
g_mutex_unlock (&priv->lock);
gst_element_post_message (priv->payloader,
gst_message_new_element (GST_OBJECT_CAST (priv->payloader),
gst_structure_new_empty ("GstRTSPStreamBlocking")));
- return GST_PAD_PROBE_OK;
+done:
+ return ret;
}
static void
@@ -5233,7 +5245,8 @@ set_blocked (GstRTSPStream * stream, gboolean blocked)
priv->blocking = FALSE;
priv->blocked_id[i] = gst_pad_add_probe (priv->send_src[i],
GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER |
- GST_PAD_PROBE_TYPE_BUFFER_LIST, pad_blocking,
+ GST_PAD_PROBE_TYPE_BUFFER_LIST |
+ GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, pad_blocking,
g_object_ref (stream), g_object_unref);
}
}