/* 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 */
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);
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,
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,
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);
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,
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,
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)
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; */
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)
}
/**
- * 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.
* 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;
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)
{
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);
{
}
+/* 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
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;
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);
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,
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,
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);
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,
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,
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();