* <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>
}
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 */
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? */
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++) {
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);
}