Commit 32639eac authored by Yoann Peronneau's avatar Yoann Peronneau

improves OSD sytem

The last OSD message is now deleted before printing new one.
parent b4160df3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* osd.h : Constants for use with osd modules * osd.h : Constants for use with osd modules
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: osd.h,v 1.5 2003/10/30 22:34:48 hartman Exp $ * $Id: osd.h,v 1.6 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -45,6 +45,6 @@ struct text_style_t ...@@ -45,6 +45,6 @@ struct text_style_t
}; };
static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE }; static const text_style_t default_text_style = { 22, 0xffffff, VLC_FALSE, VLC_FALSE, VLC_FALSE };
VLC_EXPORT( void, vout_ShowTextRelative, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t ) ); VLC_EXPORT( subpicture_t *, vout_ShowTextRelative, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t ) );
VLC_EXPORT( void, vout_ShowTextAbsolute, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) ); VLC_EXPORT( void, vout_ShowTextAbsolute, ( vout_thread_t *, char *, text_style_t *, int, int, int, mtime_t, mtime_t ) );
VLC_EXPORT( void, vout_OSDMessage, ( vlc_object_t *, char * ) ); VLC_EXPORT( void, vout_OSDMessage, ( vlc_object_t *, char * ) );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_output.h : video output thread * video_output.h : video output thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.104 2003/12/07 19:09:37 jpsaman Exp $ * $Id: video_output.h,v 1.105 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -122,6 +122,8 @@ struct vout_thread_t ...@@ -122,6 +122,8 @@ struct vout_thread_t
picture_t p_picture[2*VOUT_MAX_PICTURES]; /**< pictures */ picture_t p_picture[2*VOUT_MAX_PICTURES]; /**< pictures */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /**< subpictures */ subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /**< subpictures */
subpicture_t * last_osd_message;
/* Statistics */ /* Statistics */
count_t c_loops; count_t c_loops;
count_t c_pictures, c_late_pictures; count_t c_pictures, c_late_pictures;
...@@ -141,7 +143,7 @@ struct vout_thread_t ...@@ -141,7 +143,7 @@ struct vout_thread_t
the text renderer */ the text renderer */
module_t * p_text_renderer_module; /**< text renderer module */ module_t * p_text_renderer_module; /**< text renderer module */
/** callback used when a new string needs to be shown on the vout */ /** callback used when a new string needs to be shown on the vout */
int ( *pf_add_string ) ( vout_thread_t *, char *, text_style_t *, int, subpicture_t * ( *pf_add_string ) ( vout_thread_t *, char *, text_style_t *, int,
int, int, mtime_t, mtime_t ); int, int, mtime_t, mtime_t );
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* renderer.c : dummy text rendering functions * renderer.c : dummy text rendering functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: renderer.c,v 1.3 2003/12/07 19:09:37 jpsaman Exp $ * $Id: renderer.c,v 1.4 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/vout.h> #include <vlc/vout.h>
static int AddText ( vout_thread_t *, char *, text_style_t *, int, static subpicture_t * AddText ( vout_thread_t *, char *, text_style_t *, int,
int, int, mtime_t, mtime_t ); int, int, mtime_t, mtime_t );
int E_(OpenRenderer)( vlc_object_t *p_this ) int E_(OpenRenderer)( vlc_object_t *p_this )
...@@ -34,7 +34,7 @@ int E_(OpenRenderer)( vlc_object_t *p_this ) ...@@ -34,7 +34,7 @@ int E_(OpenRenderer)( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int AddText ( vout_thread_t *p_vout, char *psz_string, static subpicture_t * AddText ( vout_thread_t *p_vout, char *psz_string,
text_style_t *p_style , int i_flags, int i_x_margin, text_style_t *p_style , int i_flags, int i_x_margin,
int i_y_margin, mtime_t i_start, mtime_t i_stop ) int i_y_margin, mtime_t i_start, mtime_t i_stop )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2 * freetype.c : Put text on the video, using freetype2
***************************************************************************** *****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN * Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.37 2003/12/07 19:00:33 jpsaman Exp $ * $Id: freetype.c,v 1.38 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -77,7 +77,7 @@ static void RenderYUY2( vout_thread_t *, picture_t *, ...@@ -77,7 +77,7 @@ static void RenderYUY2( vout_thread_t *, picture_t *,
const subpicture_t * ); const subpicture_t * );
static void RenderRV32( vout_thread_t *, picture_t *, static void RenderRV32( vout_thread_t *, picture_t *,
const subpicture_t * ); const subpicture_t * );
static int AddText ( vout_thread_t *, char *, text_style_t *, int, static subpicture_t *AddText ( vout_thread_t *, char *, text_style_t *, int,
int, int, mtime_t, mtime_t ); int, int, mtime_t, mtime_t );
static void FreeString( subpicture_t * ); static void FreeString( subpicture_t * );
...@@ -634,7 +634,7 @@ static void RenderRV32( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -634,7 +634,7 @@ static void RenderRV32( vout_thread_t *p_vout, picture_t *p_pic,
* needed glyphs into memory. It is used as pf_add_string callback in * needed glyphs into memory. It is used as pf_add_string callback in
* the vout method by this module * the vout method by this module
*/ */
static int AddText ( vout_thread_t *p_vout, char *psz_string, static subpicture_t *AddText ( vout_thread_t *p_vout, char *psz_string,
text_style_t *p_style, int i_flags, int i_hmargin, text_style_t *p_style, int i_flags, int i_hmargin,
int i_vmargin, mtime_t i_start, mtime_t i_stop ) int i_vmargin, mtime_t i_start, mtime_t i_stop )
{ {
...@@ -654,7 +654,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string, ...@@ -654,7 +654,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
/* Sanity check */ /* Sanity check */
if ( !psz_string || !*psz_string ) if ( !psz_string || !*psz_string )
{ {
return VLC_EGENERIC; return NULL;
} }
result.x = 0; result.x = 0;
...@@ -672,7 +672,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string, ...@@ -672,7 +672,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
p_subpic = vout_CreateSubPicture( p_vout, MEMORY_SUBPICTURE ); p_subpic = vout_CreateSubPicture( p_vout, MEMORY_SUBPICTURE );
if ( p_subpic == NULL ) if ( p_subpic == NULL )
{ {
return VLC_EGENERIC; return NULL;
} }
p_subpic->p_sys = 0; p_subpic->p_sys = 0;
p_subpic->pf_render = Render; p_subpic->pf_render = Render;
...@@ -851,7 +851,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string, ...@@ -851,7 +851,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
p_string->i_height = result.y; p_string->i_height = result.y;
p_string->i_width = result.x; p_string->i_width = result.x;
vout_DisplaySubPicture( p_vout, p_subpic ); vout_DisplaySubPicture( p_vout, p_subpic );
return VLC_SUCCESS; return p_subpic;
#undef face #undef face
#undef glyph #undef glyph
...@@ -859,7 +859,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string, ...@@ -859,7 +859,7 @@ static int AddText ( vout_thread_t *p_vout, char *psz_string,
error: error:
FreeString( p_subpic ); FreeString( p_subpic );
vout_DestroySubPicture( p_vout, p_subpic ); vout_DestroySubPicture( p_vout, p_subpic );
return VLC_EGENERIC; return NULL;
} }
static void FreeString( subpicture_t *p_subpic ) static void FreeString( subpicture_t *p_subpic )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_text.c : text manipulation functions * video_text.c : text manipulation functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: video_text.c,v 1.46 2003/10/30 22:34:48 hartman Exp $ * $Id: video_text.c,v 1.47 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -33,21 +33,25 @@ ...@@ -33,21 +33,25 @@
* \param i_vmargin vertical margin in pixels * \param i_vmargin vertical margin in pixels
* \param i_duration Amount of time the text is to be shown. * \param i_duration Amount of time the text is to be shown.
*/ */
void vout_ShowTextRelative( vout_thread_t *p_vout, char *psz_string, subpicture_t *vout_ShowTextRelative( vout_thread_t *p_vout, char *psz_string,
text_style_t *p_style, int i_flags, text_style_t *p_style, int i_flags,
int i_hmargin, int i_vmargin, int i_hmargin, int i_vmargin,
mtime_t i_duration ) mtime_t i_duration )
{ {
subpicture_t *p_subpic = NULL;
mtime_t i_now = mdate(); mtime_t i_now = mdate();
if ( p_vout->pf_add_string ) if ( p_vout->pf_add_string )
{ {
p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags, i_hmargin, p_subpic = p_vout->pf_add_string( p_vout, psz_string, p_style, i_flags,
i_vmargin, i_now, i_now + i_duration ); i_hmargin, i_vmargin, i_now, i_now + i_duration );
} }
else else
{ {
msg_Warn( p_vout, "No text renderer found" ); msg_Warn( p_vout, "No text renderer found" );
} }
return p_subpic;
} }
/** /**
...@@ -96,9 +100,13 @@ void vout_OSDMessage( vlc_object_t *p_caller, char *psz_string ) ...@@ -96,9 +100,13 @@ void vout_OSDMessage( vlc_object_t *p_caller, char *psz_string )
if( p_vout ) if( p_vout )
{ {
vout_ShowTextRelative( p_vout, psz_string, NULL, if( p_vout->last_osd_message )
OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, {
30,20,1000000 ); vout_DestroySubPicture( p_vout, p_vout->last_osd_message );
p_vout->last_osd_message = NULL;
}
p_vout->last_osd_message = vout_ShowTextRelative( p_vout, psz_string,
NULL, OSD_ALIGN_TOP|OSD_ALIGN_RIGHT, 30,20,1000000 );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_subpictures.c : subpicture management functions * vout_subpictures.c : subpicture management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000 VideoLAN
* $Id: vout_subpictures.c,v 1.21 2003/07/15 18:12:05 sigmunau Exp $ * $Id: vout_subpictures.c,v 1.22 2003/12/08 17:48:13 yoann Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -163,6 +163,11 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic ) ...@@ -163,6 +163,11 @@ void vout_DestroySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
p_subpic->pf_destroy( p_subpic ); p_subpic->pf_destroy( p_subpic );
} }
if( p_subpic == p_vout->last_osd_message )
{
p_vout->last_osd_message = NULL;
}
p_subpic->i_status = FREE_SUBPICTURE; p_subpic->i_status = FREE_SUBPICTURE;
vlc_mutex_unlock( &p_vout->subpicture_lock ); vlc_mutex_unlock( &p_vout->subpicture_lock );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment