From bcc9fc59a9d586c0126cb12dc1248779bddbe6b1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 5 Apr 2007 10:08:21 +0000 Subject: [PATCH] gst/gstelement.c: Make padtemplates also work when they don't contain %s or %d. Original commit message from CVS: * gst/gstelement.c: (gst_element_get_request_pad): Make padtemplates also work when they don't contain %s or %d. --- ChangeLog | 5 +++++ gst/gstelement.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b546a07f0..d7148e1d3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-04-05 Wim Taymans + + * gst/gstelement.c: (gst_element_get_request_pad): + Make padtemplates also work when they don't contain %s or %d. + 2007-04-05 Wim Taymans * docs/gst/gstreamer-sections.txt: diff --git a/gst/gstelement.c b/gst/gstelement.c index f27ae9540e..9392ff37b4 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -925,22 +925,31 @@ gst_element_get_request_pad (GstElement * element, const gchar * name) class = GST_ELEMENT_GET_CLASS (element); + /* if the name contains a %, we assume it's the complete template name. Get + * the template and try to get a pad */ if (strstr (name, "%")) { templ = gst_element_class_get_request_pad_template (class, name); req_name = NULL; if (templ) templ_found = TRUE; } else { + /* there is no % in the name, try to find a matching template */ list = gst_element_class_get_pad_template_list (class); while (!templ_found && list) { templ = (GstPadTemplate *) list->data; if (templ->presence == GST_PAD_REQUEST) { + GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, + templ->name_template); + /* see if we find an exact match */ + if (strcmp (name, templ->name_template) == 0) { + templ_found = TRUE; + req_name = name; + break; + } /* Because of sanity checks in gst_pad_template_new(), we know that %s and %d, occurring at the end of the name_template, are the only possibilities. */ - GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, - templ->name_template); - if ((str = strchr (templ->name_template, '%')) + else if ((str = strchr (templ->name_template, '%')) && strncmp (templ->name_template, name, str - templ->name_template) == 0 && strlen (name) > str - templ->name_template) {