Added DEBUG_FUNCPTR to most plugins.

Original commit message from CVS:
Added DEBUG_FUNCPTR to most plugins.
Added request pads to fakesrc and aggregator.
This commit is contained in:
Wim Taymans 2001-07-11 15:51:40 +00:00
parent d9f96e3201
commit 1b50ccc246
16 changed files with 196 additions and 122 deletions

View file

@ -107,16 +107,16 @@ gst_aggregator_class_init (GstAggregatorClass *klass)
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_aggregator_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property);
gobject_class->get_property = gst_aggregator_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property);
gstelement_class->request_new_pad = gst_aggregator_request_new_pad; gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad);
} }
static void static void
gst_aggregator_init (GstAggregator *aggregator) gst_aggregator_init (GstAggregator *aggregator)
{ {
aggregator->srcpad = gst_pad_new ("src", GST_PAD_SINK); aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (aggregator), aggregator->srcpad); gst_element_add_pad (GST_ELEMENT (aggregator), aggregator->srcpad);
aggregator->numsinkpads = 0; aggregator->numsinkpads = 0;

View file

@ -49,7 +49,7 @@ struct _elements_entry {
}; };
static struct _elements_entry _elements[] = { static struct _elements_entry _elements[] = {
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL }, { "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, NULL },
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL }, { "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
{ "disksink", gst_disksink_get_type, &gst_disksink_details, NULL }, { "disksink", gst_disksink_get_type, &gst_disksink_details, NULL },

View file

@ -43,7 +43,7 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_NUM_SOURCES, ARG_NUM_SINKS,
ARG_SILENT, ARG_SILENT,
}; };
@ -91,12 +91,12 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
g_param_spec_int("num_sources","num_sources","num_sources", g_param_spec_int ("num_sinks", "num_sinks", "num_sinks",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean("silent","silent","silent", g_param_spec_boolean ("silent", "silent", "silent",
TRUE,G_PARAM_READWRITE)); // CHECKME FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
@ -115,35 +115,21 @@ gst_fakesink_init (GstFakeSink *fakesink)
pad = gst_pad_new ("sink", GST_PAD_SINK); pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad); gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, gst_fakesink_chain); gst_pad_set_chain_function (pad, gst_fakesink_chain);
fakesink->sinkpads = g_slist_prepend (NULL, pad); fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1; fakesink->numsinkpads = 1;
fakesink->silent = FALSE; fakesink->silent = FALSE;
// we're ready right away, since we don't have any args...
// gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
} }
static void static void
gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFakeSink *sink; GstFakeSink *sink;
gint new_numsinks;
GstPad *pad;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
sink = GST_FAKESINK (object); sink = GST_FAKESINK (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES:
new_numsinks = g_value_get_int (value);
while (sink->numsinkpads < new_numsinks) {
pad = gst_pad_new (g_strdup_printf ("sink%d", sink->numsinkpads), GST_PAD_SINK);
gst_pad_set_chain_function (pad, gst_fakesink_chain);
gst_element_add_pad (GST_ELEMENT (sink), pad);
sink->sinkpads = g_slist_append (sink->sinkpads, pad);
sink->numsinkpads++;
}
break;
case ARG_SILENT: case ARG_SILENT:
sink->silent = g_value_get_boolean (value); sink->silent = g_value_get_boolean (value);
break; break;
@ -163,7 +149,7 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
sink = GST_FAKESINK (object); sink = GST_FAKESINK (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES: case ARG_NUM_SINKS:
g_value_set_int (value, sink->numsinkpads); g_value_set_int (value, sink->numsinkpads);
break; break;
case ARG_SILENT: case ARG_SILENT:

View file

@ -30,7 +30,7 @@ GstElementDetails gst_fakesrc_details = {
"Push empty (no data) buffers around", "Push empty (no data) buffers around",
VERSION, VERSION,
"Erik Walthinsen <omega@cse.ogi.edu>\n" "Erik Walthinsen <omega@cse.ogi.edu>\n"
"Wim Taymans <wim.taymans@chello.be>" "Wim Taymans <wim.taymans@chello.be>",
"(C) 1999", "(C) 1999",
}; };
@ -53,9 +53,17 @@ enum {
ARG_SILENT ARG_SILENT
}; };
GST_PADTEMPLATE_FACTORY (fakesrc_src_factory,
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
NULL /* no caps */
);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type()) #define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
static GType static GType
gst_fakesrc_output_get_type(void) { gst_fakesrc_output_get_type (void)
{
static GType fakesrc_output_type = 0; static GType fakesrc_output_type = 0;
static GEnumValue fakesrc_output[] = { static GEnumValue fakesrc_output[] = {
{ FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
@ -69,7 +77,7 @@ gst_fakesrc_output_get_type(void) {
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_output_type) { if (!fakesrc_output_type) {
fakesrc_output_type = g_enum_register_static("GstFakeSrcOutput", fakesrc_output); fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
} }
return fakesrc_output_type; return fakesrc_output_type;
} }
@ -77,6 +85,7 @@ gst_fakesrc_output_get_type(void) {
static void gst_fakesrc_class_init (GstFakeSrcClass *klass); static void gst_fakesrc_class_init (GstFakeSrcClass *klass);
static void gst_fakesrc_init (GstFakeSrc *fakesrc); static void gst_fakesrc_init (GstFakeSrc *fakesrc);
static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ);
static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@ -112,14 +121,16 @@ static void
gst_fakesrc_class_init (GstFakeSrcClass *klass) gst_fakesrc_class_init (GstFakeSrcClass *klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass; gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int("num_sources","num_sources","num_sources", g_param_spec_int ("num_sources", "num_sources", "num_sources",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED, g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
g_param_spec_boolean("loop_based","loop_based","loop_based", g_param_spec_boolean("loop_based","loop_based","loop_based",
TRUE,G_PARAM_READWRITE)); // CHECKME TRUE,G_PARAM_READWRITE)); // CHECKME
@ -145,8 +156,10 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER); G_TYPE_POINTER);
gobject_class->set_property = gst_fakesrc_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = gst_fakesrc_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
} }
static void static void
@ -165,9 +178,9 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->loop_based = TRUE; fakesrc->loop_based = TRUE;
if (fakesrc->loop_based) if (fakesrc->loop_based)
gst_element_set_loop_function (GST_ELEMENT (fakesrc), gst_fakesrc_loop); gst_element_set_loop_function (GST_ELEMENT (fakesrc), GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
else else
gst_pad_set_get_function(pad,gst_fakesrc_get); gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get));
fakesrc->num_buffers = -1; fakesrc->num_buffers = -1;
fakesrc->buffer_count = 0; fakesrc->buffer_count = 0;
@ -176,6 +189,33 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
// gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY); // gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY);
} }
static GstPad*
gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ)
{
gchar *name;
GstPad *srcpad;
GstFakeSrc *fakesrc;
g_return_val_if_fail (GST_IS_FAKESRC (element), NULL);
if (templ->direction != GST_PAD_SRC) {
g_warning ("gstfakesrc: request new pad that is not a SRC pad\n");
return NULL;
}
fakesrc = GST_FAKESRC (element);
name = g_strdup_printf ("src%d", fakesrc->numsrcpads);
srcpad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad);
fakesrc->srcpads = g_slist_prepend (fakesrc->srcpads, srcpad);
fakesrc->numsrcpads++;
return srcpad;
}
static void static void
gst_fakesrc_update_functions (GstFakeSrc *src) gst_fakesrc_update_functions (GstFakeSrc *src)
{ {
@ -201,25 +241,11 @@ static void
gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFakeSrc *src; GstFakeSrc *src;
gint new_numsrcs;
GstPad *pad;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
src = GST_FAKESRC (object); src = GST_FAKESRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES:
new_numsrcs = g_value_get_int (value);
if (new_numsrcs > src->numsrcpads) {
while (src->numsrcpads != new_numsrcs) {
pad = gst_pad_new (g_strdup_printf ("src%d", src->numsrcpads), GST_PAD_SRC);
gst_element_add_pad(GST_ELEMENT(src),pad);
src->srcpads = g_slist_append(src->srcpads,pad);
src->numsrcpads++;
}
gst_fakesrc_update_functions (src);
}
break;
case ARG_LOOP_BASED: case ARG_LOOP_BASED:
src->loop_based = g_value_get_boolean (value); src->loop_based = g_value_get_boolean (value);
gst_fakesrc_update_functions (src); gst_fakesrc_update_functions (src);
@ -385,3 +411,12 @@ gst_fakesrc_loop(GstElement *element)
} }
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
} }
gboolean
gst_fakesrc_factory_init (GstElementFactory *factory)
{
gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (fakesrc_src_factory));
return TRUE;
}

