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 (GstPluginFeature * feature);
36 /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
38 G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
41 gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
44 G_OBJECT_CLASS (klass)->finalize =
45 (GObjectFinalizeFunc) gst_plugin_feature_finalize;
49 gst_plugin_feature_init (GstPluginFeature * feature)
55 gst_plugin_feature_finalize (GstPluginFeature * feature)
57 GST_DEBUG ("finalizing feature %p", feature);
61 * gst_plugin_feature_load:
62 * @feature: the plugin feature to check
64 * Check if the plugin containing the feature is loaded,
65 * if not, the plugin will be loaded.
67 * Returns: The new feature
70 gst_plugin_feature_load (GstPluginFeature * feature)
73 GstPluginFeature *real_feature;
75 g_return_val_if_fail (feature != NULL, FALSE);
76 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
81 plugin = gst_plugin_load_by_name (feature->plugin_name);
83 g_critical ("Failed to load plugin containing feature '%s'.",
84 GST_PLUGIN_FEATURE_NAME (feature));
87 gst_object_unref (plugin);
90 gst_registry_lookup_feature (gst_registry_get_default (), feature->name);
92 if (real_feature == NULL) {
94 ("Loaded plugin containing feature '%s', but feature disappeared.",
97 gst_object_unref (feature);
103 gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
104 GstTypeNameData * data)
106 return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
108 || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
112 * gst_plugin_feature_set_name:
113 * @feature: a feature
114 * @name: the name to set
116 * Sets the name of a plugin feature. The name uniquely identifies a feature
117 * within all features of the same type. Renaming a plugin feature is not
118 * allowed. A copy is made of the name so you should free the supplied @name
119 * after calling this function.
122 gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
124 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
125 g_return_if_fail (name != NULL);
128 g_return_if_fail (strcmp (feature->name, name) == 0);
130 feature->name = g_strdup (name);
132 gst_object_set_name (GST_OBJECT (feature), feature->name);
136 * gst_plugin_feature_get_name:
137 * @feature: a feature
139 * Gets the name of a plugin feature.
143 G_CONST_RETURN gchar *
144 gst_plugin_feature_get_name (GstPluginFeature * feature)
146 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
148 return feature->name;
152 * gst_plugin_feature_set_rank:
153 * @feature: feature to rank
154 * @rank: rank value - higher number means more priority rank
156 * Specifies a rank for a plugin feature, so that autoplugging uses
157 * the most appropriate feature.
160 gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
162 g_return_if_fail (feature != NULL);
163 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
165 feature->rank = rank;
169 * gst_plugin_feature_get rank:
170 * @feature: a feature
172 * Gets the rank of a plugin feature.
174 * Returns: The rank of the feature
177 gst_plugin_feature_get_rank (GstPluginFeature * feature)
179 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
181 return feature->rank;
185 gst_plugin_feature_list_free (GList * list)
189 for (g = list; g; g = g->next) {
190 GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
192 gst_object_unref (feature);