diff --git a/ChangeLog b/ChangeLog index dc2fa22a6ed..56416a83d67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,31 @@ +2005-09-21 Stefan Kost + + * docs/gst/gstreamer-docs.sgml: + * docs/gst/gstreamer-sections.txt: + * docs/gst/tmpl/.cvsignore: + * gst/Makefile.am: + * gst/gst.h: + * gst/gstbin.c: + * gst/gstelement.h: + * gst/gstindex.c: (gst_index_class_init): + * gst/gstindex.h: + * gst/gstindexfactory.c: (gst_index_factory_get_type), + (gst_index_factory_class_init), (gst_index_factory_init), + (gst_index_factory_finalize), (gst_index_factory_new), + (gst_index_factory_destroy), (gst_index_factory_find), + (gst_index_factory_create), (gst_index_factory_make): + * gst/gstindexfactory.h: + * gst/gstpluginfeature.c: + * gst/gstpluginfeature.h: + * libs/gst/controller/gstcontroller.c: (gst_controller_new_valist): + more docs inlined, splitted gstindex.{c,h} + 2005-09-20 Thomas Vander Stichele * libs/gst/controller/gstcontroller.c: (gst_controller_new_valist): fix a leak -2005-09-20 Tim-Philipp Müller +2005-09-20 Tim-Philipp M??ller * gst/elements/gstfilesink.c: (gst_file_sink_init): Set sync to FALSE by default. @@ -26,7 +48,7 @@ so we don't timeout before popping a message with 0 timeout. Dump error messages after failed state change. -2005-09-20 Tim-Philipp Müller +2005-09-20 Tim-Philipp M??ller * tools/gst-inspect.c: (print_element_properties_info): Fix two typos. @@ -157,7 +179,7 @@ * docs/libs/tmpl/gstgetbits.sgml: * docs/libs/tmpl/gstputbits.sgml: -2005-09-19 Tim-Philipp Müller +2005-09-19 Tim-Philipp M??ller * win32/gstenumtypes.c: * win32/gstenumtypes.h: diff --git a/docs/gst/gstreamer-docs.sgml b/docs/gst/gstreamer-docs.sgml index 69606579cac..635d6ab4e8b 100644 --- a/docs/gst/gstreamer-docs.sgml +++ b/docs/gst/gstreamer-docs.sgml @@ -46,7 +46,6 @@ - @@ -134,7 +133,6 @@ &GstTagSetter; &GstTypeFind; &GstTypeFindFactory; - &GstTypes; &GstUriHandler; &GstUriType; &GstUtils; diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 6a45acd8343..50d73475d86 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -404,6 +404,8 @@ GST_DISABLE_URI GST_PTR_FORMAT GST_EXPORT GST_PLUGIN_EXPORT +GST_PADDING +GST_PADDING_INIT @@ -413,7 +415,10 @@ GST_PLUGIN_EXPORT GstElement GstElementClass GstElementFlags +GstState GstStateChange +GstStateChangeReturn + GST_STATE GST_STATE_PENDING GST_STATE_CHANGE @@ -514,9 +519,15 @@ GST_ELEMENT_GET_CLASS GST_TYPE_ELEMENT GST_TYPE_ELEMENT_FLAGS GST_ELEMENT_CAST +GST_TYPE_STATE +GST_TYPE_STATE_CHANGE +GST_TYPE_STATE_CHANGE_RETURN gst_element_get_type gst_element_flags_get_type +gst_state_get_type +gst_state_change_get_type +gst_state_change_return_get_type @@ -1438,6 +1449,8 @@ GstPluginFeature GST_PLUGIN_FEATURE_NAME GstTypeNameData GstPluginFeatureFilter +GstRank + gst_plugin_feature_type_name_filter gst_plugin_feature_set_rank gst_plugin_feature_set_name @@ -1453,8 +1466,10 @@ GST_PLUGIN_FEATURE_CLASS GST_IS_PLUGIN_FEATURE_CLASS GST_PLUGIN_FEATURE_GET_CLASS GST_TYPE_PLUGIN_FEATURE +GST_TYPE_RANK gst_plugin_feature_get_type +gst_rank_get_type @@ -1889,28 +1904,6 @@ gst_type_find_factory_get_type -
-gsttypes -GstTypes -GstState -GstStateChange -GstStateChangeReturn -GstRank - -GST_TYPE_STATE -GST_TYPE_STATE_CHANGE -GST_TYPE_STATE_CHANGE_RETURN -GST_TYPE_RANK - -GST_PADDING -GST_PADDING_INIT -gst_state_get_type -gst_state_change_get_type -gst_state_change_return_get_type -gst_rank_get_type -
- -
gsturihandler GstUriHandler diff --git a/docs/gst/tmpl/.gitignore b/docs/gst/tmpl/.gitignore index 037375c56d6..2c3c1896b43 100644 --- a/docs/gst/tmpl/.gitignore +++ b/docs/gst/tmpl/.gitignore @@ -26,13 +26,15 @@ gstfilesink.sgml gstfilter.sgml gstformat.sgml gstghostpad.sgml +gstindex.sgml +gstindexfactory.sgml gstiterator.sgml gstmacros.sgml gstmemchunk.sgml gstmessage.sgml gstminiobject.sgml gstparse.sgml -gstprobe.sgml +gstpluginfeature.sgml gstpushsrc.sgml gstqueue.sgml gstquery.sgml @@ -48,6 +50,7 @@ gsttrace.sgml gsttrashstack.sgml gsttypefind.sgml gsttypefindfactory.sgml +gsttypes.sgml gsturihandler.sgml gsturitype.sgml gstutils.sgml diff --git a/gst/Makefile.am b/gst/Makefile.am index 60d334b9fd1..de9037ac0c4 100644 --- a/gst/Makefile.am +++ b/gst/Makefile.am @@ -38,7 +38,7 @@ if GST_DISABLE_INDEX GST_INDEX_SRC = SUBDIRS_INDEX = else -GST_INDEX_SRC = gstindex.c +GST_INDEX_SRC = gstindex.c gstindexfactory.c SUBDIRS_INDEX = indexers endif @@ -160,6 +160,7 @@ gst_headers = \ gstformat.h \ gstghostpad.h \ gstindex.h \ + gstindexfactory.h \ gstinfo.h \ gstinterface.h \ gstiterator.h \ diff --git a/gst/gst.h b/gst/gst.h index 84afc31975e..a79b3705cac 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/gst/gstbin.c b/gst/gstbin.c index c6afc2d8fc2..546fe353157 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -73,6 +73,7 @@ #include "gsterror.h" #include "gstindex.h" +#include "gstindexfactory.h" #include "gstutils.h" #include "gstchildproxy.h" diff --git a/gst/gstelement.h b/gst/gstelement.h index 1f4c9f8ea87..305b8e72076 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -48,6 +48,7 @@ typedef enum { #include #include #include +#include #include #include #include diff --git a/gst/gstindex.c b/gst/gstindex.c index f592b0979ec..35f026daec3 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -19,11 +19,20 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +/** + * SECTION:gstindex + * @short_description: Generate indexes on objects + * @see_also: #GstIndexFactory + * + * GstIndex is used to generate a stream index of one or more elements + * in a pipeline. + */ #include "gst_private.h" #include "gstinfo.h" #include "gstindex.h" +#include "gstindexfactory.h" #include "gstmarshal.h" #include "gstregistry.h" /* for constructing an entry name */ @@ -149,6 +158,13 @@ gst_index_class_init (GstIndexClass * klass) parent_class = g_type_class_ref (GST_TYPE_OBJECT); + /** + * GstIndex::entry-added + * @gstindex: the object which received the signal. + * @arg1: The entry added to the index. + * + * Is emitted when a new entry is added to the index. + */ gst_index_signals[ENTRY_ADDED] = g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL, @@ -845,186 +861,3 @@ gst_index_entry_assoc_map (GstIndexEntry * entry, } return FALSE; } - - -static void gst_index_factory_class_init (GstIndexFactoryClass * klass); -static void gst_index_factory_init (GstIndexFactory * factory); -static void gst_index_factory_finalize (GObject * object); - -static GstPluginFeatureClass *factory_parent_class = NULL; - -/* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */ - -GType -gst_index_factory_get_type (void) -{ - static GType indexfactory_type = 0; - - if (!indexfactory_type) { - static const GTypeInfo indexfactory_info = { - sizeof (GstIndexFactoryClass), - NULL, - NULL, - (GClassInitFunc) gst_index_factory_class_init, - NULL, - NULL, - sizeof (GstIndexFactory), - 0, - (GInstanceInitFunc) gst_index_factory_init, - NULL - }; - - indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstIndexFactory", &indexfactory_info, 0); - } - return indexfactory_type; -} - -static void -gst_index_factory_class_init (GstIndexFactoryClass * klass) -{ - GObjectClass *gobject_class; - GstObjectClass *gstobject_class; - GstPluginFeatureClass *gstpluginfeature_class; - - gobject_class = (GObjectClass *) klass; - gstobject_class = (GstObjectClass *) klass; - gstpluginfeature_class = (GstPluginFeatureClass *) klass; - - factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE); - - gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_index_factory_finalize); -} - -static void -gst_index_factory_init (GstIndexFactory * factory) -{ -} - -static void -gst_index_factory_finalize (GObject * object) -{ - GstIndexFactory *factory = GST_INDEX_FACTORY (object); - - g_free (factory->longdesc); - - G_OBJECT_CLASS (factory_parent_class)->finalize (object); - -} - -/** - * gst_index_factory_new: - * @name: name of indexfactory to create - * @longdesc: long description of indexfactory to create - * @type: the GType of the GstIndex element of this factory - * - * Create a new indexfactory with the given parameters - * - * Returns: a new #GstIndexFactory. - */ -GstIndexFactory * -gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type) -{ - GstIndexFactory *factory; - - g_return_val_if_fail (name != NULL, NULL); - factory = GST_INDEX_FACTORY (g_object_new (GST_TYPE_INDEX_FACTORY, NULL)); - - GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name); - if (factory->longdesc) - g_free (factory->longdesc); - factory->longdesc = g_strdup (longdesc); - factory->type = type; - - return factory; -} - -/** - * gst_index_factory_destroy: - * @factory: factory to destroy - * - * Removes the index from the global list. - */ -void -gst_index_factory_destroy (GstIndexFactory * factory) -{ - g_return_if_fail (factory != NULL); - - /* we don't free the struct bacause someone might have a handle to it.. */ -} - -/** - * gst_index_factory_find: - * @name: name of indexfactory to find - * - * Search for an indexfactory of the given name. - * - * Returns: #GstIndexFactory if found, NULL otherwise - */ -GstIndexFactory * -gst_index_factory_find (const gchar * name) -{ - GstPluginFeature *feature; - - g_return_val_if_fail (name != NULL, NULL); - - GST_DEBUG ("gstindex: find \"%s\"", name); - - feature = gst_registry_find_feature (gst_registry_get_default (), name, - GST_TYPE_INDEX_FACTORY); - if (feature) - return GST_INDEX_FACTORY (feature); - - return NULL; -} - -/** - * gst_index_factory_create: - * @factory: the factory used to create the instance - * - * Create a new #GstIndex instance from the - * given indexfactory. - * - * Returns: A new #GstIndex instance. - */ -GstIndex * -gst_index_factory_create (GstIndexFactory * factory) -{ - GstIndex *new = NULL; - - g_return_val_if_fail (factory != NULL, NULL); - - factory = - GST_INDEX_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE - (factory))); - if (factory == NULL) - return NULL; - - new = GST_INDEX (g_object_new (factory->type, NULL)); - - return new; -} - -/** - * gst_index_factory_make: - * @name: the name of the factory used to create the instance - * - * Create a new #GstIndex instance from the - * indexfactory with the given name. - * - * Returns: A new #GstIndex instance. - */ -GstIndex * -gst_index_factory_make (const gchar * name) -{ - GstIndexFactory *factory; - - g_return_val_if_fail (name != NULL, NULL); - - factory = gst_index_factory_find (name); - - if (factory == NULL) - return NULL; - - return gst_index_factory_create (factory); -} diff --git a/gst/gstindex.h b/gst/gstindex.h index a22f78707bb..fbad22251f4 100644 --- a/gst/gstindex.h +++ b/gst/gstindex.h @@ -44,12 +44,29 @@ typedef struct _GstIndexGroup GstIndexGroup; typedef struct _GstIndex GstIndex; typedef struct _GstIndexClass GstIndexClass; +/** + * GstIndexCertainty: + * @GST_INDEX_UNKNOWN: accuracy is not known + * @GST_INDEX_CERTAIN: accuracy is perfect + * @GST_INDEX_FUZZY: accuracy is fuzzy + * + * The certainty of a group in the index. + */ typedef enum { GST_INDEX_UNKNOWN, GST_INDEX_CERTAIN, GST_INDEX_FUZZY } GstIndexCertainty; +/** + * GstIndexEntryType: + * @GST_INDEX_ENTRY_ID: This entry is an id that maps an index id to its owner object + * @GST_INDEX_ENTRY_ASSOCIATION: This entry is an association between formats + * @GST_INDEX_ENTRY_OBJECT: An object + * @GST_INDEX_ENTRY_FORMAT: A format definition + * + * The different types of entries in the index. + */ typedef enum { GST_INDEX_ENTRY_ID, GST_INDEX_ENTRY_ASSOCIATION, @@ -57,24 +74,79 @@ typedef enum { GST_INDEX_ENTRY_FORMAT } GstIndexEntryType; +/** + * GstIndexLookupMethod: + * @GST_INDEX_LOOKUP_EXACT: There has to be an exact indexentry with the given format/value + * @GST_INDEX_LOOKUP_BEFORE: The exact entry or the one before it + * @GST_INDEX_LOOKUP_AFTER: The exact entry or the one after it + * + * Specify the method to find an index entry in the index. + */ typedef enum { GST_INDEX_LOOKUP_EXACT, GST_INDEX_LOOKUP_BEFORE, GST_INDEX_LOOKUP_AFTER } GstIndexLookupMethod; +/** + * GST_INDEX_NASSOCS: + * @entry: The entry to query + * + * Get the number of associations in the entry. + */ #define GST_INDEX_NASSOCS(entry) ((entry)->data.assoc.nassocs) + +/** + * GST_INDEX_ASSOC_FLAGS: + * @entry: The entry to query + * + * Get the flags for this entry. + */ #define GST_INDEX_ASSOC_FLAGS(entry) ((entry)->data.assoc.flags) + +/** + * GST_INDEX_ASSOC_FORMAT: + * @entry: The entry to query + * @i: The format index + * + * Get the i-th format of the entry. + */ #define GST_INDEX_ASSOC_FORMAT(entry,i) ((entry)->data.assoc.assocs[(i)].format) + +/** + * GST_INDEX_ASSOC_VALUE: + * @entry: The entry to query + * @i: The value index + * + * Get the i-th value of the entry. + */ #define GST_INDEX_ASSOC_VALUE(entry,i) ((entry)->data.assoc.assocs[(i)].value) typedef struct _GstIndexAssociation GstIndexAssociation; +/** + * GstIndexAssociation: + * @format: the format of the association + * @value: the value of the association + * + * An association in an entry. + */ struct _GstIndexAssociation { GstFormat format; gint64 value; }; +/** + * GstAssocFlags: + * @GST_ASSOCIATION_FLAG_NONE: no extra flags + * @GST_ASSOCIATION_FLAG_KEY_UNIT: the entry marks a key unit, a key unit is one + * that marks a place where one can randomly seek to. + * @GST_ASSOCIATION_FLAG_DELTA_UNIT: the entry marks a delta unit, a delta unit + * is one that marks a place where one can relatively seek to. + * @GST_ASSOCIATION_FLAG_LAST: extra user defined flags should start here. + * + * Flags for an association entry. + */ typedef enum { GST_ASSOCIATION_FLAG_NONE = 0, GST_ASSOCIATION_FLAG_KEY_UNIT = (1 << 0), @@ -84,13 +156,42 @@ typedef enum { GST_ASSOCIATION_FLAG_LAST = (1 << 8) } GstAssocFlags; +/** + * GST_INDEX_FORMAT_FORMAT: + * @entry: The entry to query + * + * Get the format of the format entry + */ #define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format) + +/** + * GST_INDEX_FORMAT_KEY: + * @entry: The entry to query + * + * Get the key of the format entry + */ #define GST_INDEX_FORMAT_KEY(entry) ((entry)->data.format.key) +/** + * GST_INDEX_ID_INVALID: + * + * Constant for an invalid index id + */ #define GST_INDEX_ID_INVALID (-1) +/** + * GST_INDEX_ID_DESCRIPTION: + * @entry: The entry to query + * + * Get the description of the id entry + */ #define GST_INDEX_ID_DESCRIPTION(entry) ((entry)->data.id.description) +/** + * GstIndexEntry: + * + * The basic element of an index. + */ struct _GstIndexEntry { GstIndexEntryType type; gint id; @@ -117,6 +218,12 @@ struct _GstIndexEntry { } data; }; +/** + * GstIndexGroup: + * + * A group of related entries in an index. + */ + struct _GstIndexGroup { /* unique ID of group in index */ gint groupnum; @@ -131,19 +238,57 @@ struct _GstIndexGroup { gint peergroup; }; +/** + * GstIndexFilter: + * @index: The index being queried + * @entry: The entry to be added. + * + * Function to filter out entries in the index. + * + * Returns: This function should return %TRUE if the entry is to be added + * to the index, %FALSE otherwise. + * + */ typedef gboolean (*GstIndexFilter) (GstIndex *index, GstIndexEntry *entry); - +/** + * GstIndexResolverMethod: + * @GST_INDEX_RESOLVER_CUSTOM: Use a custom resolver + * @GST_INDEX_RESOLVER_GTYPE: Resolve based on the GType of the object + * @GST_INDEX_RESOLVER_PATH: Resolve on the path in graph + * + * The method used to resolve index writers + */ typedef enum { GST_INDEX_RESOLVER_CUSTOM, GST_INDEX_RESOLVER_GTYPE, GST_INDEX_RESOLVER_PATH } GstIndexResolverMethod; +/** + * GstIndexResolver: + * @index: the index being queried. + * @writer: The object that wants to write + * @writer_string: A description of the writer. + * @user_data: user_data as registered + * + * Function to resolve ids to writer descriptions. + * + * Returns: %TRUE if an id could be assigned to the writer. + */ typedef gboolean (*GstIndexResolver) (GstIndex *index, GstObject *writer, gchar **writer_string, gpointer user_data); + +/** + * GstIndexFlags: + * @GST_INDEX_WRITABLE: The index is writable + * @GST_INDEX_READABLE: The index is readable + * @GST_INDEX_FLAG_LAST: First flag that can be used by subclasses + * + * Flags for this index + */ typedef enum { GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST, GST_INDEX_READABLE, @@ -151,7 +296,20 @@ typedef enum { GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8 } GstIndexFlags; +/** + * GST_INDEX_IS_READABLE: + * @obj: The index to check + * + * Check if the index can be read from + */ #define GST_INDEX_IS_READABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_READABLE)) + +/** + * GST_INDEX_IS_WRITABLE: + * @obj: The index to check + * + * Check if the index can be written to + */ #define GST_INDEX_IS_WRITABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_WRITABLE)) struct _GstIndex { @@ -237,45 +395,6 @@ GstIndexEntry * gst_index_entry_copy (GstIndexEntry *entry); void gst_index_entry_free (GstIndexEntry *entry); gboolean gst_index_entry_assoc_map (GstIndexEntry *entry, GstFormat format, gint64 *value); -/* - * creating indexs - * - */ -#define GST_TYPE_INDEX_FACTORY (gst_index_factory_get_type()) -#define GST_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactory)) -#define GST_IS_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX_FACTORY)) -#define GST_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass)) -#define GST_IS_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX_FACTORY)) -#define GST_INDEX_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass)) - -typedef struct _GstIndexFactory GstIndexFactory; -typedef struct _GstIndexFactoryClass GstIndexFactoryClass; - -struct _GstIndexFactory { - GstPluginFeature feature; - - gchar *longdesc; /* long description of the index (well, don't overdo it..) */ - GType type; /* unique GType of the index */ - - gpointer _gst_reserved[GST_PADDING]; -}; - -struct _GstIndexFactoryClass { - GstPluginFeatureClass parent; - - gpointer _gst_reserved[GST_PADDING]; -}; - -GType gst_index_factory_get_type (void); - -GstIndexFactory* gst_index_factory_new (const gchar *name, - const gchar *longdesc, GType type); -void gst_index_factory_destroy (GstIndexFactory *factory); - -GstIndexFactory* gst_index_factory_find (const gchar *name); - -GstIndex* gst_index_factory_create (GstIndexFactory *factory); -GstIndex* gst_index_factory_make (const gchar *name); G_END_DECLS diff --git a/gst/gstindexfactory.c b/gst/gstindexfactory.c new file mode 100644 index 00000000000..6fbaef5ac1c --- /dev/null +++ b/gst/gstindexfactory.c @@ -0,0 +1,219 @@ +/* GStreamer + * Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/) + * Written by Erik Walthinsen + * + * gstindexfactory.c: Index for mappings and other data + * + * 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:gstindexfactory + * @short_description: Create GstIndexes from a factory + * @see_also: #GstIndex + * + * GstIndexFactory is used to dynamically create GstIndex implementations. + */ + + +#include "gst_private.h" + +#include "gstinfo.h" +#include "gstindex.h" +#include "gstindexfactory.h" +#include "gstmarshal.h" +#include "gstregistry.h" + +static void gst_index_factory_class_init (GstIndexFactoryClass * klass); +static void gst_index_factory_init (GstIndexFactory * factory); +static void gst_index_factory_finalize (GObject * object); + +static GstPluginFeatureClass *factory_parent_class = NULL; + +/* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */ + +GType +gst_index_factory_get_type (void) +{ + static GType indexfactory_type = 0; + + if (!indexfactory_type) { + static const GTypeInfo indexfactory_info = { + sizeof (GstIndexFactoryClass), + NULL, + NULL, + (GClassInitFunc) gst_index_factory_class_init, + NULL, + NULL, + sizeof (GstIndexFactory), + 0, + (GInstanceInitFunc) gst_index_factory_init, + NULL + }; + + indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, + "GstIndexFactory", &indexfactory_info, 0); + } + return indexfactory_type; +} + +static void +gst_index_factory_class_init (GstIndexFactoryClass * klass) +{ + GObjectClass *gobject_class; + GstObjectClass *gstobject_class; + GstPluginFeatureClass *gstpluginfeature_class; + + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstpluginfeature_class = (GstPluginFeatureClass *) klass; + + factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE); + + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_index_factory_finalize); +} + +static void +gst_index_factory_init (GstIndexFactory * factory) +{ +} + +static void +gst_index_factory_finalize (GObject * object) +{ + GstIndexFactory *factory = GST_INDEX_FACTORY (object); + + g_free (factory->longdesc); + + G_OBJECT_CLASS (factory_parent_class)->finalize (object); + +} + +/** + * gst_index_factory_new: + * @name: name of indexfactory to create + * @longdesc: long description of indexfactory to create + * @type: the GType of the GstIndex element of this factory + * + * Create a new indexfactory with the given parameters + * + * Returns: a new #GstIndexFactory. + */ +GstIndexFactory * +gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type) +{ + GstIndexFactory *factory; + + g_return_val_if_fail (name != NULL, NULL); + factory = GST_INDEX_FACTORY (g_object_new (GST_TYPE_INDEX_FACTORY, NULL)); + + GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name); + if (factory->longdesc) + g_free (factory->longdesc); + factory->longdesc = g_strdup (longdesc); + factory->type = type; + + return factory; +} + +/** + * gst_index_factory_destroy: + * @factory: factory to destroy + * + * Removes the index from the global list. + */ +void +gst_index_factory_destroy (GstIndexFactory * factory) +{ + g_return_if_fail (factory != NULL); + + /* we don't free the struct bacause someone might have a handle to it.. */ +} + +/** + * gst_index_factory_find: + * @name: name of indexfactory to find + * + * Search for an indexfactory of the given name. + * + * Returns: #GstIndexFactory if found, NULL otherwise + */ +GstIndexFactory * +gst_index_factory_find (const gchar * name) +{ + GstPluginFeature *feature; + + g_return_val_if_fail (name != NULL, NULL); + + GST_DEBUG ("gstindex: find \"%s\"", name); + + feature = gst_registry_find_feature (gst_registry_get_default (), name, + GST_TYPE_INDEX_FACTORY); + if (feature) + return GST_INDEX_FACTORY (feature); + + return NULL; +} + +/** + * gst_index_factory_create: + * @factory: the factory used to create the instance + * + * Create a new #GstIndex instance from the + * given indexfactory. + * + * Returns: A new #GstIndex instance. + */ +GstIndex * +gst_index_factory_create (GstIndexFactory * factory) +{ + GstIndex *new = NULL; + + g_return_val_if_fail (factory != NULL, NULL); + + factory = + GST_INDEX_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE + (factory))); + if (factory == NULL) + return NULL; + + new = GST_INDEX (g_object_new (factory->type, NULL)); + + return new; +} + +/** + * gst_index_factory_make: + * @name: the name of the factory used to create the instance + * + * Create a new #GstIndex instance from the + * indexfactory with the given name. + * + * Returns: A new #GstIndex instance. + */ +GstIndex * +gst_index_factory_make (const gchar * name) +{ + GstIndexFactory *factory; + + g_return_val_if_fail (name != NULL, NULL); + + factory = gst_index_factory_find (name); + + if (factory == NULL) + return NULL; + + return gst_index_factory_create (factory); +} diff --git a/gst/gstindexfactory.h b/gst/gstindexfactory.h new file mode 100644 index 00000000000..0ac9bff1676 --- /dev/null +++ b/gst/gstindexfactory.h @@ -0,0 +1,76 @@ +/* GStreamer + * Copyright (C) 1999,2000 Erik Walthinsen + * 2000 Wim Taymans + * + * gstindexfactory.h: Header for GstIndexFactory, base class to handle efficient + * storage or caching of seeking information. + * + * 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_INDEX_FACTORY_H__ +#define __GST_INDEX_FACTORY_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GST_TYPE_INDEX_FACTORY (gst_index_factory_get_type()) +#define GST_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactory)) +#define GST_IS_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX_FACTORY)) +#define GST_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass)) +#define GST_IS_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX_FACTORY)) +#define GST_INDEX_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass)) + +typedef struct _GstIndexFactory GstIndexFactory; +typedef struct _GstIndexFactoryClass GstIndexFactoryClass; + +/** + * GstIndexFactory: + * + * The GstIndexFactory object + */ +struct _GstIndexFactory { + GstPluginFeature feature; + + gchar *longdesc; /* long description of the index (well, don't overdo it..) */ + GType type; /* unique GType of the index */ + + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstIndexFactoryClass { + GstPluginFeatureClass parent; + + gpointer _gst_reserved[GST_PADDING]; +}; + +GType gst_index_factory_get_type (void); + +GstIndexFactory* gst_index_factory_new (const gchar *name, + const gchar *longdesc, GType type); +void gst_index_factory_destroy (GstIndexFactory *factory); + +GstIndexFactory* gst_index_factory_find (const gchar *name); + +GstIndex* gst_index_factory_create (GstIndexFactory *factory); +GstIndex* gst_index_factory_make (const gchar *name); + +G_END_DECLS + +#endif /* __GST_INDEX_FACTORY_H__ */ diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index fc6079c4221..5e8037ce38e 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -19,6 +19,13 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +/** + * SECTION:gstpluginfeature + * @short_description: Base class for contents of a GstPlugin + * @see_also: #GstPlugin + * + * This is a base class for anything that can be added to a #GstPlugin. + */ #include "gst_private.h" diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index 0fa88f77266..2b30f1956c9 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -36,12 +36,32 @@ G_BEGIN_DECLS #define GST_IS_PLUGIN_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN_FEATURE)) #define GST_PLUGIN_FEATURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN_FEATURE, GstPluginFeatureClass)) +/** + * GST_PLUGIN_FEATURE_NAME: + * @feature: The feature to query + * + * Get the name of the feature + */ #define GST_PLUGIN_FEATURE_NAME(feature) (GST_PLUGIN_FEATURE (feature)->name) typedef struct _GstPluginFeature GstPluginFeature; typedef struct _GstPluginFeatureClass GstPluginFeatureClass; -/* some predefined ranks */ +/** + * GstRank: + * @GST_RANK_NONE: will be chosen last or not at all + * @GST_RANK_MARGINAL: unlikly to be chosen + * @GST_RANK_SECONDARY: likely to be chosen + * @GST_RANK_PRIMARY: will be chosen first + * + * Element priority ranks. Defines the order in which the autoplugger (or + * similar rank-picking mechanisms) will choose this element over an alternative + * one with the same function. + * + * The rank is a unsigned integer ranging from 0 (GST_RANK_NONE) to 256 + * (GST_RANK_PRIMARY). These constants serve as a rough guidiance for defining + * the rank of a #GstPlugin using gst_plugin_feature_set_rank(). + */ typedef enum { GST_RANK_NONE = 0, GST_RANK_MARGINAL = 64, @@ -76,7 +96,17 @@ typedef struct { GType type; } GstTypeNameData; -/* filter */ +/** + * GstPluginFeatureFilter: + * @feature: the pluginfeature to check + * @user_data: the user_data that has been passed on e.g. + * gst_registry_feature_filter() + * + * A function that can be used with e.g. gst_registry_feature_filter() + * to get a list of pluginfeature that match certain criteria. + * + * Returns: %TRUE for a positive match, %FALSE otherwise + */ typedef gboolean (*GstPluginFeatureFilter) (GstPluginFeature *feature, gpointer user_data);