2 * Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/)
3 * Written by Erik Walthinsen <omega@ridgerun.com>
5 * gstindexfactory.c: Index for mappings and other data
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * SECTION:gstindexfactory
25 * @short_description: Create GstIndexes from a factory
26 * @see_also: #GstIndex
28 * GstIndexFactory is used to dynamically create GstIndex implementations.
32 #include "gst_private.h"
36 #include "gstindexfactory.h"
37 #include "gstmarshal.h"
38 #include "gstregistry.h"
40 static void gst_index_factory_finalize (GObject * object);
42 static GstPluginFeatureClass *factory_parent_class = NULL;
44 /* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */
45 G_DEFINE_TYPE (GstIndexFactory, gst_index_factory, GST_TYPE_PLUGIN_FEATURE);
48 gst_index_factory_class_init (GstIndexFactoryClass * klass)
50 GObjectClass *gobject_class = (GObjectClass *) klass;
52 factory_parent_class = g_type_class_peek_parent (klass);
54 gobject_class->finalize = gst_index_factory_finalize;
58 gst_index_factory_init (GstIndexFactory * factory)
63 gst_index_factory_finalize (GObject * object)
65 GstIndexFactory *factory = GST_INDEX_FACTORY (object);
67 g_free (factory->longdesc);
69 G_OBJECT_CLASS (factory_parent_class)->finalize (object);
74 * gst_index_factory_new:
75 * @name: name of indexfactory to create
76 * @longdesc: long description of indexfactory to create
77 * @type: the GType of the GstIndex element of this factory
79 * Create a new indexfactory with the given parameters
81 * Returns: (transfer full): a new #GstIndexFactory.
84 gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type)
86 GstIndexFactory *factory;
88 g_return_val_if_fail (name != NULL, NULL);
89 factory = GST_INDEX_FACTORY (g_object_newv (GST_TYPE_INDEX_FACTORY, 0, NULL));
91 GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
92 if (factory->longdesc)
93 g_free (factory->longdesc);
94 factory->longdesc = g_strdup (longdesc);
101 * gst_index_factory_destroy:
102 * @factory: factory to destroy
104 * Removes the index from the global list.
107 gst_index_factory_destroy (GstIndexFactory * factory)
109 g_return_if_fail (factory != NULL);
111 /* we don't free the struct bacause someone might have a handle to it.. */
112 /* FIXME: gst_index_factory_destroy */
116 * gst_index_factory_find:
117 * @name: name of indexfactory to find
119 * Search for an indexfactory of the given name.
121 * Returns: (transfer full): #GstIndexFactory if found, NULL otherwise
124 gst_index_factory_find (const gchar * name)
126 GstPluginFeature *feature;
128 g_return_val_if_fail (name != NULL, NULL);
130 GST_DEBUG ("gstindex: find \"%s\"", name);
132 feature = gst_registry_find_feature (gst_registry_get_default (), name,
133 GST_TYPE_INDEX_FACTORY);
135 return GST_INDEX_FACTORY (feature);
141 * gst_index_factory_create:
142 * @factory: the factory used to create the instance
144 * Create a new #GstIndex instance from the
145 * given indexfactory.
147 * Returns: (transfer full): a new #GstIndex instance.
150 gst_index_factory_create (GstIndexFactory * factory)
152 GstIndexFactory *newfactory;
153 GstIndex *new = NULL;
155 g_return_val_if_fail (factory != NULL, NULL);
158 GST_INDEX_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
160 if (newfactory == NULL)
163 new = GST_INDEX (g_object_newv (newfactory->type, 0, NULL));
165 gst_object_unref (newfactory);
171 * gst_index_factory_make:
172 * @name: the name of the factory used to create the instance
174 * Create a new #GstIndex instance from the
175 * indexfactory with the given name.
177 * Returns: (transfer full): a new #GstIndex instance.
180 gst_index_factory_make (const gchar * name)
182 GstIndexFactory *factory;
185 g_return_val_if_fail (name != NULL, NULL);
187 factory = gst_index_factory_find (name);
192 index = gst_index_factory_create (factory);
197 gst_object_unref (factory);
203 GST_INFO ("no such index factory \"%s\"!", name);
208 GST_INFO_OBJECT (factory, "couldn't create instance!");
209 gst_object_unref (factory);