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