Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

osd_text.c

00001 /*****************************************************************************
00002  * osd_text.c : text manipulation functions
00003  *****************************************************************************
00004  * Copyright (C) 1999-2005 the VideoLAN team
00005  * $Id: osd_text.c 12836 2005-10-15 13:23:08Z sigmunau $
00006  *
00007  * Author: Sigmund Augdal Helberg <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023  
00024 #include <vlc/vout.h>
00025 #include <vlc_block.h>
00026 #include <vlc_filter.h>
00027 #include <vlc_osd.h>
00028 
00040 int osd_ShowTextRelative( spu_t *p_spu, int i_channel,
00041                            char *psz_string, text_style_t *p_style,
00042                            int i_flags, int i_hmargin, int i_vmargin,
00043                            mtime_t i_duration )
00044 {
00045     mtime_t i_now = mdate();
00046 
00047     return osd_ShowTextAbsolute( p_spu, i_channel, psz_string,
00048                                   p_style, i_flags, i_hmargin, i_vmargin,
00049                                   i_now, i_now + i_duration );
00050 }
00051 
00066 int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
00067                            char *psz_string, text_style_t *p_style,
00068                            int i_flags, int i_hmargin, int i_vmargin,
00069                            mtime_t i_start, mtime_t i_stop )
00070 {
00071     subpicture_t *p_spu;
00072     video_format_t fmt;
00073 
00074     if( !psz_string ) return VLC_EGENERIC;
00075 
00076     p_spu = spu_CreateSubpicture( p_spu_channel );
00077     if( !p_spu ) return VLC_EGENERIC;
00078 
00079     /* Create a new subpicture region */
00080     memset( &fmt, 0, sizeof(video_format_t) );
00081     fmt.i_chroma = VLC_FOURCC('T','E','X','T');
00082     fmt.i_aspect = 0;
00083     fmt.i_width = fmt.i_height = 0;
00084     fmt.i_x_offset = fmt.i_y_offset = 0;
00085     p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_spu_channel), &fmt );
00086     if( !p_spu->p_region )
00087     {
00088         msg_Err( p_spu_channel, "cannot allocate SPU region" );
00089         spu_DestroySubpicture( p_spu_channel, p_spu );
00090         return VLC_EGENERIC;
00091     }
00092 
00093     p_spu->p_region->psz_text = strdup( psz_string );
00094     p_spu->i_start = i_start;
00095     p_spu->i_stop = i_stop;
00096     p_spu->b_ephemer = VLC_TRUE;
00097     p_spu->b_absolute = VLC_FALSE;
00098 
00099     p_spu->i_x = i_hmargin;
00100     p_spu->i_y = i_vmargin;
00101     p_spu->i_flags = i_flags;
00102     p_spu->i_channel = i_channel;
00103 
00104     spu_DisplaySubpicture( p_spu_channel, p_spu );
00105 
00106     return VLC_SUCCESS;
00107 }
00108 
00109 
00117 void osd_Message( spu_t *p_spu, int i_channel,
00118                         char *psz_format, ... )
00119 {
00120     char *psz_string;
00121     va_list args;
00122 
00123     if( p_spu )
00124     {
00125         va_start( args, psz_format );
00126         vasprintf( &psz_string, psz_format, args );
00127 
00128         osd_ShowTextRelative( p_spu, i_channel, psz_string, NULL,
00129                                OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,1000000 );
00130 
00131         free( psz_string );
00132         va_end( args );
00133     }
00134 }

Generated on Tue Dec 20 10:15:01 2005 for vlc-0.8.4a by  doxygen 1.4.2