A bunch of portability fixes, derived from Steve Lhomme's MSVC
[platform/upstream/gstreamer.git] / gst / gstplugin.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstplugin.c: Plugin subsystem for loading elements, types, and libs
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 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #ifdef HAVE_DIRENT_H
29 #include <dirent.h>
30 #endif
31 #ifdef HAVE_UNISTD_H
32 #include <unistd.h>
33 #endif
34 #include <signal.h>
35
36 #include "gst_private.h"
37
38 #include "gstplugin.h"
39 #include "gstversion.h"
40 #include "gstregistrypool.h"
41 #include "gstinfo.h"
42 #include "gstfilter.h"
43
44
45 #define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
46
47 static GModule *main_module = NULL;
48 static GList *_gst_plugin_static = NULL;
49
50 /* static variables for segfault handling of plugin loading */
51 static char *_gst_plugin_fault_handler_filename = NULL;
52 extern gboolean *_gst_disable_segtrap;  /* see gst.c */
53
54 #ifndef HAVE_WIN32
55 static gboolean *_gst_plugin_fault_handler_is_setup = FALSE;
56 #endif
57
58 /* list of valid licenses.
59  * One of these must be specified or the plugin won't be loaded 
60  * Contact gstreamer-devel@lists.sourceforge.net if your license should be 
61  * added.
62  *
63  * GPL: http://www.gnu.org/copyleft/gpl.html
64  * LGPL: http://www.gnu.org/copyleft/lesser.html
65  * QPL: http://www.trolltech.com/licenses/qpl.html
66  */
67 static gchar *valid_licenses[] = {
68   "LGPL",                       /* GNU Lesser General Public License */
69   "GPL",                        /* GNU General Public License */
70   "QPL",                        /* Trolltech Qt Public License */
71   "GPL/QPL",                    /* Combi-license of GPL + QPL */
72   GST_LICENSE_UNKNOWN,          /* some other license */
73   NULL
74 };
75
76 static void gst_plugin_desc_copy (GstPluginDesc * dest,
77     const GstPluginDesc * src);
78
79 static GstPlugin *gst_plugin_register_func (GstPlugin * plugin,
80     GModule * module, GstPluginDesc * desc);
81
82 static GstPlugin *
83 gst_plugin_copy (GstPlugin * plugin)
84 {
85   return g_memdup (plugin, sizeof (*plugin));
86 }
87
88 GType
89 gst_plugin_get_type (void)
90 {
91   static GType plugin_type;
92
93   if (plugin_type == 0) {
94     plugin_type = g_boxed_type_register_static ("GstPlugin",
95         (GBoxedCopyFunc) gst_plugin_copy, g_free);
96   }
97
98   return plugin_type;
99 }
100
101 GQuark
102 gst_plugin_error_quark (void)
103 {
104   static GQuark quark = 0;
105
106   if (!quark)
107     quark = g_quark_from_static_string ("gst_plugin_error");
108   return quark;
109 }
110
111 /* this function can be called in the GCC constructor extension, before
112  * the _gst_plugin_initialize() was called. In that case, we store the 
113  * plugin description in a list to initialize it when we open the main
114  * module later on.
115  * When the main module is known, we can register the plugin right away.
116  * */
117 void
118 _gst_plugin_register_static (GstPluginDesc * desc)
119 {
120   if (main_module == NULL) {
121     if (GST_CAT_DEFAULT)
122       GST_LOG ("queueing static plugin \"%s\" for loading later on",
123           desc->name);
124     _gst_plugin_static = g_list_prepend (_gst_plugin_static, desc);
125   } else {
126     GstPlugin *plugin;
127
128     if (GST_CAT_DEFAULT)
129       GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name);
130     plugin = g_new0 (GstPlugin, 1);
131     if (gst_plugin_register_func (plugin, main_module, desc)) {
132       if (GST_CAT_DEFAULT)
133         GST_INFO ("loaded static plugin \"%s\"", desc->name);
134       gst_registry_pool_add_plugin (plugin);
135     }
136   }
137 }
138
139 void
140 _gst_plugin_initialize (void)
141 {
142   main_module = g_module_open (NULL, G_MODULE_BIND_LAZY);
143
144   /* now register all static plugins */
145   g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static,
146       NULL);
147 }
148
149 /* this function could be extended to check if the plugin license matches the 
150  * applications license (would require the app to register its license somehow).
151  * We'll wait for someone who's interested in it to code it :)
152  */
153 static gboolean
154 gst_plugin_check_license (const gchar * license)
155 {
156   gchar **check_license = valid_licenses;
157
158   g_assert (check_license);
159
160   while (*check_license) {
161     if (strcmp (license, *check_license) == 0)
162       return TRUE;
163     check_license++;
164   }
165   return FALSE;
166 }
167
168 static gboolean
169 gst_plugin_check_version (gint major, gint minor)
170 {
171   /* return NULL if the major and minor version numbers are not compatible */
172   /* with ours. */
173   if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR)
174     return FALSE;
175
176   return TRUE;
177 }
178
179 static GstPlugin *
180 gst_plugin_register_func (GstPlugin * plugin, GModule * module,
181     GstPluginDesc * desc)
182 {
183   g_assert (plugin->module == NULL);
184
185   if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
186     if (GST_CAT_DEFAULT)
187       GST_INFO ("plugin \"%s\" has incompatible version, not loading",
188           plugin->filename);
189     return FALSE;
190   }
191
192   if (!desc->license || !desc->description || !desc->package || !desc->origin) {
193     if (GST_CAT_DEFAULT)
194       GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading",
195           plugin->filename);
196     return FALSE;
197   }
198
199   if (!gst_plugin_check_license (desc->license)) {
200     if (GST_CAT_DEFAULT)
201       GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading",
202           plugin->filename, desc->license);
203     return FALSE;
204   }
205
206   gst_plugin_desc_copy (&plugin->desc, desc);
207   plugin->module = module;
208
209   if (!((desc->plugin_init) (plugin))) {
210     if (GST_CAT_DEFAULT)
211       GST_INFO ("plugin \"%s\" failed to initialise", plugin->filename);
212     plugin->module = NULL;
213     return FALSE;
214   }
215
216   if (GST_CAT_DEFAULT)
217     GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename));
218
219   return plugin;
220 }
221
222 #ifndef HAVE_WIN32
223 /*
224  * _gst_plugin_fault_handler_restore:
225  * segfault handler restorer
226  */
227 static void
228 _gst_plugin_fault_handler_restore (void)
229 {
230   struct sigaction action;
231
232   memset (&action, 0, sizeof (action));
233   action.sa_handler = SIG_DFL;
234
235   sigaction (SIGSEGV, &action, NULL);
236 }
237
238 /*
239  * _gst_plugin_fault_handler_sighandler:
240  * segfault handler implementation
241  */
242 static void
243 _gst_plugin_fault_handler_sighandler (int signum)
244 {
245   /* We need to restore the fault handler or we'll keep getting it */
246   _gst_plugin_fault_handler_restore ();
247
248   switch (signum) {
249     case SIGSEGV:
250       g_print ("\nERROR: ");
251       g_print ("Caught a segmentation fault while loading plugin file:\n");
252       g_print ("%s\n\n", _gst_plugin_fault_handler_filename);
253       g_print ("Please either:\n");
254       g_print ("- remove it and restart.\n");
255       g_print ("- run with --gst-disable-segtrap and debug.\n");
256       exit (-1);
257       break;
258     default:
259       g_print ("Caught unhandled signal on plugin loading\n");
260       break;
261   }
262 }
263
264 /*
265  * _gst_plugin_fault_handler_setup:
266  * sets up the segfault handler
267  */
268 static void
269 _gst_plugin_fault_handler_setup (void)
270 {
271   struct sigaction action;
272
273   /* if asked to leave segfaults alone, just return */
274   if (_gst_disable_segtrap)
275     return;
276
277   if (_gst_plugin_fault_handler_is_setup)
278     return;
279
280   memset (&action, 0, sizeof (action));
281   action.sa_handler = _gst_plugin_fault_handler_sighandler;
282
283   sigaction (SIGSEGV, &action, NULL);
284 }
285 #else
286 static void
287 _gst_plugin_fault_handler_restore (void)
288 {
289 }
290
291 static void
292 _gst_plugin_fault_handler_setup (void)
293 {
294 }
295 #endif
296
297 static void _gst_plugin_fault_handler_setup ();
298
299 /**
300  * gst_plugin_load_file:
301  * @filename: the plugin filename to load
302  * @error: pointer to a NULL-valued GError
303  *
304  * Loads the given plugin.
305  *
306  * Returns: a new GstPlugin or NULL, if an error occurred.
307  */
308 GstPlugin *
309 gst_plugin_load_file (const gchar * filename, GError ** error)
310 {
311   GstPlugin *plugin;
312   GModule *module;
313   GstPluginDesc *desc;
314   struct stat file_status;
315   gboolean free_plugin;
316
317   g_return_val_if_fail (filename != NULL, NULL);
318
319   GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"",
320       filename);
321
322   if (g_module_supported () == FALSE) {
323     g_set_error (error,
324         GST_PLUGIN_ERROR,
325         GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported");
326     return NULL;
327   }
328
329   if (stat (filename, &file_status)) {
330     g_set_error (error,
331         GST_PLUGIN_ERROR,
332         GST_PLUGIN_ERROR_MODULE, "Problem opening file %s\n", filename);
333     return NULL;
334   }
335
336   module = g_module_open (filename, G_MODULE_BIND_LAZY);
337
338   if (module != NULL) {
339     gpointer ptr;
340
341     if (g_module_symbol (module, "gst_plugin_desc", &ptr)) {
342       desc = (GstPluginDesc *) ptr;
343
344       plugin = gst_registry_pool_find_plugin (desc->name);
345       if (!plugin) {
346         free_plugin = TRUE;
347         plugin = g_new0 (GstPlugin, 1);
348         plugin->filename = g_strdup (filename);
349         GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin,
350             filename);
351       } else {
352         free_plugin = FALSE;
353         if (gst_plugin_is_loaded (plugin)) {
354           if (plugin->filename && strcmp (plugin->filename, filename) != 0) {
355             GST_WARNING
356                 ("plugin %p from file \"%s\" with same name %s is already "
357                 "loaded, aborting loading of \"%s\"", plugin, plugin->filename,
358                 plugin->desc.name, filename);
359             g_set_error (error, GST_PLUGIN_ERROR,
360                 GST_PLUGIN_ERROR_NAME_MISMATCH,
361                 "already a plugin with name \"%s\" loaded", desc->name);
362             if (free_plugin)
363               g_free (plugin);
364             return NULL;
365           }
366           GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now",
367               plugin, filename);
368           return plugin;
369         }
370       }
371       GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...",
372           plugin, filename);
373
374       if (g_module_symbol (module, "plugin_init", &ptr)) {
375         g_print
376             ("plugin %p from file \"%s\" exports a symbol named plugin_init\n",
377             plugin, plugin->filename);
378         g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_NAME_MISMATCH,
379             "plugin \"%s\" exports a symbol named plugin_init", desc->name);
380       }
381
382       /* this is where we load the actual .so, so let's trap SIGSEGV */
383       _gst_plugin_fault_handler_setup ();
384       _gst_plugin_fault_handler_filename = plugin->filename;
385
386       if (gst_plugin_register_func (plugin, module, desc)) {
387         /* remove signal handler */
388         _gst_plugin_fault_handler_restore ();
389         _gst_plugin_fault_handler_filename = NULL;
390         GST_INFO ("plugin \"%s\" loaded", plugin->filename);
391         return plugin;
392       } else {
393         /* remove signal handler */
394         _gst_plugin_fault_handler_restore ();
395         GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"",
396             filename);
397         /* plugin == NULL */
398         g_set_error (error,
399             GST_PLUGIN_ERROR,
400             GST_PLUGIN_ERROR_MODULE,
401             "gst_plugin_register_func failed for plugin \"%s\"", filename);
402         if (free_plugin)
403           g_free (plugin);
404         return NULL;
405       }
406     } else {
407       GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
408       g_set_error (error,
409           GST_PLUGIN_ERROR,
410           GST_PLUGIN_ERROR_MODULE,
411           "Could not find plugin entry point in \"%s\"", filename);
412     }
413     return NULL;
414   } else {
415     GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename,
416         g_module_error ());
417     g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE,
418         "Error loading plugin %s, reason: %s\n", filename, g_module_error ());
419     return NULL;
420   }
421 }
422
423 static void
424 gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src)
425 {
426   dest->major_version = src->major_version;
427   dest->minor_version = src->minor_version;
428   g_free (dest->name);
429   dest->name = g_strdup (src->name);
430   g_free (dest->description);
431   dest->description = g_strdup (src->description);
432   dest->plugin_init = src->plugin_init;
433   dest->plugin_exit = src->plugin_exit;
434   g_free (dest->version);
435   dest->version = g_strdup (src->version);
436   g_free (dest->license);
437   dest->license = g_strdup (src->license);
438   g_free (dest->package);
439   dest->package = g_strdup (src->package);
440   g_free (dest->origin);
441   dest->origin = g_strdup (src->origin);
442 }
443
444 #if 0
445 /* unused */
446 static void
447 gst_plugin_desc_free (GstPluginDesc * desc)
448 {
449   g_free (desc->name);
450   g_free (desc->description);
451   g_free (desc->version);
452   g_free (desc->license);
453   g_free (desc->package);
454   g_free (desc->origin);
455
456   memset (desc, 0, sizeof (GstPluginDesc));
457 }
458 #endif
459 /**
460  * gst_plugin_unload_plugin:
461  * @plugin: The plugin to unload
462  *
463  * Unload the given plugin.
464  *
465  * Returns: whether or not the plugin unloaded
466  */
467 gboolean
468 gst_plugin_unload_plugin (GstPlugin * plugin)
469 {
470   g_return_val_if_fail (plugin != NULL, FALSE);
471
472   if (!plugin->module)
473     return TRUE;
474
475   if (g_module_close (plugin->module)) {
476     plugin->module = NULL;
477     GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded",
478         plugin->filename);
479     return TRUE;
480   } else {
481     GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"",
482         plugin->filename);
483     return FALSE;
484   }
485 }
486
487 /**
488  * gst_plugin_get_name:
489  * @plugin: plugin to get the name of
490  *
491  * Get the short name of the plugin
492  *
493  * Returns: the name of the plugin
494  */
495 const gchar *
496 gst_plugin_get_name (GstPlugin * plugin)
497 {
498   g_return_val_if_fail (plugin != NULL, NULL);
499
500   return plugin->desc.name;
501 }
502
503 /**
504  * gst_plugin_get_description:
505  * @plugin: plugin to get long name of
506  *
507  * Get the long descriptive name of the plugin
508  *
509  * Returns: the long name of the plugin
510  */
511 G_CONST_RETURN gchar *
512 gst_plugin_get_description (GstPlugin * plugin)
513 {
514   g_return_val_if_fail (plugin != NULL, NULL);
515
516   return plugin->desc.description;
517 }
518
519 /**
520  * gst_plugin_get_filename:
521  * @plugin: plugin to get the filename of
522  *
523  * get the filename of the plugin
524  *
525  * Returns: the filename of the plugin
526  */
527 G_CONST_RETURN gchar *
528 gst_plugin_get_filename (GstPlugin * plugin)
529 {
530   g_return_val_if_fail (plugin != NULL, NULL);
531
532   return plugin->filename;
533 }
534
535 /**
536  * gst_plugin_get_license:
537  * @plugin: plugin to get the license of
538  *
539  * get the license of the plugin
540  *
541  * Returns: the license of the plugin
542  */
543 G_CONST_RETURN gchar *
544 gst_plugin_get_license (GstPlugin * plugin)
545 {
546   g_return_val_if_fail (plugin != NULL, NULL);
547
548   return plugin->desc.license;
549 }
550
551 /**
552  * gst_plugin_get_package:
553  * @plugin: plugin to get the package of
554  *
555  * get the package the plugin belongs to.
556  *
557  * Returns: the package of the plugin
558  */
559 G_CONST_RETURN gchar *
560 gst_plugin_get_package (GstPlugin * plugin)
561 {
562   g_return_val_if_fail (plugin != NULL, NULL);
563
564   return plugin->desc.package;
565 }
566
567 /**
568  * gst_plugin_get_origin:
569  * @plugin: plugin to get the origin of
570  *
571  * get the URL where the plugin comes from
572  *
573  * Returns: the origin of the plugin
574  */
575 G_CONST_RETURN gchar *
576 gst_plugin_get_origin (GstPlugin * plugin)
577 {
578   g_return_val_if_fail (plugin != NULL, NULL);
579
580   return plugin->desc.origin;
581 }
582
583 /**
584  * gst_plugin_get_module:
585  * @plugin: plugin to query
586  *
587  * Gets the #GModule of the plugin. If the plugin isn't loaded yet, NULL is 
588  * returned.
589  *
590  * Returns: module belonging to the plugin or NULL if the plugin isn't 
591  *          loaded yet.
592  */
593 GModule *
594 gst_plugin_get_module (GstPlugin * plugin)
595 {
596   g_return_val_if_fail (plugin != NULL, FALSE);
597
598   return plugin->module;
599 }
600
601 /**
602  * gst_plugin_is_loaded:
603  * @plugin: plugin to query
604  *
605  * queries if the plugin is loaded into memory
606  *
607  * Returns: TRUE is loaded, FALSE otherwise
608  */
609 gboolean
610 gst_plugin_is_loaded (GstPlugin * plugin)
611 {
612   g_return_val_if_fail (plugin != NULL, FALSE);
613
614   return (plugin->module != NULL);
615 }
616
617 /**
618  * gst_plugin_feature_list:
619  * @plugin: plugin to query
620  * @filter: the filter to use
621  * @first: only return first match
622  * @user_data: user data passed to the filter function
623  *
624  * Runs a filter against all plugin features and returns a GList with
625  * the results. If the first flag is set, only the first match is 
626  * returned (as a list with a single object).
627  *
628  * Returns: a GList of features, g_list_free after use.
629  */
630 GList *
631 gst_plugin_feature_filter (GstPlugin * plugin,
632     GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
633 {
634   return gst_filter_run (plugin->features, (GstFilterFunc) filter, first,
635       user_data);
636 }
637
638 typedef struct
639 {
640   GstPluginFeatureFilter filter;
641   gboolean first;
642   gpointer user_data;
643   GList *result;
644 }
645 FeatureFilterData;
646
647 static gboolean
648 _feature_filter (GstPlugin * plugin, gpointer user_data)
649 {
650   GList *result;
651   FeatureFilterData *data = (FeatureFilterData *) user_data;
652
653   result =
654       gst_plugin_feature_filter (plugin, data->filter, data->first,
655       data->user_data);
656   if (result) {
657     data->result = g_list_concat (data->result, result);
658     return TRUE;
659   }
660   return FALSE;
661 }
662
663 /**
664  * gst_plugin_list_feature_list:
665  * @list: a list of plugins to query
666  * @filter: the filter to use
667  * @first: only return first match
668  * @user_data: user data passed to the filter function
669  *
670  * Runs a filter against all plugin features of the plugins in the given
671  * list and returns a GList with the results. 
672  * If the first flag is set, only the first match is 
673  * returned (as a list with a single object).
674  *
675  * Returns: a GList of features, g_list_free after use.
676  */
677 GList *
678 gst_plugin_list_feature_filter (GList * list,
679     GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
680 {
681   FeatureFilterData data;
682   GList *result;
683
684   data.filter = filter;
685   data.first = first;
686   data.user_data = user_data;
687   data.result = NULL;
688
689   result = gst_filter_run (list, (GstFilterFunc) _feature_filter, first, &data);
690   g_list_free (result);
691
692   return data.result;
693 }
694
695 /**
696  * gst_plugin_name_filter:
697  * @plugin: the plugin to check
698  * @name: the name of the plugin
699  *
700  * A standard filter that returns TRUE when the plugin is of the
701  * given name.
702  *
703  * Returns: TRUE if the plugin is of the given name.
704  */
705 gboolean
706 gst_plugin_name_filter (GstPlugin * plugin, const gchar * name)
707 {
708   return (plugin->desc.name && !strcmp (plugin->desc.name, name));
709 }
710
711 /**
712  * gst_plugin_find_feature:
713  * @plugin: plugin to get the feature from
714  * @name: The name of the feature to find
715  * @type: The type of the feature to find
716  *
717  * Find a feature of the given name and type in the given plugin.
718  *
719  * Returns: a GstPluginFeature or NULL if the feature was not found.
720  */
721 GstPluginFeature *
722 gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type)
723 {
724   GList *walk;
725   GstPluginFeature *result = NULL;
726   GstTypeNameData data;
727
728   g_return_val_if_fail (name != NULL, NULL);
729
730   data.type = type;
731   data.name = name;
732
733   walk = gst_filter_run (plugin->features,
734       (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, &data);
735
736   if (walk)
737     result = GST_PLUGIN_FEATURE (walk->data);
738
739   return result;
740 }
741
742 /**
743  * gst_plugin_add_feature:
744  * @plugin: plugin to add feature to
745  * @feature: feature to add
746  *
747  * Add feature to the list of those provided by the plugin.
748  * There is a separate namespace for each plugin feature type.
749  * See #gst_plugin_get_feature_list
750  */
751 void
752 gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature)
753 {
754   GstPluginFeature *oldfeature;
755
756   g_return_if_fail (plugin != NULL);
757   g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
758   g_return_if_fail (feature != NULL);
759
760   oldfeature = gst_plugin_find_feature (plugin,
761       GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature));
762
763   if (!oldfeature) {
764     feature->manager = plugin;
765     plugin->features = g_list_prepend (plugin->features, feature);
766     plugin->numfeatures++;
767   }
768 }
769
770 /**
771  * gst_plugin_get_feature_list:
772  * @plugin: the plugin to get the features from
773  *
774  * get a list of all the features that this plugin provides
775  *
776  * Returns: a GList of features, use g_list_free to free the list.
777  */
778 GList *
779 gst_plugin_get_feature_list (GstPlugin * plugin)
780 {
781   g_return_val_if_fail (plugin != NULL, NULL);
782
783   return g_list_copy (plugin->features);
784 }
785
786 /**
787  * gst_plugin_load:
788  * @name: name of plugin to load
789  *
790  * Load the named plugin.  
791  *
792  * Returns: whether the plugin was loaded or not
793  */
794 gboolean
795 gst_plugin_load (const gchar * name)
796 {
797   GstPlugin *plugin;
798   GError *error = NULL;
799
800   plugin = gst_registry_pool_find_plugin (name);
801   if (plugin) {
802     gst_plugin_load_file (plugin->filename, &error);
803     if (error) {
804       GST_WARNING ("load_plugin error: %s\n", error->message);
805       g_error_free (error);
806       return FALSE;
807     }
808     return TRUE;;
809   }
810
811   GST_DEBUG ("Could not find %s in registry pool", name);
812   return FALSE;
813 }
814
815 /**
816  * gst_library_load:
817  * @name: name of library to load
818  *
819  * Load the named library.  Name should be given as
820  * &quot;liblibrary.so&quot;.
821  *
822  * Returns: whether the library was loaded or not
823  */
824 gboolean
825 gst_library_load (const gchar * name)
826 {
827   gboolean res;
828
829   /* for now this is the same */
830   res = gst_plugin_load (name);
831
832   return res;
833 }