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)
00100 #define BG_PLUGIN_FILE (1<<1)
00101 #define BG_PLUGIN_RECORDER (1<<2)
00102
00103 #define BG_PLUGIN_URL (1<<3)
00104 #define BG_PLUGIN_PLAYBACK (1<<4)
00105
00106 #define BG_PLUGIN_BYPASS (1<<5)
00107
00108 #define BG_PLUGIN_KEEP_RUNNING (1<<6)
00109
00110 #define BG_PLUGIN_INPUT_HAS_SYNC (1<<7)
00111
00112 #define BG_PLUGIN_STDIN (1<<8)
00113
00114 #define BG_PLUGIN_TUNER (1<<9)
00115 #define BG_PLUGIN_FILTER_1 (1<<10)
00116
00117 #define BG_PLUGIN_EMBED_WINDOW (1<<11)
00118
00119 #define BG_PLUGIN_VISUALIZE_FRAME (1<<12)
00120
00121 #define BG_PLUGIN_VISUALIZE_GL (1<<13)
00122
00123 #define BG_PLUGIN_PP (1<<14)
00124 #define BG_PLUGIN_CALLBACKS (1<<15)
00125
00126 #define BG_PLUGIN_UNSUPPORTED (1<<24)
00127
00128
00129 #define BG_PLUGIN_ALL 0xFFFFFFFF
00130
00131
00136 #define BG_PLUGIN_API_VERSION 18
00137
00138
00139
00140
00141 #define BG_GET_PLUGIN_API_VERSION \
00142 int get_plugin_api_version() __attribute__ ((visibility("default"))); \
00143 int get_plugin_api_version() { return BG_PLUGIN_API_VERSION; }
00144
00145 #define BG_PLUGIN_PRIORITY_MIN 1
00146 #define BG_PLUGIN_PRIORITY_MAX 10
00147
00160 typedef enum
00161 {
00162 BG_STREAM_ACTION_OFF = 0,
00163 BG_STREAM_ACTION_DECODE,
00164
00165
00166
00167
00168 BG_STREAM_ACTION_BYPASS,
00169
00170
00171
00172
00173
00174
00175
00176
00177 } bg_stream_action_t;
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00196 typedef enum
00197 {
00198 BG_PLUGIN_NONE = 0,
00199 BG_PLUGIN_INPUT = (1<<0),
00200 BG_PLUGIN_OUTPUT_AUDIO = (1<<1),
00201 BG_PLUGIN_OUTPUT_VIDEO = (1<<2),
00202 BG_PLUGIN_RECORDER_AUDIO = (1<<3),
00203 BG_PLUGIN_RECORDER_VIDEO = (1<<4),
00204 BG_PLUGIN_ENCODER_AUDIO = (1<<5),
00205 BG_PLUGIN_ENCODER_VIDEO = (1<<6),
00206 BG_PLUGIN_ENCODER_SUBTITLE_TEXT = (1<<7),
00207 BG_PLUGIN_ENCODER_SUBTITLE_OVERLAY = (1<<8),
00208 BG_PLUGIN_ENCODER = (1<<9),
00209 BG_PLUGIN_ENCODER_PP = (1<<10),
00210 BG_PLUGIN_IMAGE_READER = (1<<11),
00211 BG_PLUGIN_IMAGE_WRITER = (1<<12),
00212 BG_PLUGIN_FILTER_AUDIO = (1<<13),
00213 BG_PLUGIN_FILTER_VIDEO = (1<<14),
00214 BG_PLUGIN_VISUALIZATION = (1<<15),
00215 BG_PLUGIN_AV_RECORDER = (1<<16),
00216 } bg_plugin_type_t;
00217
00226 typedef struct
00227 {
00228 char * device;
00229 char * name;
00230 } bg_device_info_t;
00231
00242 bg_device_info_t * bg_device_info_append(bg_device_info_t * arr,
00243 const char * device,
00244 const char * name);
00245
00251 void bg_device_info_destroy(bg_device_info_t * arr);
00252
00253
00254
00259 typedef struct bg_plugin_common_s bg_plugin_common_t;
00260
00265 struct bg_plugin_common_s
00266 {
00267 char * gettext_domain;
00268 char * gettext_directory;
00269
00270 char * name;
00271 char * long_name;
00272 bg_plugin_type_t type;
00273 int flags;
00274
00275 char * description;
00276
00277
00278
00279
00280
00281
00282
00283 int priority;
00284
00289 void * (*create)();
00290
00300 void (*destroy)(void* priv);
00301
00309 const bg_parameter_info_t * (*get_parameters)(void * priv);
00310
00314 bg_set_parameter_func_t set_parameter;
00315
00322 bg_get_parameter_func_t get_parameter;
00323
00333 int (*check_device)(const char * device, char ** name);
00334
00335
00343 bg_device_info_t * (*find_devices)();
00344
00345 };
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00362 typedef struct bg_input_callbacks_s bg_input_callbacks_t;
00363
00372 struct bg_input_callbacks_s
00373 {
00381 void (*track_changed)(void * data, int track);
00382
00391 void (*time_changed)(void * data, gavl_time_t time);
00392
00398 void (*duration_changed)(void * data, gavl_time_t duration);
00399
00407 void (*name_changed)(void * data, const char * name);
00408
00416 void (*metadata_changed)(void * data, const bg_metadata_t * m);
00417
00426 void (*buffer_notify)(void * data, float percentage);
00427
00441 int (*user_pass)(void * data, const char * resource,
00442 char ** username, char ** password);
00443
00455 void (*aspect_changed)(void * data, int stream,
00456 int pixel_width, int pixel_height);
00457
00458
00459 void * data;
00460
00461 };
00462
00463
00464
00465
00466
00471 typedef struct bg_input_plugin_s bg_input_plugin_t;
00472
00473
00483 struct bg_input_plugin_s
00484 {
00485 bg_plugin_common_t common;
00486
00492 const char * (*get_protocols)(void * priv);
00497 const char * (*get_mimetypes)(void * priv);
00498
00503 const char * (*get_extensions)(void * priv);
00504
00514 void (*set_callbacks)(void * priv, bg_input_callbacks_t * callbacks);
00515
00521 int (*open)(void * priv, const char * arg);
00522
00531 int (*open_fd)(void * priv, int fd, int64_t total_bytes,
00532 const char * mimetype);
00533
00545 int (*open_callbacks)(void * priv,
00546 int (*read_callback)(void * priv, uint8_t * data, int len),
00547 int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
00548 void * cb_priv, const char * filename, const char * mimetype,
00549 int64_t total_bytes);
00550
00556 const bg_edl_t * (*get_edl)(void * priv);
00557
00565 const char * (*get_disc_name)(void * priv);
00566
00575 int (*eject_disc)(const char * device);
00576
00584 int (*get_num_tracks)(void * priv);
00585
00602 bg_track_info_t * (*get_track_info)(void * priv, int track);
00603
00614 int (*set_track)(void * priv, int track);
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00636 int (*set_audio_stream)(void * priv, int stream, bg_stream_action_t action);
00637
00645 int (*set_video_stream)(void * priv, int stream, bg_stream_action_t action);
00646
00654 int (*set_subtitle_stream)(void * priv, int stream, bg_stream_action_t action);
00655
00667 int (*start)(void * priv);
00668
00681 bg_read_audio_func_t read_audio;
00682
00692 int (*has_still)(void * priv, int stream);
00693
00701 bg_read_video_func_t read_video;
00702
00709 int (*has_subtitle)(void * priv, int stream);
00710
00722 int (*read_subtitle_overlay)(void * priv,
00723 gavl_overlay_t*ovl, int stream);
00724
00743 int (*read_subtitle_text)(void * priv,
00744 char ** text, int * text_alloc,
00745 int64_t * start_time,
00746 int64_t * duration, int stream);
00747
00748
00749
00750
00760 int (*bypass)(void * priv);
00761
00767 void (*bypass_set_pause)(void * priv, int pause);
00768
00776 void (*bypass_set_volume)(void * priv, float volume);
00777
00789 void (*seek)(void * priv, int64_t * time, int scale);
00790
00798 void (*stop)(void * priv);
00799
00806 void (*close)(void * priv);
00807
00808 };
00809
00819 typedef struct bg_oa_plugin_s bg_oa_plugin_t;
00820
00827 struct bg_oa_plugin_s
00828 {
00829 bg_plugin_common_t common;
00830
00840 int (*open)(void * priv, gavl_audio_format_t* format);
00841
00848 int (*start)(void * priv);
00849
00855 void (*write_audio)(void * priv, gavl_audio_frame_t* frame);
00856
00865 int (*get_delay)(void * priv);
00866
00874 void (*stop)(void * priv);
00875
00882 void (*close)(void * priv);
00883 };
00884
00885
00886
00887
00888
00898 typedef struct bg_recorder_plugin_s bg_recorder_plugin_t;
00899
00906 struct bg_recorder_plugin_s
00907 {
00908 bg_plugin_common_t common;
00909
00919 int (*open)(void * priv, gavl_audio_format_t * audio_format, gavl_video_format_t * video_format);
00920
00923 bg_read_audio_func_t read_audio;
00924
00927 bg_read_video_func_t read_video;
00928
00933 void (*close)(void * priv);
00934 };
00935
00936
00937
00938
00939
00940
00941
00952 typedef struct bg_ov_callbacks_s bg_ov_callbacks_t;
00953
00959 struct bg_ov_callbacks_s
00960 {
00967 const bg_accelerator_map_t * accel_map;
00968
00974 int (*accel_callback)(void * data, int id);
00975
00989 int (*key_callback)(void * data, int key, int mask);
00990
00998 int (*key_release_callback)(void * data, int key, int mask);
00999
01009 int (*button_callback)(void * data, int x, int y, int button, int mask);
01010
01020 int (*button_release_callback)(void * data, int x, int y, int button, int mask);
01021
01030 int (*motion_callback)(void * data, int x, int y, int mask);
01031
01037 void (*show_window)(void * data, int show);
01038
01046 void (*brightness_callback)(void * data, float val);
01047
01055 void (*saturation_callback)(void * data, float val);
01056
01064 void (*contrast_callback)(void * data, float val);
01065
01073 void (*hue_callback)(void * data, float val);
01074
01075 void * data;
01076 };
01077
01078
01079
01084 typedef struct bg_ov_plugin_s bg_ov_plugin_t;
01085
01094 struct bg_ov_plugin_s
01095 {
01096 bg_plugin_common_t common;
01097
01107 void (*set_window)(void * priv, const char * window_id);
01108
01114 const char * (*get_window)(void * priv);
01115
01121 void (*set_window_title)(void * priv, const char * title);
01122
01123
01129 void (*set_callbacks)(void * priv, bg_ov_callbacks_t * callbacks);
01130
01141 int (*open)(void * priv, gavl_video_format_t * format, int keep_aspect);
01142
01154 gavl_video_frame_t * (*create_frame)(void * priv);
01155
01169 int (*add_overlay_stream)(void * priv, gavl_video_format_t * format);
01170
01183 gavl_overlay_t * (*create_overlay)(void * priv, int id);
01184
01191 void (*set_overlay)(void * priv, int stream, gavl_overlay_t * ovl);
01192
01200 void (*put_video)(void * priv, gavl_video_frame_t*frame);
01201
01211 void (*put_still)(void * priv, gavl_video_frame_t*frame);
01212
01221 void (*handle_events)(void * priv);
01222
01229 void (*update_aspect)(void * priv, int pixel_width, int pixel_height);
01230
01236 void (*destroy_frame)(void * priv, gavl_video_frame_t * frame);
01237
01244 void (*destroy_overlay)(void * priv, int id, gavl_overlay_t * ovl);
01245
01253 void (*close)(void * priv);
01254
01259 void (*show_window)(void * priv, int show);
01260 };
01261
01262
01263
01264
01265
01275 typedef struct bg_encoder_plugin_s bg_encoder_plugin_t;
01276
01277
01282 struct bg_encoder_plugin_s
01283 {
01284 bg_plugin_common_t common;
01285
01286 int max_audio_streams;
01287 int max_video_streams;
01288 int max_subtitle_text_streams;
01289 int max_subtitle_overlay_streams;
01290
01300 const char * (*get_extension)(void * priv);
01301
01309 int (*open)(void * data, const char * filename,
01310 bg_metadata_t * metadata, bg_chapter_list_t * chapter_list);
01311
01320 const char * (*get_filename)(void*);
01321
01322
01323
01331 const bg_parameter_info_t * (*get_audio_parameters)(void * priv);
01332
01340 const bg_parameter_info_t * (*get_video_parameters)(void * priv);
01341
01349 const bg_parameter_info_t * (*get_subtitle_text_parameters)(void * priv);
01350
01358 const bg_parameter_info_t * (*get_subtitle_overlay_parameters)(void * priv);
01359
01360
01361
01362
01363
01364
01376 int (*add_audio_stream)(void * priv, const char * language,
01377 gavl_audio_format_t * format);
01378
01389 int (*add_video_stream)(void * priv, gavl_video_format_t * format);
01390
01397 int (*add_subtitle_text_stream)(void * priv, const char * language, int * timescale);
01398
01411 int (*add_subtitle_overlay_stream)(void * priv, const char * language,
01412 gavl_video_format_t * format);
01413
01414
01415
01426 void (*set_audio_parameter)(void * priv, int stream, const char * name,
01427 const bg_parameter_value_t * v);
01428
01440 void (*set_video_parameter)(void * priv, int stream, const char * name,
01441 const bg_parameter_value_t * v);
01442
01453 void (*set_subtitle_text_parameter)(void * priv, int stream,
01454 const char * name,
01455 const bg_parameter_value_t * v);
01456
01467 void (*set_subtitle_overlay_parameter)(void * priv, int stream,
01468 const char * name,
01469 const bg_parameter_value_t * v);
01470
01479 int (*set_video_pass)(void * priv, int stream, int pass, int total_passes,
01480 const char * stats_file);
01481
01490 int (*start)(void * priv);
01491
01492
01493
01494
01495
01504 void (*get_audio_format)(void * priv, int stream, gavl_audio_format_t*ret);
01505
01514 void (*get_video_format)(void * priv, int stream, gavl_video_format_t*ret);
01515
01524 void (*get_subtitle_overlay_format)(void * priv, int stream,
01525 gavl_video_format_t*ret);
01526
01527
01528
01529
01530
01541 int (*write_audio_frame)(void * data,gavl_audio_frame_t * frame, int stream);
01542
01550 int (*write_video_frame)(void * data,gavl_video_frame_t * frame, int stream);
01551
01561 int (*write_subtitle_text)(void * data,const char * text,
01562 int64_t start,
01563 int64_t duration, int stream);
01564
01572 int (*write_subtitle_overlay)(void * data, gavl_overlay_t * ovl, int stream);
01573
01582 int (*close)(void * data, int do_delete);
01583 };
01584
01585
01586
01587
01588
01589
01604 typedef struct
01605 {
01612 void (*action_callback)(void * data, char * action);
01613
01623 void (*progress_callback)(void * data, float perc);
01624
01625 void * data;
01626
01627 } bg_e_pp_callbacks_t;
01628
01634 typedef struct bg_encoder_pp_plugin_s bg_encoder_pp_plugin_t;
01635
01641 struct bg_encoder_pp_plugin_s
01642 {
01643 bg_plugin_common_t common;
01644
01645 int max_audio_streams;
01646 int max_video_streams;
01647
01648 char * supported_extensions;
01649
01656 void (*set_callbacks)(void * priv,bg_e_pp_callbacks_t * callbacks);
01657
01665 int (*init)(void * priv);
01666
01683 void (*add_track)(void * priv, const char * filename,
01684 bg_metadata_t * metadata, int pp_only);
01685
01695 void (*run)(void * priv, const char * directory, int cleanup);
01696
01706 void (*stop)(void * priv);
01707 };
01708
01709
01723 typedef struct bg_image_reader_plugin_s bg_image_reader_plugin_t;
01724
01728 struct bg_image_reader_plugin_s
01729 {
01730 bg_plugin_common_t common;
01731 const char * extensions;
01732
01740 int (*read_header)(void * priv, const char * filename,
01741 gavl_video_format_t * format);
01742
01752 int (*read_image)(void * priv, gavl_video_frame_t * frame);
01753 };
01754
01759 typedef struct bg_image_writer_plugin_s bg_image_writer_plugin_t;
01760
01765 struct bg_image_writer_plugin_s
01766 {
01767 bg_plugin_common_t common;
01768 const char * extensions;
01769
01779 const char * (*get_extension)(void * priv);
01780
01791 int (*write_header)(void * priv, const char * filename,
01792 gavl_video_format_t * format);
01793
01804 int (*write_image)(void * priv, gavl_video_frame_t * frame);
01805 } ;
01806
01837
01838
01843 typedef struct bg_fa_plugin_s bg_fa_plugin_t;
01844
01849 struct bg_fa_plugin_s
01850 {
01851 bg_plugin_common_t common;
01852
01861 void (*connect_input_port)(void * priv, bg_read_audio_func_t func,
01862 void * data,
01863 int stream, int port);
01864
01874 void (*set_input_format)(void * priv, gavl_audio_format_t * format, int port);
01875
01876
01883 void (*reset)(void * priv);
01884
01892 void (*get_output_format)(void * priv, gavl_audio_format_t * format);
01893
01903 int (*need_restart)(void * priv);
01904
01908 bg_read_audio_func_t read_audio;
01909
01910 };
01911
01916 typedef struct bg_fv_plugin_s bg_fv_plugin_t;
01917
01922 struct bg_fv_plugin_s
01923 {
01924 bg_plugin_common_t common;
01925
01934 gavl_video_options_t * (*get_options)(void * priv);
01935
01944 void (*connect_input_port)(void * priv,
01945 bg_read_video_func_t func,
01946 void * data, int stream, int port);
01947
01954 void (*set_input_format)(void * priv, gavl_video_format_t * format, int port);
01955
01962 void (*reset)(void * priv);
01963
01971 void (*get_output_format)(void * priv, gavl_video_format_t * format);
01972
01982 int (*need_restart)(void * priv);
01983
01987 bg_read_video_func_t read_video;
01988
01989 };
01990
01991
02010 typedef struct bg_visualization_plugin_s bg_visualization_plugin_t;
02011
02012
02027 struct bg_visualization_plugin_s
02028 {
02029 bg_plugin_common_t common;
02030
02036 bg_ov_callbacks_t * (*get_callbacks)(void * priv);
02037
02049 int (*open_ov)(void * priv, gavl_audio_format_t * audio_format,
02050 gavl_video_format_t * video_format);
02051
02062 int (*open_win)(void * priv, gavl_audio_format_t * audio_format,
02063 const char * window_id);
02064
02077 void (*update)(void * priv, gavl_audio_frame_t * frame);
02078
02088 void (*draw_frame)(void * priv, gavl_video_frame_t * frame);
02089
02098 void (*show_frame)(void * priv);
02099
02104 void (*close)(void * priv);
02105
02106 };
02107
02108
02109
02114 #endif // __BG_PLUGIN_H_