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 <gmerlin/plugin.h>
00029 #include <gmerlin/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   char * cmp_name; 
00108   
00109   };
00110 
00117 typedef struct bg_plugin_registry_s bg_plugin_registry_t;
00118 
00123 typedef struct bg_plugin_handle_s bg_plugin_handle_t;
00124 
00133 struct bg_plugin_handle_s
00134   {
00135   /* Private members, should not be accessed! */
00136     
00137   void * dll_handle; 
00138   pthread_mutex_t mutex; 
00139   int refcount;          
00140   bg_plugin_registry_t * plugin_reg; 
00141   
00142   /* These are for use by applications */
00143   
00144   const bg_plugin_common_t * plugin; 
00145   bg_plugin_common_t * plugin_nc; 
00146   const bg_plugin_info_t * info; 
00147   void * priv; 
00148 
00149   char * location; 
00150   bg_edl_t * edl; 
00151   };
00152 
00153 /*
00154  *  pluginregistry.c
00155  */
00156 
00165 bg_plugin_registry_t *
00166 bg_plugin_registry_create(bg_cfg_section_t * section);
00167 
00173 void bg_plugin_registry_destroy(bg_plugin_registry_t * reg);
00174 
00183 int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t * reg,
00184                                        uint32_t type_mask, uint32_t flag_mask);
00197 const bg_plugin_info_t *
00198 bg_plugin_find_by_index(bg_plugin_registry_t * reg, int index,
00199                         uint32_t type_mask, uint32_t flag_mask);
00200 
00208 const bg_plugin_info_t *
00209 bg_plugin_find_by_name(bg_plugin_registry_t * reg, const char * name);
00210 
00221 const bg_plugin_info_t *
00222 bg_plugin_find_by_filename(bg_plugin_registry_t * reg,
00223                            const char * filename, int type_mask);
00224 
00225 
00232 const bg_plugin_info_t *
00233 bg_plugin_find_by_protocol(bg_plugin_registry_t * reg,
00234                            const char * protocol);
00235 
00236 
00237 /* Another method: Return long names as strings (NULL terminated) */
00238 
00253 char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t*reg,
00254                                        uint32_t type_mask,
00255                                        uint32_t flag_mask);
00256 
00261 void bg_plugin_registry_free_plugins(char ** plugins);
00262 
00263 
00264 /*  Finally a version for finding/loading plugins */
00265 
00266 /*
00267  *  info can be NULL
00268  *  If ret is non NULL before the call, the plugin will be unrefed
00269  *
00270  *  Return values are 0 for error, 1 on success
00271  */
00272 
00288 int bg_input_plugin_load(bg_plugin_registry_t * reg,
00289                          const char * location,
00290                          const bg_plugin_info_t * info,
00291                          bg_plugin_handle_t ** ret,
00292                          bg_input_callbacks_t * callbacks, int prefer_edl);
00293 
00308 int bg_input_plugin_load_edl(bg_plugin_registry_t * reg,
00309                              const bg_edl_t * edl,
00310                              const bg_plugin_info_t * info,
00311                              bg_plugin_handle_t ** ret,
00312                              bg_input_callbacks_t * callbacks);
00313 
00314 /* Set the supported extensions and mimetypes for a plugin */
00315 
00325 void bg_plugin_registry_set_extensions(bg_plugin_registry_t * reg,
00326                                        const char * plugin_name,
00327                                        const char * extensions);
00328 
00338 void bg_plugin_registry_set_protocols(bg_plugin_registry_t * reg,
00339                                       const char * plugin_name,
00340                                       const char * protocols);
00341 
00351 void bg_plugin_registry_set_priority(bg_plugin_registry_t * reg,
00352                                      const char * plugin_name,
00353                                      int priority);
00354 
00355 
00362 bg_cfg_section_t *
00363 bg_plugin_registry_get_section(bg_plugin_registry_t * reg,
00364                                const char * plugin_name);
00365 
00375 void bg_plugin_registry_set_parameter_info(bg_plugin_registry_t * reg,
00376                                            uint32_t type_mask,
00377                                            uint32_t flag_mask,
00378                                            bg_parameter_info_t * ret);
00379 
00380 
00391 void bg_plugin_registry_set_default(bg_plugin_registry_t * reg,
00392                                     bg_plugin_type_t type,
00393                                     const char * plugin_name);
00394 
00403 const bg_plugin_info_t * bg_plugin_registry_get_default(bg_plugin_registry_t * reg,
00404                                                         bg_plugin_type_t type);
00405 
00406 
00429 void bg_plugin_registry_set_encode_audio_to_video(bg_plugin_registry_t * reg,
00430                                                   int audio_to_video);
00431 
00438 int bg_plugin_registry_get_encode_audio_to_video(bg_plugin_registry_t * reg);
00439 
00446 void bg_plugin_registry_set_encode_subtitle_text_to_video(bg_plugin_registry_t * reg,
00447                                                           int subtitle_text_to_video);
00448 
00455 int bg_plugin_registry_get_encode_subtitle_text_to_video(bg_plugin_registry_t * reg);
00456 
00463 void bg_plugin_registry_set_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg,
00464                                                              int subtitle_overlay_to_video);
00465 
00471 int bg_plugin_registry_get_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg);
00472 
00479 void bg_plugin_registry_set_encode_pp(bg_plugin_registry_t * reg,
00480                                       int encode_pp);
00481 
00487 int bg_plugin_registry_get_encode_pp(bg_plugin_registry_t * reg);
00488 
00495 void bg_plugin_registry_set_visualize(bg_plugin_registry_t * reg,
00496                                        int enable);
00497 
00504 int bg_plugin_registry_get_visualize(bg_plugin_registry_t * reg);
00505 
00506 
00515 void bg_plugin_registry_add_device(bg_plugin_registry_t * reg,
00516                                    const char * plugin_name,
00517                                    const char * device,
00518                                    const char * name);
00519 
00532 void bg_plugin_registry_set_device_name(bg_plugin_registry_t * reg,
00533                                         const char * plugin_name,
00534                                         const char * device,
00535                                         const char * name);
00536 
00537 /* Rescan the available devices */
00538 
00548 void bg_plugin_registry_find_devices(bg_plugin_registry_t * reg,
00549                                      const char * plugin_name);
00550 
00562 void bg_plugin_registry_remove_device(bg_plugin_registry_t * reg,
00563                                       const char * plugin_name,
00564                                       const char * device,
00565                                       const char * name);
00566 
00578 gavl_video_frame_t * bg_plugin_registry_load_image(bg_plugin_registry_t * reg,
00579                                                    const char * filename,
00580                                                    gavl_video_format_t * format);
00581 
00582 /* Same as above for writing. Does implicit pixelformat conversion */
00583 
00592 void
00593 bg_plugin_registry_save_image(bg_plugin_registry_t * reg,
00594                               const char * filename,
00595                               gavl_video_frame_t * frame,
00596                               const gavl_video_format_t * format);
00597 
00598 
00599 
00600 /*
00601  *  These are the actual loading/unloading functions
00602  *  (loader.c)
00603  */
00604 
00605 /* Load a plugin and return handle with reference count of 1 */
00606 
00615 bg_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t * reg,
00616                                     const bg_plugin_info_t * info);
00617 
00628 bg_plugin_handle_t * bg_ov_plugin_load(bg_plugin_registry_t * reg,
00629                                        const bg_plugin_info_t * info,
00630                                        const char * window_id);
00631 
00636 void bg_plugin_lock(bg_plugin_handle_t * h);
00637 
00642 void bg_plugin_unlock(bg_plugin_handle_t * h);
00643 
00644 /* Reference counting for input plugins */
00645 
00650 void bg_plugin_ref(bg_plugin_handle_t * h);
00651 
00652 /* Plugin will be unloaded when refcount is zero */
00653 
00661 void bg_plugin_unref(bg_plugin_handle_t * h);
00662 
00673 void bg_plugin_unref_nolock(bg_plugin_handle_t * h);
00674 
00675 /* Check if 2 plugins handles are equal */
00676 
00684 int bg_plugin_equal(bg_plugin_handle_t * h1,
00685                     bg_plugin_handle_t * h2);                    
00686 
00687 #endif // __BG_PLUGINREGISTRY_H_

Generated on Thu Dec 18 08:10:52 2008 for gmerlin by  doxygen 1.5.7.1