00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BG_PLUGIN_H_
00023 #define __BG_PLUGIN_H_
00024
00025 #include <gavl/gavl.h>
00026 #include <gmerlin/parameter.h>
00027 #include <gmerlin/streaminfo.h>
00028 #include <gmerlin/accelerator.h>
00029 #include <gmerlin/edl.h>
00030
00074 typedef int (*bg_read_audio_func_t)(void * priv, gavl_audio_frame_t* frame, int stream,
00075 int num_samples);
00076
00088 typedef int (*bg_read_video_func_t)(void * priv, gavl_video_frame_t* frame, int stream);
00089
00099 #define BG_PLUGIN_REMOVABLE (1<<0) //!< Plugin handles removable media (CD, DVD etc.)
00100 #define BG_PLUGIN_FILE (1<<1) //!< Plugin reads/writes files
00101 #define BG_PLUGIN_RECORDER (1<<2) //!< Plugin does hardware recording
00102
00103 #define BG_PLUGIN_URL (1<<3) //!< Plugin can load URLs
00104 #define BG_PLUGIN_PLAYBACK (1<<4) //!< Plugin is an audio or video driver for playback
00105
00106 #define BG_PLUGIN_BYPASS (1<<5) //!< Plugin can send A/V data directly to the output bypassing the player engine
00107
00108 #define BG_PLUGIN_KEEP_RUNNING (1<<6) //!< Plugin should not be stopped and restarted if tracks change
00109
00110 #define BG_PLUGIN_INPUT_HAS_SYNC (1<<7) //!< For input plugins in bypass mode: Plugin will set the time via callback
00111
00112 #define BG_PLUGIN_STDIN (1<<8) //!< Plugin can read from stdin ("-")
00113
00114 #define BG_PLUGIN_TUNER (1<<9) //!< Plugin has some kind of tuner. Channels will be loaded as tracks.
00115 #define BG_PLUGIN_FILTER_1 (1<<10) //!< Plugin acts as a filter with one input
00116
00117 #define BG_PLUGIN_EMBED_WINDOW (1<<11) //!< Plugin can embed it's window into another application
00118
00119 #define BG_PLUGIN_VISUALIZE_FRAME (1<<12) //!< Visualization plugin outputs video frames
00120
00121 #define BG_PLUGIN_VISUALIZE_GL (1<<13) //!< Visualization plugin outputs via OpenGL
00122
00123 #define BG_PLUGIN_PP (1<<14) //!< Postprocessor
00124 #define BG_PLUGIN_CALLBACKS (1<<15) //!< Plugin can be opened from callbacks
00125
00126 #define BG_PLUGIN_UNSUPPORTED (1<<24) //!< Plugin is not supported. Only for a foreign API plugins
00127
00128
00129 #define BG_PLUGIN_ALL 0xFFFFFFFF //!< Mask of all possible plugin flags
00130
00134 #define BG_PLUGIN_API_VERSION 19
00135
00136
00137
00138
00139 #define BG_GET_PLUGIN_API_VERSION \
00140 int get_plugin_api_version() __attribute__ ((visibility("default"))); \
00141 int get_plugin_api_version() { return BG_PLUGIN_API_VERSION; }
00142
00143 #define BG_PLUGIN_PRIORITY_MIN 1
00144 #define BG_PLUGIN_PRIORITY_MAX 10
00145
00158 typedef enum
00159 {
00160 BG_STREAM_ACTION_OFF = 0,
00161 BG_STREAM_ACTION_DECODE,
00162
00163
00164
00165
00166 BG_STREAM_ACTION_BYPASS,
00167
00168
00169
00170
00171
00172
00173
00174
00175 } bg_stream_action_t;
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00194 typedef enum
00195 {
00196 BG_PLUGIN_NONE = 0,
00197 BG_PLUGIN_INPUT = (1<<0),
00198 BG_PLUGIN_OUTPUT_AUDIO = (1<<1),
00199 BG_PLUGIN_OUTPUT_VIDEO = (1<<2),
00200 BG_PLUGIN_RECORDER_AUDIO = (1<<3),
00201 BG_PLUGIN_RECORDER_VIDEO = (1<<4),
00202 BG_PLUGIN_ENCODER_AUDIO = (1<<5),
00203 BG_PLUGIN_ENCODER_VIDEO = (1<<6),
00204 BG_PLUGIN_ENCODER_SUBTITLE_TEXT = (1<<7),
00205 BG_PLUGIN_ENCODER_SUBTITLE_OVERLAY = (1<<8),
00206 BG_PLUGIN_ENCODER = (1<<9),
00207 BG_PLUGIN_ENCODER_PP = (1<<10),
00208 BG_PLUGIN_IMAGE_READER = (1<<11),
00209 BG_PLUGIN_IMAGE_WRITER = (1<<12),
00210 BG_PLUGIN_FILTER_AUDIO = (1<<13),
00211 BG_PLUGIN_FILTER_VIDEO = (1<<14),
00212 BG_PLUGIN_VISUALIZATION = (1<<15),
00213 BG_PLUGIN_AV_RECORDER = (1<<16),
00214 } bg_plugin_type_t;
00215
00224 typedef struct
00225 {
00226 char * device;
00227 char * name;
00228 } bg_device_info_t;
00229
00240 bg_device_info_t * bg_device_info_append(bg_device_info_t * arr,
00241 const char * device,
00242 const char * name);
00243
00249 void bg_device_info_destroy(bg_device_info_t * arr);
00250
00251
00252
00257 typedef struct bg_plugin_common_s bg_plugin_common_t;
00258
00263 struct bg_plugin_common_s
00264 {
00265 char * gettext_domain;
00266 char * gettext_directory;
00267
00268 char * name;
00269 char * long_name;
00270 bg_plugin_type_t type;
00271 int flags;
00272
00273 char * description;
00274
00275
00276
00277
00278
00279
00280
00281 int priority;
00282
00287 void * (*create)();
00288
00298 void (*destroy)(void* priv);
00299
00307 const bg_parameter_info_t * (*get_parameters)(void * priv);
00308
00312 bg_set_parameter_func_t set_parameter;
00313
00320 bg_get_parameter_func_t get_parameter;
00321
00331 int (*check_device)(const char * device, char ** name);
00332
00333
00341 bg_device_info_t * (*find_devices)();
00342
00343 };
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00360 typedef struct bg_input_callbacks_s bg_input_callbacks_t;
00361
00370 struct bg_input_callbacks_s
00371 {
00379 void (*track_changed)(void * data, int track);
00380
00389 void (*time_changed)(void * data, gavl_time_t time);
00390
00396 void (*duration_changed)(void * data, gavl_time_t duration);
00397
00405 void (*name_changed)(void * data, const char * name);
00406
00414 void (*metadata_changed)(void * data, const bg_metadata_t * m);
00415
00424 void (*buffer_notify)(void * data, float percentage);
00425
00439 int (*user_pass)(void * data, const char * resource,
00440 char ** username, char ** password);
00441
00453 void (*aspect_changed)(void * data, int stream,
00454 int pixel_width, int pixel_height);
00455
00456
00457 void * data;
00458
00459 };
00460
00461
00462
00463
00464
00469 typedef struct bg_input_plugin_s bg_input_plugin_t;
00470
00471
00481 struct bg_input_plugin_s
00482 {
00483 bg_plugin_common_t common;
00484
00490 const char * (*get_protocols)(void * priv);
00495 const char * (*get_mimetypes)(void * priv);
00496
00501 const char * (*get_extensions)(void * priv);
00502
00512 void (*set_callbacks)(void * priv, bg_input_callbacks_t * callbacks);
00513
00519 int (*open)(void * priv, const char * arg);
00520
00529 int (*open_fd)(void * priv, int fd, int64_t total_bytes,
00530 const char * mimetype);
00531
00543 int (*open_callbacks)(void * priv,
00544 int (*read_callback)(void * priv, uint8_t * data, int len),
00545 int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
00546 void * cb_priv, const char * filename, const char * mimetype,
00547 int64_t total_bytes);
00548
00554 const bg_edl_t * (*get_edl)(void * priv);
00555
00563 const char * (*get_disc_name)(void * priv);
00564
00573 int (*eject_disc)(const char * device);
00574
00582 int (*get_num_tracks)(void * priv);
00583
00600 bg_track_info_t * (*get_track_info)(void * priv, int track);
00601
00612 int (*set_track)(void * priv, int track);
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00634 int (*set_audio_stream)(void * priv, int stream, bg_stream_action_t action);
00635
00643 int (*set_video_stream)(void * priv, int stream, bg_stream_action_t action);
00644
00652 int (*set_subtitle_stream)(void * priv, int stream, bg_stream_action_t action);
00653
00665 int (*start)(void * priv);
00666
00679 bg_read_audio_func_t read_audio;
00680
00690 int (*has_still)(void * priv, int stream);
00691
00699 bg_read_video_func_t read_video;
00700
00707 int (*has_subtitle)(void * priv, int stream);
00708
00720 int (*read_subtitle_overlay)(void * priv,
00721 gavl_overlay_t*ovl, int stream);
00722
00741 int (*read_subtitle_text)(void * priv,
00742 char ** text, int * text_alloc,
00743 int64_t * start_time,
00744 int64_t * duration, int stream);
00745
00746
00747
00748
00758 int (*bypass)(void * priv);
00759
00765 void (*bypass_set_pause)(void * priv, int pause);
00766
00774 void (*bypass_set_volume)(void * priv, float volume);
00775
00787 void (*seek)(void * priv, int64_t * time, int scale);
00788
00796 void (*stop)(void * priv);
00797
00804 void (*close)(void * priv);
00805
00806 };
00807
00817 typedef struct bg_oa_plugin_s bg_oa_plugin_t;
00818
00825 struct bg_oa_plugin_s
00826 {
00827 bg_plugin_common_t common;
00828
00838 int (*open)(void * priv, gavl_audio_format_t* format);
00839
00846 int (*start)(void * priv);
00847
00853 void (*write_audio)(void * priv, gavl_audio_frame_t* frame);
00854
00863 int (*get_delay)(void * priv);
00864
00872 void (*stop)(void * priv);
00873
00880 void (*close)(void * priv);
00881 };
00882
00883
00884
00885
00886
00896 typedef struct bg_recorder_plugin_s bg_recorder_plugin_t;
00897
00904 struct bg_recorder_plugin_s
00905 {
00906 bg_plugin_common_t common;
00907
00917 int (*open)(void * priv, gavl_audio_format_t * audio_format, gavl_video_format_t * video_format);
00918
00921 bg_read_audio_func_t read_audio;
00922
00925 bg_read_video_func_t read_video;
00926
00931 void (*close)(void * priv);
00932 };
00933
00934
00935
00936
00937
00938
00939
00950 typedef struct bg_ov_callbacks_s bg_ov_callbacks_t;
00951
00957 struct bg_ov_callbacks_s
00958 {
00965 const bg_accelerator_map_t * accel_map;
00966
00972 int (*accel_callback)(void * data, int id);
00973
00987 int (*key_callback)(void * data, int key, int mask);
00988
00996 int (*key_release_callback)(void * data, int key, int mask);
00997
01007 int (*button_callback)(void * data, int x, int y, int button, int mask);
01008
01018 int (*button_release_callback)(void * data, int x, int y, int button, int mask);
01019
01028 int (*motion_callback)(void * data, int x, int y, int mask);
01029
01035 void (*show_window)(void * data, int show);
01036
01044 void (*brightness_callback)(void * data, float val);
01045
01053 void (*saturation_callback)(void * data, float val);
01054
01062 void (*contrast_callback)(void * data, float val);
01063
01071 void (*hue_callback)(void * data, float val);
01072
01073 void * data;
01074 };
01075
01076
01077
01082 typedef struct bg_ov_plugin_s bg_ov_plugin_t;
01083
01092 struct bg_ov_plugin_s
01093 {
01094 bg_plugin_common_t common;
01095
01105 void (*set_window)(void * priv, const char * window_id);
01106
01112 const char * (*get_window)(void * priv);
01113
01119 void (*set_window_title)(void * priv, const char * title);
01120
01121
01127 void (*set_callbacks)(void * priv, bg_ov_callbacks_t * callbacks);
01128
01139 int (*open)(void * priv, gavl_video_format_t * format, int keep_aspect);
01140
01152 gavl_video_frame_t * (*create_frame)(void * priv);
01153
01167 int (*add_overlay_stream)(void * priv, gavl_video_format_t * format);
01168
01181 gavl_overlay_t * (*create_overlay)(void * priv, int id);
01182
01189 void (*set_overlay)(void * priv, int stream, gavl_overlay_t * ovl);
01190
01198 void (*put_video)(void * priv, gavl_video_frame_t*frame);
01199
01209 void (*put_still)(void * priv, gavl_video_frame_t*frame);
01210
01219 void (*handle_events)(void * priv);
01220
01227 void (*update_aspect)(void * priv, int pixel_width, int pixel_height);
01228
01234 void (*destroy_frame)(void * priv, gavl_video_frame_t * frame);
01235
01242 void (*destroy_overlay)(void * priv, int id, gavl_overlay_t * ovl);
01243
01251 void (*close)(void * priv);
01252
01257 void (*show_window)(void * priv, int show);
01258 };
01259
01260
01261
01262
01263
01273 typedef struct bg_encoder_plugin_s bg_encoder_plugin_t;
01274
01275
01280 struct bg_encoder_plugin_s
01281 {
01282 bg_plugin_common_t common;
01283
01284 int max_audio_streams;
01285 int max_video_streams;
01286 int max_subtitle_text_streams;
01287 int max_subtitle_overlay_streams;
01288
01298 const char * (*get_extension)(void * priv);
01299
01307 int (*open)(void * data, const char * filename,
01308 const bg_metadata_t * metadata, const bg_chapter_list_t * chapter_list);
01309
01318 const char * (*get_filename)(void*);
01319
01320
01321
01329 const bg_parameter_info_t * (*get_audio_parameters)(void * priv);
01330
01338 const bg_parameter_info_t * (*get_video_parameters)(void * priv);
01339
01347 const bg_parameter_info_t * (*get_subtitle_text_parameters)(void * priv);
01348
01356 const bg_parameter_info_t * (*get_subtitle_overlay_parameters)(void * priv);
01357
01358
01359
01360
01361
01362
01374 int (*add_audio_stream)(void * priv, const char * language,
01375 gavl_audio_format_t * format);
01376
01387 int (*add_video_stream)(void * priv, gavl_video_format_t * format);
01388
01395 int (*add_subtitle_text_stream)(void * priv, const char * language, int * timescale);
01396
01409 int (*add_subtitle_overlay_stream)(void * priv, const char * language,
01410 gavl_video_format_t * format);
01411
01412
01413
01424 void (*set_audio_parameter)(void * priv, int stream, const char * name,
01425 const bg_parameter_value_t * v);
01426
01438 void (*set_video_parameter)(void * priv, int stream, const char * name,
01439 const bg_parameter_value_t * v);
01440
01451 void (*set_subtitle_text_parameter)(void * priv, int stream,
01452 const char * name,
01453 const bg_parameter_value_t * v);
01454
01465 void (*set_subtitle_overlay_parameter)(void * priv, int stream,
01466 const char * name,
01467 const bg_parameter_value_t * v);
01468
01477 int (*set_video_pass)(void * priv, int stream, int pass, int total_passes,
01478 const char * stats_file);
01479
01488 int (*start)(void * priv);
01489
01490
01491
01492
01493
01502 void (*get_audio_format)(void * priv, int stream, gavl_audio_format_t*ret);
01503
01512 void (*get_video_format)(void * priv, int stream, gavl_video_format_t*ret);
01513
01522 void (*get_subtitle_overlay_format)(void * priv, int stream,
01523 gavl_video_format_t*ret);
01524
01525
01526
01527
01528
01539 int (*write_audio_frame)(void * data,gavl_audio_frame_t * frame, int stream);
01540
01548 int (*write_video_frame)(void * data,gavl_video_frame_t * frame, int stream);
01549
01559 int (*write_subtitle_text)(void * data,const char * text,
01560 int64_t start,
01561 int64_t duration, int stream);
01562
01570 int (*write_subtitle_overlay)(void * data, gavl_overlay_t * ovl, int stream);
01571
01580 int (*close)(void * data, int do_delete);
01581 };
01582
01583
01584
01585
01586
01587
01602 typedef struct
01603 {
01610 void (*action_callback)(void * data, char * action);
01611
01621 void (*progress_callback)(void * data, float perc);
01622
01623 void * data;
01624
01625 } bg_e_pp_callbacks_t;
01626
01632 typedef struct bg_encoder_pp_plugin_s bg_encoder_pp_plugin_t;
01633
01639 struct bg_encoder_pp_plugin_s
01640 {
01641 bg_plugin_common_t common;
01642
01643 int max_audio_streams;
01644 int max_video_streams;
01645
01646 char * supported_extensions;
01647
01654 void (*set_callbacks)(void * priv,bg_e_pp_callbacks_t * callbacks);
01655
01663 int (*init)(void * priv);
01664
01681 void (*add_track)(void * priv, const char * filename,
01682 bg_metadata_t * metadata, int pp_only);
01683
01693 void (*run)(void * priv, const char * directory, int cleanup);
01694
01704 void (*stop)(void * priv);
01705 };
01706
01707
01721 typedef struct bg_image_reader_plugin_s bg_image_reader_plugin_t;
01722
01726 struct bg_image_reader_plugin_s
01727 {
01728 bg_plugin_common_t common;
01729 const char * extensions;
01730
01738 int (*read_header)(void * priv, const char * filename,
01739 gavl_video_format_t * format);
01740
01741 const bg_metadata_t * (*get_metadata)(void * priv);
01742
01749 char ** (*get_info)(void * priv);
01750
01760 int (*read_image)(void * priv, gavl_video_frame_t * frame);
01761 };
01762
01767 typedef struct bg_image_writer_plugin_s bg_image_writer_plugin_t;
01768
01773 struct bg_image_writer_plugin_s
01774 {
01775 bg_plugin_common_t common;
01776 const char * extensions;
01777
01787 const char * (*get_extension)(void * priv);
01788
01799 int (*write_header)(void * priv, const char * filename,
01800 gavl_video_format_t * format, const bg_metadata_t * m);
01801
01812 int (*write_image)(void * priv, gavl_video_frame_t * frame);
01813 } ;
01814
01845
01846
01851 typedef struct bg_fa_plugin_s bg_fa_plugin_t;
01852
01857 struct bg_fa_plugin_s
01858 {
01859 bg_plugin_common_t common;
01860
01869 void (*connect_input_port)(void * priv, bg_read_audio_func_t func,
01870 void * data,
01871 int stream, int port);
01872
01882 void (*set_input_format)(void * priv, gavl_audio_format_t * format, int port);
01883
01884
01891 void (*reset)(void * priv);
01892
01900 void (*get_output_format)(void * priv, gavl_audio_format_t * format);
01901
01911 int (*need_restart)(void * priv);
01912
01916 bg_read_audio_func_t read_audio;
01917
01918 };
01919
01924 typedef struct bg_fv_plugin_s bg_fv_plugin_t;
01925
01930 struct bg_fv_plugin_s
01931 {
01932 bg_plugin_common_t common;
01933
01942 gavl_video_options_t * (*get_options)(void * priv);
01943
01952 void (*connect_input_port)(void * priv,
01953 bg_read_video_func_t func,
01954 void * data, int stream, int port);
01955
01962 void (*set_input_format)(void * priv, gavl_video_format_t * format, int port);
01963
01970 void (*reset)(void * priv);
01971
01979 void (*get_output_format)(void * priv, gavl_video_format_t * format);
01980
01990 int (*need_restart)(void * priv);
01991
01995 bg_read_video_func_t read_video;
01996
01997 };
01998
01999
02018 typedef struct bg_visualization_plugin_s bg_visualization_plugin_t;
02019
02020
02035 struct bg_visualization_plugin_s
02036 {
02037 bg_plugin_common_t common;
02038
02044 bg_ov_callbacks_t * (*get_callbacks)(void * priv);
02045
02057 int (*open_ov)(void * priv, gavl_audio_format_t * audio_format,
02058 gavl_video_format_t * video_format);
02059
02070 int (*open_win)(void * priv, gavl_audio_format_t * audio_format,
02071 const char * window_id);
02072
02085 void (*update)(void * priv, gavl_audio_frame_t * frame);
02086
02096 void (*draw_frame)(void * priv, gavl_video_frame_t * frame);
02097
02106 void (*show_frame)(void * priv);
02107
02112 void (*close)(void * priv);
02113
02114 };
02115
02116
02117
02122 #endif // __BG_PLUGIN_H_