Fixed autoplugging.

Original commit message from CVS:
Fixed autoplugging.
This commit is contained in:
Wim Taymans 2000-12-05 18:08:59 +00:00
parent 06913f27c3
commit 855b6877e9
6 changed files with 47 additions and 41 deletions

View file

@ -81,7 +81,7 @@ noinst_HEADERS = \
gsti386.h \
gstppc.h
#CFLAGS += -O2 -Wall
CFLAGS += -O6 -Wall
libgst_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS)
libgst_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)

View file

@ -120,6 +120,7 @@ gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc)
{
GST_SRC_SET_FLAGS (asyncdisksrc, GST_SRC_ASYNC);
g_print("init\n");
asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_pull_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull);
// FIXME must set pullregion

View file

@ -567,7 +567,6 @@ gst_bin_pullsrc_wrapper (int argc,char *argv[])
GstElement *element = GST_ELEMENT (argv);
GList *pads;
GstPad *pad;
GstBuffer *buf;
G_GNUC_UNUSED const gchar *name = gst_element_get_name (element);
DEBUG("entering gst_bin_pullsrc_wrapper(%d,\"%s\")\n",argc,name);
@ -577,7 +576,7 @@ gst_bin_pullsrc_wrapper (int argc,char *argv[])
while (pads) {
pad = GST_PAD (pads->data);
if (pad->direction == GST_PAD_SRC) {
if (pad->pullfunc == NULL) fprintf(stderr,"error, no pullfunc\n");
if (pad->pullfunc == NULL) fprintf(stderr,"error, no pullfunc in \"%s\"\n", name);
(pad->pullfunc)(pad);
}
pads = g_list_next(pads);
@ -839,7 +838,7 @@ gst_bin_iterate_func (GstBin *bin)
GList *pads;
GstPad *pad;
DEBUG_ENTER("(%s)",gst_element_get_name(GST_ELEMENT(bin)));
DEBUG_ENTER("(%s)", gst_element_get_name (GST_ELEMENT (bin)));
g_return_if_fail (bin != NULL);
g_return_if_fail (GST_IS_BIN (bin));
@ -849,7 +848,7 @@ gst_bin_iterate_func (GstBin *bin)
// all we really have to do is switch to the first child
// FIXME this should be lots more intelligent about where to start
GST_FLAG_SET(GST_ELEMENT (bin->children->data),GST_ELEMENT_COTHREAD_STOPPING);
GST_FLAG_SET (GST_ELEMENT (bin->children->data), GST_ELEMENT_COTHREAD_STOPPING);
cothread_switch (GST_ELEMENT (bin->children->data)->threadstate);
} else {
@ -862,33 +861,33 @@ gst_bin_iterate_func (GstBin *bin)
entries = bin->entries;
}
g_assert(entries != NULL);
g_assert (entries != NULL);
while (entries) {
entry = GST_ELEMENT (entries->data);
if (GST_IS_SRC (entry)) {
// if (GST_SRC_PUSH_FUNCTION(entry))
// gst_src_push (GST_SRC (entry));
// else {
pads = entry->pads;
while (pads) {
pad = GST_PAD(pads->data);
if (pad->direction == GST_PAD_SRC) {
if (pad->pullfunc == NULL) fprintf(stderr,"error, no pullfunc\n");
pads = entry->pads;
while (pads) {
pad = GST_PAD (pads->data);
if (pad->direction == GST_PAD_SRC) {
if (pad->pullfunc == NULL)
fprintf(stderr, "error, no pullfunc in \"%s\"\n", gst_element_get_name (entry));
else
(pad->pullfunc)(pad);
}
pads = g_list_next(pads);
}
// }
pads = g_list_next (pads);
}
} else if (GST_IS_CONNECTION (entry))
gst_connection_push (GST_CONNECTION (entry));
else if (GST_IS_BIN (entry))
gst_bin_iterate (GST_BIN (entry));
else
else {
fprintf(stderr, "gstbin: entry \"%s\" cannot be handled\n", gst_element_get_name (entry));
g_assert_not_reached ();
}
entries = g_list_next (entries);
}
}
DEBUG_LEAVE("(%s)",gst_element_get_name(GST_ELEMENT(bin)));
DEBUG_LEAVE("(%s)", gst_element_get_name (GST_ELEMENT (bin)));
}

View file

