2001-08-21 20:16:48 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstpluginfeature.c: Abstract base class for all plugin features
|
|
|
|
*
|
|
|
|
* 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-10-15 16:01:57 +00:00
|
|
|
|
more docs inlined, splitted gstindex.{c,h}
Original commit message from CVS:
* 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 20:40:00 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
#include "gst_private.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2001-08-21 20:16:48 +00:00
|
|
|
#include "gstpluginfeature.h"
|
|
|
|
#include "gstplugin.h"
|
2002-05-08 20:40:48 +00:00
|
|
|
#include "gstregistry.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2005-10-06 09:49:42 +00:00
|
|
|
#define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
|
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
static void gst_plugin_feature_finalize (GObject * object);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
|
2005-10-15 19:57:03 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2006-04-08 20:57:31 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
G_OBJECT_CLASS (klass)->finalize =
|
2005-09-18 21:24:55 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_plugin_feature_finalize);
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_init (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2007-06-27 10:12:14 +00:00
|
|
|
/* do nothing, needed because of G_DEFINE_TYPE */
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
static void
|
2005-09-18 21:24:55 +00:00
|
|
|
gst_plugin_feature_finalize (GObject * object)
|
2005-09-18 06:59:25 +00:00
|
|
|
{
|
gst/: Use _CAST macros to avoid unneeded type checking.
Original commit message from CVS:
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
2006-06-12 09:17:44 +00:00
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (object);
|
2005-09-18 21:24:55 +00:00
|
|
|
|
2005-12-12 18:12:13 +00:00
|
|
|
GST_DEBUG ("finalizing feature %p: '%s'", feature,
|
|
|
|
GST_PLUGIN_FEATURE_NAME (feature));
|
2007-07-31 10:10:27 +00:00
|
|
|
g_free (feature->name);
|
2005-09-18 21:24:55 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2005-09-18 06:59:25 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
2005-09-15 00:13:26 +00:00
|
|
|
* gst_plugin_feature_load:
|
2001-10-21 18:00:31 +00:00
|
|
|
* @feature: the plugin feature to check
|
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* Loads the plugin containing @feature if it's not already loaded. @feature is
|
|
|
|
* unaffected; use the return value instead.
|
2001-10-21 18:00:31 +00:00
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* Normally this function is used like this:
|
2009-02-15 14:37:17 +00:00
|
|
|
* |[
|
2005-09-22 12:05:05 +00:00
|
|
|
* GstPluginFeature *loaded_feature;
|
2009-02-15 14:37:17 +00:00
|
|
|
*
|
2005-09-22 12:05:05 +00:00
|
|
|
* loaded_feature = gst_plugin_feature_load (feature);
|
|
|
|
* // presumably, we're no longer interested in the potentially-unloaded feature
|
|
|
|
* gst_object_unref (feature);
|
|
|
|
* feature = loaded_feature;
|
2009-02-15 14:37:17 +00:00
|
|
|
* ]|
|
2005-09-22 12:05:05 +00:00
|
|
|
*
|
|
|
|
* Returns: A reference to the loaded feature, or NULL on error.
|
2001-10-21 18:00:31 +00:00
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
GstPluginFeature *
|
|
|
|
gst_plugin_feature_load (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2003-01-27 21:37:13 +00:00
|
|
|
GstPlugin *plugin;
|
2005-09-15 00:13:26 +00:00
|
|
|
GstPluginFeature *real_feature;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-27 21:37:13 +00:00
|
|
|
g_return_val_if_fail (feature != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
|
2005-12-12 18:12:13 +00:00
|
|
|
GST_DEBUG ("loading plugin for feature %p; '%s'", feature,
|
|
|
|
GST_PLUGIN_FEATURE_NAME (feature));
|
2005-09-18 06:59:25 +00:00
|
|
|
if (feature->loaded)
|
2006-12-07 12:11:14 +00:00
|
|
|
return gst_object_ref (feature);
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG ("loading plugin %s", feature->plugin_name);
|
2005-09-18 06:59:25 +00:00
|
|
|
plugin = gst_plugin_load_by_name (feature->plugin_name);
|
2006-04-11 11:47:39 +00:00
|
|
|
if (!plugin)
|
|
|
|
goto load_failed;
|
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG ("loaded plugin %s", feature->plugin_name);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (plugin);
|
2005-01-09 01:35:01 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
real_feature =
|
|
|
|
gst_registry_lookup_feature (gst_registry_get_default (), feature->name);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2006-04-11 11:47:39 +00:00
|
|
|
if (real_feature == NULL)
|
|
|
|
goto disappeared;
|
|
|
|
else if (!real_feature->loaded)
|
|
|
|
goto not_found;
|
|
|
|
|
|
|
|
return real_feature;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
load_failed:
|
|
|
|
{
|
|
|
|
GST_WARNING ("Failed to load plugin containing feature '%s'.",
|
|
|
|
GST_PLUGIN_FEATURE_NAME (feature));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
disappeared:
|
|
|
|
{
|
2005-10-04 11:10:04 +00:00
|
|
|
GST_INFO
|
2005-09-15 00:13:26 +00:00
|
|
|
("Loaded plugin containing feature '%s', but feature disappeared.",
|
|
|
|
feature->name);
|
2006-04-11 11:47:39 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
not_found:
|
|
|
|
{
|
2005-10-04 11:10:04 +00:00
|
|
|
GST_INFO ("Tried to load plugin containing feature '%s', but feature was "
|
|
|
|
"not found.", real_feature->name);
|
|
|
|
return NULL;
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
2005-11-21 14:50:22 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_type_name_filter:
|
|
|
|
* @feature: the #GstPluginFeature
|
|
|
|
* @data: the type and name to check against
|
|
|
|
*
|
|
|
|
* Compares type and name of plugin feature. Can be used with gst_filter_run().
|
|
|
|
*
|
|
|
|
* Returns: TRUE if equal.
|
|
|
|
*/
|
2003-04-14 18:53:03 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
|
|
|
|
GstTypeNameData * data)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
2009-08-20 10:54:40 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
|
|
|
|
(data->name == NULL
|
2004-03-15 19:27:17 +00:00
|
|
|
|| !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
|
2003-04-14 18:53:03 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-28 20:25:30 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_plugin_feature_set_name:
|
2003-10-28 20:25:30 +00:00
|
|
|
* @feature: a feature
|
|
|
|
* @name: the name to set
|
|
|
|
*
|
|
|
|
* Sets the name of a plugin feature. The name uniquely identifies a feature
|
2005-10-15 15:30:24 +00:00
|
|
|
* within all features of the same type. Renaming a plugin feature is not
|
2005-03-07 18:27:42 +00:00
|
|
|
* allowed. A copy is made of the name so you should free the supplied @name
|
|
|
|
* after calling this function.
|
2003-10-28 20:25:30 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
|
2003-10-28 20:25:30 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
|
|
|
if (feature->name) {
|
|
|
|
g_return_if_fail (strcmp (feature->name, name) == 0);
|
|
|
|
} else {
|
2007-07-31 10:10:27 +00:00
|
|
|
feature->name = g_strdup (name);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
2009-05-02 12:43:11 +00:00
|
|
|
gst_object_set_name (GST_OBJECT_CAST (feature), feature->name);
|
2003-10-28 20:25:30 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
2005-03-07 18:27:42 +00:00
|
|
|
* gst_plugin_feature_get_name:
|
2003-11-24 03:21:54 +00:00
|
|
|
* @feature: a feature
|
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Gets the name of a plugin feature.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Returns: the name
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
2005-03-07 18:27:42 +00:00
|
|
|
G_CONST_RETURN gchar *
|
|
|
|
gst_plugin_feature_get_name (GstPluginFeature * feature)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
return feature->name;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
2005-03-07 18:27:42 +00:00
|
|
|
* gst_plugin_feature_set_rank:
|
|
|
|
* @feature: feature to rank
|
|
|
|
* @rank: rank value - higher number means more priority rank
|
|
|
|
*
|
|
|
|
* Specifies a rank for a plugin feature, so that autoplugging uses
|
|
|
|
* the most appropriate feature.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
|
|
|
|
{
|
|
|
|
g_return_if_fail (feature != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
|
|
|
|
|
|
|
|
feature->rank = rank;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-10-14 11:09:29 +00:00
|
|
|
* gst_plugin_feature_get_rank:
|
2003-11-24 03:21:54 +00:00
|
|
|
* @feature: a feature
|
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Gets the rank of a plugin feature.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2005-03-07 18:27:42 +00:00
|
|
|
* Returns: The rank of the feature
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
2005-03-07 18:27:42 +00:00
|
|
|
guint
|
|
|
|
gst_plugin_feature_get_rank (GstPluginFeature * feature)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
2005-03-07 18:27:42 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-07 18:27:42 +00:00
|
|
|
return feature->rank;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
2005-09-15 20:56:30 +00:00
|
|
|
|
2005-09-22 12:05:05 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_list_free:
|
|
|
|
* @list: list of #GstPluginFeature
|
|
|
|
*
|
|
|
|
* Unrefs each member of @list, then frees the list.
|
|
|
|
*/
|
2005-09-15 20:56:30 +00:00
|
|
|
void
|
|
|
|
gst_plugin_feature_list_free (GList * list)
|
|
|
|
{
|
|
|
|
GList *g;
|
|
|
|
|
|
|
|
for (g = list; g; g = g->next) {
|
gst/: Use _CAST macros to avoid unneeded type checking.
Original commit message from CVS:
* gst/gst.c: (gst_debug_help):
* gst/gstplugin.c: (gst_plugin_finalize), (gst_plugin_list_free):
* gst/gstpluginfeature.c: (gst_plugin_feature_finalize),
(gst_plugin_feature_list_free):
* gst/gstregistry.c: (gst_registry_add_plugin),
(gst_registry_add_feature), (gst_registry_plugin_filter),
(gst_registry_feature_filter), (gst_registry_find_plugin),
(gst_registry_find_feature), (gst_registry_get_plugin_list),
(gst_registry_lookup_feature_locked), (gst_registry_lookup_locked):
* gst/gstregistryxml.c: (load_feature),
(gst_registry_xml_read_cache), (gst_registry_xml_write_cache):
* gst/gstminiobject.c: (gst_mini_object_unref),
(gst_mini_object_replace), (gst_value_mini_object_free),
(gst_value_mini_object_copy):
Use _CAST macros to avoid unneeded type checking.
Added some more G_UNLIKELY.
2006-06-12 09:17:44 +00:00
|
|
|
GstPluginFeature *feature = GST_PLUGIN_FEATURE_CAST (g->data);
|
2005-09-15 20:56:30 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (feature);
|
2005-09-15 20:56:30 +00:00
|
|
|
}
|
|
|
|
g_list_free (list);
|
|
|
|
}
|
2005-10-14 11:09:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_feature_check_version:
|
|
|
|
* @feature: a feature
|
|
|
|
* @min_major: minimum required major version
|
|
|
|
* @min_minor: minimum required minor version
|
|
|
|
* @min_micro: minimum required micro version
|
|
|
|
*
|
|
|
|
* Checks whether the given plugin feature is at least
|
|
|
|
* the required version
|
|
|
|
*
|
|
|
|
* Returns: #TRUE if the plugin feature has at least
|
|
|
|
* the required version, otherwise #FALSE.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_plugin_feature_check_version (GstPluginFeature * feature,
|
|
|
|
guint min_major, guint min_minor, guint min_micro)
|
|
|
|
{
|
|
|
|
GstRegistry *registry;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (feature != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG ("Looking up plugin '%s' containing plugin feature '%s'",
|
|
|
|
feature->plugin_name, feature->name);
|
|
|
|
|
|
|
|
registry = gst_registry_get_default ();
|
|
|
|
plugin = gst_registry_find_plugin (registry, feature->plugin_name);
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
const gchar *ver_str;
|
|
|
|
guint major, minor, micro;
|
|
|
|
|
|
|
|
ver_str = gst_plugin_get_version (plugin);
|
|
|
|
g_return_val_if_fail (ver_str != NULL, FALSE);
|
|
|
|
|
|
|
|
if (sscanf (ver_str, "%u.%u.%u", &major, &minor, µ) == 3) {
|
|
|
|
if (major > min_major)
|
|
|
|
ret = TRUE;
|
|
|
|
else if (major < min_major)
|
|
|
|
ret = FALSE;
|
|
|
|
else if (minor > min_minor)
|
|
|
|
ret = TRUE;
|
|
|
|
else if (minor < min_minor)
|
|
|
|
ret = FALSE;
|
|
|
|
else if (micro > min_micro)
|
|
|
|
ret = TRUE;
|
|
|
|
else
|
|
|
|
ret = (micro == min_micro);
|
|
|
|
|
|
|
|
GST_DEBUG ("Checking whether %u.%u.%u >= %u.%u.%u? %s", major, minor,
|
|
|
|
micro, min_major, min_minor, min_micro, (ret) ? "yes" : "no");
|
|
|
|
} else {
|
|
|
|
GST_WARNING ("Could not parse version string '%s' of plugin '%s'",
|
|
|
|
ver_str, feature->plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_object_unref (plugin);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Could not find plugin '%s'", feature->plugin_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|