View file

@ -85,6 +85,8 @@ struct _GstFakeSrcClass {
GType gst_fakesrc_get_type(void); GType gst_fakesrc_get_type(void);
gboolean gst_fakesrc_factory_init (GstElementFactory *factory);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View file

@ -36,6 +36,7 @@ GstElementDetails gst_identity_details = {
/* Identity signals and args */ /* Identity signals and args */
enum { enum {
SIGNAL_HANDOFF,
/* FILL ME */ /* FILL ME */
LAST_SIGNAL LAST_SIGNAL
}; };
@ -57,7 +58,7 @@ static void gst_identity_get_property (GObject *object, guint prop_id, GValue *v
static void gst_identity_chain (GstPad *pad, GstBuffer *buf); static void gst_identity_chain (GstPad *pad, GstBuffer *buf);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
//static guint gst_identity_signals[LAST_SIGNAL] = { 0 }; static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
GType GType
gst_identity_get_type (void) gst_identity_get_type (void)
@ -99,8 +100,14 @@ gst_identity_class_init (GstIdentityClass *klass)
g_param_spec_boolean("silent","silent","silent", g_param_spec_boolean("silent","silent","silent",
TRUE,G_PARAM_READWRITE)); // CHECKME TRUE,G_PARAM_READWRITE)); // CHECKME
gobject_class->set_property = gst_identity_set_property; gst_identity_signals[SIGNAL_HANDOFF] =
gobject_class->get_property = gst_identity_get_property; g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
} }
static GstBufferPool* static GstBufferPool*
@ -138,7 +145,7 @@ gst_identity_init (GstIdentity *identity)
{ {
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool); gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink); gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink);
@ -166,6 +173,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n", g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
gst_pad_push (identity->srcpad, buf); gst_pad_push (identity->srcpad, buf);
if (identity->sleep_time) if (identity->sleep_time)
@ -189,7 +199,8 @@ gst_identity_loop (GstElement *element)
g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n", g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
gst_pad_push (identity->srcpad, buf); gst_pad_push (identity->srcpad, buf);

