From ecf74cf2dbcf36c11557bb4a1aa9ec8f3fab36c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 1 May 2012 22:33:30 +0100 Subject: [PATCH] typefindfactory: add gst_type_find_factory_has_function() Add API so people don't have to poke the struct for this. --- gst/gsttypefindfactory.c | 18 ++++++++++++++++++ gst/gsttypefindfactory.h | 1 + libs/gst/base/gsttypefindhelper.c | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gst/gsttypefindfactory.c b/gst/gsttypefindfactory.c index aca0698..1707768 100644 --- a/gst/gsttypefindfactory.c +++ b/gst/gsttypefindfactory.c @@ -222,3 +222,21 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory, 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); +} diff --git a/gst/gsttypefindfactory.h b/gst/gsttypefindfactory.h index 3d8ff31..3797f29 100644 --- a/gst/gsttypefindfactory.h +++ b/gst/gsttypefindfactory.h @@ -73,6 +73,7 @@ GList * gst_type_find_factory_get_list (void); gchar ** gst_type_find_factory_get_extensions (GstTypeFindFactory *factory); GstCaps * gst_type_find_factory_get_caps (GstTypeFindFactory *factory); +gboolean gst_type_find_factory_has_function (GstTypeFindFactory *factory); void gst_type_find_factory_call_function (GstTypeFindFactory *factory, GstTypeFind *find); diff --git a/libs/gst/base/gsttypefindhelper.c b/libs/gst/base/gsttypefindhelper.c index 41f66bf..d9bbe72 100644 --- a/libs/gst/base/gsttypefindhelper.c +++ b/libs/gst/base/gsttypefindhelper.c @@ -623,7 +623,7 @@ gst_type_find_helper_for_extension (GstObject * obj, const gchar * extension) factory = GST_TYPE_FIND_FACTORY (l->data); /* we only want to check those factories without a function */ - if (factory->function != NULL) + if (gst_type_find_factory_has_function (factory)) continue; /* get the extension that this typefind factory can handle */ -- 2.7.4