From 31f4ac7b30364c42d91c9410e906bc01c00cfea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 28 Feb 2010 10:42:38 +0100 Subject: [PATCH] frei0r: Sync properties to the controller if one was set --- gst/frei0r/Makefile.am | 4 ++-- gst/frei0r/gstfrei0r.c | 3 +++ gst/frei0r/gstfrei0rfilter.c | 22 ++++++++++++++++++++++ gst/frei0r/gstfrei0rmixer.c | 22 +++++++++++++++++++--- gst/frei0r/gstfrei0rsrc.c | 15 ++++++++++++++- 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/gst/frei0r/Makefile.am b/gst/frei0r/Makefile.am index 400801d998..8135f5c324 100644 --- a/gst/frei0r/Makefile.am +++ b/gst/frei0r/Makefile.am @@ -6,8 +6,8 @@ libgstfrei0r_la_SOURCES = \ gstfrei0rsrc.c \ gstfrei0rmixer.c -libgstfrei0r_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) -libgstfrei0r_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) \ +libgstfrei0r_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CONTROLLER_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) +libgstfrei0r_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_CONTROLLER_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) \ -lgstvideo-@GST_MAJORMINOR@ libgstfrei0r_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstfrei0r_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/gst/frei0r/gstfrei0r.c b/gst/frei0r/gstfrei0r.c index 0b750d6e8c..43e2326f02 100644 --- a/gst/frei0r/gstfrei0r.c +++ b/gst/frei0r/gstfrei0r.c @@ -26,6 +26,7 @@ #include "gstfrei0rsrc.h" #include "gstfrei0rmixer.h" +#include #include GST_DEBUG_CATEGORY (frei0r_debug); @@ -612,6 +613,8 @@ plugin_init (GstPlugin * plugin) GST_DEBUG_CATEGORY_INIT (frei0r_debug, "frei0r", 0, "frei0r"); + gst_controller_init (NULL, NULL); + gst_plugin_add_dependency_simple (plugin, "HOME/.frei0r-1/lib", "/usr/lib/frei0r-1:/usr/local/lib/frei0r-1", diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index fc60a9034f..cc0c3d2774 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -26,6 +26,8 @@ #include "gstfrei0r.h" #include "gstfrei0rfilter.h" +#include + GST_DEBUG_CATEGORY_EXTERN (frei0r_debug); #define GST_CAT_DEFAULT frei0r_debug @@ -64,6 +66,24 @@ gst_frei0r_filter_stop (GstBaseTransform * trans) return TRUE; } +static void +gst_frei0r_filter_before_transform (GstBaseTransform * trans, + GstBuffer * buffer) +{ + GstClockTime timestamp; + GstFrei0rFilter *self = GST_FREI0R_FILTER (trans); + + timestamp = GST_BUFFER_TIMESTAMP (buffer); + timestamp = + gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME, timestamp); + + GST_DEBUG_OBJECT (self, "sync to %" GST_TIME_FORMAT, + GST_TIME_ARGS (timestamp)); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) + gst_object_sync_values (G_OBJECT (self), timestamp); +} + static GstFlowReturn gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf, GstBuffer * outbuf) @@ -193,6 +213,8 @@ gst_frei0r_filter_class_init (GstFrei0rFilterClass * klass, gsttrans_class->set_caps = GST_DEBUG_FUNCPTR (gst_frei0r_filter_set_caps); gsttrans_class->stop = GST_DEBUG_FUNCPTR (gst_frei0r_filter_stop); gsttrans_class->transform = GST_DEBUG_FUNCPTR (gst_frei0r_filter_transform); + gsttrans_class->before_transform = + GST_DEBUG_FUNCPTR (gst_frei0r_filter_before_transform); } static void diff --git a/gst/frei0r/gstfrei0rmixer.c b/gst/frei0r/gstfrei0rmixer.c index 486e96e45e..5172e28c16 100644 --- a/gst/frei0r/gstfrei0rmixer.c +++ b/gst/frei0r/gstfrei0rmixer.c @@ -26,6 +26,8 @@ #include "gstfrei0r.h" #include "gstfrei0rmixer.h" +#include + GST_DEBUG_CATEGORY_EXTERN (frei0r_debug); #define GST_CAT_DEFAULT frei0r_debug @@ -546,7 +548,9 @@ gst_frei0r_mixer_collected (GstCollectPads * pads, GstFrei0rMixer * self) GstFlowReturn ret = GST_FLOW_OK; GSList *l; GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (self); + GstClockTime timestamp; gdouble time; + GstSegment *segment = NULL; if (G_UNLIKELY (self->width <= 0 || self->height <= 0)) return GST_FLOW_NOT_NEGOTIATED; @@ -573,17 +577,29 @@ gst_frei0r_mixer_collected (GstCollectPads * pads, GstFrei0rMixer * self) for (l = pads->data; l; l = l->next) { GstCollectData *cdata = l->data; - if (cdata->pad == self->sink0) + if (cdata->pad == self->sink0) { inbuf0 = gst_collect_pads_pop (pads, cdata); - else if (cdata->pad == self->sink1) + segment = &cdata->segment; + } else if (cdata->pad == self->sink1) { inbuf1 = gst_collect_pads_pop (pads, cdata); - else if (cdata->pad == self->sink2) + } else if (cdata->pad == self->sink2) { inbuf2 = gst_collect_pads_pop (pads, cdata); + } } if (!inbuf0 || !inbuf1 || (!inbuf2 && self->sink2)) goto eos; + g_assert (segment != NULL); + timestamp = GST_BUFFER_TIMESTAMP (inbuf0); + timestamp = gst_segment_to_stream_time (segment, GST_FORMAT_TIME, timestamp); + + GST_DEBUG_OBJECT (self, "sync to %" GST_TIME_FORMAT, + GST_TIME_ARGS (timestamp)); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) + gst_object_sync_values (G_OBJECT (self), timestamp); + gst_buffer_copy_metadata (outbuf, inbuf0, GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS); time = ((gdouble) GST_BUFFER_TIMESTAMP (outbuf)) / GST_SECOND; diff --git a/gst/frei0r/gstfrei0rsrc.c b/gst/frei0r/gstfrei0rsrc.c index 69b905b0f0..e811b46d75 100644 --- a/gst/frei0r/gstfrei0rsrc.c +++ b/gst/frei0r/gstfrei0rsrc.c @@ -26,6 +26,8 @@ #include "gstfrei0r.h" #include "gstfrei0rsrc.h" +#include + GST_DEBUG_CATEGORY_EXTERN (frei0r_debug); #define GST_CAT_DEFAULT frei0r_debug @@ -66,6 +68,7 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf) guint size, newsize; GstFlowReturn ret = GST_FLOW_OK; GstBuffer *outbuf = NULL; + GstClockTime timestamp; gdouble time; *buf = NULL; @@ -101,7 +104,7 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf) gst_buffer_set_caps (outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src))); } - GST_BUFFER_TIMESTAMP (outbuf) = + GST_BUFFER_TIMESTAMP (outbuf) = timestamp = gst_util_uint64_scale (self->n_frames, GST_SECOND * self->fps_d, self->fps_n); GST_BUFFER_OFFSET (outbuf) = self->n_frames; @@ -111,6 +114,16 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf) gst_util_uint64_scale (self->n_frames, GST_SECOND * self->fps_d, self->fps_n) - GST_BUFFER_TIMESTAMP (outbuf); + timestamp = + gst_segment_to_stream_time (&GST_BASE_SRC_CAST (self)->segment, + GST_FORMAT_TIME, timestamp); + + GST_DEBUG_OBJECT (self, "sync to %" GST_TIME_FORMAT, + GST_TIME_ARGS (timestamp)); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) + gst_object_sync_values (G_OBJECT (self), timestamp); + time = ((gdouble) GST_BUFFER_TIMESTAMP (outbuf)) / GST_SECOND; GST_OBJECT_LOCK (self);