Commit 681ac9f1 authored by basOS G's avatar basOS G Committed by Laurent Aimar

Added and used text_style_* methods.

It had the following functions:
- text_style_New  -- allocates default text style
- text_style_Dup  -- allocates and copies text style
- text_style_Copy -- copies text style
- text_style_Delete -- deallocates text style

NOTE that the vout_ShowText* functions will take a p_style and copy
it internally so you have to free in the caller function.
 Other modules where p_style was malloced there are now fixed to
copy before calling the vout* functions.

Original patch by basOS G with a few modifications by fenrir.
Signed-off-by: default avatarLaurent Aimar <fenrir@videolan.org>
parent 768bd8a4
...@@ -265,8 +265,25 @@ struct text_style_t ...@@ -265,8 +265,25 @@ struct text_style_t
#define STYLE_UNDERLINE 32 #define STYLE_UNDERLINE 32
#define STYLE_STRIKEOUT 64 #define STYLE_STRIKEOUT 64
static const text_style_t default_text_style = { NULL, 22, 0xffffff, 0xff, STYLE_OUTLINE, /**
0x000000, 0xff, 0x000000, 0xff, 0xffffff, 0x80, 0xffffff, 0xff, 1, 0, -1 }; * Create a default text style
*/
VLC_EXPORT( text_style_t *, text_style_New, ( void ) );
/**
* Copy a text style into another
*/
VLC_EXPORT( text_style_t *, text_style_Copy, ( text_style_t *, const text_style_t * ) );
/**
* Duplicate a text style
*/
VLC_EXPORT( text_style_t *, text_style_Duplicate, ( const text_style_t * ) );
/**
* Delete a text style created by text_style_New or text_style_Duplicate
*/
VLC_EXPORT( void, text_style_Delete, ( text_style_t * ) );
/** /**
* OSD menu button states * OSD menu button states
...@@ -590,8 +607,8 @@ static inline void osd_SetMenuUpdate( osd_menu_t *p_osd, bool b_value ) ...@@ -590,8 +607,8 @@ static inline void osd_SetMenuUpdate( osd_menu_t *p_osd, bool b_value )
* object. The types are declared in the include file include/vlc_osd.h * object. The types are declared in the include file include/vlc_osd.h
* @see vlc_osd.h * @see vlc_osd.h
*/ */
VLC_EXPORT( int, osd_ShowTextRelative, ( spu_t *, int, const char *, text_style_t *, int, int, int, mtime_t ) ); VLC_EXPORT( int, osd_ShowTextRelative, ( spu_t *, int, const char *, const text_style_t *, int, int, int, mtime_t ) );
VLC_EXPORT( int, osd_ShowTextAbsolute, ( spu_t *, int, const char *, text_style_t *, int, int, int, mtime_t, mtime_t ) ); VLC_EXPORT( int, osd_ShowTextAbsolute, ( spu_t *, int, const char *, const text_style_t *, int, int, int, mtime_t, mtime_t ) );
VLC_EXPORT( void, osd_Message, ( spu_t *, int, char *, ... ) LIBVLC_FORMAT( 3, 4 ) ); VLC_EXPORT( void, osd_Message, ( spu_t *, int, char *, ... ) LIBVLC_FORMAT( 3, 4 ) );
/** /**
...@@ -611,34 +628,9 @@ VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, int, int, s ...@@ -611,34 +628,9 @@ VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, int, int, s
* Vout text and widget overlays * Vout text and widget overlays
**********************************************************************/ **********************************************************************/
/** VLC_EXPORT( int, vout_ShowTextRelative, ( vout_thread_t *, int, char *, const text_style_t *, int, int, int, mtime_t ) );
* Show text on the video for some time
* \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel
* \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info
* \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels
* \param i_vmargin vertical margin in pixels
* \param i_duration Amount of time the text is to be shown.
*/
VLC_EXPORT( int, vout_ShowTextRelative, ( vout_thread_t *, int, char *, text_style_t *, int, int, int, mtime_t ) );
/** VLC_EXPORT( int, vout_ShowTextAbsolute, ( vout_thread_t *, int, const char *, const text_style_t *, int, int, int, mtime_t, mtime_t ) );
* Show text on the video from a given start date to a given end date
* \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel
* \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info
* \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels
* \param i_vmargin vertical margin in pixels
* \param i_start the time when this string is to appear on the video
* \param i_stop the time when this string should stop to be displayed
* if this is 0 the string will be shown untill the next string
* is about to be shown
*/
VLC_EXPORT( int, vout_ShowTextAbsolute, ( vout_thread_t *, int, const char *, text_style_t *, int, int, int, mtime_t, mtime_t ) );
/** /**
* Write an informative message at the default location, * Write an informative message at the default location,
......
This diff is collapsed.
This diff is collapsed.
...@@ -310,20 +310,19 @@ static int Create( vlc_object_t *p_this ) ...@@ -310,20 +310,19 @@ static int Create( vlc_object_t *p_this )
if( !p_intf->p_sys ) if( !p_intf->p_sys )
return VLC_ENOMEM; return VLC_ENOMEM;
p_sys->p_style = malloc( sizeof( text_style_t ) ); p_sys->p_style = text_style_New();
if( !p_sys->p_style ) if( !p_sys->p_style )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
vlc_memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
p_intf->pf_run = Run; p_intf->pf_run = Run;
p_sys->p_image = image_HandlerCreate( p_this ); p_sys->p_image = image_HandlerCreate( p_this );
if( !p_sys->p_image ) if( !p_sys->p_image )
{ {
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys ); free( p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
...@@ -520,7 +519,7 @@ static void Destroy( vlc_object_t *p_this ) ...@@ -520,7 +519,7 @@ static void Destroy( vlc_object_t *p_this )
if( p_sys->p_overlay ) if( p_sys->p_overlay )
picture_Release( p_sys->p_overlay ); picture_Release( p_sys->p_overlay );
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys ); free( p_sys );
} }
...@@ -865,7 +864,7 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string, ...@@ -865,7 +864,7 @@ static picture_t *RenderText( intf_thread_t *p_intf, const char *psz_string,
subpicture_region_Delete( p_region ); subpicture_region_Delete( p_region );
return NULL; return NULL;
} }
p_region->p_style = p_style; p_region->p_style = text_style_Duplicate( p_style );
p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP; p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
if( p_sys->p_text->pf_render_text ) if( p_sys->p_text->pf_render_text )
......
...@@ -358,9 +358,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -358,9 +358,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
if( p_overlay->format.i_chroma == VLC_FOURCC('T','E','X','T') ) if( p_overlay->format.i_chroma == VLC_FOURCC('T','E','X','T') )
{ {
p_region->psz_text = strdup( p_overlay->data.p_text ); p_region->psz_text = strdup( p_overlay->data.p_text );
p_region->p_style = malloc( sizeof(struct text_style_t) ); p_region->p_style = text_style_Duplicate( p_overlay->p_fontstyle );
if( p_region->p_style )
*p_region->p_style = p_overlay->fontstyle;
} }
else else
{ {
......
...@@ -122,7 +122,7 @@ typedef struct overlay_t ...@@ -122,7 +122,7 @@ typedef struct overlay_t
bool b_active; bool b_active;
video_format_t format; video_format_t format;
struct text_style_t fontstyle; struct text_style_t *p_fontstyle;
union { union {
picture_t *p_pic; picture_t *p_pic;
char *p_text; char *p_text;
......
...@@ -58,7 +58,7 @@ overlay_t *OverlayCreate( void ) ...@@ -58,7 +58,7 @@ overlay_t *OverlayCreate( void )
p_ovl->b_active = false; p_ovl->b_active = false;
vout_InitFormat( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0, vout_InitFormat( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0,
VOUT_ASPECT_FACTOR ); VOUT_ASPECT_FACTOR );
memcpy( &p_ovl->fontstyle, &default_text_style, sizeof(struct text_style_t) ); p_ovl->p_fontstyle = text_style_New();
p_ovl->data.p_text = NULL; p_ovl->data.p_text = NULL;
return p_ovl; return p_ovl;
...@@ -68,6 +68,7 @@ int OverlayDestroy( overlay_t *p_ovl ) ...@@ -68,6 +68,7 @@ int OverlayDestroy( overlay_t *p_ovl )
{ {
if( p_ovl->data.p_text != NULL ) if( p_ovl->data.p_text != NULL )
free( p_ovl->data.p_text ); free( p_ovl->data.p_text );
text_style_Delete( p_ovl->p_fontstyle );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -636,7 +637,7 @@ static int exec_GetTextAlpha( filter_t *p_filter, ...@@ -636,7 +637,7 @@ static int exec_GetTextAlpha( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_results->fontstyle.i_font_alpha = p_ovl->fontstyle.i_font_alpha; p_results->fontstyle.i_font_alpha = p_ovl->p_fontstyle->i_font_alpha;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -649,7 +650,7 @@ static int exec_GetTextColor( filter_t *p_filter, ...@@ -649,7 +650,7 @@ static int exec_GetTextColor( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_results->fontstyle.i_font_color = p_ovl->fontstyle.i_font_color; p_results->fontstyle.i_font_color = p_ovl->p_fontstyle->i_font_color;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -662,7 +663,7 @@ static int exec_GetTextSize( filter_t *p_filter, ...@@ -662,7 +663,7 @@ static int exec_GetTextSize( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_results->fontstyle.i_font_size = p_ovl->fontstyle.i_font_size; p_results->fontstyle.i_font_size = p_ovl->p_fontstyle->i_font_size;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -725,7 +726,7 @@ static int exec_SetTextAlpha( filter_t *p_filter, ...@@ -725,7 +726,7 @@ static int exec_SetTextAlpha( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_ovl->fontstyle.i_font_alpha = p_params->fontstyle.i_font_alpha; p_ovl->p_fontstyle->i_font_alpha = p_params->fontstyle.i_font_alpha;
p_sys->b_updated = p_ovl->b_active; p_sys->b_updated = p_ovl->b_active;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -741,7 +742,7 @@ static int exec_SetTextColor( filter_t *p_filter, ...@@ -741,7 +742,7 @@ static int exec_SetTextColor( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_ovl->fontstyle.i_font_color = p_params->fontstyle.i_font_color; p_ovl->p_fontstyle->i_font_color = p_params->fontstyle.i_font_color;
p_sys->b_updated = p_ovl->b_active; p_sys->b_updated = p_ovl->b_active;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -757,7 +758,7 @@ static int exec_SetTextSize( filter_t *p_filter, ...@@ -757,7 +758,7 @@ static int exec_SetTextSize( filter_t *p_filter,
if( p_ovl == NULL ) if( p_ovl == NULL )
return VLC_EGENERIC; return VLC_EGENERIC;
p_ovl->fontstyle.i_font_size = p_params->fontstyle.i_font_size; p_ovl->p_fontstyle->i_font_size = p_params->fontstyle.i_font_size;
p_sys->b_updated = p_ovl->b_active; p_sys->b_updated = p_ovl->b_active;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -204,8 +204,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -204,8 +204,7 @@ static int CreateFilter( vlc_object_t *p_this )
return VLC_ENOMEM; return VLC_ENOMEM;
vlc_mutex_init( &p_sys->lock ); vlc_mutex_init( &p_sys->lock );
p_sys->p_style = malloc( sizeof( text_style_t ) ); p_sys->p_style = text_style_New();
memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ) );
config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options, config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
p_filter->p_cfg ); p_filter->p_cfg );
...@@ -242,7 +241,7 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -242,7 +241,7 @@ static void DestroyFilter( vlc_object_t *p_this )
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
/* Delete the marquee variables */ /* Delete the marquee variables */
...@@ -323,7 +322,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -323,7 +322,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->p_region->i_x = p_sys->i_xoff; p_spu->p_region->i_x = p_sys->i_xoff;
p_spu->p_region->i_y = p_sys->i_yoff; p_spu->p_region->i_y = p_sys->i_yoff;
p_spu->p_region->p_style = p_sys->p_style; p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
out: out:
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
......
...@@ -272,7 +272,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -272,7 +272,7 @@ static int CreateFilter( vlc_object_t *p_this )
} }
p_sys->psz_marquee[p_sys->i_length] = '\0'; p_sys->psz_marquee[p_sys->i_length] = '\0';
p_sys->p_style = malloc( sizeof( text_style_t )); p_sys->p_style = text_style_New();
if( p_sys->p_style == NULL ) if( p_sys->p_style == NULL )
{ {
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
...@@ -282,7 +282,6 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -282,7 +282,6 @@ static int CreateFilter( vlc_object_t *p_this )
free( p_sys ); free( p_sys );
return VLC_ENOMEM; return VLC_ENOMEM;
} }
memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ));
p_sys->i_xoff = var_CreateGetInteger( p_filter, CFG_PREFIX "x" ); p_sys->i_xoff = var_CreateGetInteger( p_filter, CFG_PREFIX "x" );
p_sys->i_yoff = var_CreateGetInteger( p_filter, CFG_PREFIX "y" ); p_sys->i_yoff = var_CreateGetInteger( p_filter, CFG_PREFIX "y" );
...@@ -299,7 +298,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -299,7 +298,7 @@ static int CreateFilter( vlc_object_t *p_this )
if( FetchRSS( p_filter ) ) if( FetchRSS( p_filter ) )
{ {
msg_Err( p_filter, "failed while fetching RSS ... too bad" ); msg_Err( p_filter, "failed while fetching RSS ... too bad" );
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
...@@ -311,7 +310,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -311,7 +310,7 @@ static int CreateFilter( vlc_object_t *p_this )
if( p_sys->i_feeds == 0 ) if( p_sys->i_feeds == 0 )
{ {
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
...@@ -323,7 +322,7 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -323,7 +322,7 @@ static int CreateFilter( vlc_object_t *p_this )
{ {
if( p_sys->p_feeds[i_feed].i_items == 0 ) if( p_sys->p_feeds[i_feed].i_items == 0 )
{ {
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
FreeRSS( p_filter ); FreeRSS( p_filter );
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
...@@ -351,7 +350,7 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -351,7 +350,7 @@ static void DestroyFilter( vlc_object_t *p_this )
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
free( p_sys->p_style ); text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee ); free( p_sys->psz_marquee );
free( p_sys->psz_urls ); free( p_sys->psz_urls );
FreeRSS( p_filter ); FreeRSS( p_filter );
...@@ -530,7 +529,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -530,7 +529,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
p_spu->b_absolute = false; p_spu->b_absolute = false;
} }
p_spu->p_region->p_style = p_sys->p_style; p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
if( p_feed->p_pic ) if( p_feed->p_pic )
{ {
......
...@@ -534,4 +534,8 @@ vout_ShowTextAbsolute ...@@ -534,4 +534,8 @@ vout_ShowTextAbsolute
vout_ShowTextRelative vout_ShowTextRelative
vout_UnlinkPicture vout_UnlinkPicture
__xml_Create __xml_Create
text_style_Copy
text_style_Delete
text_style_Duplicate
text_style_New
xml_Delete xml_Delete
...@@ -35,14 +35,14 @@ ...@@ -35,14 +35,14 @@
* \param p_spu pointer to the subpicture queue the text is to be showed on * \param p_spu pointer to the subpicture queue the text is to be showed on
* \param i_channel Subpicture channel * \param i_channel Subpicture channel
* \param psz_string The text to be shown * \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info * \param p_style Pointer to a struct with text style info (it is duplicated)
* \param i_flags flags for alignment and such * \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels * \param i_hmargin horizontal margin in pixels
* \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.
*/ */
int osd_ShowTextRelative( spu_t *p_spu, int i_channel, int osd_ShowTextRelative( spu_t *p_spu, int i_channel,
const char *psz_string, text_style_t *p_style, const char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_duration ) mtime_t i_duration )
{ {
...@@ -58,7 +58,7 @@ int osd_ShowTextRelative( spu_t *p_spu, int i_channel, ...@@ -58,7 +58,7 @@ int osd_ShowTextRelative( spu_t *p_spu, int i_channel,
* \param p_spu pointer to the subpicture queue the text is to be showed on * \param p_spu pointer to the subpicture queue the text is to be showed on
* \param i_channel Subpicture channel * \param i_channel Subpicture channel
* \param psz_string The text to be shown * \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info * \param p_style Pointer to a struct with text style info (it is duplicated)
* \param i_flags flags for alignment and such * \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels * \param i_hmargin horizontal margin in pixels
* \param i_vmargin vertical margin in pixels * \param i_vmargin vertical margin in pixels
...@@ -68,7 +68,7 @@ int osd_ShowTextRelative( spu_t *p_spu, int i_channel, ...@@ -68,7 +68,7 @@ int osd_ShowTextRelative( spu_t *p_spu, int i_channel,
* is about to be shown * is about to be shown
*/ */
int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel, int osd_ShowTextAbsolute( spu_t *p_spu_channel, int i_channel,
const char *psz_string, text_style_t *p_style, const char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop ) mtime_t i_start, mtime_t i_stop )
{ {
......
...@@ -36,14 +36,14 @@ ...@@ -36,14 +36,14 @@
* \param p_vout pointer to the vout the text is to be showed on * \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel * \param i_channel Subpicture channel
* \param psz_string The text to be shown * \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info * \param p_style Pointer to a struct with text style info (it is duplicated if non NULL)
* \param i_flags flags for alignment and such * \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels * \param i_hmargin horizontal margin in pixels
* \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.
*/ */
int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel, int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel,
char *psz_string, text_style_t *p_style, char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_duration ) mtime_t i_duration )
{ {
...@@ -59,7 +59,7 @@ int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel, ...@@ -59,7 +59,7 @@ int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel,
* \param p_vout pointer to the vout the text is to be showed on * \param p_vout pointer to the vout the text is to be showed on
* \param i_channel Subpicture channel * \param i_channel Subpicture channel
* \param psz_string The text to be shown * \param psz_string The text to be shown
* \param p_style Pointer to a struct with text style info * \param p_style Pointer to a struct with text style info (it is duplicated if non NULL)
* \param i_flags flags for alignment and such * \param i_flags flags for alignment and such
* \param i_hmargin horizontal margin in pixels * \param i_hmargin horizontal margin in pixels
* \param i_vmargin vertical margin in pixels * \param i_vmargin vertical margin in pixels
...@@ -69,14 +69,12 @@ int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel, ...@@ -69,14 +69,12 @@ int vout_ShowTextRelative( vout_thread_t *p_vout, int i_channel,
* is about to be shown * is about to be shown
*/ */
int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
const char *psz_string, text_style_t *p_style, const char *psz_string, const text_style_t *p_style,
int i_flags, int i_hmargin, int i_vmargin, int i_flags, int i_hmargin, int i_vmargin,
mtime_t i_start, mtime_t i_stop ) mtime_t i_start, mtime_t i_stop )
{ {
(void)p_style;
subpicture_t *p_spu; subpicture_t *p_spu;
video_format_t fmt; video_format_t fmt;
/* (void)p_style; FIXME: <-- why ask for this if it's unused?!? */
if( !psz_string ) return VLC_EGENERIC; if( !psz_string ) return VLC_EGENERIC;
...@@ -110,6 +108,8 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel, ...@@ -110,6 +108,8 @@ int vout_ShowTextAbsolute( vout_thread_t *p_vout, int i_channel,
p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK; p_spu->p_region->i_align = i_flags & SUBPICTURE_ALIGN_MASK;
p_spu->p_region->i_x = i_hmargin; p_spu->p_region->i_x = i_hmargin;
p_spu->p_region->i_y = i_vmargin; p_spu->p_region->i_y = i_vmargin;
if( p_style )
p_spu->p_region->p_style = text_style_Duplicate( p_style );
spu_DisplaySubpicture( p_vout->p_spu, p_spu ); spu_DisplaySubpicture( p_vout->p_spu, p_spu );
...@@ -151,3 +151,69 @@ void __vout_OSDMessage( vlc_object_t *p_caller, int i_channel, ...@@ -151,3 +151,69 @@ void __vout_OSDMessage( vlc_object_t *p_caller, int i_channel,
va_end( args ); va_end( args );
} }
} }
/* */
text_style_t *text_style_New( void )
{
text_style_t *p_style = calloc( 1, sizeof(*p_style) );
if( !p_style )
return NULL;
/* initialize to default text style */
p_style->psz_fontname = NULL;
p_style->i_font_size = 22;
p_style->i_font_color = 0xffffff;
p_style->i_font_alpha = 0xff;
p_style->i_style_flags = STYLE_OUTLINE;
p_style->i_outline_color = 0x000000;
p_style->i_outline_alpha = 0xff;
p_style->i_shadow_color = 0x000000;
p_style->i_shadow_alpha = 0xff;
p_style->i_background_color = 0xffffff;
p_style->i_background_alpha = 0x80;
p_style->i_karaoke_background_color = 0xffffff;
p_style->i_karaoke_background_alpha = 0xff;
p_style->i_outline_width = 1;
p_style->i_shadow_width = 0;
p_style->i_spacing = -1;
return p_style;
}
text_style_t *text_style_Copy( text_style_t *p_dst, const text_style_t *p_src )
{
if( !p_src )
return p_dst;
/* */
if( p_dst->psz_fontname )
free( p_dst->psz_fontname );
/* */
*p_dst = *p_src;
/* */
if( p_dst->psz_fontname )
p_dst->psz_fontname = strdup( p_dst->psz_fontname );
return p_dst;
}
text_style_t *text_style_Duplicate( const text_style_t *p_src )
{
if( !p_src )
return NULL;
text_style_t *p_dst = calloc( 1, sizeof(*p_dst) );
if( p_dst )
text_style_Copy( p_dst, p_src );
return p_dst;
}
void text_style_Delete( text_style_t *p_style )
{
if( p_style )
free( p_style->psz_fontname );
free( p_style );
}
...@@ -779,7 +779,8 @@ void subpicture_region_Delete( subpicture_region_t *p_region ) ...@@ -779,7 +779,8 @@ void subpicture_region_Delete( subpicture_region_t *p_region )
free( p_region->psz_text ); free( p_region->psz_text );
free( p_region->psz_html ); free( p_region->psz_html );
//free( p_region->p_style ); FIXME --fenrir plugin does not allocate the memory for it. I think it might lead to segfault, video renderer can live longer than the decoder if( p_region->p_style )
text_style_Delete( p_region->p_style );
free( p_region ); free( p_region );
} }
......
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