gmerlin
|
00001 /***************************************************************** 00002 * gmerlin - a general purpose multimedia framework and applications 00003 * 00004 * Copyright (c) 2001 - 2012 Members of the Gmerlin project 00005 * gmerlin-general@lists.sourceforge.net 00006 * http://gmerlin.sourceforge.net 00007 * 00008 * This program is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 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 /* Functions for messages */ 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 00279 void bg_msg_get_arg_audio_format(bg_msg_t * msg, int arg, 00280 gavl_audio_format_t * format); 00281 00282 00289 void bg_msg_set_arg_video_format(bg_msg_t * msg, int arg, 00290 const gavl_video_format_t * format); 00291 00298 void bg_msg_get_arg_video_format(bg_msg_t * msg, int arg, 00299 gavl_video_format_t * format); 00300 00301 00308 void bg_msg_set_arg_metadata(bg_msg_t * msg, int arg, 00309 const gavl_metadata_t * m); 00310 00319 void bg_msg_get_arg_metadata(bg_msg_t * msg, int arg, 00320 gavl_metadata_t * m); 00321 00322 /* 00323 * This on will be used for remote controls, 00324 * return FALSE on error 00325 */ 00326 00334 int bg_msg_read(bg_msg_t * ret, bg_msg_read_callback_t cb, void * cb_data); 00335 00343 int bg_msg_write(bg_msg_t * msg, bg_msg_write_callback_t cb, void * cb_data); 00344 00345 00353 int bg_msg_read_socket(bg_msg_t * ret, int fd, int milliseconds); 00354 00361 int bg_msg_write_socket(bg_msg_t * msg, int fd); 00362 00363 /* 00364 * Read/Write audio frame over sockets 00365 */ 00366 00378 int bg_msg_write_audio_frame(bg_msg_t * msg, 00379 const gavl_audio_format_t * format, 00380 const gavl_audio_frame_t * frame, 00381 bg_msg_write_callback_t cb, void * cb_data); 00382 00398 int bg_msg_read_audio_frame(gavl_dsp_context_t ** ctx, 00399 bg_msg_t * msg, 00400 const gavl_audio_format_t * format, 00401 const gavl_metadata_t * m, 00402 gavl_audio_frame_t * frame, 00403 bg_msg_read_callback_t cb, 00404 void * cb_data); 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 * Lock message queue for reading, block until something arrives, 00462 * return the message ID 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 /* __BG_MSGQUEUE_H_ */