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$
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 
00030 /*****************************************************************************
00031  * buffer_t: Command and response buffer
00032  *****************************************************************************/
00033 
00034 typedef struct buffer_t
00035 {
00036     size_t i_size;                         /**< Size of the allocated memory */
00037     size_t i_length;                          /**< Length of the stored data */
00038 
00039     char *p_memory;                       /**< Start of the allocated memory */
00040     char *p_begin;                             /**< Start of the stored data */
00041 } buffer_t;
00042 
00043 int BufferInit( buffer_t *p_buffer );
00044 int BufferDestroy( buffer_t *p_buffer );
00045 int BufferAdd( buffer_t *p_buffer, const char *p_data, size_t i_len );
00046 int BufferPrintf( buffer_t *p_buffer, const char *p_fmt, ... );
00047 int BufferDel( buffer_t *p_buffer, int i_len );
00048 char *BufferGetToken( buffer_t *p_buffer );
00049 
00050 /*****************************************************************************
00051  * Command structures
00052  *****************************************************************************/
00053 
00054 /** struct commandparams_t - command params structure */
00055 typedef struct commandparams_t
00056 {
00057     int32_t i_id;       /*< overlay id */
00058     int32_t i_shmid;    /*< shared memory identifier */
00059 
00060     vlc_fourcc_t fourcc;/*< chroma */
00061 
00062     int32_t i_x;        /*< x position of overlay */
00063     int32_t i_y;        /*< y position of overlay */
00064     int32_t i_width;    /*< width of overlay */
00065     int32_t i_height;   /*< height of overlay */
00066 
00067     int32_t i_alpha;    /*< alpha value of overlay */
00068 
00069     struct text_style_t fontstyle; /*< text style */
00070 
00071     bool b_visible; /*< visibility flag of overlay */
00072 } commandparams_t;
00073 
00074 typedef struct commanddesc_t
00075 {
00076     const char *psz_command;
00077     bool b_atomic;
00078     int ( *pf_parser ) ( char *psz_command, char *psz_end,
00079                          commandparams_t *p_params );
00080     int ( *pf_execute ) ( filter_t *p_filter, const commandparams_t *p_params,
00081                           commandparams_t *p_results );
00082     int ( *pf_unparse ) ( const commandparams_t *p_results,
00083                           buffer_t *p_output );
00084 } commanddesc_t;
00085 
00086 typedef struct command_t
00087 {
00088     struct commanddesc_t *p_command;
00089     int i_status;
00090     commandparams_t params;
00091     commandparams_t results;
00092     struct command_t *p_next;
00093 } command_t;
00094 
00095 void RegisterCommand( filter_t *p_filter );
00096 void UnregisterCommand( filter_t *p_filter );
00097 
00098 /*****************************************************************************
00099  * queue_t: Command queue
00100  *****************************************************************************/
00101 
00102 typedef struct queue_t
00103 {
00104     command_t *p_head;                  /**< Head (first entry) of the queue */
00105     command_t *p_tail;                   /**< Tail (last entry) of the queue */
00106 } queue_t;
00107 
00108 int QueueInit( queue_t *p_queue );
00109 int QueueDestroy( queue_t *p_queue );
00110 int QueueEnqueue( queue_t *p_queue, command_t *p_cmd );
00111 command_t *QueueDequeue( queue_t *p_queue );
00112 int QueueTransfer( queue_t *p_sink, queue_t *p_source );
00113 
00114 /*****************************************************************************
00115  * overlay_t: Overlay descriptor
00116  *****************************************************************************/
00117 
00118 typedef struct overlay_t
00119 {
00120     int i_x, i_y;
00121     int i_alpha;
00122     bool b_active;
00123 
00124     video_format_t format;
00125     struct text_style_t fontstyle;
00126     union {
00127         picture_t *p_pic;
00128         char *p_text;
00129     } data;
00130 } overlay_t;
00131 
00132 overlay_t *OverlayCreate( void );
00133 int OverlayDestroy( overlay_t *p_ovl );
00134 
00135 /*****************************************************************************
00136  * list_t: Command queue
00137  *****************************************************************************/
00138 
00139 typedef struct list_t
00140 {
00141     overlay_t **pp_head, **pp_tail;
00142 } list_t;
00143 
00144 int ListInit( list_t *p_list );
00145 int ListDestroy( list_t *p_list );
00146 ssize_t ListAdd( list_t *p_list, overlay_t *p_new );
00147 int ListRemove( list_t *p_list, size_t i_idx );
00148 overlay_t *ListGet( list_t *p_list, size_t i_idx );
00149 overlay_t *ListWalk( list_t *p_list );
00150 
00151 /*****************************************************************************
00152  * filter_sys_t: adjust filter method descriptor
00153  *****************************************************************************/
00154 
00155 struct filter_sys_t
00156 {
00157     buffer_t input, output;
00158 
00159     int i_inputfd, i_outputfd;
00160     char *psz_inputfile, *psz_outputfile;
00161 
00162     commanddesc_t **pp_commands; /* array of commands */
00163     size_t i_commands;
00164 
00165     bool b_updated, b_atomic;
00166     queue_t atomic, pending, processed;
00167     list_t overlays;
00168 };
00169 
00170 #endif

Generated on Wed Aug 13 08:02:38 2008 for VLC by  doxygen 1.5.1