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

video_text.c

00001 /*****************************************************************************
00002  * video_text.c : text manipulation functions
00003  *****************************************************************************
00004  * Copyright (C) 1999-2004 the VideoLAN team
00005  * $Id: video_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 #include <vlc/vout.h>
00024 #include <vlc_block.h>
00025 #include <vlc_filter.h>
00026 #include <vlc_osd.h>
00027 
00039 int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel,
00040                            char *psz_string, text_style_t *p_style,
00041                            int i_flags, int i_hmargin, int i_vmargin,
00042                            mtime_t i_duration )
00043 {
00044     mtime_t i_now = mdate();
00045 
00046     return vout_ShowTextAbsolute( p_vout, i_channel, psz_string,
00047                                   p_style, i_flags, i_hmargin, i_vmargin,
00048                                   i_now, i_now + i_duration );
00049 }
00050 
00065 int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
00066                            char *psz_string, text_style_t *p_style,
00067                            int i_flags, int i_hmargin, int i_vmargin,
00068                            mtime_t i_start, mtime_t i_stop )
00069 {
00070     subpicture_t *p_spu;
00071     video_format_t fmt;
00072 
00073     if( !psz_string ) return VLC_EGENERIC;
00074 
00075     p_spu = spu_CreateSubpicture( p_vout->p_spu );
00076     if( !p_spu ) return VLC_EGENERIC;
00077 
00078     /* Create a new subpicture region */
00079     memset( &fmt, 0, sizeof(video_format_t) );
00080     fmt.i_chroma = VLC_FOURCC('T','E','X','T');
00081     fmt.i_aspect = 0;
00082     fmt.i_width = fmt.i_height = 0;
00083     fmt.i_x_offset = fmt.i_y_offset = 0;
00084     p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_vout), &fmt );
00085     if( !p_spu->p_region )
00086     {
00087         msg_Err( p_vout, "cannot allocate SPU region" );
00088         spu_DestroySubpicture( p_vout->p_spu, p_spu );
00089         return VLC_EGENERIC;
00090     }
00091 
00092     p_spu->p_region->psz_text = strdup( psz_string );
00093     p_spu->i_start = i_start;
00094     p_spu->i_stop = i_stop;
00095     p_spu->b_ephemer = VLC_TRUE;
00096     p_spu->b_absolute = VLC_FALSE;
00097 
00098     p_spu->i_x = i_hmargin;
00099     p_spu->i_y = i_vmargin;
00100     p_spu->i_flags = i_flags;
00101     p_spu->i_channel = i_channel;
00102 
00103     spu_DisplaySubpicture( p_vout->p_spu, p_spu );
00104 
00105     return VLC_SUCCESS;
00106 }
00107 
00108 
00116 void __vout_OSDMessage( vlc_object_t *p_caller, int i_channel,
00117                         char *psz_format, ... )
00118 {
00119     vout_thread_t *p_vout;
00120     char *psz_string;
00121     va_list args;
00122 
00123     if( !config_GetInt( p_caller, "osd" ) ) return;
00124 
00125     p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT, FIND_ANYWHERE );
00126     if( p_vout )
00127     {
00128         va_start( args, psz_format );
00129         vasprintf( &psz_string, psz_format, args );
00130 
00131         vout_ShowTextRelative( p_vout, i_channel, psz_string, NULL,
00132                                OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,1000000 );
00133 
00134         vlc_object_release( p_vout );
00135         free( psz_string );
00136         va_end( args );
00137     }
00138 }

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