00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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 }