gmerlin
|
00001 /***************************************************************** 00002 * gmerlin - a general purpose multimedia framework and applications 00003 * 00004 * Copyright (c) 2001 - 2011 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 enum 00062 { 00063 BG_STREAM_AUDIO = (1<<0), 00064 BG_STREAM_SUBTITLE_TEXT = (1<<1), 00065 BG_STREAM_SUBTITLE_OVERLAY = (1<<2), 00066 BG_STREAM_VIDEO = (1<<3), 00067 } bg_stream_type_t; 00068 00073 typedef struct bg_plugin_info_s bg_plugin_info_t; 00074 00079 struct bg_plugin_info_s 00080 { 00081 char * gettext_domain; 00082 char * gettext_directory; 00083 00084 char * name; 00085 char * long_name; 00086 char * mimetypes; 00087 char * extensions; 00088 char * protocols; 00089 00090 char * description; 00091 00092 char * module_filename; 00093 long module_time; 00094 00095 bg_plugin_api_t api; 00096 int index; 00097 00098 bg_plugin_type_t type; 00099 int flags; 00100 int priority; 00101 00102 bg_device_info_t * devices; 00103 00104 bg_plugin_info_t * next; 00105 00106 bg_parameter_info_t * parameters; 00107 00108 int max_audio_streams; 00109 int max_video_streams; 00110 int max_subtitle_text_streams; 00111 int max_subtitle_overlay_streams; 00112 00113 bg_parameter_info_t * audio_parameters; 00114 bg_parameter_info_t * video_parameters; 00115 00116 bg_parameter_info_t * subtitle_text_parameters; 00117 bg_parameter_info_t * subtitle_overlay_parameters; 00118 00119 char * cmp_name; 00120 00121 }; 00122 00129 typedef struct 00130 { 00131 char ** blacklist; 00132 int dont_save; 00133 } bg_plugin_registry_options_t; 00134 00141 typedef struct bg_plugin_registry_s bg_plugin_registry_t; 00142 00147 typedef struct bg_plugin_handle_s bg_plugin_handle_t; 00148 00157 struct bg_plugin_handle_s 00158 { 00159 /* Private members, should not be accessed! */ 00160 00161 void * dll_handle; 00162 pthread_mutex_t mutex; 00163 int refcount; 00164 bg_plugin_registry_t * plugin_reg; 00165 00166 /* These are for use by applications */ 00167 00168 const bg_plugin_common_t * plugin; 00169 bg_plugin_common_t * plugin_nc; 00170 const bg_plugin_info_t * info; 00171 void * priv; 00172 00173 char * location; 00174 bg_edl_t * edl; 00175 }; 00176 00177 /* 00178 * pluginregistry.c 00179 */ 00180 00189 bg_plugin_registry_t * 00190 bg_plugin_registry_create(bg_cfg_section_t * section); 00191 00201 bg_plugin_registry_t * 00202 bg_plugin_registry_create_with_options(bg_cfg_section_t * section, 00203 const bg_plugin_registry_options_t * opt); 00204 00205 00206 00218 void bg_plugin_registry_scan_devices(bg_plugin_registry_t * plugin_reg, 00219 uint32_t type_mask, uint32_t flag_mask); 00220 00221 00227 void bg_plugin_registry_destroy(bg_plugin_registry_t * reg); 00228 00237 int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t * reg, 00238 uint32_t type_mask, uint32_t flag_mask); 00251 const bg_plugin_info_t * 00252 bg_plugin_find_by_index(bg_plugin_registry_t * reg, int index, 00253 uint32_t type_mask, uint32_t flag_mask); 00254 00262 const bg_plugin_info_t * 00263 bg_plugin_find_by_name(bg_plugin_registry_t * reg, const char * name); 00264 00275 const bg_plugin_info_t * 00276 bg_plugin_find_by_filename(bg_plugin_registry_t * reg, 00277 const char * filename, int type_mask); 00278 00279 00286 const bg_plugin_info_t * 00287 bg_plugin_find_by_protocol(bg_plugin_registry_t * reg, 00288 const char * protocol); 00289 00290 00291 /* Another method: Return long names as strings (NULL terminated) */ 00292 00307 char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t*reg, 00308 uint32_t type_mask, 00309 uint32_t flag_mask); 00310 00315 void bg_plugin_registry_free_plugins(char ** plugins); 00316 00317 00318 /* Finally a version for finding/loading plugins */ 00319 00320 /* 00321 * info can be NULL 00322 * If ret is non NULL before the call, the plugin will be unrefed 00323 * 00324 * Return values are 0 for error, 1 on success 00325 */ 00326 00342 int bg_input_plugin_load(bg_plugin_registry_t * reg, 00343 const char * location, 00344 const bg_plugin_info_t * info, 00345 bg_plugin_handle_t ** ret, 00346 bg_input_callbacks_t * callbacks, int prefer_edl); 00347 00362 int bg_input_plugin_load_edl(bg_plugin_registry_t * reg, 00363 const bg_edl_t * edl, 00364 const bg_plugin_info_t * info, 00365 bg_plugin_handle_t ** ret, 00366 bg_input_callbacks_t * callbacks); 00367 00368 /* Set the supported extensions and mimetypes for a plugin */ 00369 00379 void bg_plugin_registry_set_extensions(bg_plugin_registry_t * reg, 00380 const char * plugin_name, 00381 const char * extensions); 00382 00392 void bg_plugin_registry_set_protocols(bg_plugin_registry_t * reg, 00393 const char * plugin_name, 00394 const char * protocols); 00395 00405 void bg_plugin_registry_set_priority(bg_plugin_registry_t * reg, 00406 const char * plugin_name, 00407 int priority); 00408 00409 00416 bg_cfg_section_t * 00417 bg_plugin_registry_get_section(bg_plugin_registry_t * reg, 00418 const char * plugin_name); 00419 00429 void bg_plugin_registry_set_parameter_info(bg_plugin_registry_t * reg, 00430 uint32_t type_mask, 00431 uint32_t flag_mask, 00432 bg_parameter_info_t * ret); 00433 00443 void bg_plugin_registry_set_parameter_info_input(bg_plugin_registry_t * reg, 00444 uint32_t type_mask, 00445 uint32_t flag_mask, 00446 bg_parameter_info_t * ret); 00447 00448 00457 void bg_plugin_registry_set_parameter_input(void * data, const char * name, 00458 const bg_parameter_value_t * val); 00459 00460 int bg_plugin_registry_get_parameter_input(void * data, const char * name, 00461 bg_parameter_value_t * val); 00462 00463 00480 bg_parameter_info_t * 00481 bg_plugin_registry_create_encoder_parameters(bg_plugin_registry_t * reg, 00482 uint32_t stream_type_mask, 00483 uint32_t flag_mask); 00484 00494 const char * 00495 bg_encoder_section_get_plugin(bg_plugin_registry_t * plugin_reg, 00496 bg_cfg_section_t * s, 00497 bg_stream_type_t stream_type, 00498 int stream_mask); 00499 00511 void 00512 bg_encoder_section_get_plugin_config(bg_plugin_registry_t * plugin_reg, 00513 bg_cfg_section_t * s, 00514 bg_stream_type_t stream_type, 00515 int stream_mask, 00516 bg_cfg_section_t ** section_ret, 00517 const bg_parameter_info_t ** params_ret); 00518 00529 void 00530 bg_encoder_section_get_stream_config(bg_plugin_registry_t * plugin_reg, 00531 bg_cfg_section_t * s, 00532 bg_stream_type_t stream_type, 00533 int stream_mask, 00534 bg_cfg_section_t ** section_ret, 00535 const bg_parameter_info_t ** params_ret); 00536 00537 00547 bg_cfg_section_t * 00548 bg_encoder_section_get_from_registry(bg_plugin_registry_t * plugin_reg, 00549 const bg_parameter_info_t * parameters, 00550 uint32_t type_mask, 00551 uint32_t flag_mask); 00552 00563 void 00564 bg_encoder_section_store_in_registry(bg_plugin_registry_t * plugin_reg, 00565 bg_cfg_section_t * s, 00566 const bg_parameter_info_t * parameters, 00567 uint32_t type_mask, 00568 uint32_t flag_mask); 00569 00570 00582 void bg_plugin_registry_set_default(bg_plugin_registry_t * reg, 00583 bg_plugin_type_t type, uint32_t flag_mask, 00584 const char * plugin_name); 00585 00595 const bg_plugin_info_t * bg_plugin_registry_get_default(bg_plugin_registry_t * reg, 00596 bg_plugin_type_t type, uint32_t flag_mask); 00597 00598 00621 void bg_plugin_registry_set_encode_audio_to_video(bg_plugin_registry_t * reg, 00622 int audio_to_video); 00623 00630 int bg_plugin_registry_get_encode_audio_to_video(bg_plugin_registry_t * reg); 00631 00638 void bg_plugin_registry_set_encode_subtitle_text_to_video(bg_plugin_registry_t * reg, 00639 int subtitle_text_to_video); 00640 00647 int bg_plugin_registry_get_encode_subtitle_text_to_video(bg_plugin_registry_t * reg); 00648 00655 void bg_plugin_registry_set_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg, 00656 int subtitle_overlay_to_video); 00657 00663 int bg_plugin_registry_get_encode_subtitle_overlay_to_video(bg_plugin_registry_t * reg); 00664 00671 void bg_plugin_registry_set_encode_pp(bg_plugin_registry_t * reg, 00672 int encode_pp); 00673 00679 int bg_plugin_registry_get_encode_pp(bg_plugin_registry_t * reg); 00680 00687 void bg_plugin_registry_set_visualize(bg_plugin_registry_t * reg, 00688 int enable); 00689 00696 int bg_plugin_registry_get_visualize(bg_plugin_registry_t * reg); 00697 00698 00707 void bg_plugin_registry_add_device(bg_plugin_registry_t * reg, 00708 const char * plugin_name, 00709 const char * device, 00710 const char * name); 00711 00724 void bg_plugin_registry_set_device_name(bg_plugin_registry_t * reg, 00725 const char * plugin_name, 00726 const char * device, 00727 const char * name); 00728 00729 /* Rescan the available devices */ 00730 00740 void bg_plugin_registry_find_devices(bg_plugin_registry_t * reg, 00741 const char * plugin_name); 00742 00754 void bg_plugin_registry_remove_device(bg_plugin_registry_t * reg, 00755 const char * plugin_name, 00756 const char * device, 00757 const char * name); 00758 00771 gavl_video_frame_t * bg_plugin_registry_load_image(bg_plugin_registry_t * reg, 00772 const char * filename, 00773 gavl_video_format_t * format, 00774 gavl_metadata_t * m); 00775 00776 /* Same as above for writing. Does implicit pixelformat conversion */ 00777 00787 void 00788 bg_plugin_registry_save_image(bg_plugin_registry_t * reg, 00789 const char * filename, 00790 gavl_video_frame_t * frame, 00791 const gavl_video_format_t * format, 00792 const gavl_metadata_t * m); 00793 00794 00806 int bg_get_thumbnail(const char * gml, 00807 bg_plugin_registry_t * plugin_reg, 00808 char ** thumbnail_filename_ret, 00809 gavl_video_frame_t ** frame_ret, 00810 gavl_video_format_t * format_ret); 00811 00812 00813 /* 00814 * These are the actual loading/unloading functions 00815 * (loader.c) 00816 */ 00817 00818 /* Load a plugin and return handle with reference count of 1 */ 00819 00828 bg_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t * reg, 00829 const bg_plugin_info_t * info); 00830 00841 bg_plugin_handle_t * bg_ov_plugin_load(bg_plugin_registry_t * reg, 00842 const bg_plugin_info_t * info, 00843 const char * window_id); 00844 00849 void bg_plugin_lock(bg_plugin_handle_t * h); 00850 00855 void bg_plugin_unlock(bg_plugin_handle_t * h); 00856 00857 /* Reference counting for input plugins */ 00858 00863 void bg_plugin_ref(bg_plugin_handle_t * h); 00864 00865 /* Plugin will be unloaded when refcount is zero */ 00866 00874 void bg_plugin_unref(bg_plugin_handle_t * h); 00875 00887 void bg_plugin_unref_nolock(bg_plugin_handle_t * h); 00888 00897 bg_plugin_info_t * bg_plugin_info_create(const bg_plugin_common_t * plugin); 00898 00907 bg_plugin_handle_t * bg_plugin_handle_create(); 00908 00909 00910 #endif // __BG_PLUGINREGISTRY_H_