From: Wim Taymans Date: Mon, 10 Apr 2006 10:46:44 +0000 (+0000) Subject: gst/gstsegment.c: Added some more docs. X-Git-Tag: RELEASE-0_10_5~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2d86926f5d0a8eb19db06bc31130a8e2ae91cdb;p=platform%2Fupstream%2Fgstreamer.git gst/gstsegment.c: Added some more docs. Original commit message from CVS: * gst/gstsegment.c: Added some more docs. * libs/gst/base/gstbasesink.c: (gst_base_sink_perform_qos), (gst_base_sink_reset_qos): Calculate more accurate rate values. --- diff --git a/ChangeLog b/ChangeLog index b170324..e8324c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-04-10 Wim Taymans + + * gst/gstsegment.c: + Added some more docs. + + * libs/gst/base/gstbasesink.c: (gst_base_sink_perform_qos), + (gst_base_sink_reset_qos): + Calculate more accurate rate values. + 2006-04-09 Sebastien Moutte * gst/gst_private.h: diff --git a/gst/gstsegment.c b/gst/gstsegment.c index 2d13f9a..78da722 100644 --- a/gst/gstsegment.c +++ b/gst/gstsegment.c @@ -412,14 +412,18 @@ gst_segment_set_newsegment (GstSegment * segment, gboolean update, gdouble rate, * @position: the position in the segment * * Translate @position to stream time using the currently configured - * segment. + * segment. The @position value must be between @segment start and + * stop value. * * This function is typically used by elements that need to operate on * the stream time of the buffers it receives, such as effect plugins. + * In those use cases, @position is typically the buffer timestamp that + * one wants to convert to the stream time. * The stream time is always between 0 and the total duration of the - * media stream. + * media stream. * - * Returns: the position in stream_time. + * Returns: the position in stream_time or -1 when an invalid position + * was given. */ gint64 gst_segment_to_stream_time (GstSegment * segment, GstFormat format, diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 2c9459d..078f16f 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -1215,10 +1215,14 @@ gst_base_sink_perform_qos (GstBaseSink * sink, gboolean dropped) /* if we have the time when the last buffer left us, calculate * processing time */ - if (priv->last_left != -1 && entered > priv->last_left) { - pt = entered - priv->last_left; + if (priv->last_left != -1) { + if (entered > priv->last_left) { + pt = entered - priv->last_left; + } else { + pt = 0; + } } else { - pt = 0; + pt = priv->avg_pt; } GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, sink, "start: %" GST_TIME_FORMAT @@ -1233,9 +1237,6 @@ gst_base_sink_perform_qos (GstBaseSink * sink, gboolean dropped) GST_TIME_ARGS (priv->avg_duration), GST_TIME_ARGS (priv->avg_pt), priv->avg_rate); - /* record when this buffer will leave us */ - priv->last_left = left; - /* collect running averages. for first observations, we copy the * values */ if (priv->avg_duration == -1) @@ -1253,12 +1254,18 @@ gst_base_sink_perform_qos (GstBaseSink * sink, gboolean dropped) gst_guint64_to_gdouble (priv->avg_pt) / gst_guint64_to_gdouble (priv->avg_duration); else - rate = 1.0; + rate = 0.0; - if (rate > 1.0) - priv->avg_rate = UPDATE_RUNNING_AVG_N (priv->avg_rate, rate); - else - priv->avg_rate = UPDATE_RUNNING_AVG_P (priv->avg_rate, rate); + if (priv->last_left != -1) { + if (dropped || priv->avg_rate < 0.0) { + priv->avg_rate = rate; + } else { + if (rate > 1.0) + priv->avg_rate = UPDATE_RUNNING_AVG_N (priv->avg_rate, rate); + else + priv->avg_rate = UPDATE_RUNNING_AVG_P (priv->avg_rate, rate); + } + } GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, sink, "updated: avg_duration: %" GST_TIME_FORMAT ", avg_pt: %" GST_TIME_FORMAT @@ -1266,13 +1273,14 @@ gst_base_sink_perform_qos (GstBaseSink * sink, gboolean dropped) GST_TIME_ARGS (priv->avg_pt), priv->avg_rate); - if (dropped) { - priv->avg_rate = 2.0; + /* if we have a valid rate, start sending QoS messages */ + if (priv->avg_rate >= 0.0) { + gst_base_sink_send_qos (sink, priv->avg_rate, priv->current_rstart, + priv->current_jitter); } - /* always send QoS events */ - gst_base_sink_send_qos (sink, priv->avg_rate, priv->current_rstart, - priv->current_jitter); + /* record when this buffer will leave us */ + priv->last_left = left; } /* reset all qos measuring */ @@ -1287,7 +1295,7 @@ gst_base_sink_reset_qos (GstBaseSink * sink) priv->last_left = -1; priv->avg_duration = -1; priv->avg_pt = -1; - priv->avg_rate = 1.0; + priv->avg_rate = -1.0; priv->avg_render = -1; priv->rendered = 0; priv->dropped = 0;