pluginregistry.h

00001 /*****************************************************************
00002  * gmerlin - a general purpose multimedia framework and applications
00003  *
00004  * Copyright (c) 2001 - 2008 Members of the Gmerlin project
00005  * gmerlin-general@lists.sourceforge.net
00006  * http://gmerlin.sourceforge.net
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  * *****************************************************************/
00021 
00022 #ifndef __BG_PLUGINREGISTRY_H_
00023 #define __BG_PLUGINREGISTRY_H_
00024 
00025 /* Plugin registry */
00026 #include <pthread.h>
00027 
00028 #include "plugin.h"
00029 #include "cfg_registry.h"
00030 
00049 typedef enum
00050   {
00051     BG_PLUGIN_API_GMERLIN = 0, 
00052     BG_PLUGIN_API_LADSPA,      
00053     BG_PLUGIN_API_LV,          
00054   } bg_plugin_api_t;
00055 
00060 typedef struct bg_plugin_info_s
00061   {
00062   char * gettext_domain; 
00063   char * gettext_directory; 
00064   
00065   char * name;            
00066   char * long_name;       
00067   char * mimetypes;       
00068   char * extensions;      
00069   char * protocols;       
00070 
00071   char * description;     
00072 
00073   char * module_filename; 
00074   long   module_time;     
00075 
00076   bg_plugin_api_t api;    
00077   int index;              
00078   
00079   bg_plugin_type_t type; 
00080   int flags;             
00081   int priority;          
00082   
00083   bg_device_info_t * devices; 
00084   
00085   struct bg_plugin_info_s * next; 
00086 
00087   bg_parameter_info_t * parameters; 
00088   
00089   int max_audio_streams; 
00090   int max_video_streams; 
00091   int max_subtitle_text_streams;
00092   int max_subtitle_overlay_streams;
00093 
00094   bg_parameter_info_t * audio_parameters; 
00095   bg_parameter_info_t * video_parameters; 
00096 
00097   bg_parameter_info_t * subtitle_text_parameters; 
00098   bg_parameter_info_t * subtitle_overlay_parameters; 
00099   
00100   } bg_plugin_info_t;
00101 
00108 typedef struct bg_plugin_registry_s bg_plugin_registry_t;
00109 
00118 typedef struct bg_plugin_handle_s
00119   {
00120   /* Private members, should not be accessed! */
00121     
00122   void * dll_handle; 
00123   pthread_mutex_t mutex; 
00124   int refcount;          
00125   bg_plugin_registry_t * plugin_reg; 
00126   
00127   /* These are for use by applications */
00128   
00129   bg_plugin_common_t * plugin; 
00130   const bg_plugin_info_t * info; 
00131   void * priv; 
00132 
00133   char * location; 
00134   
00135   } bg_plugin_handle_t;
00136 
00137 /*
00138  *  pluginregistry.c
00139  */
00140 
00149 bg_plugin_registry_t *
00150 bg_plugin_registry_create(bg_cfg_section_t * section);
00151 
00157 void bg_plugin_registry_destroy(bg_plugin_registry_t * reg);
00158 
00167 int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t * reg,
00168                                        uint32_t type_mask, uint32_t flag_mask);
00181 const bg_plugin_info_t *
00182 bg_plugin_find_by_index(bg_plugin_registry_t * reg, int index,
00183                         uint32_t type_mask, uint32_t flag_mask);
00184 
00192 const bg_plugin_info_t *
00193 bg_plugin_find_by_name(bg_plugin_registry_t * reg, const char * name);
00194 
00205 const bg_plugin_info_t *
00206 bg_plugin_find_by_filename(bg_plugin_registry_t * reg,
00207                            const char * filename, int type_mask);
00208 
00209 
00216 const bg_plugin_info_t *
00217 bg_plugin_find_by_protocol(bg_plugin_registry_t * reg,
00218                            const char * protocol);
00219 
00220 
00221 /* Another method: Return long names as strings (NULL terminated) */
00222 
00237 char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t*reg,
00238                                        uint32_t type_mask,
00239                                        uint32_t flag_mask);
00240 
00245 void bg_plugin_registry_free_plugins(char ** plugins);
00246 
00247 
00248 /*  Finally a version for finding/loading plugins */
00249 
00250 /*
00251  *  info can be NULL
00252  *  If ret is non NULL before the call, the plugin will be unrefed
00253  *
00254  *  Return values are 0 for error, 1 on success
00255  */
00256 
00273 int bg_input_plugin_load(bg_plugin_registry_t * reg,
00274                          const char * location,
00275                          const bg_plugin_info_t * info,
00276                          bg_plugin_handle_t ** ret,
00277                          bg_input_callbacks_t * callbacks);
00278 
00279 /* Set the supported extensions and mimetypes for a plugin */
00280 
00290 void bg_plugin_registry_set_extensions(bg_plugin_registry_t * reg,
00291                                        const char * plugin_name,
00292                                        const char * extensions);
00293 
00303 void bg_plugin_registry_set_protocols(bg_plugin_registry_t * reg,
00304                                       const char * plugin_name,
00305                                       const char * protocols);
00306 
00316 void bg_plugin_registry_set_priority(bg_plugin_registry_t * reg,
00317                                      const char * plugin_name,
00318                                      int priority);
00319 
00320 
00327 bg_cfg_section_t *
00328 bg_plugin_registry_get_section(bg_plugin_registry_t * reg,
00329                                const char * plugin_name);
00330 
00340 void bg_plugin_registry_set_parameter_info(bg_plugin_registry_t * reg,
00341                                            uint32_t type_mask,
00342                                            uint32_t flag_mask,
00343                                            bg_parameter_info_t * ret);
00344 
00345 
00356 void bg_plugin_registry_set_default(bg_plugin_registry_t * reg,
00357                                     bg_plugin_type_t type,
00358                                     const char * plugin_name);
00359 
00368 const bg_plugin_info_t * bg_plugin_registry_get_default(bg_plugin_registry_t * reg,
00369                                                         bg_plugin_type_t type);
00370 
00371 
00394 void bg_plugin_registry_set_encode_audio_to_video(bg_plugin_registry_t * reg,
00395                                                   int audio_to_video);
00396 
00403 int bg_plugin_registry_get_encode_audio_to_video(bg_plugin_registry_t * reg);
00404 
00411 void bg_plugin_registry_set_encode_subtitle_text_to_video(bg_plugin_registry_t * reg,
00412                                                           int subtitle_text_to_video);
00413 
00420 int bg_plugin_registry_get_encode_subtitle_text_to_video(bg_plugin_registry_t * reg);
00421 
00428 void bg_plugin_registry_set_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg,
00429                                                              int subtitle_overlay_to_video);
00430 
00436 int bg_plugin_registry_get_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg);
00437 
00444 void bg_plugin_registry_set_encode_pp(bg_plugin_registry_t * reg,
00445                                       int encode_pp);
00446 
00452 int bg_plugin_registry_get_encode_pp(bg_plugin_registry_t * reg);
00453 
00460 void bg_plugin_registry_set_visualize(bg_plugin_registry_t * reg,
00461                                        int enable);
00462 
00469 int bg_plugin_registry_get_visualize(bg_plugin_registry_t * reg);
00470 
00471 
00480 void bg_plugin_registry_add_device(bg_plugin_registry_t * reg,
00481                                    const char * plugin_name,
00482                                    const char * device,
00483                                    const char * name);
00484 
00497 void bg_plugin_registry_set_device_name(bg_plugin_registry_t * reg,
00498                                         const char * plugin_name,
00499                                         const char * device,
00500                                         const char * name);
00501 
00502 /* Rescan the available devices */
00503 
00513 void bg_plugin_registry_find_devices(bg_plugin_registry_t * reg,
00514                                      const char * plugin_name);
00515 
00527 void bg_plugin_registry_remove_device(bg_plugin_registry_t * reg,
00528                                       const char * plugin_name,
00529                                       const char * device,
00530                                       const char * name);
00531 
00543 gavl_video_frame_t * bg_plugin_registry_load_image(bg_plugin_registry_t * reg,
00544                                                    const char * filename,
00545                                                    gavl_video_format_t * format);
00546 
00547 /* Same as above for writing. Does implicit pixelformat conversion */
00548 
00557 void
00558 bg_plugin_registry_save_image(bg_plugin_registry_t * reg,
00559                               const char * filename,
00560                               gavl_video_frame_t * frame,
00561                               const gavl_video_format_t * format);
00562 
00563 
00564 
00565 /*
00566  *  These are the actual loading/unloading functions
00567  *  (loader.c)
00568  */
00569 
00570 /* Load a plugin and return handle with reference count of 1 */
00571 
00580 bg_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t * reg,
00581                                     const bg_plugin_info_t * info);
00582 
00593 bg_plugin_handle_t * bg_ov_plugin_load(bg_plugin_registry_t * reg,
00594                                        const bg_plugin_info_t * info,
00595                                        const char * window_id);
00596 
00601 void bg_plugin_lock(bg_plugin_handle_t * h);
00602 
00607 void bg_plugin_unlock(bg_plugin_handle_t * h);
00608 
00609 /* Reference counting for input plugins */
00610 
00615 void bg_plugin_ref(bg_plugin_handle_t * h);
00616 
00617 /* Plugin will be unloaded when refcount is zero */
00618 
00626 void bg_plugin_unref(bg_plugin_handle_t * h);
00627 
00638 void bg_plugin_unref_nolock(bg_plugin_handle_t * h);
00639 
00640 /* Check if 2 plugins handles are equal */
00641 
00649 int bg_plugin_equal(bg_plugin_handle_t * h1,
00650                     bg_plugin_handle_t * h2);                    
00651 
00652 #endif // __BG_PLUGINREGISTRY_H_

Generated on Wed Jan 9 19:32:52 2008 for gmerlin by  doxygen 1.5.3