dynamicoverlay.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * dynamicoverlay.h : dynamic overlay plugin for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2008 the VideoLAN team
00005  * $Id: 3995acec9e96f5837222a3ea150a3199c8106a0c $
00006  *
00007  * Author: Jean-Paul Saman <jpsaman@videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef DYNAMIC_OVERLAY_H
00025 #define DYNAMIC_OVERLAY_H   1
00026 
00027 #include <vlc_common.h>
00028 #include <vlc_filter.h>
00029 #include <vlc_text_style.h>
00030 
00031 /*****************************************************************************
00032  * buffer_t: Command and response buffer
00033  *****************************************************************************/
00034 
00035 typedef struct buffer_t
00036 {
00037     size_t i_size;                         /**< Size of the allocated memory */
00038     size_t i_length;                          /**< Length of the stored data */
00039 
00040     char *p_memory;                       /**< Start of the allocated memory */
00041     char *p_begin;                             /**< Start of the stored data */
00042 } buffer_t;
00043 
00044 int BufferInit( buffer_t *p_buffer );
00045 int BufferDestroy( buffer_t *p_buffer );
00046 int BufferAdd( buffer_t *p_buffer, const char *p_data, size_t i_len );
00047 int BufferPrintf( buffer_t *p_buffer, const char *p_fmt, ... );
00048 int BufferDel( buffer_t *p_buffer, int i_len );
00049 char *BufferGetToken( buffer_t *p_buffer );
00050 
00051 /*****************************************************************************
00052  * Command structures
00053  *****************************************************************************/
00054 
00055 /** struct commandparams_t - command params structure */
00056 typedef struct commandparams_t
00057 {
00058     int32_t i_id;       /*< overlay id */
00059     int32_t i_shmid;    /*< shared memory identifier */
00060 
00061     vlc_fourcc_t fourcc;/*< chroma */
00062 
00063     int32_t i_x;        /*< x position of overlay */
00064     int32_t i_y;        /*< y position of overlay */
00065     int32_t i_width;    /*< width of overlay */
00066     int32_t i_height;   /*< height of overlay */
00067 
00068     int32_t i_alpha;    /*< alpha value of overlay */
00069 
00070     text_style_t fontstyle; /*< text style */
00071 
00072     bool b_visible; /*< visibility flag of overlay */
00073 } commandparams_t;
00074 
00075 typedef int (*parser_func_t)(char *psz_command, char *psz_end, commandparams_t *p_params );
00076 typedef int (*execute_func_t)( filter_t *p_filter, const commandparams_t *p_params, commandparams_t *p_results );
00077 typedef int (*unparse_func_t)( const commandparams_t *p_results, buffer_t *p_output );
00078 
00079 typedef struct commanddesc_t
00080 {
00081     char *psz_command;
00082     bool b_atomic;
00083     parser_func_t pf_parser;
00084     execute_func_t pf_execute;
00085     unparse_func_t pf_unparse;
00086 } commanddesc_t;
00087 
00088 typedef struct commanddesc_static_t
00089 {
00090     const char *psz_command;
00091     bool b_atomic;
00092     parser_func_t pf_parser;
00093     execute_func_t pf_execute;
00094     unparse_func_t pf_unparse;
00095 } commanddesc_static_t;
00096 
00097 
00098 typedef struct command_t
00099 {
00100     struct commanddesc_t *p_command;
00101     int i_status;
00102     commandparams_t params;
00103     commandparams_t results;
00104     struct command_t *p_next;
00105 } command_t;
00106 
00107 void RegisterCommand( filter_t *p_filter );
00108 void UnregisterCommand( filter_t *p_filter );
00109 
00110 /*****************************************************************************
00111  * queue_t: Command queue
00112  *****************************************************************************/
00113 
00114 typedef struct queue_t
00115 {
00116     command_t *p_head;                  /**< Head (first entry) of the queue */
00117     command_t *p_tail;                   /**< Tail (last entry) of the queue */
00118 } queue_t;
00119 
00120 int QueueInit( queue_t *p_queue );
00121 int QueueDestroy( queue_t *p_queue );
00122 int QueueEnqueue( queue_t *p_queue, command_t *p_cmd );
00123 command_t *QueueDequeue( queue_t *p_queue );
00124 int QueueTransfer( queue_t *p_sink, queue_t *p_source );
00125 
00126 /*****************************************************************************
00127  * overlay_t: Overlay descriptor
00128  *****************************************************************************/
00129 
00130 typedef struct overlay_t
00131 {
00132     int i_x, i_y;
00133     int i_alpha;
00134     bool b_active;
00135 
00136     video_format_t format;
00137     text_style_t *p_fontstyle;
00138     union {
00139         picture_t *p_pic;
00140         char *p_text;
00141     } data;
00142 } overlay_t;
00143 
00144 overlay_t *OverlayCreate( void );
00145 int OverlayDestroy( overlay_t *p_ovl );
00146 
00147 /*****************************************************************************
00148  * list_t: Command queue
00149  *****************************************************************************/
00150 
00151 typedef struct list_t
00152 {
00153     overlay_t **pp_head, **pp_tail;
00154 } list_t;
00155 
00156 int ListInit( list_t *p_list );
00157 int ListDestroy( list_t *p_list );
00158 ssize_t ListAdd( list_t *p_list, overlay_t *p_new );
00159 int ListRemove( list_t *p_list, size_t i_idx );
00160 overlay_t *ListGet( list_t *p_list, size_t i_idx );
00161 overlay_t *ListWalk( list_t *p_list );
00162 
00163 /*****************************************************************************
00164  * filter_sys_t: adjust filter method descriptor
00165  *****************************************************************************/
00166 
00167 struct filter_sys_t
00168 {
00169     buffer_t input, output;
00170 
00171     int i_inputfd, i_outputfd;
00172     char *psz_inputfile, *psz_outputfile;
00173 
00174     commanddesc_t **pp_commands; /* array of commands */
00175     size_t i_commands;
00176 
00177     bool b_updated, b_atomic;
00178     queue_t atomic, pending, processed;
00179     list_t overlays;
00180 
00181     vlc_mutex_t lock;   /* lock to protect psz_inputfile and psz_outputfile */
00182 };
00183 
00184 #endif

Generated on Tue May 25 08:05:00 2010 for VLC by  doxygen 1.5.6