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_FREI0R,      
00055   } bg_plugin_api_t;
00056 
00061 typedef struct bg_plugin_info_s  bg_plugin_info_t;
00062 
00067 struct bg_plugin_info_s
00068   {
00069   char * gettext_domain; 
00070   char * gettext_directory; 
00071   
00072   char * name;            
00073   char * long_name;       
00074   char * mimetypes;       
00075   char * extensions;      
00076   char * protocols;       
00077 
00078   char * description;     
00079 
00080   char * module_filename; 
00081   long   module_time;     
00082 
00083   bg_plugin_api_t api;    
00084   int index;              
00085   
00086   bg_plugin_type_t type; 
00087   int flags;             
00088   int priority;          
00089   
00090   bg_device_info_t * devices; 
00091   
00092   bg_plugin_info_t * next; 
00093 
00094   bg_parameter_info_t * parameters; 
00095   
00096   int max_audio_streams; 
00097   int max_video_streams; 
00098   int max_subtitle_text_streams;
00099   int max_subtitle_overlay_streams;
00100 
00101   bg_parameter_info_t * audio_parameters; 
00102   bg_parameter_info_t * video_parameters; 
00103 
00104   bg_parameter_info_t * subtitle_text_parameters; 
00105   bg_parameter_info_t * subtitle_overlay_parameters; 
00106   
00107   };
00108 
00115 typedef struct bg_plugin_registry_s bg_plugin_registry_t;
00116 
00121 typedef struct bg_plugin_handle_s bg_plugin_handle_t;
00122 
00131 struct bg_plugin_handle_s
00132   {
00133   /* Private members, should not be accessed! */
00134     
00135   void * dll_handle; 
00136   pthread_mutex_t mutex; 
00137   int refcount;          
00138   bg_plugin_registry_t * plugin_reg; 
00139   
00140   /* These are for use by applications */
00141   
00142   const bg_plugin_common_t * plugin; 
00143   bg_plugin_common_t * plugin_nc; 
00144   const bg_plugin_info_t * info; 
00145   void * priv; 
00146 
00147   char * location; 
00148   bg_edl_t * edl; 
00149   };
00150 
00151 /*
00152  *  pluginregistry.c
00153  */
00154 
00163 bg_plugin_registry_t *
00164 bg_plugin_registry_create(bg_cfg_section_t * section);
00165 
00171 void bg_plugin_registry_destroy(bg_plugin_registry_t * reg);
00172 
00181 int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t * reg,
00182                                        uint32_t type_mask, uint32_t flag_mask);
00195 const bg_plugin_info_t *
00196 bg_plugin_find_by_index(bg_plugin_registry_t * reg, int index,
00197                         uint32_t type_mask, uint32_t flag_mask);
00198 
00206 const bg_plugin_info_t *
00207 bg_plugin_find_by_name(bg_plugin_registry_t * reg, const char * name);
00208 
00219 const bg_plugin_info_t *
00220 bg_plugin_find_by_filename(bg_plugin_registry_t * reg,
00221                            const char * filename, int type_mask);
00222 
00223 
00230 const bg_plugin_info_t *
00231 bg_plugin_find_by_protocol(bg_plugin_registry_t * reg,
00232                            const char * protocol);
00233 
00234 
00235 /* Another method: Return long names as strings (NULL terminated) */
00236 
00251 char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t*reg,
00252                                        uint32_t type_mask,
00253                                        uint32_t flag_mask);
00254 
00259 void bg_plugin_registry_free_plugins(char ** plugins);
00260 
00261 
00262 /*  Finally a version for finding/loading plugins */
00263 
00264 /*
00265  *  info can be NULL
00266  *  If ret is non NULL before the call, the plugin will be unrefed
00267  *
00268  *  Return values are 0 for error, 1 on success
00269  */
00270 
00286 int bg_input_plugin_load(bg_plugin_registry_t * reg,
00287                          const char * location,
00288                          const bg_plugin_info_t * info,
00289                          bg_plugin_handle_t ** ret,
00290                          bg_input_callbacks_t * callbacks, int prefer_edl);
00291 
00306 int bg_input_plugin_load_edl(bg_plugin_registry_t * reg,
00307                              const bg_edl_t * edl,
00308                              const bg_plugin_info_t * info,
00309                              bg_plugin_handle_t ** ret,
00310                              bg_input_callbacks_t * callbacks);
00311 
00312 /* Set the supported extensions and mimetypes for a plugin */
00313 
00323 void bg_plugin_registry_set_extensions(bg_plugin_registry_t * reg,
00324                                        const char * plugin_name,
00325                                        const char * extensions);
00326 
00336 void bg_plugin_registry_set_protocols(bg_plugin_registry_t * reg,
00337                                       const char * plugin_name,
00338                                       const char * protocols);
00339 
00349 void bg_plugin_registry_set_priority(bg_plugin_registry_t * reg,
00350                                      const char * plugin_name,
00351                                      int priority);
00352 
00353 
00360 bg_cfg_section_t *
00361 bg_plugin_registry_get_section(bg_plugin_registry_t * reg,
00362                                const char * plugin_name);
00363 
00373 void bg_plugin_registry_set_parameter_info(bg_plugin_registry_t * reg,
00374                                            uint32_t type_mask,
00375                                            uint32_t flag_mask,
00376                                            bg_parameter_info_t * ret);
00377 
00378 
00389 void bg_plugin_registry_set_default(bg_plugin_registry_t * reg,
00390                                     bg_plugin_type_t type,
00391                                     const char * plugin_name);
00392 
00401 const bg_plugin_info_t * bg_plugin_registry_get_default(bg_plugin_registry_t * reg,
00402                                                         bg_plugin_type_t type);
00403 
00404 
00427 void bg_plugin_registry_set_encode_audio_to_video(bg_plugin_registry_t * reg,
00428                                                   int audio_to_video);
00429 
00436 int bg_plugin_registry_get_encode_audio_to_video(bg_plugin_registry_t * reg);
00437 
00444 void bg_plugin_registry_set_encode_subtitle_text_to_video(bg_plugin_registry_t * reg,
00445                                                           int subtitle_text_to_video);
00446 
00453 int bg_plugin_registry_get_encode_subtitle_text_to_video(bg_plugin_registry_t * reg);
00454 
00461 void bg_plugin_registry_set_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg,
00462                                                              int subtitle_overlay_to_video);
00463 
00469 int bg_plugin_registry_get_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg);
00470 
00477 void bg_plugin_registry_set_encode_pp(bg_plugin_registry_t * reg,
00478                                       int encode_pp);
00479 
00485 int bg_plugin_registry_get_encode_pp(bg_plugin_registry_t * reg);
00486 
00493 void bg_plugin_registry_set_visualize(bg_plugin_registry_t * reg,
00494                                        int enable);
00495 
00502 int bg_plugin_registry_get_visualize(bg_plugin_registry_t * reg);
00503 
00504 
00513 void bg_plugin_registry_add_device(bg_plugin_registry_t * reg,
00514                                    const char * plugin_name,
00515                                    const char * device,
00516                                    const char * name);
00517 
00530 void bg_plugin_registry_set_device_name(bg_plugin_registry_t * reg,
00531                                         const char * plugin_name,
00532                                         const char * device,
00533                                         const char * name);
00534 
00535 /* Rescan the available devices */
00536 
00546 void bg_plugin_registry_find_devices(bg_plugin_registry_t * reg,
00547                                      const char * plugin_name);
00548 
00560 void bg_plugin_registry_remove_device(bg_plugin_registry_t * reg,
00561                                       const char * plugin_name,
00562                                       const char * device,
00563                                       const char * name);
00564 
00576 gavl_video_frame_t * bg_plugin_registry_load_image(bg_plugin_registry_t * reg,
00577                                                    const char * filename,
00578                                                    gavl_video_format_t * format);
00579 
00580 /* Same as above for writing. Does implicit pixelformat conversion */
00581 
00590 void
00591 bg_plugin_registry_save_image(bg_plugin_registry_t * reg,
00592                               const char * filename,
00593                               gavl_video_frame_t * frame,
00594                               const gavl_video_format_t * format);
00595 
00596 
00597 
00598 /*
00599  *  These are the actual loading/unloading functions
00600  *  (loader.c)
00601  */
00602 
00603 /* Load a plugin and return handle with reference count of 1 */
00604 
00613 bg_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t * reg,
00614                                     const bg_plugin_info_t * info);
00615 
00626 bg_plugin_handle_t * bg_ov_plugin_load(bg_plugin_registry_t * reg,
00627                                        const bg_plugin_info_t * info,
00628                                        const char * window_id);
00629 
00634 void bg_plugin_lock(bg_plugin_handle_t * h);
00635 
00640 void bg_plugin_unlock(bg_plugin_handle_t * h);
00641 
00642 /* Reference counting for input plugins */
00643 
00648 void bg_plugin_ref(bg_plugin_handle_t * h);
00649 
00650 /* Plugin will be unloaded when refcount is zero */
00651 
00659 void bg_plugin_unref(bg_plugin_handle_t * h);
00660 
00671 void bg_plugin_unref_nolock(bg_plugin_handle_t * h);
00672 
00673 /* Check if 2 plugins handles are equal */
00674 
00682 int bg_plugin_equal(bg_plugin_handle_t * h1,
00683                     bg_plugin_handle_t * h2);                    
00684 
00685 #endif // __BG_PLUGINREGISTRY_H_

Generated on Sat Aug 9 12:12:42 2008 for gmerlin by  doxygen 1.5.6