mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
can now take comma delimited list of pads. eg gstreamer-launch disksrc location=~/mp3/gnome.mp3 ! mad ! int2float src...
Original commit message from CVS: can now take comma delimited list of pads. eg gstreamer-launch disksrc location=~/mp3/gnome.mp3 ! mad ! int2float src%d,src%d\!sink%d,sink%d float2int ! osssink
This commit is contained in:
parent
96d791a0d8
commit
c1c2236210
1 changed files with 96 additions and 40 deletions
|
@ -100,15 +100,16 @@ gst_parse_unique_name(gchar *type,gst_parse_priv *priv)
|
||||||
static gint
|
static gint
|
||||||
gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *priv)
|
gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *priv)
|
||||||
{
|
{
|
||||||
gint i = 0;
|
gint i = 0, j = 0;
|
||||||
gchar *arg;
|
gchar *arg;
|
||||||
GstElement *element = NULL, *previous = NULL, *prevelement = NULL;
|
GstElement *element = NULL, *previous = NULL, *prevelement = NULL;
|
||||||
gchar closingchar = '\0';
|
gchar closingchar = '\0';
|
||||||
gint len;
|
gint len;
|
||||||
gchar *ptr;
|
gchar *ptr;
|
||||||
gchar *sinkpadname = NULL, *srcpadname = NULL;
|
gchar *sinkpadname = NULL, *srcpadname = NULL, *tempname;
|
||||||
GstPad *temppad;
|
GstPad *temppad;
|
||||||
GSList *sinkpads = NULL, *srcpads = NULL;
|
GSList *sinkpads = NULL, *srcpads = NULL;
|
||||||
|
gint numsrcpads = 0, numsinkpads = 0;
|
||||||
GList *pads;
|
GList *pads;
|
||||||
gint elementcount = 0;
|
gint elementcount = 0;
|
||||||
gint retval = 0;
|
gint retval = 0;
|
||||||
|
@ -166,18 +167,40 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
||||||
|
|
||||||
g_slist_free(srcpads);
|
g_slist_free(srcpads);
|
||||||
srcpads = NULL;
|
srcpads = NULL;
|
||||||
|
numsrcpads=0;
|
||||||
|
tempname=NULL;
|
||||||
|
|
||||||
// if the srcpadname doesn't have any commas in it, find an actual pad
|
// find src pads
|
||||||
if (!srcpadname || !strchr(srcpadname,',')) {
|
|
||||||
if (srcpadname != NULL) {
|
if (srcpadname != NULL) {
|
||||||
if ((temppad = gst_element_get_pad(previous,srcpadname))){
|
while (1){
|
||||||
srcpads = g_slist_append(srcpads,temppad);
|
// split name at commas
|
||||||
|
if ((ptr = strchr(srcpadname,','))){
|
||||||
|
tempname = g_strndup(srcpadname,(ptr-srcpadname));
|
||||||
|
srcpadname = &ptr[1];
|
||||||
|
} else {
|
||||||
|
tempname = srcpadname;
|
||||||
}
|
}
|
||||||
else if ((temppad = gst_element_request_pad_by_name(previous,srcpadname))) {
|
|
||||||
|
// look for pad with that name
|
||||||
|
if ((temppad = gst_element_get_pad(previous,tempname))){
|
||||||
srcpads = g_slist_append(srcpads,temppad);
|
srcpads = g_slist_append(srcpads,temppad);
|
||||||
|
numsrcpads++;
|
||||||
}
|
}
|
||||||
if (!srcpads) {
|
|
||||||
GST_DEBUG(0,"NO SUCH pad %s in element %s\n",srcpadname,GST_ELEMENT_NAME(previous));
|
// try to create a pad using that padtemplate name
|
||||||
|
else if ((temppad = gst_element_request_pad_by_name(previous,tempname))) {
|
||||||
|
srcpads = g_slist_append(srcpads,temppad);
|
||||||
|
numsrcpads++;
|
||||||
|
}
|
||||||
|
if (!temppad) {
|
||||||
|
GST_DEBUG(0,"NO SUCH pad %s in element %s\n",tempname,GST_ELEMENT_NAME(previous));
|
||||||
|
} else {
|
||||||
|
GST_DEBUG(0,"have src pad %s:%s\n",GST_DEBUG_PAD_NAME(temppad));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there is no more commas in srcpadname then we're done
|
||||||
|
if (tempname == srcpadname) break;
|
||||||
|
g_free(tempname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -190,6 +213,7 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
||||||
if (GST_IS_GHOST_PAD(temppad)) GST_DEBUG(0,"it's a ghost pad\n");
|
if (GST_IS_GHOST_PAD(temppad)) GST_DEBUG(0,"it's a ghost pad\n");
|
||||||
if (gst_pad_get_direction (temppad) == GST_PAD_SRC){
|
if (gst_pad_get_direction (temppad) == GST_PAD_SRC){
|
||||||
srcpads = g_slist_append(srcpads,temppad);
|
srcpads = g_slist_append(srcpads,temppad);
|
||||||
|
numsrcpads++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pads = g_list_next (pads);
|
pads = g_list_next (pads);
|
||||||
|
@ -197,7 +221,6 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
||||||
if (!srcpads) GST_DEBUG(0,"error, can't find a src pad!!!\n");
|
if (!srcpads) 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(GST_PARSE_LISTPAD(srcpads)));
|
else GST_DEBUG(0,"have src pad %s:%s\n",GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(srcpads)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// argument with = in it
|
// argument with = in it
|
||||||
} else if (strstr(arg, "=")) {
|
} else if (strstr(arg, "=")) {
|
||||||
|
@ -255,19 +278,44 @@ 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 || srcpadname != NULL) {
|
if (srcpads != NULL) {
|
||||||
if (srcpads)
|
|
||||||
GST_DEBUG(0, "need to connect to srcpad %s:%s\n",GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(srcpads)));
|
|
||||||
|
|
||||||
g_slist_free(sinkpads);
|
g_slist_free(sinkpads);
|
||||||
sinkpads = NULL;
|
sinkpads = NULL;
|
||||||
|
numsinkpads=0;
|
||||||
|
tempname=NULL;
|
||||||
|
|
||||||
|
// find sink pads
|
||||||
if (sinkpadname != NULL) {
|
if (sinkpadname != NULL) {
|
||||||
if ((temppad = gst_element_get_pad(element,sinkpadname))){
|
while (1){
|
||||||
sinkpads = g_slist_append(sinkpads,temppad);
|
// split name at commas
|
||||||
|
if ((ptr = strchr(sinkpadname,','))){
|
||||||
|
tempname = g_strndup(sinkpadname,(ptr-sinkpadname));
|
||||||
|
sinkpadname = &ptr[1];
|
||||||
|
} else {
|
||||||
|
tempname = sinkpadname;
|
||||||
}
|
}
|
||||||
else if ((temppad = gst_element_request_pad_by_name(element,sinkpadname))) {
|
|
||||||
|
// look for pad with that name
|
||||||
|
if ((temppad = gst_element_get_pad(element,tempname))){
|
||||||
sinkpads = g_slist_append(sinkpads,temppad);
|
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 {
|
else {
|
||||||
|
@ -278,6 +326,7 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
||||||
pads = g_list_next (pads);
|
pads = g_list_next (pads);
|
||||||
if (gst_pad_get_direction (temppad) == GST_PAD_SINK){
|
if (gst_pad_get_direction (temppad) == GST_PAD_SINK){
|
||||||
sinkpads = g_slist_append(sinkpads,temppad);
|
sinkpads = g_slist_append(sinkpads,temppad);
|
||||||
|
numsinkpads++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,16 +341,23 @@ gst_parse_launch_cmdline(int argc,char *argv[],GstBin *parent,gst_parse_priv *pr
|
||||||
connect->srcpadname = srcpadname;
|
connect->srcpadname = srcpadname;
|
||||||
connect->target = GST_PARSE_LISTPAD(sinkpads);
|
connect->target = GST_PARSE_LISTPAD(sinkpads);
|
||||||
|
|
||||||
GST_DEBUG(0,"SETTING UP dynamic connection %s:%s and %s:%s\n",gst_element_get_name (previous),
|
GST_DEBUG(0,"SETTING UP dynamic connection %s:%s and %s:%s\n",
|
||||||
srcpadname,GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads)));
|
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_pad", dynamic_connect, connect);
|
||||||
gtk_signal_connect (GTK_OBJECT (previous), "new_ghost_pad", dynamic_connect, connect);
|
gtk_signal_connect (GTK_OBJECT (previous), "new_ghost_pad", dynamic_connect, connect);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(srcpads)),
|
for (j=0; (j<numsrcpads) && (j<numsinkpads); j++){
|
||||||
GST_DEBUG_PAD_NAME(GST_PARSE_LISTPAD(sinkpads)));
|
GST_DEBUG(0,"CONNECTING %s:%s and %s:%s\n",
|
||||||
gst_pad_connect(GST_PARSE_LISTPAD(srcpads),GST_PARSE_LISTPAD(sinkpads));
|
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);
|
g_slist_free(srcpads);
|
||||||
|
|
Loading…
Reference in a new issue