Commit 72d2a5b4 authored by Antoine Cellerier's avatar Antoine Cellerier

subpicture_t now has a b_pausable attribute. When set to VLC_TRUE (default...

subpicture_t now has a b_pausable attribute. When set to VLC_TRUE (default value is VLC_FALSE), this will keep displaying the subpicture_t when the parent input is paused. This means that subtitles should now be paused when clicking on pause. (refs #29)
parent 532a761d
......@@ -104,7 +104,7 @@ VLC_EXPORT( subpicture_region_t *,__spu_MakeRegion, ( vlc_object_t *, video_form
#define spu_DestroyRegion(a,b) __spu_DestroyRegion(VLC_OBJECT(a),b)
VLC_EXPORT( void, __spu_DestroyRegion, ( vlc_object_t *, subpicture_region_t * ) );
VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t ) );
VLC_EXPORT( subpicture_t *, spu_SortSubpictures, ( spu_t *, mtime_t, vlc_bool_t ) );
VLC_EXPORT( void, spu_RenderSubpictures, ( spu_t *, video_format_t *, picture_t *, picture_t *, subpicture_t *, int, int ) );
/** @}*/
......
......@@ -323,7 +323,7 @@ struct module_symbols_t
subpicture_region_t * (*__spu_CreateRegion_inner) (vlc_object_t *, video_format_t *);
subpicture_region_t * (*__spu_MakeRegion_inner) (vlc_object_t *, video_format_t *, picture_t *);
void (*__spu_DestroyRegion_inner) (vlc_object_t *, subpicture_region_t *);
subpicture_t * (*spu_SortSubpictures_inner) (spu_t *, mtime_t);
subpicture_t * (*spu_SortSubpictures_inner) (spu_t *, mtime_t, vlc_bool_t);
void (*spu_RenderSubpictures_inner) (spu_t *, video_format_t *, picture_t *, picture_t *, subpicture_t *, int, int);
char * (*stream_ReadLine_inner) (stream_t *);
stream_t * (*__stream_DemuxNew_inner) (vlc_object_t *p_obj, char *psz_demux, es_out_t *out);
......
......@@ -246,6 +246,8 @@ struct subpicture_t
vlc_bool_t b_ephemer; /**< If this flag is set to true the subtitle
will be displayed untill the next one appear */
vlc_bool_t b_fade; /**< enable fading */
vlc_bool_t b_pausable; /**< subpicture will be paused if
stream is paused */
/**@}*/
subpicture_region_t *p_region; /**< region list composing this subtitle */
......
......@@ -496,6 +496,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL;
p_spu->b_pausable = VLC_TRUE;
p_spu->i_x = p_sys->i_x_start;
p_spu->i_x = p_spu->i_x * 3 / 4; /* FIXME: use aspect ratio for x? */
p_spu->i_y = p_sys->i_y_start;
......
......@@ -285,6 +285,8 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
picture_t *p_image = (picture_t *)p_dec->p_sys;
picture_t *p_pic;
printf("pouet\n");
if( pp_block == NULL || !*pp_block ) return NULL;
p_pic = p_dec->pf_vout_buffer_new( p_dec );
if( p_pic == NULL )
......
......@@ -71,6 +71,8 @@ subpicture_t * E_(ParsePacket)( decoder_t *p_dec )
p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL;
p_spu->b_pausable = VLC_TRUE;
/* Rationale for the "p_spudec->i_rle_size * 4": we are going to
* expand the RLE stuff so that we won't need to read nibbles later
* on. This will speed things up a lot. Plus, we'll only need to do
......
......@@ -381,6 +381,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
return NULL;
}
p_spu->b_pausable = VLC_TRUE;
/* Create a new subpicture region */
memset( &fmt, 0, sizeof(video_format_t) );
fmt.i_chroma = VLC_FOURCC('T','E','X','T');
......
......@@ -466,6 +466,8 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, block_t *p_data )
p_spu = p_dec->pf_spu_buffer_new( p_dec );
if( !p_spu ) return NULL;
p_spu->b_pausable = VLC_TRUE;
p_spu->i_x = p_sys->i_x_start;
p_spu->i_y = p_sys->i_y_start;
p_spu->i_start = p_data->i_pts;
......
......@@ -2319,7 +2319,8 @@ static int transcode_video_process( sout_stream_t *p_stream,
/* Check if we have a subpicture to overlay */
if( p_sys->p_spu )
{
p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date );
p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date,
VLC_FALSE /* Fixme: check if stream is paused */ );
/* TODO: get another pic */
}
......@@ -2884,7 +2885,7 @@ static int transcode_osd_process( sout_stream_t *p_stream,
/* Check if we have a subpicture to send */
if( p_sys->p_spu && in->i_dts > 0)
{
p_subpic = spu_SortSubpictures( p_sys->p_spu, in->i_dts );
p_subpic = spu_SortSubpictures( p_sys->p_spu, in->i_dts, VLC_FALSE );
}
else
{
......
......@@ -780,6 +780,8 @@ static void RunThread( vout_thread_t *p_vout)
display_date = 0;
current_date = mdate();
p_input = NULL;
i_loops++;
if( i_loops % 20 == 0 )
{
......@@ -1042,7 +1044,11 @@ static void RunThread( vout_thread_t *p_vout)
*/
if( display_date > 0 )
{
p_subpic = spu_SortSubpictures( p_vout->p_spu, display_date );
if( !p_input )
p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT,
FIND_PARENT );
p_subpic = spu_SortSubpictures( p_vout->p_spu, display_date,
p_input ? var_GetBool( p_input, "state" ) == PAUSE_S : VLC_FALSE );
}
/*
......
......@@ -445,7 +445,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
picture_t *p_pif;
vlc_value_t val, format;
DIR *path;
int i_ret;
var_Get( p_vout, "snapshot-path", &val );
......
......@@ -401,6 +401,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
memset( p_subpic, 0, sizeof(subpicture_t) );
p_subpic->i_status = RESERVED_SUBPICTURE;
p_subpic->b_absolute = VLC_TRUE;
p_subpic->b_pausable = VLC_FALSE;
p_subpic->b_fade = VLC_FALSE;
p_subpic->i_alpha = 0xFF;
p_subpic->p_region = 0;
......@@ -412,7 +413,7 @@ subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
p_subpic->pf_create_region = __spu_CreateRegion;
p_subpic->pf_make_region = __spu_MakeRegion;
p_subpic->pf_destroy_region = __spu_DestroyRegion;
return p_subpic;
}
......@@ -823,7 +824,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
* to be removed if a newer one is available), which makes it a lot
* more difficult to guess if a subpicture has to be rendered or not.
*****************************************************************************/
subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date )
subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
vlc_bool_t b_paused )
{
int i_index, i_channel;
subpicture_t *p_subpic = NULL;
......@@ -869,7 +871,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date )
if( display_date > p_spu->p_subpicture[i_index].i_stop &&
( !p_spu->p_subpicture[i_index].b_ephemer ||
p_spu->p_subpicture[i_index].i_stop >
p_spu->p_subpicture[i_index].i_start ) )
p_spu->p_subpicture[i_index].i_start ) &&
!( p_spu->p_subpicture[i_index].b_pausable &&
b_paused ) )
{
/* Too late, destroy the subpic */
spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
......
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