Added dynamic pads to the command line parser. ./gstreamer-launch disksrc location=/some/systemstream.mpg ! mpeg1pars...

Original commit message from CVS:
Added dynamic pads to the command line parser.

./gstreamer-launch disksrc location=/some/systemstream.mpg ! mpeg1parse video_00!
queue ! \{ mp1videoparse ! mpeg_play ! aasink \}

will now work.
This commit is contained in:
Wim Taymans 2001-05-03 21:44:55 +00:00
parent 17f02e233d
commit fe084f66f1

View file

@ -62,6 +62,21 @@ gst_parse_newpad(GstElement *element,GstPad *pad,launch_delayed_pad *peer)
} }
*/ */
typedef struct {
gchar *srcpadname;
GstPad *target;
} dyn_connect;
static void
dynamic_connect (GstElement *element, GstPad *newpad, gpointer data)
{
dyn_connect *connect = (dyn_connect *)data;
if (!strcmp (gst_pad_get_name (newpad), connect->srcpadname)) {
gst_pad_connect (newpad, connect->target);
}
}
static gchar * static gchar *
gst_parse_unique_name(gchar *type,gst_parse_priv *priv) gst_parse_unique_name(gchar *type,gst_parse_priv *priv)
{ {
@ -148,11 +163,11 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
if (!srcpadname || !strchr(srcpadname,',')) { if (!srcpadname || !strchr(srcpadname,',')) {
if (srcpadname != NULL) { if (srcpadname != NULL) {
srcpad = gst_element_get_pad(previous,srcpadname); srcpad = gst_element_get_pad(previous,srcpadname);
if (!srcpad) if (!srcpad) {
GST_DEBUG(0,"NO SUCH pad %s in element %s\n",srcpadname,GST_ELEMENT_NAME(previous)); GST_DEBUG(0,"NO SUCH pad %s in element %s\n",srcpadname,GST_ELEMENT_NAME(previous));
} }
}
if (srcpad == NULL) { else if (srcpad == NULL) {
// check through the list to find the first sink pad // check through the list to find the first sink pad
GST_DEBUG(0,"CHECKING through element %s for pad named %s\n",GST_ELEMENT_NAME(previous),srcpadname); GST_DEBUG(0,"CHECKING through element %s for pad named %s\n",GST_ELEMENT_NAME(previous),srcpadname);
pads = gst_element_get_pad_list(previous); pads = gst_element_get_pad_list(previous);
@ -164,11 +179,10 @@ if (GST_IS_GHOST_PAD(srcpad)) GST_DEBUG(0,"it's a ghost pad\n");
if (gst_pad_get_direction (srcpad) == GST_PAD_SRC) break; if (gst_pad_get_direction (srcpad) == GST_PAD_SRC) break;
srcpad = NULL; srcpad = NULL;
} }
}
if (!srcpad) GST_DEBUG(0,"error, can't find a src pad!!!\n"); if (!srcpad) GST_DEBUG(0,"error, can't find a src pad!!!\n");
else GST_DEBUG(0,"have src pad %s:%s\n",GST_DEBUG_PAD_NAME(srcpad)); else GST_DEBUG(0,"have src pad %s:%s\n",GST_DEBUG_PAD_NAME(srcpad));
} }
}
// argument with = in it // argument with = in it
} else if (strstr(arg, "=")) { } else if (strstr(arg, "=")) {
@ -226,8 +240,9 @@ if (GST_IS_GHOST_PAD(srcpad)) GST_DEBUG(0,"it's a ghost pad\n");
gst_bin_add (GST_BIN (parent), element); gst_bin_add (GST_BIN (parent), element);
elementcount++; elementcount++;
if (srcpad != NULL) { if (srcpad != NULL || srcpadname != NULL) {
DEBUG("need to connect to sinkpad %s:%s\n",GST_DEBUG_PAD_NAME(srcpad)); if (srcpad)
DEBUG("need to connect to srcpad %s:%s\n",GST_DEBUG_PAD_NAME(srcpad));
sinkpad = NULL; sinkpad = NULL;
@ -248,13 +263,27 @@ if (GST_IS_GHOST_PAD(srcpad)) GST_DEBUG(0,"it's a ghost pad\n");
if (!sinkpad) DEBUG("error, can't find a sink pad!!!\n"); if (!sinkpad) DEBUG("error, can't find a sink pad!!!\n");
else DEBUG("have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(sinkpad)); else DEBUG("have sink pad %s:%s\n",GST_DEBUG_PAD_NAME(sinkpad));
if (!srcpad) {
dyn_connect *connect = g_malloc (sizeof (dyn_connect));
connect->srcpadname = srcpadname;
connect->target = sinkpad;
GST_DEBUG(0,"SETTING UP dynamic connection %s:%s and %s:%s\n",gst_element_get_name (previous),
srcpadname,GST_DEBUG_PAD_NAME(sinkpad));
gtk_signal_connect (GTK_OBJECT (previous), "new_pad", dynamic_connect, connect);
}
else {
GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",GST_DEBUG_PAD_NAME(srcpad),GST_DEBUG_PAD_NAME(sinkpad)); GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",GST_DEBUG_PAD_NAME(srcpad),GST_DEBUG_PAD_NAME(sinkpad));
gst_pad_connect(srcpad,sinkpad); gst_pad_connect(srcpad,sinkpad);
}
sinkpad = NULL; sinkpad = NULL;
srcpad = NULL; srcpad = NULL;
} }
// if we're the first element, ghost all the sinkpads // if we're the first element, ghost all the sinkpads
if (elementcount == 1) { if (elementcount == 1) {
DEBUG("first element, ghosting all of %s's sink pads to parent %s\n", DEBUG("first element, ghosting all of %s's sink pads to parent %s\n",