gmerlin
msgqueue.h
1/*****************************************************************
2 * gmerlin - a general purpose multimedia framework and applications
3 *
4 * Copyright (c) 2001 - 2012 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22#ifndef __BG_MSGQUEUE_H_
23#define __BG_MSGQUEUE_H_
24
25#include <gavl/gavl.h>
26#include <gavl/gavldsp.h>
27#include <gmerlin/streaminfo.h>
28
29
48#define BG_MSG_NONE -1
49#define BG_MSG_MAX_ARGS 4
50
54typedef struct bg_msg_s bg_msg_t;
55
63typedef int (*bg_msg_read_callback_t)(void * priv, uint8_t * data, int len);
64
72typedef int (*bg_msg_write_callback_t)(void * priv, const uint8_t * data, int len);
73
79
85
94
95/* Functions for messages */
96
102void bg_msg_set_id(bg_msg_t * msg, int id);
103
110
111
118void bg_msg_set_arg_int(bg_msg_t * msg, int arg, int value);
119
126int bg_msg_get_arg_int(bg_msg_t * msg, int arg);
127
134void bg_msg_set_arg_time(bg_msg_t * msg, int arg, gavl_time_t value);
135
143
150void bg_msg_set_arg_string(bg_msg_t * msg, int arg, const char * value);
151
161char * bg_msg_get_arg_string(bg_msg_t * msg, int arg);
162
163
169void bg_msg_set_arg_float(bg_msg_t * msg, int arg, double value);
170
177double bg_msg_get_arg_float(bg_msg_t * msg, int arg);
178
184void bg_msg_set_arg_color_rgb(bg_msg_t * msg, int arg, const float * value);
185
191void bg_msg_get_arg_color_rgb(bg_msg_t * msg, int arg, float * value);
192
193
199void bg_msg_set_arg_color_rgba(bg_msg_t * msg, int arg, const float * value);
200
206void bg_msg_get_arg_color_rgba(bg_msg_t * msg, int arg, float * value);
207
213void bg_msg_set_arg_position(bg_msg_t * msg, int arg, const double * value);
214
215
221void bg_msg_get_arg_position(bg_msg_t * msg, int arg, double * value);
222
229void * bg_msg_set_arg_ptr(bg_msg_t * msg, int arg, int len);
230
241void * bg_msg_get_arg_ptr(bg_msg_t * msg, int arg, int * len);
242
251void bg_msg_set_arg_ptr_nocopy(bg_msg_t * msg, int arg, void * ptr);
252
261void * bg_msg_get_arg_ptr_nocopy(bg_msg_t * msg, int arg);
262
263
271 const gavl_audio_format_t * format);
272
280 gavl_audio_format_t * format);
281
282
290 const gavl_video_format_t * format);
291
299 gavl_video_format_t * format);
300
301
309 const gavl_metadata_t * m);
310
320 gavl_metadata_t * m);
321
322/*
323 * This on will be used for remote controls,
324 * return FALSE on error
325 */
326
334int bg_msg_read(bg_msg_t * ret, bg_msg_read_callback_t cb, void * cb_data);
335
343int bg_msg_write(bg_msg_t * msg, bg_msg_write_callback_t cb, void * cb_data);
344
345
353int bg_msg_read_socket(bg_msg_t * ret, int fd, int milliseconds);
354
361int bg_msg_write_socket(bg_msg_t * msg, int fd);
362
363/*
364 * Read/Write audio frame over sockets
365 */
366
379 const gavl_audio_format_t * format,
380 const gavl_audio_frame_t * frame,
381 bg_msg_write_callback_t cb, void * cb_data);
382
399 bg_msg_t * msg,
400 const gavl_audio_format_t * format,
401 const gavl_metadata_t * m,
402 gavl_audio_frame_t * frame,
404 void * cb_data);
405
414 const char * name,
416 const bg_parameter_value_t * val);
417
418
429 char ** name,
430 bg_parameter_type_t * type,
432
433
446typedef struct bg_msg_queue_s bg_msg_queue_t;
447
453
459
460/*
461 * Lock message queue for reading, block until something arrives,
462 * return the message ID
463 */
464
477
488
496
505
513
520int bg_msg_queue_peek(bg_msg_queue_t * mq, uint32_t * id);
521
537typedef struct bg_msg_queue_list_s bg_msg_queue_list_t;
538
544
550
557void
559 void (*set_message)(bg_msg_t * message,
560 const void * data),
561 const void * data);
562
569 bg_msg_queue_t * queue);
570
577 bg_msg_queue_t * queue);
578
582#endif /* __BG_MSGQUEUE_H_ */
struct gavl_dsp_context_s gavl_dsp_context_t
void bg_msg_queue_list_remove(bg_msg_queue_list_t *list, bg_msg_queue_t *queue)
Remove a queue from the list.
struct bg_msg_queue_list_s bg_msg_queue_list_t
Opaque message queue list type. You don't want to know what's inside.
Definition msgqueue.h:537
void bg_msg_queue_list_destroy(bg_msg_queue_list_t *list)
Destroy a message queue list.
bg_msg_queue_list_t * bg_msg_queue_list_create()
Create a message queue list.
void bg_msg_queue_list_send(bg_msg_queue_list_t *list, void(*set_message)(bg_msg_t *message, const void *data), const void *data)
Send a message to all queues in the list.
void bg_msg_queue_list_add(bg_msg_queue_list_t *list, bg_msg_queue_t *queue)
Add a queue to the list.
struct bg_msg_queue_s bg_msg_queue_t
Opaque message queue type. You don't want to know what's inside.
Definition msgqueue.h:446
bg_msg_queue_t * bg_msg_queue_create()
Create a message queue.
int bg_msg_queue_peek(bg_msg_queue_t *mq, uint32_t *id)
Check, if there is a message for readinbg available and get the ID.
void bg_msg_queue_unlock_write(bg_msg_queue_t *mq)
Unlock a message queue for writing.
bg_msg_t * bg_msg_queue_lock_write(bg_msg_queue_t *mq)
Lock a message queue for writing.
bg_msg_t * bg_msg_queue_try_lock_read(bg_msg_queue_t *mq)
Try to lock a message queue for reading.
void bg_msg_queue_destroy(bg_msg_queue_t *mq)
Destroy a message queue.
void bg_msg_queue_unlock_read(bg_msg_queue_t *mq)
Unlock a message queue for reading.
bg_msg_t * bg_msg_queue_lock_read(bg_msg_queue_t *mq)
Lock a message queue for reading.
int bg_msg_read_audio_frame(gavl_dsp_context_t **ctx, bg_msg_t *msg, const gavl_audio_format_t *format, const gavl_metadata_t *m, gavl_audio_frame_t *frame, bg_msg_read_callback_t cb, void *cb_data)
Read an audio frame.
void bg_msg_get_parameter(bg_msg_t *msg, char **name, bg_parameter_type_t *type, bg_parameter_value_t *val)
Get a parameter.
void * bg_msg_get_arg_ptr_nocopy(bg_msg_t *msg, int arg)
Get a pointer argument without copying data.
int bg_msg_write_socket(bg_msg_t *msg, int fd)
Write a message to a socket.
void bg_msg_set_arg_color_rgba(bg_msg_t *msg, int arg, const float *value)
Set an RGBA color argument.
void bg_msg_get_arg_metadata(bg_msg_t *msg, int arg, gavl_metadata_t *m)
Get a matadata argument.
void bg_msg_get_arg_color_rgb(bg_msg_t *msg, int arg, float *value)
Get an RGB color argument.
int bg_msg_read_socket(bg_msg_t *ret, int fd, int milliseconds)
Read a message from a socket.
void * bg_msg_set_arg_ptr(bg_msg_t *msg, int arg, int len)
Set a binary data argument.
void bg_msg_get_arg_position(bg_msg_t *msg, int arg, double *value)
Get a position argument.
void bg_msg_set_arg_float(bg_msg_t *msg, int arg, double value)
Set a float argument.
void bg_msg_set_arg_audio_format(bg_msg_t *msg, int arg, const gavl_audio_format_t *format)
Set an audio format argument.
char * bg_msg_get_arg_string(bg_msg_t *msg, int arg)
Get a string argument.
void bg_msg_free(bg_msg_t *msg)
Free internal memory of the message.
void bg_msg_set_arg_time(bg_msg_t *msg, int arg, gavl_time_t value)
Set a time argument.
void bg_msg_set_arg_position(bg_msg_t *msg, int arg, const double *value)
Set a position argument.
void bg_msg_set_arg_string(bg_msg_t *msg, int arg, const char *value)
Set a string argument.
void bg_msg_set_arg_ptr_nocopy(bg_msg_t *msg, int arg, void *ptr)
Set a pointer argument without copying data.
gavl_time_t bg_msg_get_arg_time(bg_msg_t *msg, int arg)
Get a time argument.
struct bg_msg_s bg_msg_t
Opaque message type, you don't want to know what's inside.
Definition msgqueue.h:54
bg_msg_t * bg_msg_create()
Create a message.
void bg_msg_set_arg_video_format(bg_msg_t *msg, int arg, const gavl_video_format_t *format)
Set a video format argument.
void bg_msg_set_arg_color_rgb(bg_msg_t *msg, int arg, const float *value)
Set an RGB color argument.
void * bg_msg_get_arg_ptr(bg_msg_t *msg, int arg, int *len)
Set a binary data argument.
int bg_msg_read(bg_msg_t *ret, bg_msg_read_callback_t cb, void *cb_data)
Read a message using a callback.
int bg_msg_write_audio_frame(bg_msg_t *msg, const gavl_audio_format_t *format, const gavl_audio_frame_t *frame, bg_msg_write_callback_t cb, void *cb_data)
Write an audio frame.
int bg_msg_get_arg_int(bg_msg_t *msg, int arg)
Get an integer argument.
int(* bg_msg_read_callback_t)(void *priv, uint8_t *data, int len)
Callback for bg_msg_read.
Definition msgqueue.h:63
double bg_msg_get_arg_float(bg_msg_t *msg, int arg)
Get a float argument.
void bg_msg_set_arg_int(bg_msg_t *msg, int arg, int value)
Set an integer argument.
void bg_msg_set_arg_metadata(bg_msg_t *msg, int arg, const gavl_metadata_t *m)
Set a matadata argument.
void bg_msg_get_arg_color_rgba(bg_msg_t *msg, int arg, float *value)
Get an RGBA color argument.
void bg_msg_set_id(bg_msg_t *msg, int id)
Set the ID of a message.
void bg_msg_get_arg_video_format(bg_msg_t *msg, int arg, gavl_video_format_t *format)
Get a video format argument.
int(* bg_msg_write_callback_t)(void *priv, const uint8_t *data, int len)
Callback for bg_msg_write.
Definition msgqueue.h:72
int bg_msg_get_id(bg_msg_t *msg)
Get the ID of a message.
void bg_msg_set_parameter(bg_msg_t *msg, const char *name, bg_parameter_type_t type, const bg_parameter_value_t *val)
Set a parameter.
void bg_msg_get_arg_audio_format(bg_msg_t *msg, int arg, gavl_audio_format_t *format)
Get an audio format argument.
int bg_msg_write(bg_msg_t *msg, bg_msg_write_callback_t cb, void *cb_data)
Write a message using a callback.
void bg_msg_destroy(bg_msg_t *msg)
Destroy a message.
bg_parameter_type_t
Parameter type.
Definition parameter.h:54
int64_t gavl_time_t
Container for a parameter value.
Definition parameter.h:83