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 #define BG_PLUGIN_URL (1<<3) //!< Plugin can load URLs
00103 #define BG_PLUGIN_PLAYBACK (1<<4) //!< Plugin is an audio or video driver for playback
00104 #define BG_PLUGIN_STDIN (1<<8) //!< Plugin can read from stdin ("-")
00105 #define BG_PLUGIN_TUNER (1<<9) //!< Plugin has some kind of tuner. Channels will be loaded as tracks.
00106 #define BG_PLUGIN_FILTER_1 (1<<10) //!< Plugin acts as a filter with one input
00107 #define BG_PLUGIN_EMBED_WINDOW (1<<11) //!< Plugin can embed it's window into another application
00108 #define BG_PLUGIN_VISUALIZE_FRAME (1<<12) //!< Visualization plugin outputs video frames
00109 #define BG_PLUGIN_VISUALIZE_GL (1<<13) //!< Visualization plugin outputs via OpenGL
00110 #define BG_PLUGIN_PP (1<<14) //!< Postprocessor
00111 #define BG_PLUGIN_CALLBACKS (1<<15) //!< Plugin can be opened from callbacks
00112 #define BG_PLUGIN_BROADCAST (1<<16) //!< Plugin can broadcasts (e.g. webstreams)
00113 #define BG_PLUGIN_DEVPARAM (1<<17) //!< Plugin has pluggable devices as parameters, which must be updated regurarly
00114
00115 #define BG_PLUGIN_UNSUPPORTED (1<<24) //!< Plugin is not supported. Only for a foreign API plugins
00116
00117
00118 #define BG_PLUGIN_ALL 0xFFFFFFFF //!< Mask of all possible plugin flags
00119
00123 #define BG_PLUGIN_API_VERSION 23
00124
00125
00126
00127
00128 #define BG_GET_PLUGIN_API_VERSION \
00129 int get_plugin_api_version() __attribute__ ((visibility("default"))); \
00130 int get_plugin_api_version() { return BG_PLUGIN_API_VERSION; }
00131
00132 #define BG_PLUGIN_PRIORITY_MIN 1
00133 #define BG_PLUGIN_PRIORITY_MAX 10
00134
00147 typedef enum
00148 {
00149 BG_STREAM_ACTION_OFF = 0,
00150 BG_STREAM_ACTION_DECODE,
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 } bg_stream_action_t;
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00181 typedef enum
00182 {
00183 BG_PLUGIN_NONE = 0,
00184 BG_PLUGIN_INPUT = (1<<0),
00185 BG_PLUGIN_OUTPUT_AUDIO = (1<<1),
00186 BG_PLUGIN_OUTPUT_VIDEO = (1<<2),
00187 BG_PLUGIN_RECORDER_AUDIO = (1<<3),
00188 BG_PLUGIN_RECORDER_VIDEO = (1<<4),
00189 BG_PLUGIN_ENCODER_AUDIO = (1<<5),
00190 BG_PLUGIN_ENCODER_VIDEO = (1<<6),
00191 BG_PLUGIN_ENCODER_SUBTITLE_TEXT = (1<<7),
00192 BG_PLUGIN_ENCODER_SUBTITLE_OVERLAY = (1<<8),
00193 BG_PLUGIN_ENCODER = (1<<9),
00194 BG_PLUGIN_ENCODER_PP = (1<<10),
00195 BG_PLUGIN_IMAGE_READER = (1<<11),
00196 BG_PLUGIN_IMAGE_WRITER = (1<<12),
00197 BG_PLUGIN_FILTER_AUDIO = (1<<13),
00198 BG_PLUGIN_FILTER_VIDEO = (1<<14),
00199 BG_PLUGIN_VISUALIZATION = (1<<15),
00200 BG_PLUGIN_AV_RECORDER = (1<<16),
00201 } bg_plugin_type_t;
00202
00211 typedef struct
00212 {
00213 char * device;
00214 char * name;
00215 } bg_device_info_t;
00216
00227 bg_device_info_t * bg_device_info_append(bg_device_info_t * arr,
00228 const char * device,
00229 const char * name);
00230
00236 void bg_device_info_destroy(bg_device_info_t * arr);
00237
00238
00239
00244 typedef struct bg_plugin_common_s bg_plugin_common_t;
00245
00250 struct bg_plugin_common_s
00251 {
00252 char * gettext_domain;
00253 char * gettext_directory;
00254
00255 char * name;
00256 char * long_name;
00257 bg_plugin_type_t type;
00258 int flags;
00259
00260 char * description;
00261
00262
00263
00264
00265
00266
00267
00268 int priority;
00269
00274 void * (*create)();
00275
00285 void (*destroy)(void* priv);
00286
00294 const bg_parameter_info_t * (*get_parameters)(void * priv);
00295
00299 bg_set_parameter_func_t set_parameter;
00300
00307 bg_get_parameter_func_t get_parameter;
00308
00318 int (*check_device)(const char * device, char ** name);
00319
00320
00328 bg_device_info_t * (*find_devices)();
00329
00330 };
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00347 typedef struct bg_input_callbacks_s bg_input_callbacks_t;
00348
00357 struct bg_input_callbacks_s
00358 {
00364 void (*duration_changed)(void * data, gavl_time_t duration);
00365
00373 void (*name_changed)(void * data, const char * name);
00374
00382 void (*metadata_changed)(void * data, const bg_metadata_t * m);
00383
00392 void (*buffer_notify)(void * data, float percentage);
00393
00407 int (*user_pass)(void * data, const char * resource,
00408 char ** username, char ** password);
00409
00421 void (*aspect_changed)(void * data, int stream,
00422 int pixel_width, int pixel_height);
00423
00424
00425 void * data;
00426
00427 };
00428
00429
00430
00431
00432
00437 typedef struct bg_input_plugin_s bg_input_plugin_t;
00438
00439
00449 struct bg_input_plugin_s
00450 {
00451 bg_plugin_common_t common;
00452
00458 const char * (*get_protocols)(void * priv);
00463 const char * (*get_mimetypes)(void * priv);
00464
00469 const char * (*get_extensions)(void * priv);
00470
00480 void (*set_callbacks)(void * priv, bg_input_callbacks_t * callbacks);
00481
00487 int (*open)(void * priv, const char * arg);
00488
00497 int (*open_fd)(void * priv, int fd, int64_t total_bytes,
00498 const char * mimetype);
00499
00511 int (*open_callbacks)(void * priv,
00512 int (*read_callback)(void * priv, uint8_t * data, int len),
00513 int64_t (*seek_callback)(void * priv, uint64_t pos, int whence),
00514 void * cb_priv, const char * filename, const char * mimetype,
00515 int64_t total_bytes);
00516
00522 const bg_edl_t * (*get_edl)(void * priv);
00523
00531 const char * (*get_disc_name)(void * priv);
00532
00541 int (*eject_disc)(const char * device);
00542
00550 int (*get_num_tracks)(void * priv);
00551
00568 bg_track_info_t * (*get_track_info)(void * priv, int track);
00569
00580 int (*set_track)(void * priv, int track);
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00602 int (*set_audio_stream)(void * priv, int stream, bg_stream_action_t action);
00603
00611 int (*set_video_stream)(void * priv, int stream, bg_stream_action_t action);
00612
00620 int (*set_subtitle_stream)(void * priv, int stream, bg_stream_action_t action);
00621
00633 int (*start)(void * priv);
00634
00644 gavl_frame_table_t * (*get_frame_table)(void * priv, int stream);
00645
00658 bg_read_audio_func_t read_audio;
00659
00669 int (*has_still)(void * priv, int stream);
00670
00678 bg_read_video_func_t read_video;
00679
00692 void (*skip_video)(void * priv, int stream, int64_t * time, int scale, int exact);
00693
00700 int (*has_subtitle)(void * priv, int stream);
00701
00713 int (*read_subtitle_overlay)(void * priv,
00714 gavl_overlay_t*ovl, int stream);
00715
00734 int (*read_subtitle_text)(void * priv,
00735 char ** text, int * text_alloc,
00736 int64_t * start_time,
00737 int64_t * duration, int stream);
00738
00750 void (*seek)(void * priv, int64_t * time, int scale);
00751
00759 void (*stop)(void * priv);
00760
00767 void (*close)(void * priv);
00768
00769 };
00770
00781 typedef struct bg_oa_callbacks_s bg_oa_callbacks_t;
00782
00788 struct bg_oa_callbacks_s
00789 {
00790 bg_read_audio_func_t read_audio;
00791 };
00792
00797 typedef struct bg_oa_plugin_s bg_oa_plugin_t;
00798
00805 struct bg_oa_plugin_s
00806 {
00807 bg_plugin_common_t common;
00808
00818 int (*open)(void * priv, gavl_audio_format_t* format);
00819
00826 int (*start)(void * priv);
00827
00833 void (*write_audio)(void * priv, gavl_audio_frame_t* frame);
00834
00843 int (*get_delay)(void * priv);
00844
00852 void (*stop)(void * priv);
00853
00860 void (*close)(void * priv);
00861 };
00862
00863
00864
00865
00866
00876 typedef struct bg_recorder_plugin_s bg_recorder_plugin_t;
00877
00884 struct bg_recorder_plugin_s
00885 {
00886 bg_plugin_common_t common;
00887
00897 int (*open)(void * priv, gavl_audio_format_t * audio_format, gavl_video_format_t * video_format);
00898
00901 bg_read_audio_func_t read_audio;
00902
00905 bg_read_video_func_t read_video;
00906
00911 void (*close)(void * priv);
00912 };
00913
00914
00915
00916
00917
00918
00919
00930 typedef struct bg_ov_callbacks_s bg_ov_callbacks_t;
00931
00937 struct bg_ov_callbacks_s
00938 {
00945 const bg_accelerator_map_t * accel_map;
00946
00952 int (*accel_callback)(void * data, int id);
00953
00967 int (*key_callback)(void * data, int key, int mask);
00968
00976 int (*key_release_callback)(void * data, int key, int mask);
00977
00987 int (*button_callback)(void * data, int x, int y, int button, int mask);
00988
00998 int (*button_release_callback)(void * data, int x, int y, int button, int mask);
00999
01008 int (*motion_callback)(void * data, int x, int y, int mask);
01009
01015 void (*show_window)(void * data, int show);
01016
01024 void (*brightness_callback)(void * data, float val);
01025
01033 void (*saturation_callback)(void * data, float val);
01034
01042 void (*contrast_callback)(void * data, float val);
01043
01051 void (*hue_callback)(void * data, float val);
01052
01053 void * data;
01054 };
01055
01056
01057
01062 typedef struct bg_ov_plugin_s bg_ov_plugin_t;
01063
01072 struct bg_ov_plugin_s
01073 {
01074 bg_plugin_common_t common;
01075
01086 void (*set_window)(void * priv, const char * window_id);
01087
01093 const char * (*get_window)(void * priv);
01094
01107 void (*set_window_options)(void * priv, const char * name,
01108 const char * klass,
01109 const gavl_video_frame_t * icon,
01110 const gavl_video_format_t * icon_format);
01111
01117 void (*set_window_title)(void * priv, const char * title);
01118
01119
01125 void (*set_callbacks)(void * priv, bg_ov_callbacks_t * callbacks);
01126
01137 int (*open)(void * priv, gavl_video_format_t * format, int keep_aspect);
01138
01150 gavl_video_frame_t * (*create_frame)(void * priv);
01151
01165 int (*add_overlay_stream)(void * priv, gavl_video_format_t * format);
01166
01179 gavl_overlay_t * (*create_overlay)(void * priv, int id);
01180
01187 void (*set_overlay)(void * priv, int stream, gavl_overlay_t * ovl);
01188
01196 void (*put_video)(void * priv, gavl_video_frame_t*frame);
01197
01207 void (*put_still)(void * priv, gavl_video_frame_t*frame);
01208
01217 void (*handle_events)(void * priv);
01218
01225 void (*update_aspect)(void * priv, int pixel_width, int pixel_height);
01226
01232 void (*destroy_frame)(void * priv, gavl_video_frame_t * frame);
01233
01240 void (*destroy_overlay)(void * priv, int id, gavl_overlay_t * ovl);
01241
01249 void (*close)(void * priv);
01250
01255 void (*show_window)(void * priv, int show);
01256 };
01257
01258
01259
01260
01261
01272 typedef struct bg_encoder_callbacks_s bg_encoder_callbacks_t;
01273
01279 struct bg_encoder_callbacks_s
01280 {
01281
01290 int (*create_output_file)(void * data, const char * filename);
01291
01300 int (*create_temp_file)(void * data, const char * filename);
01301
01302 void * data;
01303 };
01304
01305
01310 typedef struct bg_encoder_plugin_s bg_encoder_plugin_t;
01311
01312
01317 struct bg_encoder_plugin_s
01318 {
01319 bg_plugin_common_t common;
01320
01321 int max_audio_streams;
01322 int max_video_streams;
01323 int max_subtitle_text_streams;
01324 int max_subtitle_overlay_streams;
01325
01331 void (*set_callbacks)(void * priv, bg_encoder_callbacks_t * cb);
01332
01343 int (*open)(void * data, const char * filename,
01344 const bg_metadata_t * metadata,
01345 const bg_chapter_list_t * chapter_list);
01346
01355 const char * (*get_filename)(void*);
01356
01357
01358
01366 const bg_parameter_info_t * (*get_audio_parameters)(void * priv);
01367
01375 const bg_parameter_info_t * (*get_video_parameters)(void * priv);
01376
01384 const bg_parameter_info_t * (*get_subtitle_text_parameters)(void * priv);
01385
01393 const bg_parameter_info_t * (*get_subtitle_overlay_parameters)(void * priv);
01394
01395
01396
01397
01398
01399
01411 int (*add_audio_stream)(void * priv, const char * language,
01412 const gavl_audio_format_t * format);
01413
01424 int (*add_video_stream)(void * priv, const gavl_video_format_t * format);
01425
01432 int (*add_subtitle_text_stream)(void * priv, const char * language,
01433 int * timescale);
01434
01447 int (*add_subtitle_overlay_stream)(void * priv, const char * language,
01448 const gavl_video_format_t * format);
01449
01450
01451
01462 void (*set_audio_parameter)(void * priv, int stream, const char * name,
01463 const bg_parameter_value_t * v);
01464
01476 void (*set_video_parameter)(void * priv, int stream, const char * name,
01477 const bg_parameter_value_t * v);
01478
01489 void (*set_subtitle_text_parameter)(void * priv, int stream,
01490 const char * name,
01491 const bg_parameter_value_t * v);
01492
01503 void (*set_subtitle_overlay_parameter)(void * priv, int stream,
01504 const char * name,
01505 const bg_parameter_value_t * v);
01506
01515 int (*set_video_pass)(void * priv, int stream, int pass, int total_passes,
01516 const char * stats_file);
01517
01526 int (*start)(void * priv);
01527
01528
01529
01530
01531
01540 void (*get_audio_format)(void * priv, int stream, gavl_audio_format_t*ret);
01541
01550 void (*get_video_format)(void * priv, int stream, gavl_video_format_t*ret);
01551
01560 void (*get_subtitle_overlay_format)(void * priv, int stream,
01561 gavl_video_format_t*ret);
01562
01563
01564
01565
01566
01577 int (*write_audio_frame)(void * data,gavl_audio_frame_t * frame, int stream);
01578
01586 int (*write_video_frame)(void * data,gavl_video_frame_t * frame, int stream);
01587
01597 int (*write_subtitle_text)(void * data,const char * text,
01598 int64_t start,
01599 int64_t duration, int stream);
01600
01608 int (*write_subtitle_overlay)(void * data, gavl_overlay_t * ovl, int stream);
01609
01618 int (*close)(void * data, int do_delete);
01619 };
01620
01621
01622
01623
01624
01625
01640 typedef struct
01641 {
01648 void (*action_callback)(void * data, char * action);
01649
01659 void (*progress_callback)(void * data, float perc);
01660
01661 void * data;
01662
01663 } bg_e_pp_callbacks_t;
01664
01670 typedef struct bg_encoder_pp_plugin_s bg_encoder_pp_plugin_t;
01671
01677 struct bg_encoder_pp_plugin_s
01678 {
01679 bg_plugin_common_t common;
01680
01681 int max_audio_streams;
01682 int max_video_streams;
01683
01684 char * supported_extensions;
01685
01692 void (*set_callbacks)(void * priv,bg_e_pp_callbacks_t * callbacks);
01693
01701 int (*init)(void * priv);
01702
01719 void (*add_track)(void * priv, const char * filename,
01720 bg_metadata_t * metadata, int pp_only);
01721
01731 void (*run)(void * priv, const char * directory, int cleanup);
01732
01742 void (*stop)(void * priv);
01743 };
01744
01745
01759 typedef struct bg_image_reader_plugin_s bg_image_reader_plugin_t;
01760
01764 struct bg_image_reader_plugin_s
01765 {
01766 bg_plugin_common_t common;
01767 const char * extensions;
01768
01776 int (*read_header)(void * priv, const char * filename,
01777 gavl_video_format_t * format);
01778
01779 const bg_metadata_t * (*get_metadata)(void * priv);
01780
01787 char ** (*get_info)(void * priv);
01788
01798 int (*read_image)(void * priv, gavl_video_frame_t * frame);
01799 };
01800
01805 typedef struct bg_iw_callbacks_s bg_iw_callbacks_t;
01806
01807 struct bg_iw_callbacks_s
01808 {
01809
01818 int (*create_output_file)(void * data, const char * filename);
01819
01820 void * data;
01821 };
01822
01827 typedef struct bg_image_writer_plugin_s bg_image_writer_plugin_t;
01828
01833 struct bg_image_writer_plugin_s
01834 {
01835 bg_plugin_common_t common;
01836 const char * extensions;
01837
01843 void (*set_callbacks)(void * priv, bg_iw_callbacks_t * cb);
01844
01855 int (*write_header)(void * priv, const char * filename,
01856 gavl_video_format_t * format, const bg_metadata_t * m);
01857
01868 int (*write_image)(void * priv, gavl_video_frame_t * frame);
01869 } ;
01870
01901
01902
01907 typedef struct bg_fa_plugin_s bg_fa_plugin_t;
01908
01913 struct bg_fa_plugin_s
01914 {
01915 bg_plugin_common_t common;
01916
01925 void (*connect_input_port)(void * priv, bg_read_audio_func_t func,
01926 void * data,
01927 int stream, int port);
01928
01938 void (*set_input_format)(void * priv, gavl_audio_format_t * format, int port);
01939
01940
01947 void (*reset)(void * priv);
01948
01956 void (*get_output_format)(void * priv, gavl_audio_format_t * format);
01957
01967 int (*need_restart)(void * priv);
01968
01972 bg_read_audio_func_t read_audio;
01973
01974 };
01975
01980 typedef struct bg_fv_plugin_s bg_fv_plugin_t;
01981
01986 struct bg_fv_plugin_s
01987 {
01988 bg_plugin_common_t common;
01989
01998 gavl_video_options_t * (*get_options)(void * priv);
01999
02008 void (*connect_input_port)(void * priv,
02009 bg_read_video_func_t func,
02010 void * data, int stream, int port);
02011
02018 void (*set_input_format)(void * priv, gavl_video_format_t * format, int port);
02019
02026 void (*reset)(void * priv);
02027
02035 void (*get_output_format)(void * priv, gavl_video_format_t * format);
02036
02046 int (*need_restart)(void * priv);
02047
02051 bg_read_video_func_t read_video;
02052
02053 };
02054
02055
02074 typedef struct bg_visualization_plugin_s bg_visualization_plugin_t;
02075
02076
02091 struct bg_visualization_plugin_s
02092 {
02093 bg_plugin_common_t common;
02094
02100 void (*set_callbacks)(void * priv, bg_ov_callbacks_t * cb);
02101
02113 int (*open_ov)(void * priv, gavl_audio_format_t * audio_format,
02114 gavl_video_format_t * video_format);
02115
02126 int (*open_win)(void * priv, gavl_audio_format_t * audio_format,
02127 const char * window_id);
02128
02141 void (*update)(void * priv, gavl_audio_frame_t * frame);
02142
02152 void (*draw_frame)(void * priv, gavl_video_frame_t * frame);
02153
02162 void (*show_frame)(void * priv);
02163
02168 void (*close)(void * priv);
02169
02170 };
02171
02172
02173
02178 #endif // __BG_PLUGIN_H_