X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gst%2Fgsttypefindfactory.c;h=fb5c098495b04bc036dfb2e54b3ac48b3a909a01;hb=dc5a62f70234f729c0f3443ab725e9f0232cc1fe;hp=47850fd0775b696ef9317a18deaa1bc3aaab96b3;hpb=83a815e648ee4c301ab81f964a4667e8797b9e8d;p=platform%2Fupstream%2Fgstreamer.git diff --git a/gst/gsttypefindfactory.c b/gst/gsttypefindfactory.c index 47850fd..fb5c098 100644 --- a/gst/gsttypefindfactory.c +++ b/gst/gsttypefindfactory.c @@ -15,22 +15,24 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. */ /** * SECTION:gsttypefindfactory + * @title: GstTypeFindFactory * @short_description: Information about registered typefind functions * - * These functions allow querying informations about registered typefind + * These functions allow querying information about registered typefind * functions. How to create and register these functions is described in * the section * "Writing typefind functions". * - * - * how to write a simple typefinder - * + * The following example shows how to write a very simple typefinder that + * identifies the given data. You can get quite a bit more complicated than + * that though. + * |[ * typedef struct { * guint8 *data; * guint size; @@ -70,14 +72,7 @@ * g_list_free (type_list); * return find.caps; * }; - * - * - * - * The above example shows how to write a very simple typefinder that - * identifies the given data. You can get quite a bit more complicated than - * that though. - * - * Last reviewed on 2005-11-09 (0.9.4) + * ]| */ #include "gst_private.h" @@ -86,60 +81,32 @@ #include "gsttypefindfactory.h" #include "gstregistry.h" -GST_DEBUG_CATEGORY (gst_type_find_debug); -#define GST_CAT_DEFAULT gst_type_find_debug +GST_DEBUG_CATEGORY (type_find_debug); +#define GST_CAT_DEFAULT type_find_debug -static void gst_type_find_factory_class_init (gpointer g_class, - gpointer class_data); -static void gst_type_find_factory_init (GTypeInstance * instance, - gpointer g_class); static void gst_type_find_factory_dispose (GObject * object); -static GstPluginFeatureClass *parent_class = NULL; - -GType -gst_type_find_factory_get_type (void) -{ - static GType typefind_type = 0; - - if (!typefind_type) { - static const GTypeInfo typefind_info = { - sizeof (GstTypeFindFactoryClass), - NULL, - NULL, - gst_type_find_factory_class_init, - NULL, - NULL, - sizeof (GstTypeFindFactory), - 0, - gst_type_find_factory_init, - NULL - }; - - typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstTypeFindFactory", &typefind_info, 0); - GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND", - GST_DEBUG_FG_GREEN, "typefinding subsystem"); - } - - return typefind_type; +#define _do_init \ +{ \ + GST_DEBUG_CATEGORY_INIT (type_find_debug, "GST_TYPEFIND", \ + GST_DEBUG_FG_GREEN, "typefinding subsystem"); \ } +#define gst_type_find_factory_parent_class parent_class +G_DEFINE_TYPE_WITH_CODE (GstTypeFindFactory, gst_type_find_factory, + GST_TYPE_PLUGIN_FEATURE, _do_init); + static void -gst_type_find_factory_class_init (gpointer g_class, gpointer class_data) +gst_type_find_factory_class_init (GstTypeFindFactoryClass * klass) { - GObjectClass *object_class = G_OBJECT_CLASS (g_class); - - parent_class = g_type_class_peek_parent (g_class); + GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->dispose = gst_type_find_factory_dispose; } static void -gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class) +gst_type_find_factory_init (GstTypeFindFactory * factory) { - GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance); - factory->user_data = factory; factory->user_data_notify = NULL; } @@ -161,20 +128,28 @@ gst_type_find_factory_dispose (GObject * object) factory->user_data_notify (factory->user_data); factory->user_data = NULL; } + + G_OBJECT_CLASS (parent_class)->dispose (object); } /** * gst_type_find_factory_get_list: * * Gets the list of all registered typefind factories. You must free the - * list using g_list_free. + * list using gst_plugin_feature_list_free(). + * + * The returned factories are sorted by highest rank first, and then by + * factory name. * - * Returns: the list of all registered #GstTypeFindFactory. + * Free-function: gst_plugin_feature_list_free + * + * Returns: (transfer full) (element-type Gst.TypeFindFactory): the list of all + * registered #GstTypeFindFactory. */ GList * gst_type_find_factory_get_list (void) { - return gst_registry_get_feature_list (gst_registry_get_default (), + return gst_registry_get_feature_list (gst_registry_get (), GST_TYPE_TYPE_FIND_FACTORY); } @@ -184,7 +159,7 @@ gst_type_find_factory_get_list (void) * * Gets the #GstCaps associated with a typefind factory. * - * Returns: The #GstCaps associated with this factory + * Returns: (transfer none): the #GstCaps associated with this factory */ GstCaps * gst_type_find_factory_get_caps (GstTypeFindFactory * factory) @@ -200,24 +175,25 @@ gst_type_find_factory_get_caps (GstTypeFindFactory * factory) * * Gets the extensions associated with a #GstTypeFindFactory. The returned * array should not be changed. If you need to change stuff in it, you should - * copy it using g_stdupv(). This function may return NULL to indicate + * copy it using g_strdupv(). This function may return %NULL to indicate * a 0-length list. * - * Returns: a NULL-terminated array of extensions associated with this factory + * Returns: (transfer none) (array zero-terminated=1) (element-type utf8) (nullable): + * a %NULL-terminated array of extensions associated with this factory */ -gchar ** +const gchar *const * gst_type_find_factory_get_extensions (GstTypeFindFactory * factory) { g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL); - return factory->extensions; + return (const gchar * const *) factory->extensions; } /** * gst_type_find_factory_call_function: * @factory: A #GstTypeFindFactory - * @find: A properly setup #GstTypeFind entry. The get_data and suggest_type - * members must be set. + * @find: (transfer none): a properly setup #GstTypeFind entry. The get_data + * and suggest_type members must be set. * * Calls the #GstTypeFindFunction associated with this factory. */ @@ -236,8 +212,26 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory, GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory))); if (new_factory) { - g_assert (new_factory->function != NULL); - - new_factory->function (find, new_factory->user_data); + if (new_factory->function) + new_factory->function (find, new_factory->user_data); + gst_object_unref (new_factory); } } + +/** + * gst_type_find_factory_has_function: + * @factory: A #GstTypeFindFactory + * + * Check whether the factory has a typefind function. Typefind factories + * without typefind functions are a last-effort fallback mechanism to + * e.g. assume a certain media type based on the file extension. + * + * Returns: %TRUE if the factory has a typefind functions set, otherwise %FALSE + */ +gboolean +gst_type_find_factory_has_function (GstTypeFindFactory * factory) +{ + g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), FALSE); + + return (factory->function != NULL); +}