should restore dynamic connection of pads (couldn't really test it though)

Original commit message from CVS:
should restore dynamic connection of pads (couldn't really test it though)
This commit is contained in:
Steve Baker 2001-06-15 06:33:29 +00:00
parent 4af8c58268
commit 933a7aeff4

View file

@ -278,95 +278,91 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
gst_bin_add (GST_BIN (parent), element); gst_bin_add (GST_BIN (parent), element);
elementcount++; elementcount++;
if (srcpads != NULL) { g_slist_free(sinkpads);
sinkpads = NULL;
numsinkpads=0;
tempname=NULL;
g_slist_free(sinkpads); // find sink pads
sinkpads = NULL; if (sinkpadname != NULL) {
numsinkpads=0; while (1){
tempname=NULL; // split name at commas
if ((ptr = strchr(sinkpadname,','))){
// find sink pads tempname = g_strndup(sinkpadname,(ptr-sinkpadname));
if (sinkpadname != NULL) { sinkpadname = &ptr[1];
while (1){ } else {
// split name at commas tempname = sinkpadname;
if ((ptr = strchr(sinkpadname,','))){
tempname = g_strndup(sinkpadname,(ptr-sinkpadname));
sinkpadname = &ptr[1];
} else {
tempname = sinkpadname;
}
// look for pad with that name
if ((temppad = gst_element_get_pad(element,tempname))){
sinkpads = g_slist_append(sinkpads,temppad);
numsinkpads++;
}
// try to create a pad using that padtemplate name
else if ((temppad = gst_element_request_pad_by_name(element,tempname))) {
sinkpads = g_slist_append(sinkpads,temppad);
numsinkpads++;
}
if (!temppad) {
GST_DEBUG(0,"NO SUCH pad %s in element %s\n",tempname,GST_ELEMENT_NAME(element));
} else {
GST_DEBUG(0,"have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(temppad));
}
// if there is no more commas in sinkpadname then we're done
if (tempname == sinkpadname) break;
g_free(tempname);
} }
}
else { // look for pad with that name
// check through the list to find the first sink pad if ((temppad = gst_element_get_pad(element,tempname))){
pads = gst_element_get_pad_list(element); sinkpads = g_slist_append(sinkpads,temppad);
while (pads) { numsinkpads++;
temppad = GST_PAD(pads->data);
pads = g_list_next (pads);
if (gst_pad_get_direction (temppad) == GST_PAD_SINK){
sinkpads = g_slist_append(sinkpads,temppad);
numsinkpads++;
break;
}
} }
}
// try to create a pad using that padtemplate name
if (!sinkpads) DEBUG("error, can't find a sink pad!!!\n"); else if ((temppad = gst_element_request_pad_by_name(element,tempname))) {
else DEBUG("have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads))); sinkpads = g_slist_append(sinkpads,temppad);
numsinkpads++;
if (!srcpads) {
dyn_connect *connect = g_malloc (sizeof (dyn_connect));
connect->srcpadname = srcpadname;
connect->target = GST_PARSE_LISTPAD(sinkpads);
GST_DEBUG(0,"SETTING UP dynamic connection %s:%s and %s:%s\n",
gst_element_get_name (previous),
srcpadname,
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads)));
gtk_signal_connect (GTK_OBJECT (previous), "new_pad", dynamic_connect, connect);
gtk_signal_connect (GTK_OBJECT (previous), "new_ghost_pad", dynamic_connect, connect);
}
else {
for (j=0; (j<numsrcpads) && (j<numsinkpads); j++){
GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(g_slist_nth(srcpads,j))),
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(g_slist_nth(sinkpads,j))));
gst_pad_connect(
GST_PARSE_LISTPAD(g_slist_nth(srcpads,j)),
GST_PARSE_LISTPAD(g_slist_nth(sinkpads,j)));
} }
if (!temppad) {
GST_DEBUG(0,"NO SUCH pad %s in element %s\n",tempname,GST_ELEMENT_NAME(element));
} else {
GST_DEBUG(0,"have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(temppad));
}
// if there is no more commas in sinkpadname then we're done
if (tempname == sinkpadname) break;
g_free(tempname);
} }
g_slist_free(srcpads);
srcpads = NULL;
g_slist_free(sinkpads);
sinkpads = NULL;
} }
else {
// check through the list to find the first sink pad
pads = gst_element_get_pad_list(element);
while (pads) {
temppad = GST_PAD(pads->data);
pads = g_list_next (pads);
if (gst_pad_get_direction (temppad) == GST_PAD_SINK){
sinkpads = g_slist_append(sinkpads,temppad);
numsinkpads++;
break;
}
}
}
if (!sinkpads) GST_DEBUG(0,"can't find a sink pad for %s\n", gst_element_get_name (previous));
else GST_DEBUG(0,"have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads)));
if (!srcpads && sinkpads) {
dyn_connect *connect = g_malloc (sizeof (dyn_connect));
connect->srcpadname = srcpadname;
connect->target = GST_PARSE_LISTPAD(sinkpads);
GST_DEBUG(0,"SETTING UP dynamic connection %s:%s and %s:%s\n",
gst_element_get_name (previous),
srcpadname,
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads)));
gtk_signal_connect (GTK_OBJECT (previous), "new_pad", dynamic_connect, connect);
gtk_signal_connect (GTK_OBJECT (previous), "new_ghost_pad", dynamic_connect, connect);
}
else {
for (j=0; (j<numsrcpads) && (j<numsinkpads); j++){
GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(g_slist_nth(srcpads,j))),
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(g_slist_nth(sinkpads,j))));
gst_pad_connect(
GST_PARSE_LISTPAD(g_slist_nth(srcpads,j)),
GST_PARSE_LISTPAD(g_slist_nth(sinkpads,j)));
}
}
g_slist_free(srcpads);
srcpads = NULL;
g_slist_free(sinkpads);
sinkpads = NULL;
// thomas: if we're the first element, connect eos signal // thomas: if we're the first element, connect eos signal
if (elementcount == 1) if (elementcount == 1)