diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-11-09 10:31:10 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-11-09 10:31:10 +0100 |
commit | 84c8d27906bfa90eac32bcf61d80cd2f4a6a700c (patch) | |
tree | 31e812c88915bac18ece9e81490685042c83b347 | |
parent | 308f6301a8104ba93061575cbae909675261ff01 (diff) |
make internal links a queryintlinks-query
-rw-r--r-- | gst/playback/gststreamselector.c | 198 | ||||
-rw-r--r-- | gst/playback/gststreamsynchronizer.c | 49 |
2 files changed, 113 insertions, 134 deletions
diff --git a/gst/playback/gststreamselector.c b/gst/playback/gststreamselector.c index 4b309c460..125efaad3 100644 --- a/gst/playback/gststreamselector.c +++ b/gst/playback/gststreamselector.c @@ -90,17 +90,14 @@ struct _GstSelectorPadClass GstPadClass parent; }; -static void gst_selector_pad_class_init (GstSelectorPadClass * klass); -static void gst_selector_pad_init (GstSelectorPad * pad); static void gst_selector_pad_finalize (GObject * object); static void gst_selector_pad_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static GstPadClass *selector_pad_parent_class = NULL; - static void gst_selector_pad_reset (GstSelectorPad * pad); static gboolean gst_selector_pad_event (GstPad * pad, GstEvent * event); +static gboolean gst_selector_pad_query (GstPad * pad, GstQuery * query); static GstCaps *gst_selector_pad_getcaps (GstPad * pad, GstCaps * filter); static GstFlowReturn gst_selector_pad_chain (GstPad * pad, GstBuffer * buf); @@ -112,30 +109,8 @@ enum PROP_PAD_LAST }; -static GType -gst_selector_pad_get_type (void) -{ - static GType selector_pad_type = 0; - - if (!selector_pad_type) { - static const GTypeInfo selector_pad_info = { - sizeof (GstSelectorPadClass), - NULL, - NULL, - (GClassInitFunc) gst_selector_pad_class_init, - NULL, - NULL, - sizeof (GstSelectorPad), - 0, - (GInstanceInitFunc) gst_selector_pad_init, - }; - - selector_pad_type = - g_type_register_static (GST_TYPE_PAD, "GstPlaybinSelectorPad", - &selector_pad_info, 0); - } - return selector_pad_type; -} +GType gst_selector_pad_get_type (void); +G_DEFINE_TYPE (GstSelectorPad, gst_selector_pad, GST_TYPE_PAD); static void gst_selector_pad_class_init (GstSelectorPadClass * klass) @@ -144,8 +119,6 @@ gst_selector_pad_class_init (GstSelectorPadClass * klass) gobject_class = (GObjectClass *) klass; - selector_pad_parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gst_selector_pad_finalize; gobject_class->get_property = gst_selector_pad_get_property; @@ -176,7 +149,7 @@ gst_selector_pad_finalize (GObject * object) if (pad->tags) gst_tag_list_free (pad->tags); - G_OBJECT_CLASS (selector_pad_parent_class)->finalize (object); + G_OBJECT_CLASS (gst_selector_pad_parent_class)->finalize (object); } static void @@ -298,6 +271,50 @@ gst_selector_pad_getcaps (GstPad * pad, GstCaps * filter) return caps; } +static gboolean +gst_stream_selector_pad_query_internal_links (GstStreamSelector * sel, + GstPad * pad, GstQuery * query) +{ + GValue value = { 0, }; + GstPad *otherpad; + GstIterator *it = NULL; + + otherpad = gst_stream_selector_get_linked_pad (pad, TRUE); + if (otherpad) { + g_value_init (&value, GST_TYPE_PAD); + g_value_take_object (&value, otherpad); + it = gst_iterator_new_single (GST_TYPE_PAD, &value); + g_value_unset (&value); + } + + if (it) + gst_query_set_internal_links_iterator (query, it); + + return (it ? TRUE : FALSE); +} + +static gboolean +gst_selector_pad_query (GstPad * pad, GstQuery * query) +{ + gboolean res; + GstStreamSelector *sel; + + sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad)); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_INTERNAL_LINKS: + res = gst_stream_selector_pad_query_internal_links (sel, pad, query); + break; + default: + res = gst_pad_query_default (pad, query); + break; + } + + gst_object_unref (sel); + + return res; +} + static GstFlowReturn gst_selector_pad_chain (GstPad * pad, GstBuffer * buf) { @@ -351,10 +368,6 @@ ignore: static void gst_stream_selector_dispose (GObject * object); -static void gst_stream_selector_init (GstStreamSelector * sel); -static void gst_stream_selector_base_init (GstStreamSelectorClass * klass); -static void gst_stream_selector_class_init (GstStreamSelectorClass * klass); - static void gst_stream_selector_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_stream_selector_get_property (GObject * object, @@ -364,54 +377,11 @@ static GstPad *gst_stream_selector_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * unused, const GstCaps * caps); static void gst_stream_selector_release_pad (GstElement * element, GstPad * pad); -static GstIterator *gst_stream_selector_pad_iterate_linked_pads (GstPad * pad); static GstCaps *gst_stream_selector_getcaps (GstPad * pad, GstCaps * filter); +static gboolean gst_stream_selector_query (GstPad * pad, GstQuery * query); -static GstElementClass *parent_class = NULL; - -GType -gst_stream_selector_get_type (void) -{ - static GType stream_selector_type = 0; - - if (!stream_selector_type) { - static const GTypeInfo stream_selector_info = { - sizeof (GstStreamSelectorClass), - (GBaseInitFunc) gst_stream_selector_base_init, - NULL, - (GClassInitFunc) gst_stream_selector_class_init, - NULL, - NULL, - sizeof (GstStreamSelector), - 0, - (GInstanceInitFunc) gst_stream_selector_init, - }; - stream_selector_type = - g_type_register_static (GST_TYPE_ELEMENT, - "GstStreamSelector", &stream_selector_info, 0); - GST_DEBUG_CATEGORY_INIT (stream_selector_debug, - "streamselector", 0, "A stream-selector element"); - } - - return stream_selector_type; -} - -static void -gst_stream_selector_base_init (GstStreamSelectorClass * klass) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (klass); - - gst_element_class_set_details_simple (element_class, - "StreamSelector", "Generic", - "N-to-1 input stream_selectoring", - "Julien Moutte <julien@moutte.net>, " - "Jan Schmidt <thaytan@mad.scientist.com>, " - "Wim Taymans <wim.taymans@gmail.com>"); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_stream_selector_sink_factory)); - gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&gst_stream_selector_src_factory)); -} +#define gst_stream_selector_parent_class parent_class +G_DEFINE_TYPE (GstStreamSelector, gst_stream_selector, GST_TYPE_ELEMENT); static void gst_stream_selector_class_init (GstStreamSelectorClass * klass) @@ -437,16 +407,31 @@ gst_stream_selector_class_init (GstStreamSelectorClass * klass) gstelement_class->request_new_pad = gst_stream_selector_request_new_pad; gstelement_class->release_pad = gst_stream_selector_release_pad; + + gst_element_class_set_details_simple (gstelement_class, + "StreamSelector", "Generic", + "N-to-1 input stream_selectoring", + "Julien Moutte <julien@moutte.net>, " + "Jan Schmidt <thaytan@mad.scientist.com>, " + "Wim Taymans <wim.taymans@gmail.com>"); + + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&gst_stream_selector_sink_factory)); + gst_element_class_add_pad_template (gstelement_class, + gst_static_pad_template_get (&gst_stream_selector_src_factory)); + + GST_DEBUG_CATEGORY_INIT (stream_selector_debug, + "streamselector", 0, "A stream-selector element"); } static void gst_stream_selector_init (GstStreamSelector * sel) { sel->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_iterate_internal_links_function (sel->srcpad, - GST_DEBUG_FUNCPTR (gst_stream_selector_pad_iterate_linked_pads)); gst_pad_set_getcaps_function (sel->srcpad, GST_DEBUG_FUNCPTR (gst_stream_selector_getcaps)); + gst_pad_set_query_function (sel->srcpad, + GST_DEBUG_FUNCPTR (gst_stream_selector_query)); gst_element_add_pad (GST_ELEMENT (sel), sel->srcpad); /* sinkpad management */ sel->padcount = 0; @@ -579,6 +564,28 @@ gst_stream_selector_getcaps (GstPad * pad, GstCaps * filter) return caps; } +static gboolean +gst_stream_selector_query (GstPad * pad, GstQuery * query) +{ + gboolean res; + + GstStreamSelector *sel; + + sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad)); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_INTERNAL_LINKS: + res = gst_stream_selector_pad_query_internal_links (sel, pad, query); + break; + default: + res = gst_pad_query_default (pad, query); + break; + } + gst_object_unref (sel); + + return res; +} + /* check if the pad is the active sinkpad */ static gboolean gst_stream_selector_is_active_sinkpad (GstStreamSelector * sel, GstPad * pad) @@ -614,27 +621,6 @@ gst_stream_selector_activate_sinkpad (GstStreamSelector * sel, GstPad * pad) return active_sinkpad; } -static GstIterator * -gst_stream_selector_pad_iterate_linked_pads (GstPad * pad) -{ - GstStreamSelector *sel = GST_STREAM_SELECTOR (gst_pad_get_parent (pad)); - GValue value = { 0, }; - GstPad *otherpad; - GstIterator *ret = NULL; - - otherpad = gst_stream_selector_get_linked_pad (pad, TRUE); - if (otherpad) { - g_value_init (&value, GST_TYPE_PAD); - g_value_set_object (&value, otherpad); - ret = gst_iterator_new_single (GST_TYPE_PAD, &value); - g_value_unset (&value); - gst_object_unref (otherpad); - } - gst_object_unref (sel); - - return ret; -} - static GstPad * gst_stream_selector_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * unused, const GstCaps * caps) @@ -660,8 +646,8 @@ gst_stream_selector_request_new_pad (GstElement * element, GST_DEBUG_FUNCPTR (gst_selector_pad_getcaps)); gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_selector_pad_chain)); - gst_pad_set_iterate_internal_links_function (sinkpad, - GST_DEBUG_FUNCPTR (gst_stream_selector_pad_iterate_linked_pads)); + gst_pad_set_query_function (sinkpad, + GST_DEBUG_FUNCPTR (gst_selector_pad_query)); gst_pad_set_active (sinkpad, TRUE); gst_element_add_pad (GST_ELEMENT (sel), sinkpad); diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index 668318fbb..5f4616bd7 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -113,26 +113,6 @@ out: } /* Generic pad functions */ -static GstIterator * -gst_stream_synchronizer_iterate_internal_links (GstPad * pad) -{ - GstIterator *it = NULL; - GstPad *opad; - - opad = gst_stream_get_other_pad_from_pad (pad); - if (opad) { - GValue value = { 0, }; - - g_value_init (&value, GST_TYPE_PAD); - g_value_set_object (&value, opad); - it = gst_iterator_new_single (GST_TYPE_PAD, &value); - g_value_unset (&value); - gst_object_unref (opad); - } - - return it; -} - static gboolean gst_stream_synchronizer_query (GstPad * pad, GstQuery * query) { @@ -142,11 +122,28 @@ gst_stream_synchronizer_query (GstPad * pad, GstQuery * query) GST_LOG_OBJECT (pad, "Handling query %s", GST_QUERY_TYPE_NAME (query)); opad = gst_stream_get_other_pad_from_pad (pad); - if (opad) { - ret = gst_pad_peer_query (opad, query); - gst_object_unref (opad); - } + if (opad == NULL) + return FALSE; + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_INTERNAL_LINKS: + { + GValue value = { 0, }; + GstIterator *it; + + g_value_init (&value, GST_TYPE_PAD); + g_value_take_object (&value, opad); + it = gst_iterator_new_single (GST_TYPE_PAD, &value); + g_value_unset (&value); + + gst_query_set_internal_links_iterator (query, it); + break; + } + default: + ret = gst_pad_peer_query (opad, query); + gst_object_unref (opad); + break; + } return ret; } @@ -681,8 +678,6 @@ gst_stream_synchronizer_request_new_pad (GstElement * element, stream->sinkpad = gst_pad_new_from_static_template (&sinktemplate, tmp); g_free (tmp); gst_pad_set_element_private (stream->sinkpad, stream); - gst_pad_set_iterate_internal_links_function (stream->sinkpad, - GST_DEBUG_FUNCPTR (gst_stream_synchronizer_iterate_internal_links)); gst_pad_set_query_function (stream->sinkpad, GST_DEBUG_FUNCPTR (gst_stream_synchronizer_query)); gst_pad_set_getcaps_function (stream->sinkpad, @@ -698,8 +693,6 @@ gst_stream_synchronizer_request_new_pad (GstElement * element, stream->srcpad = gst_pad_new_from_static_template (&srctemplate, tmp); g_free (tmp); gst_pad_set_element_private (stream->srcpad, stream); - gst_pad_set_iterate_internal_links_function (stream->srcpad, - GST_DEBUG_FUNCPTR (gst_stream_synchronizer_iterate_internal_links)); gst_pad_set_query_function (stream->srcpad, GST_DEBUG_FUNCPTR (gst_stream_synchronizer_query)); gst_pad_set_getcaps_function (stream->srcpad, |