summaryrefslogtreecommitdiffstats
path: root/gst/level
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2008-08-10 11:32:03 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2008-08-10 11:32:03 +0000
commitcac09e5a1b5079a642fe72157ce6197d7d46d5e4 (patch)
treed09b667bdee1f938b6c8e2f5af8119b517454dc6 /gst/level
parentb7dcc1908490d94b8c14b83f9683f3c802776ab6 (diff)
gst/level/gstlevel.*: Send same timestamp/duration details as videoanalysis. This gives applications better chance to...
Original commit message from CVS: * gst/level/gstlevel.c: * gst/level/gstlevel.h: Send same timestamp/duration details as videoanalysis. This gives applications better chance to sync analysis results with playback.
Diffstat (limited to 'gst/level')
-rw-r--r--gst/level/gstlevel.c69
-rw-r--r--gst/level/gstlevel.h1
2 files changed, 58 insertions, 12 deletions
diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c
index 3b14cdcc..2cbf8930 100644
--- a/gst/level/gstlevel.c
+++ b/gst/level/gstlevel.c
@@ -34,8 +34,37 @@
* <listitem>
* <para>
* #GstClockTime
+ * <classname>&quot;timestamp&quot;</classname>:
+ * the timestamp of the buffer that triggered the message.
+ * </para>
+ * </listitem>
+ * <listitem>
+ * <para>
+ * #GstClockTime
+ * <classname>&quot;stream-time&quot;</classname>:
+ * the stream time of the buffer.
+ * </para>
+ * </listitem>
+ * <listitem>
+ * <para>
+ * #GstClockTime
+ * <classname>&quot;running-time&quot;</classname>:
+ * the running_time of the buffer.
+ * </para>
+ * </listitem>
+ * <listitem>
+ * <para>
+ * #GstClockTime
+ * <classname>&quot;duration&quot;</classname>:
+ * the duration of the buffer.
+ * </para>
+ * </listitem>
+ * <listitem>
+ * <para>
+ * #GstClockTime
* <classname>&quot;endtime&quot;</classname>:
- * the end time of the buffer that triggered the message
+ * the end time of the buffer that triggered the message as stream time (this
+ * is deprecated, as it can be calculated from stream-time + duration)
* </para>
* </listitem>
* <listitem>
@@ -65,7 +94,7 @@
* the Root Mean Square (or average power) level in dB for each channel
* </para>
* </listitem>
- * </itemizedlist>
+ * </itemizedlist>
* </para>
* <title>Example application</title>
* <para>
@@ -470,15 +499,29 @@ gst_level_start (GstBaseTransform * trans)
}
static GstMessage *
-gst_level_message_new (GstLevel * l, GstClockTime endtime)
+gst_level_message_new (GstLevel * l, GstClockTime timestamp,
+ GstClockTime duration)
{
+ GstBaseTransform *trans = GST_BASE_TRANSFORM_CAST (l);
GstStructure *s;
GValue v = { 0, };
+ GstClockTime endtime, running_time, stream_time;
g_value_init (&v, GST_TYPE_LIST);
- s = gst_structure_new ("level", "endtime", GST_TYPE_CLOCK_TIME,
- endtime, NULL);
+ running_time = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
+ timestamp);
+ stream_time = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
+ timestamp);
+ /* endtime is for backwards compatibility */
+ endtime = stream_time + duration;
+
+ s = gst_structure_new ("level",
+ "endtime", GST_TYPE_CLOCK_TIME, endtime,
+ "timestamp", G_TYPE_UINT64, timestamp,
+ "stream-time", G_TYPE_UINT64, stream_time,
+ "running-time", G_TYPE_UINT64, running_time,
+ "duration", G_TYPE_UINT64, duration, NULL);
/* will copy-by-value */
gst_structure_set_value (s, "rms", &v);
gst_structure_set_value (s, "peak", &v);
@@ -600,6 +643,10 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
}
}
+ if (G_UNLIKELY (!filter->num_frames)) {
+ /* remember start timestamp for message */
+ filter->message_ts = GST_BUFFER_TIMESTAMP (in);
+ }
filter->num_frames += num_frames;
/* do we need to message ? */
@@ -607,16 +654,14 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
GST_CLOCK_TIME_TO_FRAMES (filter->interval, filter->rate)) {
if (filter->message) {
GstMessage *m;
- GstClockTime endtime =
- gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
- GST_BUFFER_TIMESTAMP (in))
- + GST_FRAMES_TO_CLOCK_TIME (num_frames, filter->rate);
+ GstClockTime duration =
+ GST_FRAMES_TO_CLOCK_TIME (filter->num_frames, filter->rate);
- m = gst_level_message_new (filter, endtime);
+ m = gst_level_message_new (filter, filter->message_ts, duration);
GST_LOG_OBJECT (filter,
- "message: end time %" GST_TIME_FORMAT ", num_frames %d",
- GST_TIME_ARGS (endtime), filter->num_frames);
+ "message: ts %" GST_TIME_FORMAT ", num_frames %d",
+ GST_TIME_ARGS (filter->message_ts), filter->num_frames);
for (i = 0; i < filter->channels; ++i) {
double RMS;
diff --git a/gst/level/gstlevel.h b/gst/level/gstlevel.h
index 3cd5d3a8..d8c06a2f 100644
--- a/gst/level/gstlevel.h
+++ b/gst/level/gstlevel.h
@@ -67,6 +67,7 @@ struct _GstLevel {
gdouble decay_peak_falloff; /* falloff in dB/sec */
gint num_frames; /* frame count (1 sample per channel)
* since last emit */
+ GstClockTime message_ts; /* starttime for next message */
/* per-channel arrays for intermediate values */
gdouble *CS; /* normalized Cumulative Square */