View file

@ -65,6 +65,9 @@ struct _GstIdentity {
struct _GstIdentityClass { struct _GstIdentityClass {
GstElementClass parent_class; GstElementClass parent_class;
/* signals */
void (*handoff) (GstElement *element, GstBuffer *buf);
}; };
GType gst_identity_get_type(void); GType gst_identity_get_type(void);

View file

@ -102,10 +102,10 @@ gst_tee_class_init (GstTeeClass *klass)
g_param_spec_int ("num_pads", "num_pads", "num_pads", g_param_spec_int ("num_pads", "num_pads", "num_pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
gobject_class->set_property = gst_tee_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property);
gobject_class->get_property = gst_tee_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property);
gstelement_class->request_new_pad = gst_tee_request_new_pad; gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad);
} }
static void static void
@ -113,7 +113,7 @@ gst_tee_init (GstTee *tee)
{ {
tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_chain_function (tee->sinkpad, gst_tee_chain); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
tee->numsrcpads = 0; tee->numsrcpads = 0;
tee->srcpads = NULL; tee->srcpads = NULL;

View file

@ -107,16 +107,16 @@ gst_aggregator_class_init (GstAggregatorClass *klass)
g_param_spec_boolean ("silent", "silent", "silent", g_param_spec_boolean ("silent", "silent", "silent",
FALSE, G_PARAM_READWRITE)); FALSE, G_PARAM_READWRITE));
gobject_class->set_property = gst_aggregator_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property);
gobject_class->get_property = gst_aggregator_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property);
gstelement_class->request_new_pad = gst_aggregator_request_new_pad; gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad);
} }
static void static void
gst_aggregator_init (GstAggregator *aggregator) gst_aggregator_init (GstAggregator *aggregator)
{ {
aggregator->srcpad = gst_pad_new ("src", GST_PAD_SINK); aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_element_add_pad (GST_ELEMENT (aggregator), aggregator->srcpad); gst_element_add_pad (GST_ELEMENT (aggregator), aggregator->srcpad);
aggregator->numsinkpads = 0; aggregator->numsinkpads = 0;

View file

@ -49,7 +49,7 @@ struct _elements_entry {
}; };
static struct _elements_entry _elements[] = { static struct _elements_entry _elements[] = {
{ "fakesrc", gst_fakesrc_get_type, &gst_fakesrc_details, NULL }, { "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, NULL },
{ "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL }, { "disksrc", gst_disksrc_get_type, &gst_disksrc_details, NULL },
{ "disksink", gst_disksink_get_type, &gst_disksink_details, NULL }, { "disksink", gst_disksink_get_type, &gst_disksink_details, NULL },

View file

@ -43,7 +43,7 @@ enum {
enum { enum {
ARG_0, ARG_0,
ARG_NUM_SOURCES, ARG_NUM_SINKS,
ARG_SILENT, ARG_SILENT,
}; };
@ -91,12 +91,12 @@ gst_fakesink_class_init (GstFakeSinkClass *klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS,
g_param_spec_int("num_sources","num_sources","num_sources", g_param_spec_int ("num_sinks", "num_sinks", "num_sinks",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SILENT, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
g_param_spec_boolean("silent","silent","silent", g_param_spec_boolean ("silent", "silent", "silent",
TRUE,G_PARAM_READWRITE)); // CHECKME FALSE, G_PARAM_READWRITE));
gst_fakesink_signals[SIGNAL_HANDOFF] = gst_fakesink_signals[SIGNAL_HANDOFF] =
g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
@ -115,35 +115,21 @@ gst_fakesink_init (GstFakeSink *fakesink)
pad = gst_pad_new ("sink", GST_PAD_SINK); pad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (fakesink), pad); gst_element_add_pad (GST_ELEMENT (fakesink), pad);
gst_pad_set_chain_function (pad, gst_fakesink_chain); gst_pad_set_chain_function (pad, gst_fakesink_chain);
fakesink->sinkpads = g_slist_prepend (NULL, pad); fakesink->sinkpads = g_slist_prepend (NULL, pad);
fakesink->numsinkpads = 1; fakesink->numsinkpads = 1;
fakesink->silent = FALSE; fakesink->silent = FALSE;
// we're ready right away, since we don't have any args...
// gst_element_set_state(GST_ELEMENT(fakesink),GST_STATE_READY);
} }
static void static void
gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFakeSink *sink; GstFakeSink *sink;
gint new_numsinks;
GstPad *pad;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
sink = GST_FAKESINK (object); sink = GST_FAKESINK (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES:
new_numsinks = g_value_get_int (value);
while (sink->numsinkpads < new_numsinks) {
pad = gst_pad_new (g_strdup_printf ("sink%d", sink->numsinkpads), GST_PAD_SINK);
gst_pad_set_chain_function (pad, gst_fakesink_chain);
gst_element_add_pad (GST_ELEMENT (sink), pad);
sink->sinkpads = g_slist_append (sink->sinkpads, pad);
sink->numsinkpads++;
}
break;
case ARG_SILENT: case ARG_SILENT:
sink->silent = g_value_get_boolean (value); sink->silent = g_value_get_boolean (value);
break; break;
@ -163,7 +149,7 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam
sink = GST_FAKESINK (object); sink = GST_FAKESINK (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES: case ARG_NUM_SINKS:
g_value_set_int (value, sink->numsinkpads); g_value_set_int (value, sink->numsinkpads);
break; break;
case ARG_SILENT: case ARG_SILENT:

View file

@ -30,7 +30,7 @@ GstElementDetails gst_fakesrc_details = {
"Push empty (no data) buffers around", "Push empty (no data) buffers around",
VERSION, VERSION,
"Erik Walthinsen <omega@cse.ogi.edu>\n" "Erik Walthinsen <omega@cse.ogi.edu>\n"
"Wim Taymans <wim.taymans@chello.be>" "Wim Taymans <wim.taymans@chello.be>",
"(C) 1999", "(C) 1999",
}; };
@ -53,9 +53,17 @@ enum {
ARG_SILENT ARG_SILENT
}; };
GST_PADTEMPLATE_FACTORY (fakesrc_src_factory,
"src%d",
GST_PAD_SRC,
GST_PAD_REQUEST,
NULL /* no caps */
);
#define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type()) #define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type())
static GType static GType
gst_fakesrc_output_get_type(void) { gst_fakesrc_output_get_type (void)
{
static GType fakesrc_output_type = 0; static GType fakesrc_output_type = 0;
static GEnumValue fakesrc_output[] = { static GEnumValue fakesrc_output[] = {
{ FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"},
@ -69,7 +77,7 @@ gst_fakesrc_output_get_type(void) {
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!fakesrc_output_type) { if (!fakesrc_output_type) {
fakesrc_output_type = g_enum_register_static("GstFakeSrcOutput", fakesrc_output); fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output);
} }
return fakesrc_output_type; return fakesrc_output_type;
} }
@ -77,6 +85,7 @@ gst_fakesrc_output_get_type(void) {
static void gst_fakesrc_class_init (GstFakeSrcClass *klass); static void gst_fakesrc_class_init (GstFakeSrcClass *klass);
static void gst_fakesrc_init (GstFakeSrc *fakesrc); static void gst_fakesrc_init (GstFakeSrc *fakesrc);
static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ);
static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
@ -112,14 +121,16 @@ static void
gst_fakesrc_class_init (GstFakeSrcClass *klass) gst_fakesrc_class_init (GstFakeSrcClass *klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass*)klass; gobject_class = (GObjectClass*)klass;
gstelement_class = (GstElementClass*)klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NUM_SOURCES, g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES,
g_param_spec_int("num_sources","num_sources","num_sources", g_param_spec_int ("num_sources", "num_sources", "num_sources",
G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); // CHECKME 1, G_MAXINT, 1, G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED, g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOOP_BASED,
g_param_spec_boolean("loop_based","loop_based","loop_based", g_param_spec_boolean("loop_based","loop_based","loop_based",
TRUE,G_PARAM_READWRITE)); // CHECKME TRUE,G_PARAM_READWRITE)); // CHECKME
@ -145,8 +156,10 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass)
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER); G_TYPE_POINTER);
gobject_class->set_property = gst_fakesrc_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property);
gobject_class->get_property = gst_fakesrc_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property);
gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad);
} }
static void static void
@ -165,9 +178,9 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
fakesrc->loop_based = TRUE; fakesrc->loop_based = TRUE;
if (fakesrc->loop_based) if (fakesrc->loop_based)
gst_element_set_loop_function (GST_ELEMENT (fakesrc), gst_fakesrc_loop); gst_element_set_loop_function (GST_ELEMENT (fakesrc), GST_DEBUG_FUNCPTR (gst_fakesrc_loop));
else else
gst_pad_set_get_function(pad,gst_fakesrc_get); gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get));
fakesrc->num_buffers = -1; fakesrc->num_buffers = -1;
fakesrc->buffer_count = 0; fakesrc->buffer_count = 0;
@ -176,6 +189,33 @@ gst_fakesrc_init (GstFakeSrc *fakesrc)
// gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY); // gst_element_set_state(GST_ELEMENT(fakesrc),GST_STATE_READY);
} }
static GstPad*
gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ)
{
gchar *name;
GstPad *srcpad;
GstFakeSrc *fakesrc;
g_return_val_if_fail (GST_IS_FAKESRC (element), NULL);
if (templ->direction != GST_PAD_SRC) {
g_warning ("gstfakesrc: request new pad that is not a SRC pad\n");
return NULL;
}
fakesrc = GST_FAKESRC (element);
name = g_strdup_printf ("src%d", fakesrc->numsrcpads);
srcpad = gst_pad_new_from_template (templ, name);
gst_element_add_pad (GST_ELEMENT (fakesrc), srcpad);
fakesrc->srcpads = g_slist_prepend (fakesrc->srcpads, srcpad);
fakesrc->numsrcpads++;
return srcpad;
}
static void static void
gst_fakesrc_update_functions (GstFakeSrc *src) gst_fakesrc_update_functions (GstFakeSrc *src)
{ {
@ -201,25 +241,11 @@ static void
gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{ {
GstFakeSrc *src; GstFakeSrc *src;
gint new_numsrcs;
GstPad *pad;
/* it's not null if we got it, but it might not be ours */ /* it's not null if we got it, but it might not be ours */
src = GST_FAKESRC (object); src = GST_FAKESRC (object);
switch (prop_id) { switch (prop_id) {
case ARG_NUM_SOURCES:
new_numsrcs = g_value_get_int (value);
if (new_numsrcs > src->numsrcpads) {
while (src->numsrcpads != new_numsrcs) {
pad = gst_pad_new (g_strdup_printf ("src%d", src->numsrcpads), GST_PAD_SRC);
gst_element_add_pad(GST_ELEMENT(src),pad);
src->srcpads = g_slist_append(src->srcpads,pad);
src->numsrcpads++;
}
gst_fakesrc_update_functions (src);
}
break;
case ARG_LOOP_BASED: case ARG_LOOP_BASED:
src->loop_based = g_value_get_boolean (value); src->loop_based = g_value_get_boolean (value);
gst_fakesrc_update_functions (src); gst_fakesrc_update_functions (src);
@ -385,3 +411,12 @@ gst_fakesrc_loop(GstElement *element)
} }
} while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element));
} }
gboolean
gst_fakesrc_factory_init (GstElementFactory *factory)
{
gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (fakesrc_src_factory));
return TRUE;
}

