gmerlin
pluginregistry.h
1 /*****************************************************************
2  * gmerlin - a general purpose multimedia framework and applications
3  *
4  * Copyright (c) 2001 - 2012 Members of the Gmerlin project
5  * gmerlin-general@lists.sourceforge.net
6  * http://gmerlin.sourceforge.net
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * *****************************************************************/
21 
22 #ifndef __BG_PLUGINREGISTRY_H_
23 #define __BG_PLUGINREGISTRY_H_
24 
25 /* Plugin registry */
26 #include <pthread.h>
27 
28 #include <gmerlin/plugin.h>
29 #include <gmerlin/cfg_registry.h>
30 
49 typedef enum
50  {
56 
61 typedef enum
62  {
63  BG_STREAM_AUDIO = (1<<0),
64  BG_STREAM_TEXT = (1<<1),
65  BG_STREAM_OVERLAY = (1<<2),
66  BG_STREAM_VIDEO = (1<<3),
68 
74 
80  {
81  char * gettext_domain;
83 
84  char * name;
85  char * long_name;
86  char * mimetypes;
87  char * extensions;
88  char * protocols;
90 
91  char * description;
92 
93  char * module_filename;
94  long module_time;
95 
97  int index;
98 
100  int flags;
101  int priority;
102 
104 
106 
108 
109 
114 
117 
120 
121  char * cmp_name;
122 
123  };
124 
131 typedef struct
132  {
133  char ** blacklist;
134  int dont_save;
136 
143 typedef struct bg_plugin_registry_s bg_plugin_registry_t;
144 
150 
160  {
161  /* Private members, should not be accessed! */
162 
163  void * dll_handle;
164  pthread_mutex_t mutex;
165  int refcount;
167 
168  /* These are for use by applications */
169 
173  void * priv;
174 
175  // char * location; //!< Applications can save the argument of an open call here
176  gavl_edl_t * edl;
177  };
178 
179 /*
180  * pluginregistry.c
181  */
182 
193 
205  const bg_plugin_registry_options_t * opt);
206 
207 
208 
221  uint32_t type_mask, uint32_t flag_mask);
222 
223 
230 
240  uint32_t type_mask, uint32_t flag_mask);
253 const bg_plugin_info_t *
255  uint32_t type_mask, uint32_t flag_mask);
256 
264 const bg_plugin_info_t *
266 
277 const bg_plugin_info_t *
279  const char * filename, int type_mask);
280 
291 const bg_plugin_info_t *
293  const char * mimetype, int type_mask);
294 
295 
296 
305 const bg_plugin_info_t *
307  gavl_codec_id_t id,
308  int typemask, int flagmask);
309 
310 
317 const bg_plugin_info_t *
319  const char * protocol);
320 
321 
322 /* Another method: Return long names as strings (NULL terminated) */
323 
339  uint32_t type_mask,
340  uint32_t flag_mask);
341 
346 void bg_plugin_registry_free_plugins(char ** plugins);
347 
348 
349 /* Finally a version for finding/loading plugins */
350 
351 /*
352  * info can be NULL
353  * If ret is non NULL before the call, the plugin will be unrefed
354  *
355  * Return values are 0 for error, 1 on success
356  */
357 
374  const char * location,
375  const bg_plugin_info_t * info,
376  bg_plugin_handle_t ** ret,
377  bg_input_callbacks_t * callbacks, int prefer_edl);
378 
396  const char * location,
397  const bg_plugin_info_t * info,
398  bg_plugin_handle_t ** ret,
399  bg_input_callbacks_t * callbacks, int prefer_edl,
400  int * track);
401 
402 
418  const gavl_edl_t * edl,
419  const bg_plugin_info_t * info,
420  bg_plugin_handle_t ** ret,
421  bg_input_callbacks_t * callbacks);
422 
423 /* Set the supported extensions and mimetypes for a plugin */
424 
435  const char * plugin_name,
436  const char * extensions);
437 
448  const char * plugin_name,
449  const char * protocols);
450 
461  const char * plugin_name,
462  int priority);
463 
464 
473  const char * plugin_name);
474 
485  uint32_t type_mask,
486  uint32_t flag_mask,
487  bg_parameter_info_t * ret);
488 
499  uint32_t type_mask,
500  uint32_t flag_mask,
501  bg_parameter_info_t * ret);
502 
503 
512 void bg_plugin_registry_set_parameter_input(void * data, const char * name,
513  const bg_parameter_value_t * val);
514 
515 int bg_plugin_registry_get_parameter_input(void * data, const char * name,
516  bg_parameter_value_t * val);
517 
518 
537  uint32_t stream_type_mask,
538  uint32_t flag_mask,
539  int stream_params);
540 
554  uint32_t flag_mask);
555 
568 void
570  bg_plugin_handle_t ** plugin,
571  const char * name,
572  const bg_parameter_value_t * val);
573 
586  bg_cfg_section_t * section);
587 
588 
598 const char *
600  bg_cfg_section_t * s,
601  bg_stream_type_t stream_type,
602  int stream_mask);
603 
615 void
617  bg_cfg_section_t * s,
618  bg_stream_type_t stream_type,
619  int stream_mask,
620  bg_cfg_section_t ** section_ret,
621  const bg_parameter_info_t ** params_ret);
622 
633 void
635  bg_cfg_section_t * s,
636  bg_stream_type_t stream_type,
637  int stream_mask,
638  bg_cfg_section_t ** section_ret,
639  const bg_parameter_info_t ** params_ret);
640 
641 
654  uint32_t type_mask,
655  uint32_t flag_mask);
656 
667 void
669  bg_cfg_section_t * s,
671  uint32_t type_mask,
672  uint32_t flag_mask);
673 
674 
687  bg_plugin_type_t type, uint32_t flag_mask,
688  const char * plugin_name);
689 
700  bg_plugin_type_t type, uint32_t flag_mask);
701 
702 
726  int audio_to_video);
727 
735 
743  int text_to_video);
744 
752 
760  int overlay_to_video);
761 
768 
776  int encode_pp);
777 
784 
792  int enable);
793 
801 
802 
812  const char * plugin_name,
813  const char * device,
814  const char * name);
815 
829  const char * plugin_name,
830  const char * device,
831  const char * name);
832 
833 /* Rescan the available devices */
834 
845  const char * plugin_name);
846 
859  const char * plugin_name,
860  const char * device,
861  const char * name);
862 
876  const char * filename,
877  gavl_video_format_t * format,
878  gavl_metadata_t * m);
879 
880 /* Same as above for writing. Does implicit pixelformat conversion */
881 
891 void
893  const char * filename,
894  gavl_video_frame_t * frame,
895  const gavl_video_format_t * format,
896  const gavl_metadata_t * m);
897 
898 
910 int bg_get_thumbnail(const char * gml,
911  bg_plugin_registry_t * plugin_reg,
912  char ** thumbnail_filename_ret,
913  gavl_video_frame_t ** frame_ret,
914  gavl_video_format_t * format_ret);
915 
927 char * bg_make_thumbnail(bg_plugin_registry_t * plugin_reg,
928  gavl_video_frame_t * in_frame,
929  gavl_video_format_t * input_format,
930  int max_width, int max_height,
931  const char * out_file_base,
932  const char * mimetype);
933 
934 
935 /*
936  * These are the actual loading/unloading functions
937  * (loader.c)
938  */
939 
940 /* Load a plugin and return handle with reference count of 1 */
941 
951  const bg_plugin_info_t * info);
952 
964  const bg_plugin_info_t * info,
965  const char * window_id);
966 
971 void bg_plugin_lock(void * h);
972 
977 void bg_plugin_unlock(void * h);
978 
979 /* Reference counting for input plugins */
980 
986 
987 /* Plugin will be unloaded when refcount is zero */
988 
997 
1010 
1020 
1030 
1040 
1046 
1047 #endif // __BG_PLUGINREGISTRY_H_
void bg_plugin_registry_set_compressor_parameter(bg_plugin_registry_t *plugin_reg, bg_plugin_handle_t **plugin, const char *name, const bg_parameter_value_t *val)
Set a compressor parameter.
void bg_plugin_unref_nolock(bg_plugin_handle_t *h)
Decrease the reference count without locking.
char ** blacklist
Plugins, which should be ignored.
Definition: pluginregistry.h:133
bg_parameter_info_t * bg_plugin_registry_create_encoder_parameters(bg_plugin_registry_t *reg, uint32_t stream_type_mask, uint32_t flag_mask, int stream_params)
Create a parameter array for encoders.
void bg_plugin_registry_add_device(bg_plugin_registry_t *reg, const char *plugin_name, const char *device, const char *name)
Add a device to a plugin.
struct bg_cfg_section_s bg_cfg_section_t
Configuration section.
Definition: cfg_registry.h:59
Information about a plugin.
Definition: pluginregistry.h:79
void * dll_handle
dll_handle (don&#39;t touch)
Definition: pluginregistry.h:163
bg_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t *reg, const bg_plugin_info_t *info)
Load a plugin.
gavl_edl_t * edl
EDL.
Definition: pluginregistry.h:176
bg_cfg_section_t * bg_encoder_section_get_from_registry(bg_plugin_registry_t *plugin_reg, const bg_parameter_info_t *parameters, uint32_t type_mask, uint32_t flag_mask)
Get an encoder configuration section from a registry.
int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask)
Count plugins.
Ladspa API.
Definition: pluginregistry.h:52
const bg_plugin_info_t * bg_plugin_find_by_compression(bg_plugin_registry_t *reg, gavl_codec_id_t id, int typemask, int flagmask)
Find a plugin by the compression ID.
char * long_name
Humanized name.
Definition: pluginregistry.h:85
void bg_plugin_registry_save_image(bg_plugin_registry_t *reg, const char *filename, gavl_video_frame_t *frame, const gavl_video_format_t *format, const gavl_metadata_t *m)
Save an image.
void bg_plugin_registry_set_encode_text_to_video(bg_plugin_registry_t *reg, int text_to_video)
Specify whether text subtitles should be encoded into the same file as the video if possible...
const bg_plugin_info_t * info
Info about this plugin.
Definition: pluginregistry.h:172
int bg_plugin_registry_get_encode_overlay_to_video(bg_plugin_registry_t *reg)
Query whether overlay subtitles should be encoded into the same file as the video if possible...
Callbacks for input plugins.
Definition: plugin.h:366
void bg_plugin_unlock(void *h)
Unlock a plugin.
bg_parameter_info_t * overlay_parameters
Parameters, which can be passed to set_overlay_parameter.
Definition: pluginregistry.h:119
gavl_video_frame_t * bg_plugin_registry_load_image(bg_plugin_registry_t *reg, const char *filename, gavl_video_format_t *format, gavl_metadata_t *m)
Load an image.
bg_plugin_info_t * next
Used for chaining, never touch this.
Definition: pluginregistry.h:105
char * extensions
Extensions, this plugin can handle.
Definition: pluginregistry.h:87
void bg_plugin_registry_set_parameter_info_input(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask, bg_parameter_info_t *ret)
Set a parameter info for selecting and configuring input plugins.
int bg_plugin_registry_get_encode_text_to_video(bg_plugin_registry_t *reg)
Query whether text subtitles should be encoded into the same file as the video if possible...
char * description
Description of what the plugin does.
Definition: pluginregistry.h:91
Creation options for a plugin registry.
Definition: pluginregistry.h:131
char * name
unique short name
Definition: pluginregistry.h:84
void bg_plugin_unref(bg_plugin_handle_t *h)
Decrease the reference count.
void bg_plugin_registry_destroy(bg_plugin_registry_t *reg)
Destroy a plugin registry.
bg_plugin_api_t
Identifiers for plugin APIs.
Definition: pluginregistry.h:49
void bg_plugin_registry_set_protocols(bg_plugin_registry_t *reg, const char *plugin_name, const char *protocols)
Set protocols for a plugin.
Handle of a loaded plugin.
Definition: pluginregistry.h:159
int bg_plugin_registry_get_encode_audio_to_video(bg_plugin_registry_t *reg)
Query whether audio should be encoded into the same file as the video if possible.
Device description.
Definition: plugin.h:220
void bg_plugin_registry_set_encode_pp(bg_plugin_registry_t *reg, int encode_pp)
Specify whether postprocessing should be done after encoding.
void bg_plugin_registry_set_parameter_info(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask, bg_parameter_info_t *ret)
Set a parameter info for selecting and configuring plugins.
int dont_save
If 1, don&#39;t save the registry after it was created.
Definition: pluginregistry.h:134
void bg_plugin_registry_find_devices(bg_plugin_registry_t *reg, const char *plugin_name)
Let a plugin rescan for devices.
int bg_input_plugin_load(bg_plugin_registry_t *reg, const char *location, const bg_plugin_info_t *info, bg_plugin_handle_t **ret, bg_input_callbacks_t *callbacks, int prefer_edl)
Load and open an input plugin.
bg_plugin_api_t api
API of the plugin.
Definition: pluginregistry.h:96
bg_parameter_info_t * bg_plugin_registry_create_compressor_parameters(bg_plugin_registry_t *reg, uint32_t flag_mask)
Create a parameter array for compressors.
bg_parameter_info_t * parameters
Parameters, which can be passed to the plugin.
Definition: pluginregistry.h:107
Libvisual.
Definition: pluginregistry.h:53
void bg_plugin_registry_set_extensions(bg_plugin_registry_t *reg, const char *plugin_name, const char *extensions)
Set file extensions for a plugin.
const bg_plugin_common_t * plugin
Common structure, cast this to the derived type (e.g. bg_input_plugin_t).
Definition: pluginregistry.h:170
int max_text_streams
For encoders: Maximum number of text subtitle streams (-1 means infinite)
Definition: pluginregistry.h:112
bg_device_info_t * devices
Device list returned by the plugin.
Definition: pluginregistry.h:103
bg_plugin_handle_t * bg_ov_plugin_load(bg_plugin_registry_t *reg, const bg_plugin_info_t *info, const char *window_id)
Load a video output plugin.
const bg_plugin_info_t * bg_plugin_find_by_index(bg_plugin_registry_t *reg, int index, uint32_t type_mask, uint32_t flag_mask)
Find a plugin by index.
int bg_plugin_registry_get_encode_pp(bg_plugin_registry_t *reg)
Query whether postprocessing should be done after encoding.
const bg_plugin_info_t * bg_plugin_find_by_protocol(bg_plugin_registry_t *reg, const char *protocol)
Find an input plugin for a network protocol.
void bg_encoder_section_get_stream_config(bg_plugin_registry_t *plugin_reg, bg_cfg_section_t *s, bg_stream_type_t stream_type, int stream_mask, bg_cfg_section_t **section_ret, const bg_parameter_info_t **params_ret)
Get the stream configuration for an encoding plugin.
void bg_plugin_lock(void *h)
Lock a plugin.
void bg_plugin_registry_set_encode_overlay_to_video(bg_plugin_registry_t *reg, int overlay_to_video)
Specify whether overlay subtitles should be encoded into the same file as the video if possible...
void bg_plugin_registry_set_default(bg_plugin_registry_t *reg, bg_plugin_type_t type, uint32_t flag_mask, const char *plugin_name)
Set the default for a particular plugin type.
int priority
Priority (1..10)
Definition: pluginregistry.h:101
bg_parameter_info_t * video_parameters
Parameters, which can be passed to set_video_parameter.
Definition: pluginregistry.h:116
int bg_plugin_registry_changed(bg_plugin_registry_t *reg)
Check if the plugin registry was changed.
char * mimetypes
Mimetypes, this plugin can handle.
Definition: pluginregistry.h:86
Parmeter description.
Definition: parameter.h:134
int max_audio_streams
For encoders: Maximum number of audio streams (-1 means infinite)
Definition: pluginregistry.h:110
struct bg_plugin_registry_s bg_plugin_registry_t
Opaque handle for a plugin registry.
Definition: pluginregistry.h:143
int bg_input_plugin_load_full(bg_plugin_registry_t *reg, const char *location, const bg_plugin_info_t *info, bg_plugin_handle_t **ret, bg_input_callbacks_t *callbacks, int prefer_edl, int *track)
Load and open an input plugin with URL redirection.
int max_video_streams
For encoders: Maximum number of video streams (-1 means infinite)
Definition: pluginregistry.h:111
int refcount
Reference counter (don&#39;t touch, use bg_plugin_ref and bg_plugin_unref)
Definition: pluginregistry.h:165
char * cmp_name
Name used for alphabetical sorting. Not for external use.
Definition: pluginregistry.h:121
void bg_plugin_registry_set_visualize(bg_plugin_registry_t *reg, int enable)
Specify whether visualizations should be enabled.
bg_plugin_handle_t * bg_plugin_handle_create()
Create an empty plugin handle.
const char * bg_encoder_section_get_plugin(bg_plugin_registry_t *plugin_reg, bg_cfg_section_t *s, bg_stream_type_t stream_type, int stream_mask)
Get the name for an encoding plugin.
bg_plugin_type_t type
Plugin type.
Definition: pluginregistry.h:99
void bg_plugin_registry_free_plugins(char **plugins)
Free a plugin list.
const bg_plugin_info_t * bg_plugin_find_by_name(bg_plugin_registry_t *reg, const char *name)
Find a plugin by it&#39;s unique short name.
bg_plugin_registry_t * plugin_reg
The plugin registry, from which the plugin was loaded.
Definition: pluginregistry.h:166
bg_plugin_registry_t * bg_plugin_registry_create(bg_cfg_section_t *section)
Create a plugin registry.
bg_cfg_section_t * bg_plugin_registry_get_section(bg_plugin_registry_t *reg, const char *plugin_name)
Get the config section belonging to a plugin.
long module_time
Modification time of the shared module, needed internally.
Definition: pluginregistry.h:94
const bg_plugin_info_t * bg_plugin_find_by_mimetype(bg_plugin_registry_t *reg, const char *mimetype, int type_mask)
Find a plugin by the mime type.
bg_plugin_info_t * bg_plugin_info_create(const bg_plugin_common_t *plugin)
Create a plugin info from a plugin.
void bg_plugin_registry_set_parameter_input(void *data, const char *name, const bg_parameter_value_t *val)
Set a parameter of an input plugin.
bg_stream_type_t
Identifiers for stream types.
Definition: pluginregistry.h:61
void bg_plugin_save_metadata(bg_plugin_handle_t *h)
Save the metadata to an xml file.
bg_plugin_common_t * plugin_nc
Used for dynamic allocation. Never touch this.
Definition: pluginregistry.h:171
char * protocols
Network protocols, this plugin can handle.
Definition: pluginregistry.h:88
void bg_plugin_ref(bg_plugin_handle_t *h)
Increase the reference count.
gavl_codec_id_t bg_plugin_registry_get_compressor_id(bg_plugin_registry_t *plugin_reg, bg_cfg_section_t *section)
Get a compression ID from a compressor section.
void bg_plugin_registry_set_priority(bg_plugin_registry_t *reg, const char *plugin_name, int priority)
Set priority for a plugin.
gavl_codec_id_t
const bg_plugin_info_t * bg_plugin_registry_get_default(bg_plugin_registry_t *reg, bg_plugin_type_t type, uint32_t flag_mask)
Set the default for a particular plugin type.
Base structure common to all plugins.
Definition: plugin.h:259
int bg_plugin_registry_get_visualize(bg_plugin_registry_t *reg)
Query whether visualizations should be enabled.
Container for a parameter value.
Definition: parameter.h:82
frei0r
Definition: pluginregistry.h:54
int flags
Flags (see Plugin flags)
Definition: pluginregistry.h:100
char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask)
Get a list of plugins.
void bg_encoder_section_get_plugin_config(bg_plugin_registry_t *plugin_reg, bg_cfg_section_t *s, bg_stream_type_t stream_type, int stream_mask, bg_cfg_section_t **section_ret, const bg_parameter_info_t **params_ret)
Get the plugin configuration for an encoding plugin.
bg_plugin_type_t
Plugin types.
Definition: plugin.h:189
bg_parameter_info_t * text_parameters
Parameters, which can be passed to set_text_parameter.
Definition: pluginregistry.h:118
bg_plugin_registry_t * bg_plugin_registry_create_with_options(bg_cfg_section_t *section, const bg_plugin_registry_options_t *opt)
Create a plugin registry with options.
void bg_encoder_section_store_in_registry(bg_plugin_registry_t *plugin_reg, bg_cfg_section_t *s, const bg_parameter_info_t *parameters, uint32_t type_mask, uint32_t flag_mask)
Store an encoder configuration in a registry.
Always 0 so native plugins can leave this empty.
Definition: pluginregistry.h:51
char * gettext_domain
First argument for bindtextdomain().
Definition: pluginregistry.h:81
int max_overlay_streams
For encoders: Maximum number of overlay subtitle streams (-1 means infinite)
Definition: pluginregistry.h:113
void bg_plugin_registry_remove_device(bg_plugin_registry_t *reg, const char *plugin_name, const char *device, const char *name)
Remove a device.
void bg_plugin_registry_set_device_name(bg_plugin_registry_t *reg, const char *plugin_name, const char *device, const char *name)
Change the name of a device.
int bg_input_plugin_load_edl(bg_plugin_registry_t *reg, const gavl_edl_t *edl, const bg_plugin_info_t *info, bg_plugin_handle_t **ret, bg_input_callbacks_t *callbacks)
Load and open an edl decoder.
void bg_plugin_registry_set_encode_audio_to_video(bg_plugin_registry_t *reg, int audio_to_video)
Specify whether audio should be encoded into the same file as the video if possible.
pthread_mutex_t mutex
dll_handle (don&#39;t touch, use bg_plugin_lock and bg_plugin_unlock)
Definition: pluginregistry.h:164
gavl_codec_id_t * compressions
Compressions, this plugin can handle.
Definition: pluginregistry.h:89
void bg_plugin_registry_scan_devices(bg_plugin_registry_t *plugin_reg, uint32_t type_mask, uint32_t flag_mask)
Scan for pluggable devices.
void * priv
Private handle, passed as the first argument to most plugin functions.
Definition: pluginregistry.h:173
bg_parameter_info_t * audio_parameters
Parameters, which can be passed to set_audio_parameter.
Definition: pluginregistry.h:115
int index
Index inside the module. Always 0 for native plugins.
Definition: pluginregistry.h:97
char * module_filename
Path of the shared module.
Definition: pluginregistry.h:93
char * gettext_directory
Second argument for bindtextdomain().
Definition: pluginregistry.h:82
const bg_plugin_info_t * bg_plugin_find_by_filename(bg_plugin_registry_t *reg, const char *filename, int type_mask)
Find a plugin by the file extension.