Getting tired of debugging. Disabled all the unreffing of plugins and features,...
[platform/upstream/gstreamer.git] / gst / gstpluginfeature.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstpluginfeature.c: Abstract base class for all plugin features
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #include "gst_private.h"
24
25 #include "gstpluginfeature.h"
26 #include "gstplugin.h"
27 #include "gstregistry.h"
28 #include "gstinfo.h"
29
30 #include <string.h>
31
32 static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
33 static void gst_plugin_feature_init (GstPluginFeature * feature);
34
35 /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
36
37 G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, G_TYPE_OBJECT);
38
39 static void
40 gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
41 {
42
43 }
44
45 static void
46 gst_plugin_feature_init (GstPluginFeature * feature)
47 {
48
49 }
50
51 /**
52  * gst_plugin_feature_load:
53  * @feature: the plugin feature to check
54  *
55  * Check if the plugin containing the feature is loaded,
56  * if not, the plugin will be loaded.
57  *
58  * Returns: The new feature
59  */
60 GstPluginFeature *
61 gst_plugin_feature_load (GstPluginFeature * feature)
62 {
63   GstPlugin *plugin;
64   GstPluginFeature *real_feature;
65
66   g_return_val_if_fail (feature != NULL, FALSE);
67   g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
68
69   plugin = gst_plugin_load (feature->plugin);
70   if (!plugin) {
71     g_critical ("Failed to load plugin containing feature '%s'.",
72         GST_PLUGIN_FEATURE_NAME (feature));
73     return NULL;
74   }
75   if (plugin == feature->plugin) {
76     return feature;
77   }
78
79   real_feature = gst_plugin_find_feature_by_name (plugin, feature->name);
80
81   if (real_feature == NULL) {
82     g_critical
83         ("Loaded plugin containing feature '%s', but feature disappeared.",
84         feature->name);
85   }
86   //gst_object_unref (feature->plugin);
87   return real_feature;
88 }
89
90 gboolean
91 gst_plugin_feature_type_name_filter (GstPluginFeature * feature,
92     GstTypeNameData * data)
93 {
94   return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) &&
95       (data->name == NULL
96           || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature))));
97 }
98
99 /**
100  * gst_plugin_feature_set_name:
101  * @feature: a feature
102  * @name: the name to set
103  *
104  * Sets the name of a plugin feature. The name uniquely identifies a feature
105  * within all features of the same type. Renaming a plugin feature is not 
106  * allowed. A copy is made of the name so you should free the supplied @name
107  * after calling this function.
108  */
109 void
110 gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
111 {
112   g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
113   g_return_if_fail (name != NULL);
114
115   if (feature->name) {
116     g_return_if_fail (strcmp (feature->name, name) == 0);
117   } else {
118     feature->name = g_strdup (name);
119   }
120 }
121
122 /**
123  * gst_plugin_feature_get_name:
124  * @feature: a feature
125  *
126  * Gets the name of a plugin feature.
127  *
128  * Returns: the name
129  */
130 G_CONST_RETURN gchar *
131 gst_plugin_feature_get_name (GstPluginFeature * feature)
132 {
133   g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL);
134
135   return feature->name;
136 }
137
138 /**
139  * gst_plugin_feature_set_rank:
140  * @feature: feature to rank
141  * @rank: rank value - higher number means more priority rank
142  *
143  * Specifies a rank for a plugin feature, so that autoplugging uses
144  * the most appropriate feature.
145  */
146 void
147 gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank)
148 {
149   g_return_if_fail (feature != NULL);
150   g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
151
152   feature->rank = rank;
153 }
154
155 /**
156  * gst_plugin_feature_get rank:
157  * @feature: a feature
158  *
159  * Gets the rank of a plugin feature.
160  *
161  * Returns: The rank of the feature
162  */
163 guint
164 gst_plugin_feature_get_rank (GstPluginFeature * feature)
165 {
166   g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE);
167
168   return feature->rank;
169 }
170
171 void
172 gst_plugin_feature_list_free (GList * list)
173 {
174 #if 0
175   GList *g;
176
177   for (g = list; g; g = g->next) {
178     GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
179
180     //gst_object_unref (feature->plugin);
181   }
182 #endif
183   g_list_free (list);
184 }