gstreamer_core/gst/gsttypefind.c
changeset 8 4a7fac7dd34a
parent 0 0e761a78d257
child 30 7e817e7e631c
--- a/gstreamer_core/gst/gsttypefind.c	Fri Mar 19 09:35:09 2010 +0200
+++ b/gstreamer_core/gst/gsttypefind.c	Fri Apr 16 15:15:52 2010 +0300
@@ -85,20 +85,20 @@
   GstTypeFindFactory *factory;
 
   g_return_val_if_fail (name != NULL, FALSE);
-  g_return_val_if_fail (func != NULL, FALSE);
 
   GST_INFO ("registering typefind function for %s", name);
 
   factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
   GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
   g_assert (GST_IS_TYPE_FIND_FACTORY (factory));
-  gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
 
+  gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
   gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
+
   if (factory->extensions)
     g_strfreev (factory->extensions);
+  factory->extensions = g_strdupv (extensions);
 
-  factory->extensions = g_strdupv (extensions);
   gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
   factory->function = func;
   factory->user_data = data;
@@ -172,6 +172,61 @@
 }
 
 /**
+ * gst_type_find_suggest_simple:
+ * @find: The #GstTypeFind object the function was called with
+ * @probability: The probability in percent that the suggestion is right
+ * @media_type: the media type of the suggested caps
+ * @fieldname: first field of the suggested caps, or NULL
+ * @...: additional arguments to the suggested caps in the same format as the
+ *     arguments passed to gst_structure_new() (ie. triplets of field name,
+ *     field GType and field value)
+ *
+ * If a #GstTypeFindFunction calls this function it suggests the caps with the
+ * given probability. A #GstTypeFindFunction may supply different suggestions
+ * in one call. It is up to the caller of the #GstTypeFindFunction to interpret
+ * these values.
+ *
+ * This function is similar to gst_type_find_suggest(), only that instead of
+ * passing a #GstCaps argument you can create the caps on the fly in the same
+ * way as you can with gst_caps_new_simple().
+ *
+ * Make sure you terminate the list of arguments with a NULL argument and that
+ * the values passed have the correct type (in terms of width in bytes when
+ * passed to the vararg function - this applies particularly to gdouble and
+ * guint64 arguments).
+ *
+ * Since: 0.10.20
+ */
+#ifdef __SYMBIAN32__
+EXPORT_C
+#endif
+
+void
+gst_type_find_suggest_simple (GstTypeFind * find, guint probability,
+    const char *media_type, const char *fieldname, ...)
+{
+  GstStructure *structure;
+  va_list var_args;
+  GstCaps *caps;
+
+  g_return_if_fail (find->suggest != NULL);
+  g_return_if_fail (probability <= 100);
+  g_return_if_fail (media_type != NULL);
+
+  caps = gst_caps_new_empty ();
+
+  va_start (var_args, fieldname);
+  structure = gst_structure_new_valist (media_type, fieldname, var_args);
+  va_end (var_args);
+
+  gst_caps_append_structure (caps, structure);
+  g_return_if_fail (gst_caps_is_fixed (caps));
+
+  find->suggest (find->data, probability, caps);
+  gst_caps_unref (caps);
+}
+
+/**
  * gst_type_find_get_length:
  * @find: The #GstTypeFind the function was called with
  *