gstreamer_core/gst/gsttypefind.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    83     const GstCaps * possible_caps, gpointer data, GDestroyNotify data_notify)
    83     const GstCaps * possible_caps, gpointer data, GDestroyNotify data_notify)
    84 {
    84 {
    85   GstTypeFindFactory *factory;
    85   GstTypeFindFactory *factory;
    86 
    86 
    87   g_return_val_if_fail (name != NULL, FALSE);
    87   g_return_val_if_fail (name != NULL, FALSE);
       
    88   g_return_val_if_fail (func != NULL, FALSE);
    88 
    89 
    89   GST_INFO ("registering typefind function for %s", name);
    90   GST_INFO ("registering typefind function for %s", name);
    90 
    91 
    91   factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
    92   factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL);
    92   GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
    93   GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
    93   g_assert (GST_IS_TYPE_FIND_FACTORY (factory));
    94   g_assert (GST_IS_TYPE_FIND_FACTORY (factory));
       
    95   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
    94 
    96 
    95   gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
       
    96   gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
    97   gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
    97 
       
    98   if (factory->extensions)
    98   if (factory->extensions)
    99     g_strfreev (factory->extensions);
    99     g_strfreev (factory->extensions);
       
   100 
   100   factory->extensions = g_strdupv (extensions);
   101   factory->extensions = g_strdupv (extensions);
   101 
       
   102   gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
   102   gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
   103   factory->function = func;
   103   factory->function = func;
   104   factory->user_data = data;
   104   factory->user_data = data;
   105   factory->user_data_notify = data_notify;
   105   factory->user_data_notify = data_notify;
   106   if (plugin && plugin->desc.name) {
   106   if (plugin && plugin->desc.name) {
   170 
   170 
   171   find->suggest (find->data, probability, caps);
   171   find->suggest (find->data, probability, caps);
   172 }
   172 }
   173 
   173 
   174 /**
   174 /**
   175  * gst_type_find_suggest_simple:
       
   176  * @find: The #GstTypeFind object the function was called with
       
   177  * @probability: The probability in percent that the suggestion is right
       
   178  * @media_type: the media type of the suggested caps
       
   179  * @fieldname: first field of the suggested caps, or NULL
       
   180  * @...: additional arguments to the suggested caps in the same format as the
       
   181  *     arguments passed to gst_structure_new() (ie. triplets of field name,
       
   182  *     field GType and field value)
       
   183  *
       
   184  * If a #GstTypeFindFunction calls this function it suggests the caps with the
       
   185  * given probability. A #GstTypeFindFunction may supply different suggestions
       
   186  * in one call. It is up to the caller of the #GstTypeFindFunction to interpret
       
   187  * these values.
       
   188  *
       
   189  * This function is similar to gst_type_find_suggest(), only that instead of
       
   190  * passing a #GstCaps argument you can create the caps on the fly in the same
       
   191  * way as you can with gst_caps_new_simple().
       
   192  *
       
   193  * Make sure you terminate the list of arguments with a NULL argument and that
       
   194  * the values passed have the correct type (in terms of width in bytes when
       
   195  * passed to the vararg function - this applies particularly to gdouble and
       
   196  * guint64 arguments).
       
   197  *
       
   198  * Since: 0.10.20
       
   199  */
       
   200 #ifdef __SYMBIAN32__
       
   201 EXPORT_C
       
   202 #endif
       
   203 
       
   204 void
       
   205 gst_type_find_suggest_simple (GstTypeFind * find, guint probability,
       
   206     const char *media_type, const char *fieldname, ...)
       
   207 {
       
   208   GstStructure *structure;
       
   209   va_list var_args;
       
   210   GstCaps *caps;
       
   211 
       
   212   g_return_if_fail (find->suggest != NULL);
       
   213   g_return_if_fail (probability <= 100);
       
   214   g_return_if_fail (media_type != NULL);
       
   215 
       
   216   caps = gst_caps_new_empty ();
       
   217 
       
   218   va_start (var_args, fieldname);
       
   219   structure = gst_structure_new_valist (media_type, fieldname, var_args);
       
   220   va_end (var_args);
       
   221 
       
   222   gst_caps_append_structure (caps, structure);
       
   223   g_return_if_fail (gst_caps_is_fixed (caps));
       
   224 
       
   225   find->suggest (find->data, probability, caps);
       
   226   gst_caps_unref (caps);
       
   227 }
       
   228 
       
   229 /**
       
   230  * gst_type_find_get_length:
   175  * gst_type_find_get_length:
   231  * @find: The #GstTypeFind the function was called with
   176  * @find: The #GstTypeFind the function was called with
   232  *
   177  *
   233  * Get the length of the data stream.
   178  * Get the length of the data stream.
   234  *
   179  *