@ -505,8 +505,6 @@ gst_pad_disconnect (GstPad *srcpad,
srcpad->peer = NULL;
sinkpad->peer = NULL;
srcpad->chainfunc = NULL;
srcpad->pullfunc = NULL;
}
/**
@ -688,7 +686,7 @@ gst_pad_add_type_id (GstPad *pad,
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (gst_type_find_by_id (id) != NULL);
g_list_append(pad->types, GINT_TO_POINTER((gint)id));
pad->types = g_list_append(pad->types, GINT_TO_POINTER((gint)id));
}
/**

View file

@ -157,15 +157,15 @@ gst_pipeline_typefind (GstPipeline *pipeline, GstElement *element)
gst_bin_add (GST_BIN (pipeline), typefind);
gst_bin_create_plan (GST_BIN (pipeline));
gst_element_set_state (GST_ELEMENT (element), GST_STATE_READY);
gst_element_set_state (GST_ELEMENT (element), GST_STATE_PLAYING);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
// keep pushing buffers... the have_type signal handler will set the found flag
// while (!found) {
// gst_src_push(GST_SRC(element));
// }
while (!found) {
gst_bin_iterate (GST_BIN (pipeline));
}
gst_element_set_state (GST_ELEMENT (element), GST_STATE_NULL);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
if (found) {
type_id = gst_util_get_int_arg (GTK_OBJECT (typefind), "type");
@ -187,7 +187,7 @@ gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
gboolean connected = FALSE;
guint16 type;
type = ((GstType *)pad->types->data)->id;
type = GPOINTER_TO_INT (pad->types->data);
g_print("gstpipeline: autoplug pad connect function type %d for \"%s\" to \"%s\"\n", type,
gst_element_get_name(src), gst_element_get_name(sink));
@ -195,7 +195,7 @@ gst_pipeline_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
sinkpads = gst_element_get_pad_list(sink);
while (sinkpads) {
GstPad *sinkpad = (GstPad *)sinkpads->data;
guint16 sinktype = ((GstType *)sinkpad->types->data)->id;
guint16 sinktype = GPOINTER_TO_INT (sinkpad->types->data);
// if we have a match, connect the pads
if (sinktype == type &&
@ -228,9 +228,10 @@ gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink)
while (srcpads) {
GstPad *srcpad = (GstPad *)srcpads->data;
GList *srctypes = gst_pad_get_type_ids(srcpad);
guint16 srctype = 0;
if (srcpad)
srctype = ((GstType *)srcpad->types->data)->id;
if (srctypes)
srctype = GPOINTER_TO_INT (srctypes->data);
if (srcpad->direction == GST_PAD_SRC && !GST_PAD_CONNECTED(srcpad)) {
@ -238,9 +239,10 @@ gst_pipeline_pads_autoplug (GstElement *src, GstElement *sink)
// FIXME could O(n) if the types were sorted...
while (sinkpads) {
GstPad *sinkpad = (GstPad *)sinkpads->data;
GList *sinktypes = gst_pad_get_type_ids(sinkpad);
guint16 sinktype = 0;
if (srcpad)
sinktype = ((GstType *)sinkpad->types->data)->id;
if (sinktypes)
sinktype = GPOINTER_TO_INT (sinktypes->data);
// if we have a match, connect the pads
if (sinktype == srctype &&
@ -400,12 +402,15 @@ gst_pipeline_autoplug (GstPipeline *pipeline)
if (pad->direction == GST_PAD_SINK) {
GList *types = gst_pad_get_type_ids(pad);
if (types)
if (types) {
sink_type = GPOINTER_TO_INT (types->data);
break;
}
else
sink_type = 0;
break;
}
g_print ("type %d\n", sink_type);
pads = g_list_next(pads);
}
@ -415,7 +420,7 @@ gst_pipeline_autoplug (GstPipeline *pipeline)
elements = g_list_next(elements);
}
while (factories[0]) {
// fase 3: add common elements
factory = (GstElementFactory *)(factories[0]->data);
@ -497,15 +502,17 @@ differ:
sinkpad = (GstPad *)sinkpads->data;
// FIXME connect matching pads, not just the first one...
/*
if (sinkpad->direction == GST_PAD_SINK &&
!GST_PAD_CONNECTED(sinkpad)) {
guint16 sinktype = 0;
GList *types = gst_pad_get_type_ids(sinkpad);
if (types)
sinktype = GPOINTER_TO_INT (types->data);
// the queue has the type of the elements it connects
srcpad->type = sinkpad->type;
gst_element_get_pad(queue, "sink")->type = sinkpad->type;
gst_pad_set_type_id (srcpad, sinktype);
gst_pad_set_type_id (gst_element_get_pad(queue, "sink"), sinktype);
break;
}
*/
sinkpads = g_list_next(sinkpads);
}
gst_pipeline_pads_autoplug(thesrcelement, queue);

View file

@ -120,6 +120,7 @@ gst_asyncdisksrc_init (GstAsyncDiskSrc *asyncdisksrc)
{
GST_SRC_SET_FLAGS (asyncdisksrc, GST_SRC_ASYNC);
g_print("init\n");
asyncdisksrc->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_pull_function (asyncdisksrc->srcpad,gst_asyncdisksrc_pull);
// FIXME must set pullregion