diff --git a/gst/elements/gstelements.c b/gst/elements/gstelements.c index 4deec4a51f..a41efd6ac8 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 5e2d7df67c..fb9a1582d0 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 483f948fb3..cafc18b87c 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 4deec4a51f..a41efd6ac8 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 5e2d7df67c..fb9a1582d0 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 483f948fb3..cafc18b87c 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 }