1 /*****************************************************************************
2 * dynamicoverlay.h : dynamic overlay plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2008 the VideoLAN team
7 * Author: Jean-Paul Saman <jpsaman@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef DYNAMIC_OVERLAY_H
25 #define DYNAMIC_OVERLAY_H 1
27 #include <vlc_common.h>
28 #include <vlc_filter.h>
30 /*****************************************************************************
31 * buffer_t: Command and response buffer
32 *****************************************************************************/
34 typedef struct buffer_t
36 size_t i_size; /**< Size of the allocated memory */
37 size_t i_length; /**< Length of the stored data */
39 char *p_memory; /**< Start of the allocated memory */
40 char *p_begin; /**< Start of the stored data */
43 int BufferInit( buffer_t *p_buffer );
44 int BufferDestroy( buffer_t *p_buffer );
45 int BufferAdd( buffer_t *p_buffer, const char *p_data, size_t i_len );
46 int BufferPrintf( buffer_t *p_buffer, const char *p_fmt, ... );
47 int BufferDel( buffer_t *p_buffer, int i_len );
48 char *BufferGetToken( buffer_t *p_buffer );
50 /*****************************************************************************
52 *****************************************************************************/
54 /** struct commandparams_t - command params structure */
55 typedef struct commandparams_t
57 int32_t i_id; /*< overlay id */
58 int32_t i_shmid; /*< shared memory identifier */
60 vlc_fourcc_t fourcc;/*< chroma */
62 int32_t i_x; /*< x position of overlay */
63 int32_t i_y; /*< y position of overlay */
64 int32_t i_width; /*< width of overlay */
65 int32_t i_height; /*< height of overlay */
67 int32_t i_alpha; /*< alpha value of overlay */
69 struct text_style_t fontstyle; /*< text style */
71 bool b_visible; /*< visibility flag of overlay */
74 typedef struct commanddesc_t
76 const char *psz_command;
78 int ( *pf_parser ) ( char *psz_command, char *psz_end,
79 commandparams_t *p_params );
80 int ( *pf_execute ) ( filter_t *p_filter, const commandparams_t *p_params,
81 commandparams_t *p_results );
82 int ( *pf_unparse ) ( const commandparams_t *p_results,
86 typedef struct command_t
88 struct commanddesc_t *p_command;
90 commandparams_t params;
91 commandparams_t results;
92 struct command_t *p_next;
95 void RegisterCommand( filter_t *p_filter );
96 void UnregisterCommand( filter_t *p_filter );
98 /*****************************************************************************
99 * queue_t: Command queue
100 *****************************************************************************/
102 typedef struct queue_t
104 command_t *p_head; /**< Head (first entry) of the queue */
105 command_t *p_tail; /**< Tail (last entry) of the queue */
108 int QueueInit( queue_t *p_queue );
109 int QueueDestroy( queue_t *p_queue );
110 int QueueEnqueue( queue_t *p_queue, command_t *p_cmd );
111 command_t *QueueDequeue( queue_t *p_queue );
112 int QueueTransfer( queue_t *p_sink, queue_t *p_source );
114 /*****************************************************************************
115 * overlay_t: Overlay descriptor
116 *****************************************************************************/
118 typedef struct overlay_t
124 video_format_t format;
125 struct text_style_t fontstyle;
132 overlay_t *OverlayCreate( void );
133 int OverlayDestroy( overlay_t *p_ovl );
135 /*****************************************************************************
136 * list_t: Command queue
137 *****************************************************************************/
139 typedef struct list_t
141 overlay_t **pp_head, **pp_tail;
144 int ListInit( list_t *p_list );
145 int ListDestroy( list_t *p_list );
146 ssize_t ListAdd( list_t *p_list, overlay_t *p_new );
147 int ListRemove( list_t *p_list, size_t i_idx );
148 overlay_t *ListGet( list_t *p_list, size_t i_idx );
149 overlay_t *ListWalk( list_t *p_list );
151 /*****************************************************************************
152 * filter_sys_t: adjust filter method descriptor
153 *****************************************************************************/
157 buffer_t input, output;
159 int i_inputfd, i_outputfd;
160 char *psz_inputfile, *psz_outputfile;
162 commanddesc_t **pp_commands; /* array of commands */
165 bool b_updated, b_atomic;
166 queue_t atomic, pending, processed;