Fixed a bug in gstbin.c the manager was not detected.

Original commit message from CVS:
Fixed a bug in gstbin.c the manager was not detected.
Some other testcases
bin, thread, pipeline use the elementfactory on gst_*_new
This commit is contained in:
Wim Taymans 2000-12-22 23:23:10 +00:00
parent 9987a75b1b
commit 0062e168ca
11 changed files with 110 additions and 63 deletions

View file

@ -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;
}

View file

@ -57,6 +57,9 @@ struct _GstFakeSrc {
struct _GstFakeSrcClass {
GstSrcClass parent_class;
/* signals */
void (*handoff) (GstElement *element,GstPad *pad);
};
GtkType gst_fakesrc_get_type(void);

View file

@ -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) {

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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);
}

View file

@ -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;
}

View file

@ -57,6 +57,9 @@ struct _GstFakeSrc {
struct _GstFakeSrcClass {
GstSrcClass parent_class;
/* signals */
void (*handoff) (GstElement *element,GstPad *pad);
};
GtkType gst_fakesrc_get_type(void);

View file

@ -14,7 +14,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -30,14 +30,14 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity2.src</peer>
</pad>
<arg>
<name>GtkObject::user_data</name>
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -46,7 +46,7 @@
</pad>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity2.sink</peer>
</pad>
<arg>
<name>GstIdentity::loop_based</name>
@ -57,12 +57,12 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity2</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -92,7 +92,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -115,7 +115,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -140,7 +140,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -170,7 +170,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -193,7 +193,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -218,7 +218,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -248,7 +248,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -271,7 +271,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -296,7 +296,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -326,7 +326,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -349,7 +349,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -374,7 +374,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -404,7 +404,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -427,7 +427,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -452,7 +452,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -482,7 +482,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -505,7 +505,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -530,7 +530,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>
@ -560,7 +560,7 @@
<version>0.9.2</version>
<pad>
<name>src</name>
<peer>identity.sink</peer>
<peer>identity1.sink</peer>
</pad>
<arg>
<name>GstFakeSrc::num_sources</name>
@ -583,7 +583,7 @@
</arg>
</element>
<element>
<name>identity</name>
<name>identity1</name>
<type>identity</type>
<version>0.9.2</version>
<pad>
@ -608,7 +608,7 @@
<version>0.9.2</version>
<pad>
<name>sink</name>
<peer>identity.src</peer>
<peer>identity1.src</peer>
</pad>
<pad>
<name>src</name>

View file

@ -1,10 +1,21 @@
#include <gst/gst.h>
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);
}