From bb1cb289215d727e937dfe4da5ffd9fdaad8f3a3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 11 Jul 2001 16:45:43 +0000 Subject: [PATCH] Added request pads to fakesink. Original commit message from CVS: Added request pads to fakesink. --- gst/elements/gstelements.c | 2 +- gst/elements/gstfakesink.c | 55 +++++++++++++++++++++++++++++++++++++++--- gst/elements/gstfakesink.h | 1 + plugins/elements/gstelements.c | 2 +- plugins/elements/gstfakesink.c | 55 +++++++++++++++++++++++++++++++++++++++--- plugins/elements/gstfakesink.h | 1 + 6 files changed, 108 insertions(+), 8 deletions(-) diff --git a/gst/elements/gstelements.c b/gst/elements/gstelements.c index 4deec4a..a41efd6 100644 --- a/gst/elements/gstelements.c +++ b/gst/elements/gstelements.c @@ -50,7 +50,7 @@ struct _elements_entry { static struct _elements_entry _elements[] = { { "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, gst_fakesrc_factory_init }, - { "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL }, + { "fakesink", gst_fakesink_get_type, &gst_fakesink_details, gst_fakesink_factory_init }, { "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL }, { "disksink", gst_disksink_get_type, &gst_disksink_details, NULL }, { "identity", gst_identity_get_type, &gst_identity_details, NULL }, diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index 5e2d7df..fb9a158 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -47,10 +47,19 @@ enum { ARG_SILENT, }; +GST_PADTEMPLATE_FACTORY (fakesink_sink_factory, + "sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + NULL /* no caps */ +); + static void gst_fakesink_class_init (GstFakeSinkClass *klass); static void gst_fakesink_init (GstFakeSink *fakesink); +static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ); + static void gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_fakesink_get_property (GObject *object, guint prop_id, @@ -86,8 +95,10 @@ static void gst_fakesink_class_init (GstFakeSinkClass *klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; gobject_class = (GObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); @@ -104,8 +115,10 @@ gst_fakesink_class_init (GstFakeSinkClass *klass) g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - gobject_class->set_property = gst_fakesink_set_property; - gobject_class->get_property = gst_fakesink_get_property; + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); + + gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); } static void @@ -114,13 +127,40 @@ gst_fakesink_init (GstFakeSink *fakesink) GstPad *pad; pad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (fakesink), pad); - gst_pad_set_chain_function (pad, gst_fakesink_chain); + gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); fakesink->sinkpads = g_slist_prepend (NULL, pad); fakesink->numsinkpads = 1; fakesink->silent = FALSE; } +static GstPad* +gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ) +{ + gchar *name; + GstPad *sinkpad; + GstFakeSink *fakesink; + + g_return_val_if_fail (GST_IS_FAKESINK (element), NULL); + + if (templ->direction != GST_PAD_SINK) { + g_warning ("gstfakesink: request new pad that is not a SINK pad\n"); + return NULL; + } + + fakesink = GST_FAKESINK (element); + + name = g_strdup_printf ("sink%d", fakesink->numsinkpads); + + sinkpad = gst_pad_new_from_template (templ, name); + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); + + fakesink->sinkpads = g_slist_prepend (fakesink->sinkpads, sinkpad); + fakesink->numsinkpads++; + + return sinkpad; +} + static void gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { @@ -188,3 +228,12 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf) gst_buffer_unref (buf); } + +gboolean +gst_fakesink_factory_init (GstElementFactory *factory) +{ + gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (fakesink_sink_factory)); + + return TRUE; +} + diff --git a/gst/elements/gstfakesink.h b/gst/elements/gstfakesink.h index 483f948..cafc18b 100644 --- a/gst/elements/gstfakesink.h +++ b/gst/elements/gstfakesink.h @@ -68,6 +68,7 @@ struct _GstFakeSinkClass { GType gst_fakesink_get_type(void); +gboolean gst_fakesink_factory_init (GstElementFactory *factory); #ifdef __cplusplus } diff --git a/plugins/elements/gstelements.c b/plugins/elements/gstelements.c index 4deec4a..a41efd6 100644 --- a/plugins/elements/gstelements.c +++ b/plugins/elements/gstelements.c @@ -50,7 +50,7 @@ struct _elements_entry { static struct _elements_entry _elements[] = { { "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, gst_fakesrc_factory_init }, - { "fakesink", gst_fakesink_get_type, &gst_fakesink_details, NULL }, + { "fakesink", gst_fakesink_get_type, &gst_fakesink_details, gst_fakesink_factory_init }, { "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL }, { "disksink", gst_disksink_get_type, &gst_disksink_details, NULL }, { "identity", gst_identity_get_type, &gst_identity_details, NULL }, diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 5e2d7df..fb9a158 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -47,10 +47,19 @@ enum { ARG_SILENT, }; +GST_PADTEMPLATE_FACTORY (fakesink_sink_factory, + "sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + NULL /* no caps */ +); + static void gst_fakesink_class_init (GstFakeSinkClass *klass); static void gst_fakesink_init (GstFakeSink *fakesink); +static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ); + static void gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_fakesink_get_property (GObject *object, guint prop_id, @@ -86,8 +95,10 @@ static void gst_fakesink_class_init (GstFakeSinkClass *klass) { GObjectClass *gobject_class; + GstElementClass *gstelement_class; gobject_class = (GObjectClass*)klass; + gstelement_class = (GstElementClass*)klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); @@ -104,8 +115,10 @@ gst_fakesink_class_init (GstFakeSinkClass *klass) g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - gobject_class->set_property = gst_fakesink_set_property; - gobject_class->get_property = gst_fakesink_get_property; + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); + + gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); } static void @@ -114,13 +127,40 @@ gst_fakesink_init (GstFakeSink *fakesink) GstPad *pad; pad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (fakesink), pad); - gst_pad_set_chain_function (pad, gst_fakesink_chain); + gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); fakesink->sinkpads = g_slist_prepend (NULL, pad); fakesink->numsinkpads = 1; fakesink->silent = FALSE; } +static GstPad* +gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ) +{ + gchar *name; + GstPad *sinkpad; + GstFakeSink *fakesink; + + g_return_val_if_fail (GST_IS_FAKESINK (element), NULL); + + if (templ->direction != GST_PAD_SINK) { + g_warning ("gstfakesink: request new pad that is not a SINK pad\n"); + return NULL; + } + + fakesink = GST_FAKESINK (element); + + name = g_strdup_printf ("sink%d", fakesink->numsinkpads); + + sinkpad = gst_pad_new_from_template (templ, name); + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); + + fakesink->sinkpads = g_slist_prepend (fakesink->sinkpads, sinkpad); + fakesink->numsinkpads++; + + return sinkpad; +} + static void gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { @@ -188,3 +228,12 @@ gst_fakesink_chain (GstPad *pad, GstBuffer *buf) gst_buffer_unref (buf); } + +gboolean +gst_fakesink_factory_init (GstElementFactory *factory) +{ + gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (fakesink_sink_factory)); + + return TRUE; +} + diff --git a/plugins/elements/gstfakesink.h b/plugins/elements/gstfakesink.h index 483f948..cafc18b 100644 --- a/plugins/elements/gstfakesink.h +++ b/plugins/elements/gstfakesink.h @@ -68,6 +68,7 @@ struct _GstFakeSinkClass { GType gst_fakesink_get_type(void); +gboolean gst_fakesink_factory_init (GstElementFactory *factory); #ifdef __cplusplus } -- 2.7.4