mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
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.
This commit is contained in:
parent
8a0f6da824
commit
14550f2ee2
1 changed files with 12 additions and 15 deletions
|
@ -779,7 +779,6 @@ update_buffering (GstQueue2 * queue)
|
||||||
GST_LOG_OBJECT (queue, "we are EOS");
|
GST_LOG_OBJECT (queue, "we are EOS");
|
||||||
} else {
|
} else {
|
||||||
/* figure out the percent we are filled, we take the max of all formats. */
|
/* figure out the percent we are filled, we take the max of all formats. */
|
||||||
|
|
||||||
if (!QUEUE_IS_USING_RING_BUFFER (queue)) {
|
if (!QUEUE_IS_USING_RING_BUFFER (queue)) {
|
||||||
percent = GET_PERCENT (bytes, 0);
|
percent = GET_PERCENT (bytes, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -811,7 +810,7 @@ update_buffering (GstQueue2 * queue)
|
||||||
if (post) {
|
if (post) {
|
||||||
GstMessage *message;
|
GstMessage *message;
|
||||||
GstBufferingMode mode;
|
GstBufferingMode mode;
|
||||||
gint64 buffering_left = -1;
|
gint64 buffering_left;
|
||||||
|
|
||||||
/* scale to high percent so that it becomes the 100% mark */
|
/* scale to high percent so that it becomes the 100% mark */
|
||||||
percent = percent * 100 / queue->high_percent;
|
percent = percent * 100 / queue->high_percent;
|
||||||
|
@ -819,31 +818,29 @@ update_buffering (GstQueue2 * queue)
|
||||||
if (percent > 100)
|
if (percent > 100)
|
||||||
percent = 100;
|
percent = 100;
|
||||||
|
|
||||||
|
buffering_left = (percent == 100 ? 0 : -1);
|
||||||
|
|
||||||
if (percent != queue->buffering_percent) {
|
if (percent != queue->buffering_percent) {
|
||||||
queue->buffering_percent = percent;
|
queue->buffering_percent = percent;
|
||||||
|
|
||||||
if (!QUEUE_IS_USING_QUEUE (queue)) {
|
if (!QUEUE_IS_USING_QUEUE (queue)) {
|
||||||
gint64 duration;
|
|
||||||
|
|
||||||
if (QUEUE_IS_USING_RING_BUFFER (queue))
|
if (QUEUE_IS_USING_RING_BUFFER (queue))
|
||||||
mode = GST_BUFFERING_TIMESHIFT;
|
mode = GST_BUFFERING_TIMESHIFT;
|
||||||
else
|
else
|
||||||
mode = GST_BUFFERING_DOWNLOAD;
|
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 {
|
} else {
|
||||||
mode = GST_BUFFERING_STREAM;
|
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);
|
GST_DEBUG_OBJECT (queue, "buffering %d percent", (gint) percent);
|
||||||
message = gst_message_new_buffering (GST_OBJECT_CAST (queue),
|
message = gst_message_new_buffering (GST_OBJECT_CAST (queue),
|
||||||
(gint) percent);
|
(gint) percent);
|
||||||
|
|
Loading…
Reference in a new issue