From 52eb796bec687faa8d0f4c221cb989cd68574543 Mon Sep 17 00:00:00 2001 From: David Svensson Fors Date: Tue, 11 Jun 2013 15:28:32 +0200 Subject: [PATCH] media: use segment stop in collect_media_stats Use segment stop instead of duration as range end point. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=701185 --- gst/rtsp-server/rtsp-media.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index 2482c8e..199eb54 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -350,7 +350,8 @@ static void collect_media_stats (GstRTSPMedia * media) { GstRTSPMediaPrivate *priv = media->priv; - gint64 position, duration; + GstQuery *query; + gint64 position, stop; if (priv->status != GST_RTSP_MEDIA_STATUS_PREPARED && priv->status != GST_RTSP_MEDIA_STATUS_PREPARING) @@ -375,15 +376,18 @@ collect_media_stats (GstRTSPMedia * media) position = 0; } - /* get the duration */ - if (!gst_element_query_duration (priv->pipeline, GST_FORMAT_TIME, - &duration)) { - GST_INFO ("duration query failed"); - duration = -1; + /* get the current segment stop */ + query = gst_query_new_segment (GST_FORMAT_TIME); + if (gst_element_query (priv->pipeline, query)) { + gst_query_parse_segment (query, NULL, NULL, NULL, &stop); + } else { + GST_INFO ("segment query failed"); + stop = -1; } + gst_query_unref (query); - GST_INFO ("stats: position %" GST_TIME_FORMAT ", duration %" - GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (duration)); + GST_INFO ("stats: position %" GST_TIME_FORMAT ", stop %" + GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (stop)); if (position == -1) { priv->range.min.type = GST_RTSP_TIME_NOW; @@ -394,14 +398,14 @@ collect_media_stats (GstRTSPMedia * media) priv->range.min.seconds = ((gdouble) position) / GST_SECOND; priv->range_start = position; } - if (duration == -1) { + if (stop == -1) { priv->range.max.type = GST_RTSP_TIME_END; priv->range.max.seconds = -1; priv->range_stop = -1; } else { priv->range.max.type = GST_RTSP_TIME_SECONDS; - priv->range.max.seconds = ((gdouble) duration) / GST_SECOND; - priv->range_stop = duration; + priv->range.max.seconds = ((gdouble) stop) / GST_SECOND; + priv->range_stop = stop; } } } -- 2.7.4