From a43fadec2ebdd16449f8d080fc6ae026beef05d5 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 18 Mar 2002 04:41:37 +0000 Subject: [PATCH] s/gst_element_install_std_props/gst_element_class_install_std_props/ -- it just makes more sense that way added jack ... Original commit message from CVS: * s/gst_element_install_std_props/gst_element_class_install_std_props/ -- it just makes more sense that way * added jack element, doesn't quite work right yet but i didn't want to lose the work -- it does build, register, and attempt to run though * imposed some restrictions on the naming of request pads to better allow for reverse parsing * added '%s' to reverse parsing * added new bin flag to indicate that it is self-iterating, and some lame code in gst-launch to test it out * fixen on launch-gui * added pkg-config stuff for the editor's libs --- gst/autoplug/gstspider.c | 4 ++-- gst/elements/gstdisksink.c | 2 +- gst/elements/gstfakesink.c | 2 +- gst/elements/gstfakesrc.c | 2 +- gst/elements/gstfdsink.c | 2 +- gst/elements/gstfdsrc.c | 2 +- gst/elements/gstfilesrc.c | 2 +- gst/gstbin.c | 3 +++ gst/gstbin.h | 5 +++- gst/gstelement.c | 52 +++++++++++++++++++++++++++++------------- gst/gstelement.h | 2 +- gst/gstpad.c | 38 ++++++++++++++++++++++++++++++ plugins/elements/gstdisksink.c | 2 +- plugins/elements/gstfakesink.c | 2 +- plugins/elements/gstfakesrc.c | 2 +- plugins/elements/gstfdsink.c | 2 +- plugins/elements/gstfdsrc.c | 2 +- plugins/elements/gstfilesrc.c | 2 +- tools/gst-launch.c | 9 ++++++-- 19 files changed, 103 insertions(+), 34 deletions(-) diff --git a/gst/autoplug/gstspider.c b/gst/autoplug/gstspider.c index ecc59c9..af3e374 100644 --- a/gst/autoplug/gstspider.c +++ b/gst/autoplug/gstspider.c @@ -59,14 +59,14 @@ enum { /* generic templates */ GST_PADTEMPLATE_FACTORY (spider_src_factory, - "src_%02d", + "src_%d", GST_PAD_SRC, GST_PAD_REQUEST, NULL /* no caps */ ); GST_PADTEMPLATE_FACTORY (spider_sink_factory, - "sink_%02d", + "sink_%d", GST_PAD_SINK, GST_PAD_REQUEST, NULL /* no caps */ diff --git a/gst/elements/gstdisksink.c b/gst/elements/gstdisksink.c index badfd16..93efdf3 100644 --- a/gst/elements/gstdisksink.c +++ b/gst/elements/gstdisksink.c @@ -101,7 +101,7 @@ gst_disksink_class_init (GstDiskSinkClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "location", ARG_LOCATION, G_PARAM_READWRITE, NULL); diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index 5508099..c6d0198 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -113,7 +113,7 @@ gst_fakesink_class_init (GstFakeSinkClass *klass) NULL, G_PARAM_READABLE)); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "silent", ARG_SILENT, G_PARAM_READWRITE, "dump", ARG_DUMP, G_PARAM_READWRITE, diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index e4d496e..18ef726 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -236,7 +236,7 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) g_param_spec_string ("last_message", "last_message", "last_message", NULL, G_PARAM_READABLE)); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "silent", ARG_SILENT, G_PARAM_READWRITE, "dump", ARG_DUMP, G_PARAM_READWRITE, diff --git a/gst/elements/gstfdsink.c b/gst/elements/gstfdsink.c index 8df24db..3b6e9d8 100644 --- a/gst/elements/gstfdsink.c +++ b/gst/elements/gstfdsink.c @@ -89,7 +89,7 @@ gst_fdsink_class_init (GstFdSinkClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "fd", ARG_FD, G_PARAM_READWRITE, NULL); diff --git a/gst/elements/gstfdsrc.c b/gst/elements/gstfdsrc.c index acb738e..54cf985 100644 --- a/gst/elements/gstfdsrc.c +++ b/gst/elements/gstfdsrc.c @@ -98,7 +98,7 @@ gst_fdsrc_class_init (GstFdSrcClass *klass) parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "location", ARG_LOCATION, G_PARAM_WRITABLE, "bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE, diff --git a/gst/elements/gstfilesrc.c b/gst/elements/gstfilesrc.c index 409b38d..2995e10 100644 --- a/gst/elements/gstfilesrc.c +++ b/gst/elements/gstfilesrc.c @@ -149,7 +149,7 @@ gst_filesrc_class_init (GstFileSrcClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "fd", ARG_FD, G_PARAM_READABLE, "offset", ARG_OFFSET, G_PARAM_READWRITE, diff --git a/gst/gstbin.c b/gst/gstbin.c index 840f3c8..9e426b4 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -890,6 +890,9 @@ gst_bin_iterate (GstBin * bin) GST_DEBUG_ENTER ("(\"%s\")", GST_ELEMENT_NAME (bin)); + g_return_val_if_fail (bin != NULL, FALSE); + g_return_val_if_fail (GST_IS_BIN (bin), FALSE); + oclass = GST_BIN_CLASS (G_OBJECT_GET_CLASS (bin)); if (oclass->iterate) diff --git a/gst/gstbin.h b/gst/gstbin.h index e922403..016ddec 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -63,8 +63,11 @@ typedef enum { GST_BIN_FLAG_FIXED_CLOCK, + /* bin iterates itself, like a bin with a jack element in it */ + GST_BIN_SELF_ITERATING, + /* padding */ - GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 4, + GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5, } GstBinFlags; /*typedef struct _GstBin GstBin; */ diff --git a/gst/gstelement.c b/gst/gstelement.c index 4740494..cc25b55 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -712,28 +712,40 @@ gst_element_request_pad_by_name (GstElement *element, const gchar *name) gboolean templ_found = FALSE; GList *list; gint n; + gchar *str; g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (name != NULL, NULL); - if (strstr (name, "%d")) { - templ = gst_element_get_padtemplate_by_name (element, name); - templ_found = (templ != NULL); - req_name = NULL; + if (strstr (name, "%")) { + templ = gst_element_get_padtemplate_by_name (element, name); + req_name = NULL; + if (templ) + templ_found = TRUE; } else { - list = gst_element_get_padtemplate_list(element); - while (!templ_found && list) { - templ = (GstPadTemplate*) list->data; - if (strstr (templ->name_template, "%d")) { - if (sscanf(name, templ->name_template, &n)) { - templ_found = TRUE; - req_name = name; - break; - } + list = gst_element_get_padtemplate_list(element); + while (!templ_found && list) { + templ = (GstPadTemplate*) list->data; + if (templ->presence == GST_PAD_REQUEST) { + /* we know that %s and %d are the ony possibilities because of sanity + checks in gst_padtemplate_new */ + if (strstr (templ->name_template, "%d")) { + if (sscanf(name, templ->name_template, &n)) { + templ_found = TRUE; + req_name = name; + break; + } + } else if (strstr (templ->name_template, "%s")) { + if (sscanf(name, templ->name_template, &str)) { + templ_found = TRUE; + req_name = name; + break; } - list = list->next; + } } + list = list->next; + } } if (!templ_found) @@ -1875,7 +1887,7 @@ gst_element_populate_std_props (GObjectClass * klass, } /** - * gst_element_install_std_props: + * gst_element_class_install_std_props: * @klass: the class to add the properties to * @first_name: the first in a NULL terminated * 'name', 'id', 'flags' triplet list. @@ -1886,7 +1898,7 @@ gst_element_populate_std_props (GObjectClass * klass, * the flags determine readability / writeability. **/ void -gst_element_install_std_props (GstElementClass * klass, const char *first_name, ...) +gst_element_class_install_std_props (GstElementClass * klass, const char *first_name, ...) { const char *name; @@ -1910,6 +1922,14 @@ gst_element_install_std_props (GstElementClass * klass, const char *first_name, va_end (args); } +/** + * gst_element_get_managing_bin: + * @element: the element in question + * + * Get the managing bin (a pipeline or a thread, for example) of an element. + * + * Returns: the bin, or NULL on failure + **/ GstBin* gst_element_get_managing_bin (GstElement *element) { diff --git a/gst/gstelement.h b/gst/gstelement.h index 2cb26d5..7440cba 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -243,7 +243,7 @@ void gst_element_error (GstElement *element, const gchar *error, ...); GstElementFactory* gst_element_get_factory (GstElement *element); -void gst_element_install_std_props (GstElementClass *klass, +void gst_element_class_install_std_props (GstElementClass *klass, const char *first_name, ...); GstBin* gst_element_get_managing_bin (GstElement *element); diff --git a/gst/gstpad.c b/gst/gstpad.c index fbf2d8a..9ac7a1b 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2009,6 +2009,41 @@ gst_padtemplate_init (GstPadTemplate *templ) { } +/* ALWAYS padtemplates cannot have conversion specifications, it doesn't make + * sense. + * SOMETIMES padtemplates can do whatever they want, they are provided by the + * element. + * REQUEST padtemplates can be reverse-parsed (the user asks for 'sink1', the + * 'sink%d' template is automatically selected), so we need to restrict their + * naming. + */ +static gboolean +name_is_valid (const gchar *name, GstPadPresence presence) +{ + const gchar *str; + + if (presence == GST_PAD_ALWAYS) { + if (strchr (name, '%')) { + g_warning ("invalid name template %s: conversion specifications are not" + " allowed for GST_PAD_ALWAYS padtemplates", name); + return FALSE; + } + } else if (presence == GST_PAD_REQUEST) { + if ((str = strchr (name, '%')) && strchr (str + 1, '%')) { + g_warning ("invalid name template %s: only one conversion specification" + " allowed in GST_PAD_REQUEST padtemplate", name); + return FALSE; + } + if (str && (*(str+1) != 's' && *(str+1) != 'd')) { + g_warning ("invalid name template %s: conversion specification must be of" + " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name); + return FALSE; + } + } + + return TRUE; +} + /** * gst_padtemplate_new: * @name_template: the name template @@ -2032,6 +2067,9 @@ gst_padtemplate_new (gchar *name_template, g_return_val_if_fail (name_template != NULL, NULL); + if (!name_is_valid (name_template, presence)) + return NULL; + new = g_object_new(gst_padtemplate_get_type () ,NULL); GST_PADTEMPLATE_NAME_TEMPLATE (new) = name_template; diff --git a/plugins/elements/gstdisksink.c b/plugins/elements/gstdisksink.c index badfd16..93efdf3 100644 --- a/plugins/elements/gstdisksink.c +++ b/plugins/elements/gstdisksink.c @@ -101,7 +101,7 @@ gst_disksink_class_init (GstDiskSinkClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "location", ARG_LOCATION, G_PARAM_READWRITE, NULL); diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 5508099..c6d0198 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -113,7 +113,7 @@ gst_fakesink_class_init (GstFakeSinkClass *klass) NULL, G_PARAM_READABLE)); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "silent", ARG_SILENT, G_PARAM_READWRITE, "dump", ARG_DUMP, G_PARAM_READWRITE, diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index e4d496e..18ef726 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -236,7 +236,7 @@ gst_fakesrc_class_init (GstFakeSrcClass *klass) g_param_spec_string ("last_message", "last_message", "last_message", NULL, G_PARAM_READABLE)); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "silent", ARG_SILENT, G_PARAM_READWRITE, "dump", ARG_DUMP, G_PARAM_READWRITE, diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c index 8df24db..3b6e9d8 100644 --- a/plugins/elements/gstfdsink.c +++ b/plugins/elements/gstfdsink.c @@ -89,7 +89,7 @@ gst_fdsink_class_init (GstFdSinkClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "fd", ARG_FD, G_PARAM_READWRITE, NULL); diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index acb738e..54cf985 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -98,7 +98,7 @@ gst_fdsrc_class_init (GstFdSrcClass *klass) parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "location", ARG_LOCATION, G_PARAM_WRITABLE, "bytesperread", ARG_BYTESPERREAD, G_PARAM_READWRITE, diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 409b38d..2995e10 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -149,7 +149,7 @@ gst_filesrc_class_init (GstFileSrcClass *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - gst_element_install_std_props ( + gst_element_class_install_std_props ( GST_ELEMENT_CLASS (klass), "fd", ARG_FD, G_PARAM_READABLE, "offset", ARG_OFFSET, G_PARAM_READWRITE, diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 792cfef..a17ac8f 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -198,8 +198,13 @@ main(int argc, char *argv[]) exit (-1); } - g_idle_add (idle_func, pipeline); - gst_main (); + if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_ITERATING)) { + g_idle_add (idle_func, pipeline); + gst_main (); + } else { + g_print ("sleeping 100...\n"); + sleep (100); + } gst_element_set_state (pipeline, GST_STATE_NULL); gst_buffer_print_stats(); -- 2.7.4