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