mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
77a5695718
Original commit message from CVS: * gst/gstbuffer.c: (gst_subbuffer_class_init): * gst/gstclock.c: (gst_clock_class_init): * gst/gstelement.c: (gst_element_class_init): * gst/gstindex.c: (gst_index_class_init): * gst/gstindexfactory.c: (gst_index_factory_class_init): * gst/gstobject.c: (gst_object_class_init), (gst_signal_object_class_init): * gst/gstpad.c: (gst_pad_class_init): * gst/gstpadtemplate.c: (gst_pad_template_class_init): * gst/gstpluginfeature.c: (gst_plugin_feature_class_init): * gst/gstregistry.c: (gst_registry_class_init): * gst/gstsystemclock.c: (gst_system_clock_class_init): * gst/gsttask.c: (gst_task_class_init): * gst/gstxml.c: (gst_xml_class_init): * libs/gst/base/gstbasesink.c: (gst_base_sink_class_init): * libs/gst/base/gstbasesrc.c: (gst_base_src_class_init), (gst_base_src_loop): * libs/gst/controller/gstcontroller.c: (_gst_controller_class_init): * plugins/elements/gstfdsrc.c: (gst_fd_src_class_init): * plugins/indexers/gstfileindex.c: (gst_file_index_class_init): * plugins/indexers/gstmemindex.c: (gst_mem_index_class_init): * tests/old/examples/plugins/example.c: (gst_example_class_init): * tests/old/testsuite/threads/signals.c: (gst_test_class_init): Fix #337365 (g_type_class_ref <-> g_type_class_peek_parent)
223 lines
5.5 KiB
C
223 lines
5.5 KiB
C
/* GStreamer
|
|
* Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/)
|
|
* Written by Erik Walthinsen <omega@ridgerun.com>
|
|
*
|
|
* 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 (G_UNLIKELY (indexfactory_type == 0)) {
|
|
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_peek_parent (klass);
|
|
|
|
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)
|
|
{
|
|
GstIndexFactory *newfactory;
|
|
GstIndex *new = NULL;
|
|
|
|
g_return_val_if_fail (factory != NULL, NULL);
|
|
|
|
newfactory =
|
|
GST_INDEX_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
|
|
(factory)));
|
|
if (newfactory == NULL)
|
|
return NULL;
|
|
|
|
new = GST_INDEX (g_object_new (newfactory->type, NULL));
|
|
|
|
gst_object_unref (newfactory);
|
|
|
|
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);
|
|
}
|