mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
gst/: splitted gsttypefind into gsttypefind, gsttypefindfactory
Original commit message from CVS: * gst/Makefile.am: * gst/elements/gstbufferstore.h: * gst/elements/gsttypefindelement.c: * gst/elements/gsttypefindelement.h: * gst/gst.h: * gst/gsttypefind.c: * gst/gsttypefind.h: * gst/gsttypefindfactory.c: (gst_type_find_factory_get_type), (gst_type_find_factory_class_init), (gst_type_find_factory_init), (gst_type_find_factory_dispose), (gst_type_find_factory_unload_thyself), (gst_type_find_load_plugin), (gst_type_find_factory_get_list), (gst_type_find_factory_get_caps), (gst_type_find_factory_get_extensions), (gst_type_find_factory_call_function): * gst/gsttypefindfactory.h: * gst/registries/gstlibxmlregistry.c: * gst/registries/gstxmlregistry.c: splitted gsttypefind into gsttypefind, gsttypefindfactory
This commit is contained in:
parent
c477a458d7
commit
628f773e65
15 changed files with 383 additions and 287 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2005-09-07 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* gst/Makefile.am:
|
||||
* gst/elements/gstbufferstore.h:
|
||||
* gst/elements/gsttypefindelement.c:
|
||||
* gst/elements/gsttypefindelement.h:
|
||||
* gst/gst.h:
|
||||
* gst/gsttypefind.c:
|
||||
* gst/gsttypefind.h:
|
||||
* gst/gsttypefindfactory.c: (gst_type_find_factory_get_type),
|
||||
(gst_type_find_factory_class_init), (gst_type_find_factory_init),
|
||||
(gst_type_find_factory_dispose),
|
||||
(gst_type_find_factory_unload_thyself),
|
||||
(gst_type_find_load_plugin), (gst_type_find_factory_get_list),
|
||||
(gst_type_find_factory_get_caps),
|
||||
(gst_type_find_factory_get_extensions),
|
||||
(gst_type_find_factory_call_function):
|
||||
* gst/gsttypefindfactory.h:
|
||||
* gst/registries/gstlibxmlregistry.c:
|
||||
* gst/registries/gstxmlregistry.c:
|
||||
splitted gsttypefind into gsttypefind, gsttypefindfactory
|
||||
|
||||
2005-09-07 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
* gst/base/gstbasesink.c (gst_base_sink_activate_pull): Fix a race
|
||||
|
|
|
@ -115,6 +115,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
$(GST_TRACE_SRC) \
|
||||
gsttrashstack.c \
|
||||
gsttypefind.c \
|
||||
gsttypefindfactory.c \
|
||||
$(GST_URI_SRC) \
|
||||
gsturitype.c \
|
||||
gstutils.c \
|
||||
|
@ -191,6 +192,7 @@ gst_headers = \
|
|||
gsttrace.h \
|
||||
gsttrashstack.h \
|
||||
gsttypefind.h \
|
||||
gsttypefindfactory.h \
|
||||
gsturi.h \
|
||||
gsturitype.h \
|
||||
gstutils.h \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.h: keep an easily accessible list of all buffers
|
||||
* gstbufferstore.h: keep an easily accessible list of all buffers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.c: element that detects type of stream
|
||||
* gsttypefindelement.c: element that detects type of stream
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.h: element that detects type of stream
|
||||
* gsttypefindelement.h: element that detects type of stream
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <gst/gsttask.h>
|
||||
#include <gst/gsttrace.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
#include <gst/gsttypefindfactory.h>
|
||||
#include <gst/gsturi.h>
|
||||
#include <gst/gsturitype.h>
|
||||
#include <gst/gstutils.h>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.h: typefinding subsystem
|
||||
* gsttypefind.c: typefinding subsystem
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -23,248 +23,16 @@
|
|||
* @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.
|
||||
*/
|
||||
|
||||
#include "gst_private.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gsttypefind.h"
|
||||
#include "gsttypefindfactory.h"
|
||||
#include "gstregistrypool.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_type_find_debug);
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_type_find_debug);
|
||||
#define GST_CAT_DEFAULT gst_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 void gst_type_find_factory_unload_thyself (GstPluginFeature * feature);
|
||||
|
||||
static void gst_type_find_load_plugin (GstTypeFind * find, gpointer data);
|
||||
|
||||
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;
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_class_init (gpointer g_class, gpointer class_data)
|
||||
{
|
||||
GstPluginFeatureClass *gstpluginfeature_class =
|
||||
GST_PLUGIN_FEATURE_CLASS (g_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (g_class);
|
||||
|
||||
object_class->dispose = gst_type_find_factory_dispose;
|
||||
|
||||
gstpluginfeature_class->unload_thyself =
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself);
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
|
||||
|
||||
factory->user_data = factory;
|
||||
factory->function = gst_type_find_load_plugin;
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_dispose (GObject * object)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object);
|
||||
|
||||
if (factory->caps) {
|
||||
gst_caps_unref (factory->caps);
|
||||
factory->caps = NULL;
|
||||
}
|
||||
if (factory->extensions) {
|
||||
g_strfreev (factory->extensions);
|
||||
factory->extensions = NULL;
|
||||
}
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_unload_thyself (GstPluginFeature * feature)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
||||
|
||||
factory->function = gst_type_find_load_plugin;
|
||||
factory->user_data = factory;
|
||||
}
|
||||
static void
|
||||
gst_type_find_load_plugin (GstTypeFind * find, gpointer data)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (data);
|
||||
|
||||
GST_DEBUG_OBJECT (factory, "need to load typefind function %s",
|
||||
GST_PLUGIN_FEATURE_NAME (factory));
|
||||
|
||||
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 */
|
||||
g_warning ("could not load valid typefind function for feature '%s'\n",
|
||||
GST_PLUGIN_FEATURE_NAME (factory));
|
||||
} else {
|
||||
g_assert (factory->function);
|
||||
gst_type_find_factory_call_function (factory, find);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_type_find_factory_get_caps:
|
||||
* @factory: a factory
|
||||
*
|
||||
* Gets the caps associated with a typefind factory.
|
||||
*
|
||||
* Returns: the #GstCaps associated with this factory
|
||||
*/
|
||||
const GstCaps *
|
||||
gst_type_find_factory_get_caps (const GstTypeFindFactory * factory)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
||||
|
||||
return factory->caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* copy it using g_stdupv(). This function may return NULL to indicate
|
||||
* a 0-length list.
|
||||
*
|
||||
* Returns: a NULL-terminated array of extensions associated with this factory
|
||||
*/
|
||||
gchar **
|
||||
gst_type_find_factory_get_extensions (const GstTypeFindFactory * factory)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
||||
|
||||
return factory->extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
gst_type_find_factory_call_function (const GstTypeFindFactory * factory,
|
||||
GstTypeFind * find)
|
||||
{
|
||||
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);
|
||||
|
||||
/* should never happen */
|
||||
g_assert (factory->function != NULL);
|
||||
|
||||
factory->function (find, factory->user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_type_find_register:
|
||||
* @plugin: the GstPlugin to register with
|
||||
|
|
|
@ -29,16 +29,7 @@
|
|||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_TYPE_FIND_FACTORY (gst_type_find_factory_get_type())
|
||||
#define GST_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactory))
|
||||
#define GST_IS_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_FACTORY))
|
||||
#define GST_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
|
||||
#define GST_IS_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_FACTORY))
|
||||
#define GST_TYPE_FIND_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
|
||||
|
||||
typedef struct _GstTypeFind GstTypeFind;
|
||||
typedef struct _GstTypeFindFactory GstTypeFindFactory;
|
||||
typedef struct _GstTypeFindFactoryClass GstTypeFindFactoryClass;
|
||||
|
||||
typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer data);
|
||||
|
||||
|
@ -50,6 +41,11 @@ typedef enum {
|
|||
GST_TYPE_FIND_MAXIMUM = 100
|
||||
} GstTypeFindProbability;
|
||||
|
||||
/**
|
||||
* GstTypeFind:
|
||||
*
|
||||
* Object that stores typefind callbacks.
|
||||
*/
|
||||
struct _GstTypeFind {
|
||||
/* private to the caller of the typefind function */
|
||||
guint8 * (* peek) (gpointer data,
|
||||
|
@ -68,31 +64,6 @@ struct _GstTypeFind {
|
|||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
/**
|
||||
* GstTypeFindFactory:
|
||||
*
|
||||
* Object that stores information about a typefind function.
|
||||
*/
|
||||
struct _GstTypeFindFactory {
|
||||
GstPluginFeature feature;
|
||||
/* <private> */
|
||||
|
||||
GstTypeFindFunction function;
|
||||
gchar ** extensions;
|
||||
GstCaps * caps; /* FIXME: not yet saved in registry */
|
||||
|
||||
gpointer user_data;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstTypeFindFactoryClass {
|
||||
GstPluginFeatureClass parent;
|
||||
/* <private> */
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
/* typefind function interface */
|
||||
guint8 * gst_type_find_peek (GstTypeFind * find,
|
||||
gint64 offset,
|
||||
|
@ -111,18 +82,6 @@ gboolean gst_type_find_register (GstPlugin * plugin,
|
|||
const GstCaps * possible_caps,
|
||||
gpointer data);
|
||||
|
||||
/* typefinding interface */
|
||||
|
||||
GType gst_type_find_factory_get_type (void);
|
||||
|
||||
GList * gst_type_find_factory_get_list (void);
|
||||
|
||||
gchar ** gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory);
|
||||
const GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory);
|
||||
void gst_type_find_factory_call_function (const GstTypeFindFactory *factory,
|
||||
GstTypeFind *find);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_TYPE_FIND_H__ */
|
||||
|
|
262
gst/gsttypefindfactory.c
Normal file
262
gst/gsttypefindfactory.c
Normal file
|
@ -0,0 +1,262 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefindfactory.c: typefinding subsystem
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "gst_private.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gsttypefind.h"
|
||||
#include "gsttypefindfactory.h"
|
||||
#include "gstregistrypool.h"
|
||||
|
||||
GST_DEBUG_CATEGORY (gst_type_find_debug);
|
||||
#define GST_CAT_DEFAULT gst_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 void gst_type_find_factory_unload_thyself (GstPluginFeature * feature);
|
||||
|
||||
static void gst_type_find_load_plugin (GstTypeFind * find, gpointer data);
|
||||
|
||||
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;
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_class_init (gpointer g_class, gpointer class_data)
|
||||
{
|
||||
GstPluginFeatureClass *gstpluginfeature_class =
|
||||
GST_PLUGIN_FEATURE_CLASS (g_class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (g_class);
|
||||
|
||||
object_class->dispose = gst_type_find_factory_dispose;
|
||||
|
||||
gstpluginfeature_class->unload_thyself =
|
||||
GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself);
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
|
||||
|
||||
factory->user_data = factory;
|
||||
factory->function = gst_type_find_load_plugin;
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_dispose (GObject * object)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object);
|
||||
|
||||
if (factory->caps) {
|
||||
gst_caps_unref (factory->caps);
|
||||
factory->caps = NULL;
|
||||
}
|
||||
if (factory->extensions) {
|
||||
g_strfreev (factory->extensions);
|
||||
factory->extensions = NULL;
|
||||
}
|
||||
}
|
||||
static void
|
||||
gst_type_find_factory_unload_thyself (GstPluginFeature * feature)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
||||
|
||||
factory->function = gst_type_find_load_plugin;
|
||||
factory->user_data = factory;
|
||||
}
|
||||
static void
|
||||
gst_type_find_load_plugin (GstTypeFind * find, gpointer data)
|
||||
{
|
||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (data);
|
||||
|
||||
GST_DEBUG_OBJECT (factory, "need to load typefind function %s",
|
||||
GST_PLUGIN_FEATURE_NAME (factory));
|
||||
|
||||
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 */
|
||||
g_warning ("could not load valid typefind function for feature '%s'\n",
|
||||
GST_PLUGIN_FEATURE_NAME (factory));
|
||||
} else {
|
||||
g_assert (factory->function);
|
||||
gst_type_find_factory_call_function (factory, find);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_type_find_factory_get_caps:
|
||||
* @factory: a factory
|
||||
*
|
||||
* Gets the caps associated with a typefind factory.
|
||||
*
|
||||
* Returns: the #GstCaps associated with this factory
|
||||
*/
|
||||
const GstCaps *
|
||||
gst_type_find_factory_get_caps (const GstTypeFindFactory * factory)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
||||
|
||||
return factory->caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* copy it using g_stdupv(). This function may return NULL to indicate
|
||||
* a 0-length list.
|
||||
*
|
||||
* Returns: a NULL-terminated array of extensions associated with this factory
|
||||
*/
|
||||
gchar **
|
||||
gst_type_find_factory_get_extensions (const GstTypeFindFactory * factory)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL);
|
||||
|
||||
return factory->extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
gst_type_find_factory_call_function (const GstTypeFindFactory * factory,
|
||||
GstTypeFind * find)
|
||||
{
|
||||
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);
|
||||
|
||||
/* should never happen */
|
||||
g_assert (factory->function != NULL);
|
||||
|
||||
factory->function (find, factory->user_data);
|
||||
}
|
80
gst/gsttypefindfactory.h
Normal file
80
gst/gsttypefindfactory.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefindfactory.h: typefinding subsystem
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_TYPE_FIND_FACTORY_H__
|
||||
#define __GST_TYPE_FIND_FACTORY_H__
|
||||
|
||||
#include <gst/gstcaps.h>
|
||||
#include <gst/gstplugin.h>
|
||||
#include <gst/gstpluginfeature.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_TYPE_FIND_FACTORY (gst_type_find_factory_get_type())
|
||||
#define GST_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactory))
|
||||
#define GST_IS_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_FACTORY))
|
||||
#define GST_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
|
||||
#define GST_IS_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_FACTORY))
|
||||
#define GST_TYPE_FIND_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass))
|
||||
|
||||
typedef struct _GstTypeFindFactory GstTypeFindFactory;
|
||||
typedef struct _GstTypeFindFactoryClass GstTypeFindFactoryClass;
|
||||
|
||||
/**
|
||||
* GstTypeFindFactory:
|
||||
*
|
||||
* Object that stores information about a typefind function.
|
||||
*/
|
||||
struct _GstTypeFindFactory {
|
||||
GstPluginFeature feature;
|
||||
/* <private> */
|
||||
|
||||
GstTypeFindFunction function;
|
||||
gchar ** extensions;
|
||||
GstCaps * caps; /* FIXME: not yet saved in registry */
|
||||
|
||||
gpointer user_data;
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstTypeFindFactoryClass {
|
||||
GstPluginFeatureClass parent;
|
||||
/* <private> */
|
||||
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
/* typefinding interface */
|
||||
|
||||
GType gst_type_find_factory_get_type (void);
|
||||
|
||||
GList * gst_type_find_factory_get_list (void);
|
||||
|
||||
gchar ** gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory);
|
||||
const GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory);
|
||||
void gst_type_find_factory_call_function (const GstTypeFindFactory *factory,
|
||||
GstTypeFind *find);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_TYPE_FIND_FACTORY_H__ */
|
|
@ -54,6 +54,7 @@
|
|||
#include <gst/gst_private.h>
|
||||
#include <gst/gstelement.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
#include <gst/gsttypefindfactory.h>
|
||||
#include <gst/gsturi.h>
|
||||
#include <gst/gstinfo.h>
|
||||
#include <gst/gstenumtypes.h>
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <gst/gst_private.h>
|
||||
#include <gst/gstelement.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
#include <gst/gsttypefindfactory.h>
|
||||
#include <gst/gsturi.h>
|
||||
#include <gst/gstinfo.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.h: keep an easily accessible list of all buffers
|
||||
* gstbufferstore.h: keep an easily accessible list of all buffers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.c: element that detects type of stream
|
||||
* gsttypefindelement.c: element that detects type of stream
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* gsttypefind.h: element that detects type of stream
|
||||
* gsttypefindelement.h: element that detects type of stream
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
Loading…
Reference in a new issue