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 "streaminfo.h"
00027
00028
00047 #define BG_MSG_NONE -1
00048 #define BG_MSG_MAX_ARGS 4
00049
00050
00053 typedef struct bg_msg_s bg_msg_t;
00054
00062 typedef int (*bg_msg_read_callback_t)(void * priv, uint8_t * data, int len);
00063
00071 typedef int (*bg_msg_write_callback_t)(void * priv, uint8_t * data, int len);
00072
00077 bg_msg_t * bg_msg_create();
00078
00083 void bg_msg_destroy(bg_msg_t * msg);
00084
00092 void bg_msg_free(bg_msg_t * msg);
00093
00094
00095
00101 void bg_msg_set_id(bg_msg_t * msg, int id);
00102
00108 int bg_msg_get_id(bg_msg_t * msg);
00109
00110
00117 void bg_msg_set_arg_int(bg_msg_t * msg, int arg, int value);
00118
00125 int bg_msg_get_arg_int(bg_msg_t * msg, int arg);
00126
00133 void bg_msg_set_arg_time(bg_msg_t * msg, int arg, gavl_time_t value);
00134
00141 gavl_time_t bg_msg_get_arg_time(bg_msg_t * msg, int arg);
00142
00149 void bg_msg_set_arg_string(bg_msg_t * msg, int arg, const char * value);
00150
00160 char * bg_msg_get_arg_string(bg_msg_t * msg, int arg);
00161
00162
00168 void bg_msg_set_arg_float(bg_msg_t * msg, int arg, double value);
00169
00176 double bg_msg_get_arg_float(bg_msg_t * msg, int arg);
00177
00183 void bg_msg_set_arg_color_rgb(bg_msg_t * msg, int arg, const float * value);
00184
00190 void bg_msg_get_arg_color_rgb(bg_msg_t * msg, int arg, float * value);
00191
00192
00198 void bg_msg_set_arg_color_rgba(bg_msg_t * msg, int arg, const float * value);
00199
00205 void bg_msg_get_arg_color_rgba(bg_msg_t * msg, int arg, float * value);
00206
00207
00208
00215 void * bg_msg_set_arg_ptr(bg_msg_t * msg, int arg, int len);
00216
00227 void * bg_msg_get_arg_ptr(bg_msg_t * msg, int arg, int * len);
00228
00237 void bg_msg_set_arg_ptr_nocopy(bg_msg_t * msg, int arg, void * ptr);
00238
00247 void * bg_msg_get_arg_ptr_nocopy(bg_msg_t * msg, int arg);
00248
00249
00256 void bg_msg_set_arg_audio_format(bg_msg_t * msg, int arg,
00257 const gavl_audio_format_t * format);
00258
00265 void bg_msg_get_arg_audio_format(bg_msg_t * msg, int arg,
00266 gavl_audio_format_t * format);
00267
00268
00275 void bg_msg_set_arg_video_format(bg_msg_t * msg, int arg,
00276 const gavl_video_format_t * format);
00277
00284 void bg_msg_get_arg_video_format(bg_msg_t * msg, int arg,
00285 gavl_video_format_t * format);
00286
00287
00294 void bg_msg_set_arg_metadata(bg_msg_t * msg, int arg,
00295 const bg_metadata_t * m);
00296
00305 void bg_msg_get_arg_metadata(bg_msg_t * msg, int arg,
00306 bg_metadata_t * m);
00307
00308
00309
00310
00311
00312
00320 int bg_msg_read(bg_msg_t * ret, bg_msg_read_callback_t cb, void * cb_data);
00321
00329 int bg_msg_write(bg_msg_t * msg, bg_msg_write_callback_t cb, void * cb_data);
00330
00331
00339 int bg_msg_read_socket(bg_msg_t * ret, int fd, int milliseconds);
00340
00347 int bg_msg_write_socket(bg_msg_t * msg, int fd);
00348
00349
00350
00351
00352
00364 int bg_msg_write_audio_frame(bg_msg_t * msg,
00365 const gavl_audio_format_t * format,
00366 const gavl_audio_frame_t * frame,
00367 bg_msg_write_callback_t cb, void * cb_data);
00368
00381 int bg_msg_read_audio_frame(bg_msg_t * msg,
00382 const gavl_audio_format_t * format,
00383 gavl_audio_frame_t * frame,
00384 bg_msg_read_callback_t cb,
00385 void * cb_data);
00386
00394 void bg_msg_set_parameter(bg_msg_t * msg,
00395 const char * name,
00396 bg_parameter_type_t type,
00397 const bg_parameter_value_t * val);
00398
00399
00409 void bg_msg_get_parameter(bg_msg_t * msg,
00410 char ** name,
00411 bg_parameter_type_t * type,
00412 bg_parameter_value_t * val);
00413
00414
00427 typedef struct bg_msg_queue_s bg_msg_queue_t;
00428
00433 bg_msg_queue_t * bg_msg_queue_create();
00434
00439 void bg_msg_queue_destroy(bg_msg_queue_t * mq);
00440
00441
00442
00443
00444
00445
00457 bg_msg_t * bg_msg_queue_lock_read(bg_msg_queue_t * mq);
00458
00468 bg_msg_t * bg_msg_queue_try_lock_read(bg_msg_queue_t * mq);
00469
00476 void bg_msg_queue_unlock_read(bg_msg_queue_t * mq);
00477
00485 bg_msg_t * bg_msg_queue_lock_write(bg_msg_queue_t * mq);
00486
00493 void bg_msg_queue_unlock_write(bg_msg_queue_t * mq);
00494
00501 int bg_msg_queue_peek(bg_msg_queue_t * mq, uint32_t * id);
00502
00518 typedef struct bg_msg_queue_list_s bg_msg_queue_list_t;
00519
00524 bg_msg_queue_list_t * bg_msg_queue_list_create();
00525
00530 void bg_msg_queue_list_destroy(bg_msg_queue_list_t * list);
00531
00538 void
00539 bg_msg_queue_list_send(bg_msg_queue_list_t * list,
00540 void (*set_message)(bg_msg_t * message,
00541 const void * data),
00542 const void * data);
00543
00549 void bg_msg_queue_list_add(bg_msg_queue_list_t * list,
00550 bg_msg_queue_t * queue);
00551
00557 void bg_msg_queue_list_remove(bg_msg_queue_list_t * list,
00558 bg_msg_queue_t * queue);
00559
00563 #endif