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 16
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
00690 bg_read_video_func_t read_video;
00691
00698 int (*has_subtitle)(void * priv, int stream);
00699
00711 int (*read_subtitle_overlay)(void * priv,
00712 gavl_overlay_t*ovl, int stream);
00713
00732 int (*read_subtitle_text)(void * priv,
00733 char ** text, int * text_alloc,
00734 int64_t * start_time,
00735 int64_t * duration, int stream);
00736
00737
00738
00739
00749 int (*bypass)(void * priv);
00750
00756 void (*bypass_set_pause)(void * priv, int pause);
00757
00765 void (*bypass_set_volume)(void * priv, float volume);
00766
00778 void (*seek)(void * priv, int64_t * time, int scale);
00779
00787 void (*stop)(void * priv);
00788
00795 void (*close)(void * priv);
00796
00797 };
00798
00808 typedef struct bg_oa_plugin_s bg_oa_plugin_t;
00809
00816 struct bg_oa_plugin_s
00817 {
00818 bg_plugin_common_t common;
00819
00829 int (*open)(void * priv, gavl_audio_format_t* format);
00830
00837 int (*start)(void * priv);
00838
00844 void (*write_audio)(void * priv, gavl_audio_frame_t* frame);
00845
00854 int (*get_delay)(void * priv);
00855
00863 void (*stop)(void * priv);
00864
00871 void (*close)(void * priv);
00872 };
00873
00874
00875
00876
00877
00887 typedef struct bg_recorder_plugin_s bg_recorder_plugin_t;
00888
00895 struct bg_recorder_plugin_s
00896 {
00897 bg_plugin_common_t common;
00898
00908 int (*open)(void * priv, gavl_audio_format_t * audio_format, gavl_video_format_t * video_format);
00909
00912 bg_read_audio_func_t read_audio;
00913
00916 bg_read_video_func_t read_video;
00917
00922 void (*close)(void * priv);
00923 };
00924
00925
00926
00927
00928
00929
00930
00941 typedef struct bg_ov_callbacks_s bg_ov_callbacks_t;
00942
00948 struct bg_ov_callbacks_s
00949 {
00956 const bg_accelerator_map_t * accel_map;
00957
00963 int (*accel_callback)(void * data, int id);
00964
00978 int (*key_callback)(void * data, int key, int mask);
00979
00987 int (*key_release_callback)(void * data, int key, int mask);
00988
00998 int (*button_callback)(void * data, int x, int y, int button, int mask);
00999
01009 int (*button_release_callback)(void * data, int x, int y, int button, int mask);
01010
01019 int (*motion_callback)(void * data, int x, int y, int mask);
01020
01026 void (*show_window)(void * data, int show);
01027
01035 void (*brightness_callback)(void * data, float val);
01036
01044 void (*saturation_callback)(void * data, float val);
01045
01053 void (*contrast_callback)(void * data, float val);
01054
01062 void (*hue_callback)(void * data, float val);
01063
01064 void * data;
01065 };
01066
01067
01068
01073 typedef struct bg_ov_plugin_s bg_ov_plugin_t;
01074
01083 struct bg_ov_plugin_s
01084 {
01085 bg_plugin_common_t common;
01086
01096 void (*set_window)(void * priv, const char * window_id);
01097
01103 const char * (*get_window)(void * priv);
01104
01110 void (*set_window_title)(void * priv, const char * title);
01111
01112
01118 void (*set_callbacks)(void * priv, bg_ov_callbacks_t * callbacks);
01119
01130 int (*open)(void * priv, gavl_video_format_t * format, int keep_aspect);
01131
01143 gavl_video_frame_t * (*create_frame)(void * priv);
01144
01158 int (*add_overlay_stream)(void * priv, gavl_video_format_t * format);
01159
01172 gavl_overlay_t * (*create_overlay)(void * priv, int id);
01173
01180 void (*set_overlay)(void * priv, int stream, gavl_overlay_t * ovl);
01181
01189 void (*put_video)(void * priv, gavl_video_frame_t*frame);
01190
01200 void (*put_still)(void * priv, gavl_video_frame_t*frame);
01201
01210 void (*handle_events)(void * priv);
01211
01218 void (*update_aspect)(void * priv, int pixel_width, int pixel_height);
01219
01225 void (*destroy_frame)(void * priv, gavl_video_frame_t * frame);
01226
01233 void (*destroy_overlay)(void * priv, int id, gavl_overlay_t * ovl);
01234
01242 void (*close)(void * priv);
01243
01248 void (*show_window)(void * priv, int show);
01249 };
01250
01251
01252
01253
01254
01264 typedef struct bg_encoder_plugin_s bg_encoder_plugin_t;
01265
01266
01271 struct bg_encoder_plugin_s
01272 {
01273 bg_plugin_common_t common;
01274
01275 int max_audio_streams;
01276 int max_video_streams;
01277 int max_subtitle_text_streams;
01278 int max_subtitle_overlay_streams;
01279
01289 const char * (*get_extension)(void * priv);
01290
01298 int (*open)(void * data, const char * filename,
01299 bg_metadata_t * metadata, bg_chapter_list_t * chapter_list);
01300
01309 const char * (*get_filename)(void*);
01310
01311
01312
01320 const bg_parameter_info_t * (*get_audio_parameters)(void * priv);
01321
01329 const bg_parameter_info_t * (*get_video_parameters)(void * priv);
01330
01338 const bg_parameter_info_t * (*get_subtitle_text_parameters)(void * priv);
01339
01347 const bg_parameter_info_t * (*get_subtitle_overlay_parameters)(void * priv);
01348
01349
01350
01351
01352
01353
01365 int (*add_audio_stream)(void * priv, const char * language,
01366 gavl_audio_format_t * format);
01367
01378 int (*add_video_stream)(void * priv, gavl_video_format_t * format);
01379
01386 int (*add_subtitle_text_stream)(void * priv, const char * language, int * timescale);
01387
01400 int (*add_subtitle_overlay_stream)(void * priv, const char * language,
01401 gavl_video_format_t * format);
01402
01403
01404
01415 void (*set_audio_parameter)(void * priv, int stream, const char * name,
01416 const bg_parameter_value_t * v);
01417
01429 void (*set_video_parameter)(void * priv, int stream, const char * name,
01430 const bg_parameter_value_t * v);
01431
01442 void (*set_subtitle_text_parameter)(void * priv, int stream,
01443 const char * name,
01444 const bg_parameter_value_t * v);
01445
01456 void (*set_subtitle_overlay_parameter)(void * priv, int stream,
01457 const char * name,
01458 const bg_parameter_value_t * v);
01459
01468 int (*set_video_pass)(void * priv, int stream, int pass, int total_passes,
01469 const char * stats_file);
01470
01479 int (*start)(void * priv);
01480
01481
01482
01483
01484
01493 void (*get_audio_format)(void * priv, int stream, gavl_audio_format_t*ret);
01494
01503 void (*get_video_format)(void * priv, int stream, gavl_video_format_t*ret);
01504
01513 void (*get_subtitle_overlay_format)(void * priv, int stream,
01514 gavl_video_format_t*ret);
01515
01516
01517
01518
01519
01530 int (*write_audio_frame)(void * data,gavl_audio_frame_t * frame, int stream);
01531
01539 int (*write_video_frame)(void * data,gavl_video_frame_t * frame, int stream);
01540
01550 int (*write_subtitle_text)(void * data,const char * text,
01551 int64_t start,
01552 int64_t duration, int stream);
01553
01561 int (*write_subtitle_overlay)(void * data, gavl_overlay_t * ovl, int stream);
01562
01571 int (*close)(void * data, int do_delete);
01572 };
01573
01574
01575
01576
01577
01578
01593 typedef struct
01594 {
01601 void (*action_callback)(void * data, char * action);
01602
01612 void (*progress_callback)(void * data, float perc);
01613
01614 void * data;
01615
01616 } bg_e_pp_callbacks_t;
01617
01623 typedef struct bg_encoder_pp_plugin_s bg_encoder_pp_plugin_t;
01624
01630 struct bg_encoder_pp_plugin_s
01631 {
01632 bg_plugin_common_t common;
01633
01634 int max_audio_streams;
01635 int max_video_streams;
01636
01637 char * supported_extensions;
01638
01645 void (*set_callbacks)(void * priv,bg_e_pp_callbacks_t * callbacks);
01646
01654 int (*init)(void * priv);
01655
01672 void (*add_track)(void * priv, const char * filename,
01673 bg_metadata_t * metadata, int pp_only);
01674
01684 void (*run)(void * priv, const char * directory, int cleanup);
01685
01695 void (*stop)(void * priv);
01696 };
01697
01698
01712 typedef struct bg_image_reader_plugin_s bg_image_reader_plugin_t;
01713
01717 struct bg_image_reader_plugin_s
01718 {
01719 bg_plugin_common_t common;
01720 const char * extensions;
01721
01729 int (*read_header)(void * priv, const char * filename,
01730 gavl_video_format_t * format);
01731
01741 int (*read_image)(void * priv, gavl_video_frame_t * frame);
01742 };
01743
01748 typedef struct bg_image_writer_plugin_s bg_image_writer_plugin_t;
01749
01754 struct bg_image_writer_plugin_s
01755 {
01756 bg_plugin_common_t common;
01757
01767 const char * (*get_extension)(void * priv);
01768
01779 int (*write_header)(void * priv, const char * filename,
01780 gavl_video_format_t * format);
01781
01792 int (*write_image)(void * priv, gavl_video_frame_t * frame);
01793 } ;
01794
01825
01826
01831 typedef struct bg_fa_plugin_s bg_fa_plugin_t;
01832
01837 struct bg_fa_plugin_s
01838 {
01839 bg_plugin_common_t common;
01840
01849 void (*connect_input_port)(void * priv, bg_read_audio_func_t func,
01850 void * data,
01851 int stream, int port);
01852
01862 void (*set_input_format)(void * priv, gavl_audio_format_t * format, int port);
01863
01864
01871 void (*reset)(void * priv);
01872
01880 void (*get_output_format)(void * priv, gavl_audio_format_t * format);
01881
01891 int (*need_restart)(void * priv);
01892
01896 bg_read_audio_func_t read_audio;
01897
01898 };
01899
01904 typedef struct bg_fv_plugin_s bg_fv_plugin_t;
01905
01910 struct bg_fv_plugin_s
01911 {
01912 bg_plugin_common_t common;
01913
01922 void (*connect_input_port)(void * priv,
01923 bg_read_video_func_t func,
01924 void * data, int stream, int port);
01925
01932 void (*set_input_format)(void * priv, gavl_video_format_t * format, int port);
01933
01940 void (*reset)(void * priv);
01941
01949 void (*get_output_format)(void * priv, gavl_video_format_t * format);
01950
01960 int (*need_restart)(void * priv);
01961
01965 bg_read_video_func_t read_video;
01966
01967 };
01968
01969
01988 typedef struct bg_visualization_plugin_s bg_visualization_plugin_t;
01989
01990
02005 struct bg_visualization_plugin_s
02006 {
02007 bg_plugin_common_t common;
02008
02014 bg_ov_callbacks_t * (*get_callbacks)(void * priv);
02015
02027 int (*open_ov)(void * priv, gavl_audio_format_t * audio_format,
02028 gavl_video_format_t * video_format);
02029
02040 int (*open_win)(void * priv, gavl_audio_format_t * audio_format,
02041 const char * window_id);
02042
02055 void (*update)(void * priv, gavl_audio_frame_t * frame);
02056
02066 void (*draw_frame)(void * priv, gavl_video_frame_t * frame);
02067
02076 void (*show_frame)(void * priv);
02077
02082 void (*close)(void * priv);
02083
02084 };
02085
02086
02087
02092 #endif // __BG_PLUGIN_H_