2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstpluginfeature.c: Abstract base class for all plugin features
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.
23 #include "gst_private.h"
25 #include "gstpluginfeature.h"
26 #include "gstplugin.h"
27 #include "gstregistry.h"
32 static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
33 static void gst_plugin_feature_init (GstPluginFeature * feature);
34 static void gst_plugin_feature_finalize (GObject * object);
36 /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
38 G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
39 GstObjectClass *parent_class = NULL;
42 gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
44 parent_class = g_type_class_ref (GST_TYPE_OBJECT);
46 G_OBJECT_CLASS (klass)->finalize =
47 GST_DEBUG_FUNCPTR (gst_plugin_feature_finalize);
51 gst_plugin_feature_init (GstPluginFeature * feature)
57 gst_plugin_feature_finalize (GObject * object)
59 GstPluginFeature *feature = GST_PLUGIN_FEATURE (object);
61 GST_DEBUG ("finalizing feature %p", feature);
62 g_free (feature->name);
63 g_free (feature->plugin_name);
65 G_OBJECT_CLASS (parent_class)->finalize (object);
69 * gst_plugin_feature_load:
70 * @feature: the plugin feature to check
72 * Check if the plugin containing the feature is loaded,
73 * if not, the plugin will be loaded.
75 * Returns: The new feature
78 gst_plugin_feature_load (GstPluginFeature * feature)
81 GstPluginFeature *real_feature;
83 g_return_val_if_fail (feature != NULL, FALSE);
84 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
89 plugin = gst_plugin_load_by_name (feature->plugin_name);
91 g_critical ("Failed to load plugin containing feature '%s'.",
92 GST_PLUGIN_FEATURE_NAME (feature));
95 gst_object_unref (plugin);
98 gst_registry_lookup_feature (gst_registry_get_default (), feature->name);
100 if (real_feature == NULL) {
102 ("Loaded plugin containing feature '%s', but feature disappeared.",
105 gst_object_unref (feature);
111 gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
112 GstTypeNameData * data)
114 return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
116 || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
120 * gst_plugin_feature_set_name:
121 * @feature: a feature
122 * @name: the name to set
124 * Sets the name of a plugin feature. The name uniquely identifies a feature
125 * within all features of the same type. Renaming a plugin feature is not
126 * allowed. A copy is made of the name so you should free the supplied @name
127 * after calling this function.
130 gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
132 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
133 g_return_if_fail (name != NULL);
136 g_return_if_fail (strcmp (feature->name, name) == 0);
138 feature->name = g_strdup (name);
140 gst_object_set_name (GST_OBJECT (feature), feature->name);
144 * gst_plugin_feature_get_name:
145 * @feature: a feature
147 * Gets the name of a plugin feature.
151 G_CONST_RETURN gchar *
152 gst_plugin_feature_get_name (GstPluginFeature * feature)
154 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
156 return feature->name;
160 * gst_plugin_feature_set_rank:
161 * @feature: feature to rank
162 * @rank: rank value - higher number means more priority rank
164 * Specifies a rank for a plugin feature, so that autoplugging uses
165 * the most appropriate feature.
168 gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
170 g_return_if_fail (feature != NULL);
171 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
173 feature->rank = rank;
177 * gst_plugin_feature_get rank:
178 * @feature: a feature
180 * Gets the rank of a plugin feature.
182 * Returns: The rank of the feature
185 gst_plugin_feature_get_rank (GstPluginFeature * feature)
187 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
189 return feature->rank;
193 gst_plugin_feature_list_free (GList * list)
197 for (g = list; g; g = g->next) {
198 GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
200 gst_object_unref (feature);