2001-01-19 00:02:53 +00:00
|
|
|
/* GStreamer
|
2003-10-28 20:25:30 +00:00
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2001-01-19 00:02:53 +00:00
|
|
|
*
|
2003-10-28 20:25:30 +00:00
|
|
|
* gsttypefind.h: typefinding subsystem
|
2001-01-19 00:02:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2005-09-06 22:03:01 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gsttypefind
|
|
|
|
* @short_description: Stream type detection
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* SECTION:gsttypefindfactory
|
|
|
|
* @short_description: Information about registered typefind functions
|
|
|
|
*
|
|
|
|
* These functions allow querying informations about registered typefind
|
|
|
|
* functions. How to create and register these functions is described in
|
|
|
|
* the section <link linkend="gstreamer-Writing-typefind-functions">
|
|
|
|
* "Writing typefind functions"</link>.
|
|
|
|
*
|
|
|
|
* <example>
|
|
|
|
* <title>how to write a simple typefinder</title>
|
|
|
|
* <programlisting>
|
|
|
|
* typedef struct {
|
|
|
|
* guint8 *data;
|
|
|
|
* guint size;
|
|
|
|
* guint probability;
|
|
|
|
* GstCaps *data;
|
|
|
|
* } MyTypeFind;
|
|
|
|
* static void
|
|
|
|
* my_peek (gpointer data, gint64 offset, guint size)
|
|
|
|
* {
|
|
|
|
* MyTypeFind *find = (MyTypeFind *) data;
|
|
|
|
* if (offset >= 0 && offset + size <= find->size) {
|
|
|
|
* return find->data + offset;
|
|
|
|
* }
|
|
|
|
* return NULL;
|
|
|
|
* }
|
|
|
|
* static void
|
|
|
|
* my_suggest (gpointer data, guint probability, GstCaps *caps)
|
|
|
|
* {
|
|
|
|
* MyTypeFind *find = (MyTypeFind *) data;
|
|
|
|
* if (probability > find->probability) {
|
|
|
|
* find->probability = probability;
|
|
|
|
* gst_caps_replace (&find->caps, caps);
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* static GstCaps *
|
|
|
|
* find_type (guint8 *data, guint size)
|
|
|
|
* {
|
|
|
|
* GList *walk, *type_list;
|
|
|
|
* MyTypeFind find = {data, size, 0, NULL};
|
|
|
|
* GstTypeFind gst_find = {my_peek, my_suggest, &find, };
|
|
|
|
*
|
|
|
|
* walk = type_list = gst_type_find_factory_get_list ();
|
|
|
|
* while (walk) {
|
|
|
|
* GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data);
|
|
|
|
* walk = g_list_next (walk)
|
|
|
|
* gst_type_find_factory_call_function (factory, &gst_find);
|
|
|
|
* }
|
|
|
|
* g_list_free (type_list);
|
|
|
|
* return find.caps;
|
|
|
|
* };
|
|
|
|
* </programlisting>
|
|
|
|
* </example>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2004-05-03 16:03:24 +00:00
|
|
|
#include "gst_private.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2001-01-19 00:02:53 +00:00
|
|
|
#include "gsttypefind.h"
|
2003-10-28 20:25:30 +00:00
|
|
|
#include "gstregistrypool.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_type_find_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_type_find_debug
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
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);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_type_find_factory_unload_thyself (GstPluginFeature * feature);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_type_find_load_plugin (GstTypeFind * find, gpointer data);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
static GstPluginFeatureClass *parent_class = NULL;
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
GType
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_type_find_factory_get_type (void)
|
2001-03-07 21:52:56 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType typefind_type = 0;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
if (!typefind_type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
static const GTypeInfo typefind_info = {
|
2003-10-28 20:25:30 +00:00
|
|
|
sizeof (GstTypeFindFactoryClass),
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_type_find_factory_class_init,
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2003-10-28 20:25:30 +00:00
|
|
|
sizeof (GstTypeFindFactory),
|
2001-06-25 01:20:11 +00:00
|
|
|
0,
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_type_find_factory_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2001-01-19 00:02:53 +00:00
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
|
2004-03-15 19:27:17 +00:00
|
|
|
"GstTypeFindFactory", &typefind_info, 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND",
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_DEBUG_FG_GREEN, "typefinding subsystem");
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
return typefind_type;
|
|
|
|
}
|
|
|
|
static void
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_type_find_factory_class_init (gpointer g_class, gpointer class_data)
|
2001-01-19 00:02:53 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPluginFeatureClass *gstpluginfeature_class =
|
|
|
|
GST_PLUGIN_FEATURE_CLASS (g_class);
|
2003-10-28 20:25:30 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
parent_class = g_type_class_peek_parent (g_class);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
object_class->dispose = gst_type_find_factory_dispose;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
gstpluginfeature_class->unload_thyself =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself);
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
|
2001-01-19 00:02:53 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
|
2003-10-01 13:11:45 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
factory->user_data = factory;
|
|
|
|
factory->function = gst_type_find_load_plugin;
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_dispose (GObject * object)
|
2001-01-19 00:02:53 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
if (factory->caps) {
|
2005-03-07 18:27:42 +00:00
|
|
|
gst_caps_unref (factory->caps);
|
2003-10-28 20:25:30 +00:00
|
|
|
factory->caps = NULL;
|
|
|
|
}
|
|
|
|
if (factory->extensions) {
|
|
|
|
g_strfreev (factory->extensions);
|
|
|
|
factory->extensions = NULL;
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
|
|
|
}
|
2003-10-28 20:25:30 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_unload_thyself (GstPluginFeature * feature)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
factory->function = gst_type_find_load_plugin;
|
|
|
|
factory->user_data = factory;
|
|
|
|
}
|
2001-03-07 21:52:56 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_load_plugin (GstTypeFind * find, gpointer data)
|
2001-01-19 00:02:53 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (data);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_OBJECT (factory, "need to load typefind function %s",
|
|
|
|
GST_PLUGIN_FEATURE_NAME (factory));
|
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
|
|
|
|
if (factory->function == gst_type_find_load_plugin) {
|
|
|
|
/* looks like we didn't get a real typefind function */
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("could not load valid typefind function for feature '%s'\n",
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_PLUGIN_FEATURE_NAME (factory));
|
2003-10-28 20:25:30 +00:00
|
|
|
} else {
|
|
|
|
g_assert (factory->function);
|
|
|
|
gst_type_find_factory_call_function (factory, find);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_factory_get_list:
|
|
|
|
*
|
|
|
|
* Gets the list of all registered typefind factories. You must free the
|
|
|
|
* list using g_list_free.
|
|
|
|
*
|
|
|
|
* Returns: the list of all registered typefind factories
|
|
|
|
*/
|
|
|
|
GList *
|
|
|
|
gst_type_find_factory_get_list (void)
|
|
|
|
{
|
|
|
|
return gst_registry_pool_feature_list (GST_TYPE_TYPE_FIND_FACTORY);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_factory_get_caps:
|
|
|
|
* @factory: a factory
|
|
|
|
*
|
|
|
|
* Gets the caps associated with a typefind factory.
|
|
|
|
*
|
|
|
|
* Returns: the #GstCaps associated with this factory
|
|
|
|
*/
|
2003-12-22 01:39:35 +00:00
|
|
|
const GstCaps *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_get_caps (const GstTypeFindFactory * factory)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
2001-03-07 21:52:56 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
return factory->caps;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_factory_get_extensions:
|
|
|
|
* @factory: a factory
|
|
|
|
*
|
|
|
|
* Gets the extensions associated with a typefind factory. The returned
|
|
|
|
* array should not be changed. If you need to change stuff in it, you should
|
2003-10-29 23:10:49 +00:00
|
|
|
* copy it using g_stdupv(). This function may return NULL to indicate
|
|
|
|
* a 0-length list.
|
2003-10-28 20:25:30 +00:00
|
|
|
*
|
|
|
|
* Returns: a NULL-terminated array of extensions associated with this factory
|
|
|
|
*/
|
|
|
|
gchar **
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_get_extensions (const GstTypeFindFactory * factory)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
return factory->extensions;
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_factory_call_function:
|
|
|
|
* @factory: a factory
|
|
|
|
* @find: a properly setup #GstTypeFind entry. The get_data and suggest_type
|
|
|
|
* members must be set.
|
|
|
|
*
|
|
|
|
* Calls the typefinding function associated with this factory.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_factory_call_function (const GstTypeFindFactory * factory,
|
|
|
|
GstTypeFind * find)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_TYPE_FIND_FACTORY (factory));
|
|
|
|
g_return_if_fail (find != NULL);
|
|
|
|
g_return_if_fail (find->peek != NULL);
|
|
|
|
g_return_if_fail (find->suggest != NULL);
|
2001-01-19 00:02:53 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/* should never happen */
|
|
|
|
g_assert (factory->function != NULL);
|
|
|
|
|
|
|
|
factory->function (find, factory->user_data);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
2003-10-31 19:32:47 +00:00
|
|
|
* gst_type_find_register:
|
2003-10-28 20:25:30 +00:00
|
|
|
* @plugin: the GstPlugin to register with
|
|
|
|
* @name: the name for registering
|
|
|
|
* @rank: rank (or importance) of this typefind function
|
|
|
|
* @func: the function to use for typefinding
|
|
|
|
* @extensions: optional extensions that could belong to this type
|
|
|
|
* @possible_caps: optionally the caps that could be returned when typefinding succeeds
|
|
|
|
* @data: optional user data. This user data must be available until the plugin
|
|
|
|
* is unloaded.
|
|
|
|
*
|
|
|
|
* Registers a new typefind function to be used for typefinding. After
|
|
|
|
* registering this function will be available for typefinding.
|
|
|
|
* This function is typically called during an element's plugin initialization.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success, FALSE otherwise
|
|
|
|
*/
|
2003-10-31 19:32:47 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
|
|
|
|
GstTypeFindFunction func, gchar ** extensions,
|
|
|
|
const GstCaps * possible_caps, gpointer data)
|
2001-01-19 00:02:53 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
GstTypeFindFactory *factory;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
g_return_val_if_fail (plugin != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (name != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (func != NULL, FALSE);
|
2003-10-28 20:25:30 +00:00
|
|
|
|
|
|
|
GST_INFO ("registering typefind function for %s", name);
|
2004-03-13 15:27:01 +00:00
|
|
|
factory =
|
|
|
|
GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name,
|
2004-03-15 19:27:17 +00:00
|
|
|
GST_TYPE_TYPE_FIND_FACTORY));
|
2003-10-28 20:25:30 +00:00
|
|
|
if (!factory) {
|
|
|
|
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);
|
2004-07-29 15:29:37 +00:00
|
|
|
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
2003-10-28 20:25:30 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG_OBJECT (factory, "using old typefind factory for %s", name);
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2003-01-17 20:41:04 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
|
|
|
|
if (factory->extensions)
|
|
|
|
g_strfreev (factory->extensions);
|
|
|
|
|
|
|
|
factory->extensions = g_strdupv (extensions);
|
gst/: Make gst_caps_replace() work like other _replace() functions.
Original commit message from CVS:
* gst/base/gstbasesink.c: (gst_basesink_base_init),
(gst_basesink_pad_getcaps), (gst_basesink_init),
(gst_basesink_chain_unlocked):
* gst/base/gsttypefindhelper.c: (helper_find_suggest),
(gst_type_find_helper):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_have_type), (gst_type_find_element_init),
(stop_typefinding), (gst_type_find_element_handle_event),
(find_suggest), (gst_type_find_element_chain),
(gst_type_find_element_checkgetrange),
(gst_type_find_element_getrange), (do_typefind),
(gst_type_find_element_activate):
* gst/gstbuffer.c: (_gst_buffer_sub_free),
(gst_buffer_default_free), (gst_buffer_default_copy),
(gst_buffer_set_caps):
* gst/gstcaps.c: (gst_caps_ref), (gst_caps_unref),
(gst_caps_replace):
* gst/gstmessage.c: (gst_message_new),
(gst_message_new_state_changed):
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_peer_set_active),
(gst_pad_set_checkgetrange_function),
(gst_pad_link_prepare_filtered), (gst_pad_relink_filtered),
(gst_pad_set_caps), (gst_pad_check_pull_range),
(gst_pad_pull_range), (gst_static_pad_template_get_caps):
* gst/gstpad.h:
* gst/gsttypefind.c: (gst_type_find_register):
Make gst_caps_replace() work like other _replace() functions.
Use _caps_replace() where possible.
Make sure _message_new() initialises its field.
Add gst_static_pad_template_get_caps()
2005-04-20 09:10:42 +00:00
|
|
|
gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
|
2003-10-28 20:25:30 +00:00
|
|
|
factory->function = func;
|
|
|
|
factory->user_data = data;
|
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
return TRUE;
|
2003-01-17 20:41:04 +00:00
|
|
|
}
|
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/*** typefind function interface **********************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_type_find_peek:
|
|
|
|
* @find: the find object the function was called with
|
|
|
|
* @offset: the offset
|
|
|
|
* @size: the number of bytes to return
|
|
|
|
*
|
|
|
|
* Returns size bytes of the stream to identify beginning at offset. If offset
|
|
|
|
* is a positive number, the offset is relative to the beginning of the stream,
|
|
|
|
* if offset is a negative number the offset is relative to the end of the
|
|
|
|
* stream. The returned memory is valid until the typefinding function returns
|
|
|
|
* and must not be freed.
|
|
|
|
* If NULL is returned, that data is not available.
|
|
|
|
*
|
|
|
|
* Returns: the requested data or NULL if that data is not available.
|
|
|
|
*/
|
|
|
|
guint8 *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
|
2003-01-17 20:41:04 +00:00
|
|
|
{
|
2003-10-28 20:25:30 +00:00
|
|
|
g_return_val_if_fail (find->peek != NULL, NULL);
|
|
|
|
|
|
|
|
return find->peek (find->data, offset, size);
|
2001-01-19 00:02:53 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_suggest:
|
|
|
|
* @find: the find object the function was called with
|
|
|
|
* @probability: the probability in percent that the suggestion is right
|
|
|
|
* @caps: the fixed caps to suggest
|
|
|
|
*
|
|
|
|
* If a typefind function calls this function it suggests the caps with the
|
|
|
|
* given probability. A typefind function may supply different suggestions
|
|
|
|
* in one call.
|
|
|
|
* It is up to the caller of the typefind function to interpret these values.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_suggest (GstTypeFind * find, guint probability,
|
|
|
|
const GstCaps * caps)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (find->suggest != NULL);
|
|
|
|
g_return_if_fail (probability <= 100);
|
|
|
|
g_return_if_fail (caps != NULL);
|
2003-12-22 01:39:35 +00:00
|
|
|
g_return_if_fail (gst_caps_is_fixed (caps));
|
2003-10-28 20:25:30 +00:00
|
|
|
|
|
|
|
find->suggest (find->data, probability, caps);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
|
|
|
* gst_type_find_get_length:
|
|
|
|
* @find: the find object the function was called with
|
|
|
|
*
|
|
|
|
* Get the length of the data stream.
|
|
|
|
*
|
|
|
|
* Returns: the length of the data stream or 0 if it is not available.
|
|
|
|
*/
|
|
|
|
guint64
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_type_find_get_length (GstTypeFind * find)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
if (find->get_length == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return find->get_length (find->data);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|