/* overwrite with our values when we need to */
g_mutex_lock (&priv->mutex);
- if (priv->min_latency != -1)
+ if (priv->min_latency != -1) {
min = priv->min_latency;
- if (priv->max_latency != -1)
max = priv->max_latency;
+ }
g_mutex_unlock (&priv->mutex);
gst_query_set_latency (query, live, min, max);
* amount of time. */
max_latency = (max_l == -1) ? -1 : (base_latency + max_l);
-
GST_DEBUG_OBJECT (basesink,
"peer min %" GST_TIME_FORMAT ", our min latency: %"
GST_TIME_FORMAT, GST_TIME_ARGS (min_l),
/* init state */
dec->priv->ctx.min_latency = 0;
- dec->priv->ctx.max_latency = GST_CLOCK_TIME_NONE;
+ dec->priv->ctx.max_latency = 0;
gst_audio_decoder_reset (dec, TRUE);
GST_DEBUG_OBJECT (dec, "init ok");
}
GST_OBJECT_LOCK (dec);
/* add our latency */
- if (min_latency != -1)
- min_latency += dec->priv->ctx.min_latency;
- if (max_latency != -1 && dec->priv->ctx.max_latency != -1)
+ min_latency += dec->priv->ctx.min_latency;
+ if (max_latency == -1 || dec->priv->ctx.max_latency == -1)
+ max_latency = -1;
+ else
max_latency += dec->priv->ctx.max_latency;
GST_OBJECT_UNLOCK (dec);
/* init state */
enc->priv->ctx.min_latency = 0;
- enc->priv->ctx.max_latency = GST_CLOCK_TIME_NONE;
+ enc->priv->ctx.max_latency = 0;
gst_audio_encoder_reset (enc, TRUE);
GST_DEBUG_OBJECT (enc, "init ok");
}
GST_OBJECT_LOCK (enc);
/* add our latency */
- if (min_latency != -1)
- min_latency += enc->priv->ctx.min_latency;
- if (max_latency != -1 && enc->priv->ctx.max_latency != -1)
+ min_latency += enc->priv->ctx.min_latency;
+ if (max_latency == -1 || enc->priv->ctx.max_latency == -1)
+ max_latency = -1;
+ else
max_latency += enc->priv->ctx.max_latency;
GST_OBJECT_UNLOCK (enc);
decoder->priv->needs_format = FALSE;
decoder->priv->min_latency = 0;
- decoder->priv->max_latency = GST_CLOCK_TIME_NONE;
+ decoder->priv->max_latency = 0;
gst_video_decoder_reset (decoder, TRUE, TRUE);
}
GST_OBJECT_LOCK (dec);
min_latency += dec->priv->min_latency;
- if (max_latency != GST_CLOCK_TIME_NONE
- && dec->priv->max_latency != GST_CLOCK_TIME_NONE) {
+ if (max_latency == GST_CLOCK_TIME_NONE
+ || dec->priv->max_latency == GST_CLOCK_TIME_NONE)
+ max_latency = GST_CLOCK_TIME_NONE;
+ else
max_latency += dec->priv->max_latency;
- } else if (dec->priv->max_latency != GST_CLOCK_TIME_NONE) {
- max_latency = dec->priv->max_latency;
- }
GST_OBJECT_UNLOCK (dec);
gst_query_set_latency (query, live, min_latency, max_latency);
priv->new_headers = FALSE;
priv->min_latency = 0;
- priv->max_latency = GST_CLOCK_TIME_NONE;
+ priv->max_latency = 0;
gst_video_encoder_reset (encoder, TRUE);
}
GST_OBJECT_LOCK (enc);
min_latency += priv->min_latency;
- if (max_latency != GST_CLOCK_TIME_NONE
- && enc->priv->max_latency != GST_CLOCK_TIME_NONE) {
+ if (max_latency == GST_CLOCK_TIME_NONE
+ || enc->priv->max_latency == GST_CLOCK_TIME_NONE)
+ max_latency = GST_CLOCK_TIME_NONE;
+ else
max_latency += enc->priv->max_latency;
- } else if (enc->priv->max_latency != GST_CLOCK_TIME_NONE) {
- max_latency = enc->priv->max_latency;
- }
GST_OBJECT_UNLOCK (enc);
gst_query_set_latency (query, live, min_latency, max_latency);
if (res) {
gst_query_parse_latency (peerquery, &live_cur, &min_cur, &max_cur);
- if (min_cur > min)
- min = min_cur;
+ if (live_cur) {
+ if (min_cur > min)
+ min = min_cur;
- if (max_cur != GST_CLOCK_TIME_NONE &&
- ((max != GST_CLOCK_TIME_NONE && max_cur > max) ||
- (max == GST_CLOCK_TIME_NONE)))
- max = max_cur;
+ if (max == GST_CLOCK_TIME_NONE)
+ max = max_cur;
+ else if (max_cur < max)
+ max = max_cur;
- live = live || live_cur;
+ live = TRUE;
+ }
}
gst_query_unref (peerquery);
"got latency min %" GST_TIME_FORMAT ", max %" GST_TIME_FORMAT
", live %d", GST_TIME_ARGS (min), GST_TIME_ARGS (max), live);
- /* for the combined latency we collect the MAX of all min latencies and
- * the MIN of all max latencies */
- if (min > fold->min)
- fold->min = min;
- if (fold->max == -1)
- fold->max = max;
- else if (max < fold->max)
- fold->max = max;
- if (!fold->live)
- fold->live = live;
+ if (live) {
+ /* for the combined latency we collect the MAX of all min latencies and
+ * the MIN of all max latencies */
+ if (min > fold->min)
+ fold->min = min;
+ if (fold->max == -1)
+ fold->max = max;
+ else if (max < fold->max)
+ fold->max = max;
+
+ fold->live = TRUE;
+ }
}
return TRUE;