vlc_subpicture.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_subpicture.h: subpicture definitions
00003  *****************************************************************************
00004  * Copyright (C) 1999 - 2009 the VideoLAN team
00005  * $Id: d914e30e4e2b587724081af96c2b7ce683f8367a $
00006  *
00007  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00008  *          Samuel Hocevar <sam@via.ecp.fr>
00009  *          Olivier Aubert <oaubert 47 videolan d07 org>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef VLC_SUBPICTURE_H
00027 #define VLC_SUBPICTURE_H 1
00028 
00029 /**
00030  * \file
00031  * This file defines subpicture structures and functions in vlc
00032  */
00033 
00034 #include <vlc_picture.h>
00035 #include <vlc_text_style.h>
00036 
00037 /**
00038  * \defgroup subpicture Video Subpictures
00039  * Subpictures are pictures that should be displayed on top of the video, like
00040  * subtitles and OSD
00041  * \ingroup video_output
00042  * @{
00043  */
00044 
00045 /**
00046  * Video subtitle region spu core private
00047  */
00048 typedef struct subpicture_region_private_t subpicture_region_private_t;
00049 
00050 /**
00051  * Video subtitle region
00052  *
00053  * A subtitle region is defined by a picture (graphic) and its rendering
00054  * coordinates.
00055  * Subtitles contain a list of regions.
00056  */
00057 struct subpicture_region_t
00058 {
00059     video_format_t  fmt;                          /**< format of the picture */
00060     picture_t       *p_picture;          /**< picture comprising this region */
00061 
00062     int             i_x;                             /**< position of region */
00063     int             i_y;                             /**< position of region */
00064     int             i_align;                  /**< alignment within a region */
00065     int             i_alpha;                               /**< transparency */
00066 
00067     char            *psz_text;       /**< text string comprising this region */
00068     char            *psz_html;       /**< HTML version of subtitle (NULL = use psz_text) */
00069     text_style_t    *p_style;        /**< a description of the text style formatting */
00070 
00071     subpicture_region_t *p_next;                /**< next region in the list */
00072     subpicture_region_private_t *p_private;  /**< Private data for spu_t *only* */
00073 };
00074 
00075 /* Subpicture region position flags */
00076 #define SUBPICTURE_ALIGN_LEFT 0x1
00077 #define SUBPICTURE_ALIGN_RIGHT 0x2
00078 #define SUBPICTURE_ALIGN_TOP 0x4
00079 #define SUBPICTURE_ALIGN_BOTTOM 0x8
00080 #define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
00081                                 SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
00082 
00083 /**
00084  * This function will create a new subpicture region.
00085  *
00086  * You must use subpicture_region_Delete to destroy it.
00087  */
00088 VLC_EXPORT( subpicture_region_t *, subpicture_region_New, ( const video_format_t *p_fmt ) );
00089 
00090 /**
00091  * This function will destroy a subpicture region allocated by
00092  * subpicture_region_New.
00093  *
00094  * You may give it NULL.
00095  */
00096 VLC_EXPORT( void, subpicture_region_Delete, ( subpicture_region_t *p_region ) );
00097 
00098 /**
00099  * This function will destroy a list of subpicture regions allocated by
00100  * subpicture_region_New.
00101  *
00102  * Provided for convenience.
00103  */
00104 VLC_EXPORT( void, subpicture_region_ChainDelete, ( subpicture_region_t *p_head ) );
00105 
00106 /**
00107  *
00108  */
00109 typedef struct subpicture_updater_sys_t subpicture_updater_sys_t;
00110 typedef struct
00111 {
00112     int  (*pf_validate)( subpicture_t *,
00113                          bool has_src_changed, const video_format_t *p_fmt_src,
00114                          bool has_dst_changed, const video_format_t *p_fmt_dst,
00115                          mtime_t);
00116     void (*pf_update)  ( subpicture_t *,
00117                          const video_format_t *p_fmt_src,
00118                          const video_format_t *p_fmt_dst,
00119                          mtime_t );
00120     void (*pf_destroy) ( subpicture_t * );
00121     subpicture_updater_sys_t *p_sys;
00122 } subpicture_updater_t;
00123 
00124 typedef struct subpicture_private_t subpicture_private_t;
00125 
00126 /**
00127  * Video subtitle
00128  *
00129  * Any subtitle destined to be displayed by a video output thread should
00130  * be stored in this structure from it's creation to it's effective display.
00131  * Subtitle type and flags should only be modified by the output thread. Note
00132  * that an empty subtitle MUST have its flags set to 0.
00133  */
00134 struct subpicture_t
00135 {
00136     /** \name Channel ID */
00137     /**@{*/
00138     int             i_channel;                    /**< subpicture channel ID */
00139     /**@}*/
00140 
00141     /** \name Type and flags
00142        Should NOT be modified except by the vout thread */
00143     /**@{*/
00144     int64_t         i_order;                 /** an increasing unique number */
00145     subpicture_t *  p_next;               /**< next subtitle to be displayed */
00146     /**@}*/
00147 
00148     subpicture_region_t *p_region;  /**< region list composing this subtitle */
00149 
00150     /** \name Date properties */
00151     /**@{*/
00152     mtime_t         i_start;                  /**< beginning of display date */
00153     mtime_t         i_stop;                         /**< end of display date */
00154     bool            b_ephemer;    /**< If this flag is set to true the subtitle
00155                                 will be displayed untill the next one appear */
00156     bool            b_fade;                               /**< enable fading */
00157     /**@}*/
00158 
00159     /** \name Display properties
00160      * These properties are only indicative and may be
00161      * changed by the video output thread, or simply ignored depending of the
00162      * subtitle type. */
00163     /**@{*/
00164     bool         b_subtitle;            /**< the picture is a movie subtitle */
00165     bool         b_absolute;                       /**< position is absolute */
00166     int          i_original_picture_width;  /**< original width of the movie */
00167     int          i_original_picture_height;/**< original height of the movie */
00168     int          i_alpha;                                  /**< transparency */
00169      /**@}*/
00170 
00171     subpicture_updater_t updater;
00172 
00173     subpicture_private_t *p_private;    /* Reserved to the core */
00174 };
00175 
00176 /**
00177  * This function create a new empty subpicture.
00178  *
00179  * You must use subpicture_Delete to destroy it.
00180  */
00181 VLC_EXPORT( subpicture_t *, subpicture_New, ( const subpicture_updater_t * ) );
00182 
00183 /**
00184  * This function delete a subpicture created by subpicture_New.
00185  * You may give it NULL.
00186  */
00187 VLC_EXPORT( void,  subpicture_Delete, ( subpicture_t *p_subpic ) );
00188 
00189 /**
00190  * This function will create a subpicture having one region in the requested
00191  * chroma showing the given picture.
00192  *
00193  * The picture_t given is not released nor used inside the
00194  * returned subpicture_t.
00195  */
00196 VLC_EXPORT( subpicture_t *, subpicture_NewFromPicture, ( vlc_object_t *, picture_t *, vlc_fourcc_t i_chroma ) );
00197 
00198 /**
00199  * This function will update the content of a subpicture created with
00200  * a non NULL subpicture_updater_t.
00201  */
00202 VLC_EXPORT( void, subpicture_Update, ( subpicture_t *, const video_format_t *src, const video_format_t *, mtime_t ) );
00203 
00204 /**@}*/
00205 
00206 #endif /* _VLC_VIDEO_H */

Generated on Mon Nov 22 07:55:20 2010 for VLC by  doxygen 1.5.6