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