00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BG_MSGQUEUE_H_
00023 #define __BG_MSGQUEUE_H_
00024
00025 #include <gavl/gavl.h>
00026 #include <gavl/gavldsp.h>
00027 #include <gmerlin/streaminfo.h>
00028
00029
00048 #define BG_MSG_NONE -1 //!< Reserved ID for non valid message
00049 #define BG_MSG_MAX_ARGS 4 //!< Maximum number of args
00050
00054 typedef struct bg_msg_s bg_msg_t;
00055
00063 typedef int (*bg_msg_read_callback_t)(void * priv, uint8_t * data, int len);
00064
00072 typedef int (*bg_msg_write_callback_t)(void * priv, const uint8_t * data, int len);
00073
00078 bg_msg_t * bg_msg_create();
00079
00084 void bg_msg_destroy(bg_msg_t * msg);
00085
00093 void bg_msg_free(bg_msg_t * msg);
00094
00095
00096
00102 void bg_msg_set_id(bg_msg_t * msg, int id);
00103
00109 int bg_msg_get_id(bg_msg_t * msg);
00110
00111
00118 void bg_msg_set_arg_int(bg_msg_t * msg, int arg, int value);
00119
00126 int bg_msg_get_arg_int(bg_msg_t * msg, int arg);
00127
00134 void bg_msg_set_arg_time(bg_msg_t * msg, int arg, gavl_time_t value);
00135
00142 gavl_time_t bg_msg_get_arg_time(bg_msg_t * msg, int arg);
00143
00150 void bg_msg_set_arg_string(bg_msg_t * msg, int arg, const char * value);
00151
00161 char * bg_msg_get_arg_string(bg_msg_t * msg, int arg);
00162
00163
00169 void bg_msg_set_arg_float(bg_msg_t * msg, int arg, double value);
00170
00177 double bg_msg_get_arg_float(bg_msg_t * msg, int arg);
00178
00184 void bg_msg_set_arg_color_rgb(bg_msg_t * msg, int arg, const float * value);
00185
00191 void bg_msg_get_arg_color_rgb(bg_msg_t * msg, int arg, float * value);
00192
00193
00199 void bg_msg_set_arg_color_rgba(bg_msg_t * msg, int arg, const float * value);
00200
00206 void bg_msg_get_arg_color_rgba(bg_msg_t * msg, int arg, float * value);
00207
00213 void bg_msg_set_arg_position(bg_msg_t * msg, int arg, const double * value);
00214
00215
00221 void bg_msg_get_arg_position(bg_msg_t * msg, int arg, double * value);
00222
00229 void * bg_msg_set_arg_ptr(bg_msg_t * msg, int arg, int len);
00230
00241 void * bg_msg_get_arg_ptr(bg_msg_t * msg, int arg, int * len);
00242
00251 void bg_msg_set_arg_ptr_nocopy(bg_msg_t * msg, int arg, void * ptr);
00252
00261 void * bg_msg_get_arg_ptr_nocopy(bg_msg_t * msg, int arg);
00262
00263
00270 void bg_msg_set_arg_audio_format(bg_msg_t * msg, int arg,
00271 const gavl_audio_format_t * format);
00272
00280 void bg_msg_get_arg_audio_format(bg_msg_t * msg, int arg,
00281 gavl_audio_format_t * format, int * big_endian);
00282
00283
00290 void bg_msg_set_arg_video_format(bg_msg_t * msg, int arg,
00291 const gavl_video_format_t * format);
00292
00300 void bg_msg_get_arg_video_format(bg_msg_t * msg, int arg,
00301 gavl_video_format_t * format, int * big_endian);
00302
00303
00310 void bg_msg_set_arg_metadata(bg_msg_t * msg, int arg,
00311 const bg_metadata_t * m);
00312
00321 void bg_msg_get_arg_metadata(bg_msg_t * msg, int arg,
00322 bg_metadata_t * m);
00323
00324
00325
00326
00327
00328
00336 int bg_msg_read(bg_msg_t * ret, bg_msg_read_callback_t cb, void * cb_data);
00337
00345 int bg_msg_write(bg_msg_t * msg, bg_msg_write_callback_t cb, void * cb_data);
00346
00347
00355 int bg_msg_read_socket(bg_msg_t * ret, int fd, int milliseconds);
00356
00363 int bg_msg_write_socket(bg_msg_t * msg, int fd);
00364
00365
00366
00367
00368
00380 int bg_msg_write_audio_frame(bg_msg_t * msg,
00381 const gavl_audio_format_t * format,
00382 const gavl_audio_frame_t * frame,
00383 bg_msg_write_callback_t cb, void * cb_data);
00384
00399 int bg_msg_read_audio_frame(gavl_dsp_context_t * ctx,
00400 bg_msg_t * msg,
00401 const gavl_audio_format_t * format,
00402 gavl_audio_frame_t * frame,
00403 bg_msg_read_callback_t cb,
00404 void * cb_data, int big_endian);
00405
00413 void bg_msg_set_parameter(bg_msg_t * msg,
00414 const char * name,
00415 bg_parameter_type_t type,
00416 const bg_parameter_value_t * val);
00417
00418
00428 void bg_msg_get_parameter(bg_msg_t * msg,
00429 char ** name,
00430 bg_parameter_type_t * type,
00431 bg_parameter_value_t * val);
00432
00433
00446 typedef struct bg_msg_queue_s bg_msg_queue_t;
00447
00452 bg_msg_queue_t * bg_msg_queue_create();
00453
00458 void bg_msg_queue_destroy(bg_msg_queue_t * mq);
00459
00460
00461
00462
00463
00464
00476 bg_msg_t * bg_msg_queue_lock_read(bg_msg_queue_t * mq);
00477
00487 bg_msg_t * bg_msg_queue_try_lock_read(bg_msg_queue_t * mq);
00488
00495 void bg_msg_queue_unlock_read(bg_msg_queue_t * mq);
00496
00504 bg_msg_t * bg_msg_queue_lock_write(bg_msg_queue_t * mq);
00505
00512 void bg_msg_queue_unlock_write(bg_msg_queue_t * mq);
00513
00520 int bg_msg_queue_peek(bg_msg_queue_t * mq, uint32_t * id);
00521
00537 typedef struct bg_msg_queue_list_s bg_msg_queue_list_t;
00538
00543 bg_msg_queue_list_t * bg_msg_queue_list_create();
00544
00549 void bg_msg_queue_list_destroy(bg_msg_queue_list_t * list);
00550
00557 void
00558 bg_msg_queue_list_send(bg_msg_queue_list_t * list,
00559 void (*set_message)(bg_msg_t * message,
00560 const void * data),
00561 const void * data);
00562
00568 void bg_msg_queue_list_add(bg_msg_queue_list_t * list,
00569 bg_msg_queue_t * queue);
00570
00576 void bg_msg_queue_list_remove(bg_msg_queue_list_t * list,
00577 bg_msg_queue_t * queue);
00578
00582 #endif