diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | gst/level/gstlevel.c | 4 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.c | 65 | ||||
-rw-r--r-- | gst/spectrum/gstspectrum.h | 3 |
4 files changed, 67 insertions, 14 deletions
@@ -1,6 +1,15 @@ 2008-08-10 Stefan Kost <ensonic@users.sf.net> * gst/level/gstlevel.c: + Little renaming (l -> level). + + * gst/spectrum/gstspectrum.c: + * gst/spectrum/gstspectrum.h: + Also send full timestamp/duration details here. + +2008-08-10 Stefan Kost <ensonic@users.sf.net> + + * 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. diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c index 2cbf8930..d117fa36 100644 --- a/gst/level/gstlevel.c +++ b/gst/level/gstlevel.c @@ -499,7 +499,7 @@ gst_level_start (GstBaseTransform * trans) } static GstMessage * -gst_level_message_new (GstLevel * l, GstClockTime timestamp, +gst_level_message_new (GstLevel * level, GstClockTime timestamp, GstClockTime duration) { GstBaseTransform *trans = GST_BASE_TRANSFORM_CAST (l); @@ -529,7 +529,7 @@ gst_level_message_new (GstLevel * l, GstClockTime timestamp, g_value_unset (&v); - return gst_message_new_element (GST_OBJECT (l), s); + return gst_message_new_element (GST_OBJECT (level), s); } static void diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c index aabb3d59..f2f8aad0 100644 --- a/gst/spectrum/gstspectrum.c +++ b/gst/spectrum/gstspectrum.c @@ -36,8 +36,37 @@ * <listitem> * <para> * #GstClockTime + * <classname>"timestamp"</classname>: + * the timestamp of the buffer that triggered the message. + * </para> + * </listitem> + * <listitem> + * <para> + * #GstClockTime + * <classname>"stream-time"</classname>: + * the stream time of the buffer. + * </para> + * </listitem> + * <listitem> + * <para> + * #GstClockTime + * <classname>"running-time"</classname>: + * the running_time of the buffer. + * </para> + * </listitem> + * <listitem> + * <para> + * #GstClockTime + * <classname>"duration"</classname>: + * the duration of the buffer. + * </para> + * </listitem> + * <listitem> + * <para> + * #GstClockTime * <classname>"endtime"</classname>: - * the end time of the buffer that triggered the message. Always present. + * 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> @@ -449,20 +478,34 @@ gst_spectrum_setup (GstAudioFilter * base, GstRingBufferSpec * format) } static GstMessage * -gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime endtime) +gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime timestamp, + GstClockTime duration) { + GstBaseTransform *trans = GST_BASE_TRANSFORM_CAST (spectrum); GstStructure *s; GValue v = { 0, }; GValue *l; guint i; gfloat *spect_magnitude = spectrum->spect_magnitude; gfloat *spect_phase = spectrum->spect_phase; + GstClockTime endtime, running_time, stream_time; GST_DEBUG_OBJECT (spectrum, "preparing message, spect = %p, bands =%d ", spect_magnitude, spectrum->bands); - s = gst_structure_new ("spectrum", "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 ("spectrum", + "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); if (spectrum->message_magnitude) { /* FIXME 0.11: this should be an array, not a list */ @@ -640,11 +683,6 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) gint width = GST_AUDIO_FILTER (spectrum)->format.width / 8; gint nfft = 2 * spectrum->bands - 2; - GstClockTime endtime = - gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME, - GST_BUFFER_TIMESTAMP (in)); - GstClockTime blktime = GST_FRAMES_TO_CLOCK_TIME (nfft, rate); - GST_LOG_OBJECT (spectrum, "input size: %d bytes", GST_BUFFER_SIZE (in)); /* can we do this nicer? */ @@ -659,13 +697,18 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) spectrum->process (spectrum, samples); + if (G_UNLIKELY (!spectrum->num_frames)) { + /* remember start timestamp for message */ + spectrum->message_ts = GST_BUFFER_TIMESTAMP (in); + } spectrum->num_frames += nfft; - endtime += blktime; /* do we need to message ? */ if (spectrum->num_frames >= GST_CLOCK_TIME_TO_FRAMES (spectrum->interval, rate)) { if (spectrum->message) { GstMessage *m; + GstClockTime duration = + GST_FRAMES_TO_CLOCK_TIME (spectrum->num_frames, rate); /* Calculate average */ for (i = 0; i < spectrum->bands; i++) { @@ -673,7 +716,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in) spect_phase[i] /= spectrum->num_fft; } - m = gst_spectrum_message_new (spectrum, endtime); + m = gst_spectrum_message_new (spectrum, spectrum->message_ts, duration); gst_element_post_message (GST_ELEMENT (spectrum), m); } diff --git a/gst/spectrum/gstspectrum.h b/gst/spectrum/gstspectrum.h index 291b2ffc..ec41668f 100644 --- a/gst/spectrum/gstspectrum.h +++ b/gst/spectrum/gstspectrum.h @@ -60,7 +60,8 @@ struct _GstSpectrum { gint num_frames; /* frame count (1 sample per channel) * since last emit */ gint num_fft; /* number of FFTs since last emit */ - + GstClockTime message_ts; /* starttime for next message */ + /* <private> */ gfloat *spect_magnitude; gfloat *spect_phase; |