From: Wim Taymans Date: Thu, 19 Jul 2012 08:54:16 +0000 (+0200) Subject: queue2: fix the buffering-left in the buffering message X-Git-Tag: RELEASE-0.11.93~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14550f2ee2fc37f93a025f8d1b49ae92352aa6b9;p=platform%2Fupstream%2Fgstreamer.git queue2: fix the buffering-left in the buffering message The buffering-left field in the buffering message should contain a time estimate in milliseconds about for long the buffering is going to take. We can calculate this value when we do rate_estimates. --- diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index 206285f..1587425 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -779,7 +779,6 @@ update_buffering (GstQueue2 * queue) GST_LOG_OBJECT (queue, "we are EOS"); } else { /* figure out the percent we are filled, we take the max of all formats. */ - if (!QUEUE_IS_USING_RING_BUFFER (queue)) { percent = GET_PERCENT (bytes, 0); } else { @@ -811,7 +810,7 @@ update_buffering (GstQueue2 * queue) if (post) { GstMessage *message; GstBufferingMode mode; - gint64 buffering_left = -1; + gint64 buffering_left; /* scale to high percent so that it becomes the 100% mark */ percent = percent * 100 / queue->high_percent; @@ -819,31 +818,29 @@ update_buffering (GstQueue2 * queue) if (percent > 100) percent = 100; + buffering_left = (percent == 100 ? 0 : -1); + if (percent != queue->buffering_percent) { queue->buffering_percent = percent; if (!QUEUE_IS_USING_QUEUE (queue)) { - gint64 duration; - if (QUEUE_IS_USING_RING_BUFFER (queue)) mode = GST_BUFFERING_TIMESHIFT; else mode = GST_BUFFERING_DOWNLOAD; - - if (queue->byte_in_rate > 0) { - if (gst_pad_peer_query_duration (queue->sinkpad, GST_FORMAT_BYTES, - &duration)) { - buffering_left = - (gdouble) ((duration - - queue->current->writing_pos) * 1000) / queue->byte_in_rate; - } - } else { - buffering_left = G_MAXINT64; - } } else { mode = GST_BUFFERING_STREAM; } + if (queue->use_rate_estimate) { + guint64 max, cur; + + max = queue->max_level.rate_time; + cur = queue->cur_level.rate_time; + if (percent != 100 && max > cur) + buffering_left = (max - cur) / 1000000; + } + GST_DEBUG_OBJECT (queue, "buffering %d percent", (gint) percent); message = gst_message_new_buffering (GST_OBJECT_CAST (queue), (gint) percent);