diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index c5c28c1b52..ecb7592d25 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -34,6 +34,7 @@ GstElementDetails gst_fakesrc_details = { /* FakeSrc signals and args */ enum { /* FILL ME */ + SIGNAL_HANDOFF, LAST_SIGNAL }; @@ -52,7 +53,7 @@ static void gst_fakesrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static GstBuffer * gst_fakesrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; -//static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; +static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; GtkType gst_fakesrc_get_type (void) @@ -91,6 +92,15 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) gtkobject_class->set_arg = gst_fakesrc_set_arg; gtkobject_class->get_arg = gst_fakesrc_get_arg; + + gst_fakesrc_signals[SIGNAL_HANDOFF] = + gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type, + GTK_SIGNAL_OFFSET (GstFakeSrcClass, handoff), + gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (gtkobject_class, gst_fakesrc_signals, + LAST_SIGNAL); + } static void gst_fakesrc_init(GstFakeSrc *fakesrc) { @@ -170,11 +180,15 @@ gst_fakesrc_get(GstPad *pad) GstFakeSrc *src; GstBuffer *buf; - g_return_if_fail(pad != NULL); + g_return_val_if_fail(pad != NULL, NULL); src = GST_FAKESRC(gst_pad_get_parent(pad)); - g_return_if_fail(GST_IS_FAKESRC(src)); + g_return_val_if_fail(GST_IS_FAKESRC(src), NULL); g_print("(%s:%s)> ",GST_DEBUG_PAD_NAME(pad)); buf = gst_buffer_new(); + + gtk_signal_emit (GTK_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], + src); + return buf; } diff --git a/gst/elements/gstfakesrc.h b/gst/elements/gstfakesrc.h index bbda3fda45..2fd445335f 100644 --- a/gst/elements/gstfakesrc.h +++ b/gst/elements/gstfakesrc.h @@ -57,6 +57,9 @@ struct _GstFakeSrc { struct _GstFakeSrcClass { GstSrcClass parent_class; + + /* signals */ + void (*handoff) (GstElement *element,GstPad *pad); }; GtkType gst_fakesrc_get_type(void); diff --git a/gst/gstbin.c b/gst/gstbin.c index ff6d859671..f1c1e10ceb 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -141,9 +141,7 @@ gst_bin_init (GstBin *bin) GstElement* gst_bin_new (gchar *name) { - GstElement *bin = GST_ELEMENT (gtk_type_new (GST_TYPE_BIN)); - gst_element_set_name (GST_ELEMENT (bin), name); - return bin; + return gst_elementfactory_make ("bin", name); } /** @@ -688,6 +686,11 @@ gst_bin_create_plan_func (GstBin *bin) // otherwise, it's what our parent says it is } else { manager = gst_element_get_manager (GST_ELEMENT (bin)); + if (!manager) { + DEBUG("manager not set for element \"%s\" assuming manager is self\n", gst_element_get_name (GST_ELEMENT (bin))); + manager = GST_ELEMENT (bin); + GST_FLAG_SET (bin, GST_BIN_FLAG_MANAGER); + } DEBUG("setting manager to \"%s\"\n", gst_element_get_name (manager)); } @@ -841,8 +844,9 @@ gst_bin_create_plan_func (GstBin *bin) // check to see if someone else gets to set up the element peer_manager = GST_ELEMENT((pad)->peer->parent)->manager; - if (peer_manager != GST_ELEMENT(bin)) + if (peer_manager != GST_ELEMENT(bin)) { DEBUG("WARNING: pad %s:%s is connected outside of bin\n",GST_DEBUG_PAD_NAME(pad)); + } // if the wrapper_function is set, we need to use the proxy functions if (wrapper_function != NULL) { diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index eb04415935..3093b4c438 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -106,17 +106,12 @@ gst_elementfactory_new (gchar *name, GtkType type, GstElementDetails *details) { GstElementFactory *factory = g_new0(GstElementFactory, 1); - GstElementClass *gstelement_class; factory->name = g_strdup(name); factory->type = type; factory->details = details; factory->padtemplates = NULL; - gstelement_class = (GstElementClass*) gtk_type_class (GST_TYPE_ELEMENT); - - gstelement_class->elementfactory = factory; - _gst_elementfactories = g_list_prepend (_gst_elementfactories, factory); return factory; @@ -158,8 +153,10 @@ gst_elementfactory_create (GstElementFactory *factory, // attempt to set the elemenfactory class pointer if necessary oclass = GST_ELEMENT_CLASS(GTK_OBJECT(element)->klass); - if (oclass->elementfactory == NULL) + if (oclass->elementfactory == NULL) { + g_print ("gstelementfactory: class %s\n", factory->name); oclass->elementfactory = factory; + } gst_element_set_name(GST_ELEMENT(element),name); diff --git a/gst/gstpad.c b/gst/gstpad.c index e098efe60a..15ab91eb0f 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -622,12 +622,15 @@ gst_pad_connect (GstPad *srcpad, /* chack pad compatibility */ if (srcpad->caps && sinkpad->caps) { if (!gst_caps_check_compatibility (srcpad->caps, sinkpad->caps)) - g_warning ("gstpad: connecting incompatible pads"); + g_warning ("gstpad: connecting incompatible pads (%s:%s) and (%s:%s)\n", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); else - g_print ("gstpad: connecting compatible pads\n"); + g_print ("gstpad: connecting compatible pads (%s:%s) and (%s:%s)\n", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); } else - g_print ("gstpad: could not check capabilities of pads\n"); + g_print ("gstpad: could not check capabilities of pads (%s:%s) and (%s:%s)\n", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); /* first set peers */ srcpad->peer = sinkpad; diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index 60080c9d5d..7bc3d20ffc 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -113,12 +113,7 @@ gst_pipeline_init (GstPipeline *pipeline) GstElement* gst_pipeline_new (guchar *name) { - GstPipeline *pipeline; - - pipeline = gtk_type_new (gst_pipeline_get_type ()); - gst_element_set_name (GST_ELEMENT (pipeline), name); - - return GST_ELEMENT (pipeline); + return gst_elementfactory_make ("bin", name); } static void diff --git a/gst/gstthread.c b/gst/gstthread.c index 07172eec6b..972e70a11d 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -121,6 +121,7 @@ gst_thread_init (GstThread *thread) // default is to create a thread GST_FLAG_SET (thread, GST_THREAD_CREATE); + GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING); thread->lock = g_mutex_new(); thread->cond = g_cond_new(); @@ -189,15 +190,7 @@ gst_thread_get_arg (GtkObject *object, GstElement* gst_thread_new (guchar *name) { - GstThread *thread; - - thread = gtk_type_new (gst_thread_get_type ()); - - gst_element_set_name (GST_ELEMENT (thread), name); - - GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING); - - return GST_ELEMENT (thread); + return gst_elementfactory_make ("bin", name); } diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index c5c28c1b52..ecb7592d25 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -34,6 +34,7 @@ GstElementDetails gst_fakesrc_details = { /* FakeSrc signals and args */ enum { /* FILL ME */ + SIGNAL_HANDOFF, LAST_SIGNAL }; @@ -52,7 +53,7 @@ static void gst_fakesrc_get_arg (GtkObject *object, GtkArg *arg, guint id); static GstBuffer * gst_fakesrc_get (GstPad *pad); static GstSrcClass *parent_class = NULL; -//static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; +static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; GtkType gst_fakesrc_get_type (void) @@ -91,6 +92,15 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) gtkobject_class->set_arg = gst_fakesrc_set_arg; gtkobject_class->get_arg = gst_fakesrc_get_arg; + + gst_fakesrc_signals[SIGNAL_HANDOFF] = + gtk_signal_new ("handoff", GTK_RUN_LAST, gtkobject_class->type, + GTK_SIGNAL_OFFSET (GstFakeSrcClass, handoff), + gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (gtkobject_class, gst_fakesrc_signals, + LAST_SIGNAL); + } static void gst_fakesrc_init(GstFakeSrc *fakesrc) { @@ -170,11 +180,15 @@ gst_fakesrc_get(GstPad *pad) GstFakeSrc *src; GstBuffer *buf; - g_return_if_fail(pad != NULL); + g_return_val_if_fail(pad != NULL, NULL); src = GST_FAKESRC(gst_pad_get_parent(pad)); - g_return_if_fail(GST_IS_FAKESRC(src)); + g_return_val_if_fail(GST_IS_FAKESRC(src), NULL); g_print("(%s:%s)> ",GST_DEBUG_PAD_NAME(pad)); buf = gst_buffer_new(); + + gtk_signal_emit (GTK_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], + src); + return buf; } diff --git a/plugins/elements/gstfakesrc.h b/plugins/elements/gstfakesrc.h index bbda3fda45..2fd445335f 100644 --- a/plugins/elements/gstfakesrc.h +++ b/plugins/elements/gstfakesrc.h @@ -57,6 +57,9 @@ struct _GstFakeSrc { struct _GstFakeSrcClass { GstSrcClass parent_class; + + /* signals */ + void (*handoff) (GstElement *element,GstPad *pad); }; GtkType gst_fakesrc_get_type(void); diff --git a/tests/sched/cases/(fs-i-i-fs).xml b/tests/sched/cases/(fs-i-i-fs).xml index a4ebc74b0c..2f49604c7c 100644 --- a/tests/sched/cases/(fs-i-i-fs).xml +++ b/tests/sched/cases/(fs-i-i-fs).xml @@ -14,7 +14,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -30,14 +30,14 @@ 0.9.2 sink - identity.src + identity2.src GtkObject::user_data - identity + identity1 identity 0.9.2 @@ -46,7 +46,7 @@ src - identity.sink + identity2.sink GstIdentity::loop_based @@ -57,12 +57,12 @@ - identity + identity2 identity 0.9.2 sink - identity.src + identity1.src src @@ -92,7 +92,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -115,7 +115,7 @@ - identity + identity1 identity 0.9.2 @@ -140,7 +140,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -170,7 +170,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -193,7 +193,7 @@ - identity + identity1 identity 0.9.2 @@ -218,7 +218,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -248,7 +248,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -271,7 +271,7 @@ - identity + identity1 identity 0.9.2 @@ -296,7 +296,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -326,7 +326,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -349,7 +349,7 @@ - identity + identity1 identity 0.9.2 @@ -374,7 +374,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -404,7 +404,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -427,7 +427,7 @@ - identity + identity1 identity 0.9.2 @@ -452,7 +452,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -482,7 +482,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -505,7 +505,7 @@ - identity + identity1 identity 0.9.2 @@ -530,7 +530,7 @@ 0.9.2 sink - identity.src + identity1.src src @@ -560,7 +560,7 @@ 0.9.2 src - identity.sink + identity1.sink GstFakeSrc::num_sources @@ -583,7 +583,7 @@ - identity + identity1 identity 0.9.2 @@ -608,7 +608,7 @@ 0.9.2 sink - identity.src + identity1.src src diff --git a/tests/sched/runxml.c b/tests/sched/runxml.c index af38833553..e1e2e658a5 100644 --- a/tests/sched/runxml.c +++ b/tests/sched/runxml.c @@ -1,10 +1,21 @@ #include +static guint outcount, incount; + static void -buffer_handoff (GstElement *src, GstElement *bin) +buffer_handoff_sink (GstElement *src, GstElement *bin) { g_print ("\n\n *** buffer arrived in sink ***\n\n"); gst_element_set_state(bin, GST_STATE_NULL); + + outcount++; +} + +static void +buffer_handoff_src (GstElement *src, GstElement *bin) +{ + g_print ("\n\n *** buffer started in src ***\n\n"); + incount++; } /* eos will be called when the src element has an end of stream */ @@ -40,6 +51,8 @@ int main(int argc,char *argv[]) src = gst_bin_get_by_name (GST_BIN (bin), "fakesrc"); if (src) { + gtk_signal_connect (GTK_OBJECT(src), "handoff", + GTK_SIGNAL_FUNC(buffer_handoff_src), bin); } else { g_print ("could not find src element\n"); @@ -49,13 +62,16 @@ int main(int argc,char *argv[]) sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink"); if (sink) { gtk_signal_connect (GTK_OBJECT(sink), "handoff", - GTK_SIGNAL_FUNC(buffer_handoff), bin); + GTK_SIGNAL_FUNC(buffer_handoff_sink), bin); } else { g_print ("could not find sink element\n"); exit(-1); } + incount = 0; + outcount = 0; + gst_element_set_state(bin, GST_STATE_READY); gst_element_set_state(bin, GST_STATE_PLAYING); @@ -66,6 +82,11 @@ int main(int argc,char *argv[]) gst_bin_iterate(GST_BIN(bin)); } + if (outcount != 1 && incount != 1) { + g_print ("test failed\n"); + exit (-1); + } + toplevelelements = g_list_next (toplevelelements); }