summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2010-01-31 20:16:18 (GMT)
committerStefan Kost <ensonic@users.sf.net>2010-01-31 20:25:51 (GMT)
commit6bff8711d0e087e8b20507dd92c25850cdff3c18 (patch)
tree61649ff52c73cf3d827b463a037dbea11f934a00
parentb3ac421b96eacbd13c74c64f446247a3d553f4b5 (diff)
signalprocessor: use the gst-controller, add some basic timestamping
Atleast for FX we now have timestamps and can sync the controller. Still need timestamps for sources.
-rw-r--r--gst-libs/gst/signalprocessor/Makefile.am11
-rw-r--r--gst-libs/gst/signalprocessor/gstsignalprocessor.c45
2 files changed, 53 insertions, 3 deletions
diff --git a/gst-libs/gst/signalprocessor/Makefile.am b/gst-libs/gst/signalprocessor/Makefile.am
index 5ec73f1..a9f2f70 100644
--- a/gst-libs/gst/signalprocessor/Makefile.am
+++ b/gst-libs/gst/signalprocessor/Makefile.am
@@ -4,7 +4,12 @@ libgstsignalprocessor_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_
libgstsignalprocessor_@GST_MAJORMINOR@include_HEADERS = gstsignalprocessor.h
libgstsignalprocessor_@GST_MAJORMINOR@_la_SOURCES = gstsignalprocessor.c
-libgstsignalprocessor_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
-libgstsignalprocessor_@GST_MAJORMINOR@_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_LIBS) -lgstaudio-@GST_MAJORMINOR@
-libgstsignalprocessor_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
+libgstsignalprocessor_@GST_MAJORMINOR@_la_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_CONTROLLER_CFLAGS) $(GST_CFLAGS)
+libgstsignalprocessor_@GST_MAJORMINOR@_la_LIBADD = \
+ $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@ \
+ $(GST_CONTROLLER_LIBS) $(GST_LIBS)
+libgstsignalprocessor_@GST_MAJORMINOR@_la_LDFLAGS = \
+ $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
diff --git a/gst-libs/gst/signalprocessor/gstsignalprocessor.c b/gst-libs/gst/signalprocessor/gstsignalprocessor.c
index eecabd9..bae230e 100644
--- a/gst-libs/gst/signalprocessor/gstsignalprocessor.c
+++ b/gst-libs/gst/signalprocessor/gstsignalprocessor.c
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <string.h>
+#include <gst/controller/gstcontroller.h>
#include <gst/audio/audio.h>
#include "gstsignalprocessor.h"
@@ -576,6 +577,15 @@ gst_signal_processor_event (GstPad * pad, GstEvent * event)
return ret;
}
+/*
+ * gst_signal_processor_prepare:
+ * @self: the element
+ * nframes: wanted sample frames
+ *
+ * Checks if wan
+ *
+ * Returns: available sample frames
+ */
static guint
gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
{
@@ -584,6 +594,8 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
GList *sinks, *srcs;
guint samples_avail = nframes;
guint i, in_group_index = 0, out_group_index = 0;
+ gboolean is_gap = FALSE;
+ GstClockTime ts, tss = GST_CLOCK_TIME_NONE, tse = GST_CLOCK_TIME_NONE;
klass = GST_SIGNAL_PROCESSOR_GET_CLASS (self);
@@ -617,8 +629,32 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
}
}
+ GST_LOG_OBJECT (self, "want %u samples, have %u samples", nframes,
+ samples_avail);
+
/* FIXME: return if samples_avail==0 ? */
+ if ((sinks = elem->sinkpads)) {
+ is_gap = TRUE;
+ while (sinks) {
+ GstSignalProcessorPad *sinkpad = (GstSignalProcessorPad *) sinks->data;
+
+ is_gap &= GST_BUFFER_FLAG_IS_SET (sinkpad->pen, GST_BUFFER_FLAG_GAP);
+ ts = GST_BUFFER_TIMESTAMP (sinkpad->pen);
+ if (GST_CLOCK_TIME_IS_VALID (ts)) {
+ tss = !GST_CLOCK_TIME_IS_VALID (tss) ? ts : MIN (tss, ts);
+ tse = !GST_CLOCK_TIME_IS_VALID (tse) ? ts : MAX (tse, ts);
+ }
+ sinks = sinks->next;
+ }
+ ts = (tss == tse) ? tss : GST_CLOCK_TIME_NONE;
+ GST_LOG_OBJECT (self, "is gap: %d, tss %" GST_TIME_FORMAT ", tse %"
+ GST_TIME_FORMAT, is_gap, GST_TIME_ARGS (tss), GST_TIME_ARGS (tse));
+ } else {
+ /* FIXME: calculate own timestamps */
+ ts = GST_CLOCK_TIME_NONE;
+ }
+
/* now assign output buffers. we can avoid allocation by reusing input
buffers, but only if process() can work in place, and if the input buffer
is the exact size of the number of samples we are processing. */
@@ -682,9 +718,18 @@ gst_signal_processor_prepare (GstSignalProcessor * self, guint nframes)
self->pending_out++;
}
+ /* set time stamp */
+ GST_BUFFER_TIMESTAMP (srcpad->pen) = ts;
+ /* FIXME: handle gap flag ? */
+
srcs = srcs->next;
}
+ /* update controlled parameters */
+ if (samples_avail && GST_CLOCK_TIME_IS_VALID (ts)) {
+ gst_object_sync_values ((GObject *) self, ts);
+ }
+
return samples_avail;
}