Improve and fix LATENCY query handling

This now follows the design docs everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=744106
This commit is contained in:
Sebastian Dröge 2015-02-11 13:41:56 +01:00
parent ee8d67ef2c
commit 4a5ce862a2
5 changed files with 16 additions and 8 deletions

View file

@ -413,6 +413,7 @@ gst_query_set_latency (GstQuery * query, gboolean live,
GstStructure *structure;
g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_LATENCY);
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency));
structure = GST_QUERY_STRUCTURE (query);
gst_structure_id_set (structure,

View file

@ -3754,6 +3754,9 @@ void
gst_base_parse_set_latency (GstBaseParse * parse, GstClockTime min_latency,
GstClockTime max_latency)
{
g_return_if_fail (min_latency != GST_CLOCK_TIME_NONE);
g_return_if_fail (min_latency <= max_latency);
GST_OBJECT_LOCK (parse);
parse->priv->min_latency = min_latency;
parse->priv->max_latency = max_latency;
@ -3923,9 +3926,10 @@ gst_base_parse_src_query_default (GstBaseParse * parse, GstQuery * query)
GST_OBJECT_LOCK (parse);
/* add our latency */
if (min_latency != -1)
min_latency += parse->priv->min_latency;
if (max_latency != -1)
min_latency += parse->priv->min_latency;
if (max_latency == -1 || parse->priv->max_latency == -1)
max_latency = -1;
else
max_latency += parse->priv->max_latency;
GST_OBJECT_UNLOCK (parse);

View file

@ -1086,8 +1086,7 @@ gst_base_sink_query_latency (GstBaseSink * sink, gboolean * live,
}
if (l) {
/* we need to add the render delay if we are live */
if (min != -1)
min += render_delay;
min += render_delay;
if (max != -1)
max += render_delay;
}

View file

@ -726,7 +726,7 @@ gst_base_src_query_latency (GstBaseSrc * src, gboolean * live,
if (min_latency)
*min_latency = min;
if (max_latency)
*max_latency = -1;
*max_latency = min;
GST_LOG_OBJECT (src, "latency: live %d, min %" GST_TIME_FORMAT
", max %" GST_TIME_FORMAT, src->is_live, GST_TIME_ARGS (min),

View file

@ -1435,13 +1435,17 @@ gst_queue_handle_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
* limit, the best thing we can do is to return an infinite delay. In
* reality a better estimate would be the byte/buffer rate but that is not
* possible right now. */
if (queue->max_size.time > 0 && max != -1)
/* TODO: Use CONVERT query? */
if (queue->max_size.time > 0 && max != -1
&& queue->leaky == GST_QUEUE_NO_LEAK)
max += queue->max_size.time;
else if (queue->max_size.time > 0 && queue->leaky != GST_QUEUE_NO_LEAK)
max = MIN (queue->max_size.time, max);
else
max = -1;
/* adjust for min-threshold */
if (queue->min_threshold.time > 0 && min != -1)
if (queue->min_threshold.time > 0)
min += queue->min_threshold.time;
gst_query_set_latency (query, live, min, max);