View file

@ -85,6 +85,8 @@ struct _GstFakeSrcClass {
GType gst_fakesrc_get_type(void); GType gst_fakesrc_get_type(void);
gboolean gst_fakesrc_factory_init (GstElementFactory *factory);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View file

@ -36,6 +36,7 @@ GstElementDetails gst_identity_details = {
/* Identity signals and args */ /* Identity signals and args */
enum { enum {
SIGNAL_HANDOFF,
/* FILL ME */ /* FILL ME */
LAST_SIGNAL LAST_SIGNAL
}; };
@ -57,7 +58,7 @@ static void gst_identity_get_property (GObject *object, guint prop_id, GValue *v
static void gst_identity_chain (GstPad *pad, GstBuffer *buf); static void gst_identity_chain (GstPad *pad, GstBuffer *buf);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
//static guint gst_identity_signals[LAST_SIGNAL] = { 0 }; static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
GType GType
gst_identity_get_type (void) gst_identity_get_type (void)
@ -99,8 +100,14 @@ gst_identity_class_init (GstIdentityClass *klass)
g_param_spec_boolean("silent","silent","silent", g_param_spec_boolean("silent","silent","silent",
TRUE,G_PARAM_READWRITE)); // CHECKME TRUE,G_PARAM_READWRITE)); // CHECKME
gobject_class->set_property = gst_identity_set_property; gst_identity_signals[SIGNAL_HANDOFF] =
gobject_class->get_property = gst_identity_get_property; g_signal_newc ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER);
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
} }
static GstBufferPool* static GstBufferPool*
@ -138,7 +145,7 @@ gst_identity_init (GstIdentity *identity)
{ {
identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool); gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink); gst_pad_set_negotiate_function (identity->sinkpad, gst_identity_negotiate_sink);
@ -166,6 +173,9 @@ gst_identity_chain (GstPad *pad, GstBuffer *buf)
g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n", g_print("identity: chain ******* (%s:%s)i (%d bytes, %llu) \n",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
gst_pad_push (identity->srcpad, buf); gst_pad_push (identity->srcpad, buf);
if (identity->sleep_time) if (identity->sleep_time)
@ -189,7 +199,8 @@ gst_identity_loop (GstElement *element)
g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n", g_print("identity: loop ******* (%s:%s)i (%d bytes, %llu) \n",
GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf));
g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
buf);
gst_pad_push (identity->srcpad, buf); gst_pad_push (identity->srcpad, buf);

View file

@ -65,6 +65,9 @@ struct _GstIdentity {
struct _GstIdentityClass { struct _GstIdentityClass {
GstElementClass parent_class; GstElementClass parent_class;
/* signals */
void (*handoff) (GstElement *element, GstBuffer *buf);
}; };
GType gst_identity_get_type(void); GType gst_identity_get_type(void);

View file

@ -102,10 +102,10 @@ gst_tee_class_init (GstTeeClass *klass)
g_param_spec_int ("num_pads", "num_pads", "num_pads", g_param_spec_int ("num_pads", "num_pads", "num_pads",
0, G_MAXINT, 0, G_PARAM_READABLE)); 0, G_MAXINT, 0, G_PARAM_READABLE));
gobject_class->set_property = gst_tee_set_property; gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property);
gobject_class->get_property = gst_tee_get_property; gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property);
gstelement_class->request_new_pad = gst_tee_request_new_pad; gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad);
} }
static void static void
@ -113,7 +113,7 @@ gst_tee_init (GstTee *tee)
{ {
tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad);
gst_pad_set_chain_function (tee->sinkpad, gst_tee_chain); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain));
tee->numsrcpads = 0; tee->numsrcpads = 0;
tee->srcpads = NULL; tee->srcpads = NULL;