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
56
61typedef 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
124
131typedef struct
132 {
133 char ** blacklist;
136
143typedef 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;
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);
253const bg_plugin_info_t *
255 uint32_t type_mask, uint32_t flag_mask);
256
264const bg_plugin_info_t *
266
277const bg_plugin_info_t *
279 const char * filename, int type_mask);
280
291const bg_plugin_info_t *
293 const char * mimetype, int type_mask);
294
295
296
305const bg_plugin_info_t *
308 int typemask, int flagmask);
309
310
317const 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
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
512void bg_plugin_registry_set_parameter_input(void * data, const char * name,
513 const bg_parameter_value_t * val);
514
515int bg_plugin_registry_get_parameter_input(void * data, const char * name,
517
518
537 uint32_t stream_type_mask,
538 uint32_t flag_mask,
539 int stream_params);
540
554 uint32_t flag_mask);
555
568void
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
598const char *
601 bg_stream_type_t stream_type,
602 int stream_mask);
603
615void
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
633void
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
653 const bg_parameter_info_t * parameters,
654 uint32_t type_mask,
655 uint32_t flag_mask);
656
667void
670 const bg_parameter_info_t * parameters,
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
891void
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
910int 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
927char * 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
971void bg_plugin_lock(void * h);
972
977void 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_
struct bg_cfg_section_s bg_cfg_section_t
Configuration section.
Definition cfg_registry.h:59
gavl_codec_id_t
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 * 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.
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 bg_plugin_registry_get_encode_pp(bg_plugin_registry_t *reg)
Query whether postprocessing should be done after encoding.
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.
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.
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.
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.
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_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.
void bg_plugin_registry_set_visualize(bg_plugin_registry_t *reg, int enable)
Specify whether visualizations should be enabled.
int bg_plugin_registry_get_visualize(bg_plugin_registry_t *reg)
Query whether visualizations should be enabled.
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.
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_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.
void bg_plugin_registry_set_protocols(bg_plugin_registry_t *reg, const char *plugin_name, const char *protocols)
Set protocols for a plugin.
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.
void bg_plugin_registry_remove_device(bg_plugin_registry_t *reg, const char *plugin_name, const char *device, const char *name)
Remove a device.
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.
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.
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_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.
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.
const bg_plugin_info_t * bg_plugin_find_by_name(bg_plugin_registry_t *reg, const char *name)
Find a plugin by it's unique short name.
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_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.
char ** bg_plugin_registry_get_plugins(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask)
Get a list of plugins.
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.
void bg_plugin_registry_set_priority(bg_plugin_registry_t *reg, const char *plugin_name, int priority)
Set priority for a 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.
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.
struct bg_plugin_registry_s bg_plugin_registry_t
Opaque handle for a plugin registry.
Definition pluginregistry.h:143
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_unref_nolock(bg_plugin_handle_t *h)
Decrease the reference count without locking.
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.
void bg_plugin_registry_set_extensions(bg_plugin_registry_t *reg, const char *plugin_name, const char *extensions)
Set file extensions for a plugin.
bg_plugin_api_t
Identifiers for plugin APIs.
Definition pluginregistry.h:50
void bg_plugin_ref(bg_plugin_handle_t *h)
Increase the reference count.
int bg_plugin_registry_get_num_plugins(bg_plugin_registry_t *reg, uint32_t type_mask, uint32_t flag_mask)
Count plugins.
void bg_plugin_registry_scan_devices(bg_plugin_registry_t *plugin_reg, uint32_t type_mask, uint32_t flag_mask)
Scan for pluggable devices.
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.
void bg_plugin_lock(void *h)
Lock a plugin.
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_add_device(bg_plugin_registry_t *reg, const char *plugin_name, const char *device, const char *name)
Add a device to a plugin.
int bg_plugin_registry_changed(bg_plugin_registry_t *reg)
Check if the plugin registry was changed.
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.
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.
void bg_plugin_registry_find_devices(bg_plugin_registry_t *reg, const char *plugin_name)
Let a plugin rescan for devices.
void bg_plugin_save_metadata(bg_plugin_handle_t *h)
Save the metadata to an xml file.
void bg_plugin_registry_free_plugins(char **plugins)
Free a plugin list.
bg_plugin_registry_t * bg_plugin_registry_create(bg_cfg_section_t *section)
Create a plugin registry.
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_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.
void bg_plugin_unlock(void *h)
Unlock a plugin.
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.
bg_stream_type_t
Identifiers for stream types.
Definition pluginregistry.h:62
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_plugin_handle_t * bg_plugin_load(bg_plugin_registry_t *reg, const bg_plugin_info_t *info)
Load a plugin.
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.
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.
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.
bg_plugin_handle_t * bg_plugin_handle_create()
Create an empty plugin handle.
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_PLUGIN_API_GMERLIN
Always 0 so native plugins can leave this empty.
Definition pluginregistry.h:51
@ BG_PLUGIN_API_LADSPA
Ladspa API.
Definition pluginregistry.h:52
@ BG_PLUGIN_API_FREI0R
frei0r
Definition pluginregistry.h:54
@ BG_PLUGIN_API_LV
Libvisual.
Definition pluginregistry.h:53
bg_plugin_type_t
Plugin types.
Definition plugin.h:191
Device description.
Definition plugin.h:222
Callbacks for input plugins.
Definition plugin.h:368
Parmeter description.
Definition parameter.h:135
Base structure common to all plugins.
Definition plugin.h:261
Handle of a loaded plugin.
Definition pluginregistry.h:160
pthread_mutex_t mutex
dll_handle (don't touch, use bg_plugin_lock and bg_plugin_unlock)
Definition pluginregistry.h:164
const bg_plugin_info_t * info
Info about this plugin.
Definition pluginregistry.h:172
const bg_plugin_common_t * plugin
Common structure, cast this to the derived type (e.g. bg_input_plugin_t).
Definition pluginregistry.h:170
void * dll_handle
dll_handle (don't touch)
Definition pluginregistry.h:163
void * priv
Private handle, passed as the first argument to most plugin functions.
Definition pluginregistry.h:173
int refcount
Reference counter (don't touch, use bg_plugin_ref and bg_plugin_unref)
Definition pluginregistry.h:165
gavl_edl_t * edl
EDL.
Definition pluginregistry.h:176
bg_plugin_common_t * plugin_nc
Used for dynamic allocation. Never touch this.
Definition pluginregistry.h:171
bg_plugin_registry_t * plugin_reg
The plugin registry, from which the plugin was loaded.
Definition pluginregistry.h:166
Information about a plugin.
Definition pluginregistry.h:80
char * mimetypes
Mimetypes, this plugin can handle.
Definition pluginregistry.h:86
char * description
Description of what the plugin does.
Definition pluginregistry.h:91
int flags
Flags (see Plugin flags)
Definition pluginregistry.h:100
char * cmp_name
Name used for alphabetical sorting. Not for external use.
Definition pluginregistry.h:121
bg_parameter_info_t * audio_parameters
Parameters, which can be passed to set_audio_parameter.
Definition pluginregistry.h:115
bg_parameter_info_t * overlay_parameters
Parameters, which can be passed to set_overlay_parameter.
Definition pluginregistry.h:119
bg_parameter_info_t * parameters
Parameters, which can be passed to the plugin.
Definition pluginregistry.h:107
char * gettext_domain
First argument for bindtextdomain().
Definition pluginregistry.h:81
int max_video_streams
For encoders: Maximum number of video streams (-1 means infinite)
Definition pluginregistry.h:111
char * extensions
Extensions, this plugin can handle.
Definition pluginregistry.h:87
bg_parameter_info_t * video_parameters
Parameters, which can be passed to set_video_parameter.
Definition pluginregistry.h:116
bg_plugin_type_t type
Plugin type.
Definition pluginregistry.h:99
char * protocols
Network protocols, this plugin can handle.
Definition pluginregistry.h:88
char * gettext_directory
Second argument for bindtextdomain().
Definition pluginregistry.h:82
bg_plugin_info_t * next
Used for chaining, never touch this.
Definition pluginregistry.h:105
bg_device_info_t * devices
Device list returned by the plugin.
Definition pluginregistry.h:103
char * module_filename
Path of the shared module.
Definition pluginregistry.h:93
bg_plugin_api_t api
API of the plugin.
Definition pluginregistry.h:96
gavl_codec_id_t * compressions
Compressions, this plugin can handle.
Definition pluginregistry.h:89
int max_text_streams
For encoders: Maximum number of text subtitle streams (-1 means infinite)
Definition pluginregistry.h:112
char * long_name
Humanized name.
Definition pluginregistry.h:85
char * name
unique short name
Definition pluginregistry.h:84
long module_time
Modification time of the shared module, needed internally.
Definition pluginregistry.h:94
int max_audio_streams
For encoders: Maximum number of audio streams (-1 means infinite)
Definition pluginregistry.h:110
int index
Index inside the module. Always 0 for native plugins.
Definition pluginregistry.h:97
int max_overlay_streams
For encoders: Maximum number of overlay subtitle streams (-1 means infinite)
Definition pluginregistry.h:113
int priority
Priority (1..10)
Definition pluginregistry.h:101
bg_parameter_info_t * text_parameters
Parameters, which can be passed to set_text_parameter.
Definition pluginregistry.h:118
Creation options for a plugin registry.
Definition pluginregistry.h:132
int dont_save
If 1, don't save the registry after it was created.
Definition pluginregistry.h:134
char ** blacklist
Plugins, which should be ignored.
Definition pluginregistry.h:133
Container for a parameter value.
Definition parameter.h:83