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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
|
|
|
|
static void gst_plugin_feature_init (GstPluginFeature * feature);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2002-07-08 19:07:30 +00:00
|
|
|
static GObjectClass *parent_class = NULL;
|
2004-03-13 15:27:01 +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
|
|
|
|
|
|
|
GType
|
|
|
|
gst_plugin_feature_get_type (void)
|
|
|
|
{
|
|
|
|
static GType plugin_feature_type = 0;
|
|
|
|
|
|
|
|
if (!plugin_feature_type) {
|
|
|
|
static const GTypeInfo plugin_feature_info = {
|
2002-05-08 20:40:48 +00:00
|
|
|
sizeof (GObjectClass),
|
2001-08-21 20:16:48 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_plugin_feature_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2002-05-08 20:40:48 +00:00
|
|
|
sizeof (GObject),
|
2004-04-09 19:05:03 +00:00
|
|
|
0,
|
2001-08-21 20:16:48 +00:00
|
|
|
(GInstanceInitFunc) gst_plugin_feature_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2001-08-21 20:16:48 +00:00
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
plugin_feature_type =
|
2004-03-15 19:27:17 +00:00
|
|
|
g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature",
|
|
|
|
&plugin_feature_info, G_TYPE_FLAG_ABSTRACT);
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
return plugin_feature_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2001-08-21 20:16:48 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
parent_class = g_type_class_ref (G_TYPE_OBJECT);
|
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
|
|
|
{
|
|
|
|
feature->manager = NULL;
|
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_ensure_loaded:
|
|
|
|
* @feature: the plugin feature to check
|
|
|
|
*
|
|
|
|
* Check if the plugin containing the feature is loaded,
|
|
|
|
* if not, the plugin will be loaded.
|
|
|
|
*
|
|
|
|
* Returns: a boolean indicating the feature is loaded.
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_ensure_loaded (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2003-01-27 21:37:13 +00:00
|
|
|
GstPlugin *plugin;
|
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);
|
|
|
|
|
|
|
|
plugin = (GstPlugin *) (feature->manager);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
if (plugin && !gst_plugin_is_loaded (plugin)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2002-05-08 20:40:48 +00:00
|
|
|
if (GST_IS_REGISTRY (plugin->manager)) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING,
|
2004-03-15 19:27:17 +00:00
|
|
|
"loading plugin %s for feature", plugin->desc.name);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager),
|
2004-03-15 19:27:17 +00:00
|
|
|
plugin) != GST_REGISTRY_OK)
|
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else
|
2003-02-10 20:32:32 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
2002-05-08 20:40:48 +00:00
|
|
|
return FALSE;
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
2001-10-21 18:00:31 +00:00
|
|
|
return TRUE;
|
2001-08-21 20:16:48 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 18:00:31 +00:00
|
|
|
/**
|
|
|
|
* gst_plugin_feature_unload_thyself:
|
|
|
|
* @feature: the plugin feature to check
|
|
|
|
*
|
|
|
|
* Unload the given feature. This will decrease the refcount
|
|
|
|
* in the plugin and will eventually unload the plugin
|
|
|
|
*/
|
2001-08-21 20:16:48 +00:00
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_unload_thyself (GstPluginFeature * feature)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPluginFeatureClass *oclass;
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
g_return_if_fail (feature != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-12-19 21:31:03 +00:00
|
|
|
oclass = GST_PLUGIN_FEATURE_GET_CLASS (feature);
|
2001-08-21 20:16:48 +00:00
|
|
|
|
|
|
|
if (oclass->unload_thyself)
|
|
|
|
oclass->unload_thyself (feature);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
|
* within all features of the same type. Renaming a plugin feature is not
|
2005-01-06 18:17:12 +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 {
|
|
|
|
feature->name = g_strdup (name);
|
|
|
|
}
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
2005-01-06 18:17:12 +00:00
|
|
|
* gst_plugin_feature_get_name:
|
2003-11-24 03:21:54 +00:00
|
|
|
* @feature: a feature
|
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Gets the name of a plugin feature.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Returns: the name
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
2005-01-06 18:17:12 +00:00
|
|
|
G_CONST_RETURN gchar *
|
|
|
|
gst_plugin_feature_get_name (GstPluginFeature * feature)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-01-06 18:17:12 +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-01-06 18:17:12 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_plugin_feature_get rank:
|
2003-11-24 03:21:54 +00:00
|
|
|
* @feature: a feature
|
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Gets the rank of a plugin feature.
|
2003-11-24 03:21:54 +00:00
|
|
|
*
|
2005-01-06 18:17:12 +00:00
|
|
|
* Returns: The rank of the feature
|
2003-11-24 03:21:54 +00:00
|
|
|
*/
|
2005-01-06 18:17:12 +00:00
|
|
|
guint
|
|
|
|
gst_plugin_feature_get_rank (GstPluginFeature * feature)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
return feature->rank;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|