[vlc-devel] [PATCH 2/2] dvdnav: ES_OUT_SET_VOUT_HIGHLIGHT
Thomas Guillem
thomas at gllm.fr
Fri Jul 13 15:41:44 CEST 2018
---
modules/access/dvdnav.c | 80 ++++++++++++++++++++++-------------------
1 file changed, 43 insertions(+), 37 deletions(-)
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index da6ca086a6..c3dd2e356c 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -140,12 +140,14 @@ typedef struct
ps_track_t tk[PS_TK_COUNT];
int i_mux_rate;
+ vlc_mutex_t mouse_lock;
+ es_out_id_t *video_es;
+
/* event */
vout_thread_t *p_vout;
/* palette for menus */
uint32_t clut[16];
- uint8_t palette[4][4];
bool b_spu_change;
/* Aspect ration */
@@ -207,6 +209,7 @@ static int CommonOpen( vlc_object_t *p_this,
p_sys->b_reset_pcr = false;
ps_track_init( p_sys->tk );
+ p_sys->video_es = NULL;
p_sys->sar.i_num = 0;
p_sys->sar.i_den = 0;
p_sys->i_mux_rate = 0;
@@ -314,18 +317,9 @@ static int CommonOpen( vlc_object_t *p_this,
i_angle = var_CreateGetInteger( p_demux, "dvdnav-angle" );
if( i_angle <= 0 ) i_angle = 1;
- /* FIXME hack hack hack hack FIXME */
- /* Get p_input and create variable */
- var_Create( p_demux->p_input, "x-start", VLC_VAR_INTEGER );
- var_Create( p_demux->p_input, "y-start", VLC_VAR_INTEGER );
- var_Create( p_demux->p_input, "x-end", VLC_VAR_INTEGER );
- var_Create( p_demux->p_input, "y-end", VLC_VAR_INTEGER );
- var_Create( p_demux->p_input, "color", VLC_VAR_ADDRESS );
- var_Create( p_demux->p_input, "menu-palette", VLC_VAR_ADDRESS );
- var_Create( p_demux->p_input, "highlight", VLC_VAR_BOOL );
-
p_sys->still.b_enabled = false;
vlc_mutex_init( &p_sys->still.lock );
+ vlc_mutex_init( &p_sys->mouse_lock );
if( !vlc_timer_create( &p_sys->still.timer, StillTimer, p_sys ) )
p_sys->still.b_created = true;
@@ -513,14 +507,7 @@ static void Close( vlc_object_t *p_this )
if( p_sys->still.b_created )
vlc_timer_destroy( p_sys->still.timer );
vlc_mutex_destroy( &p_sys->still.lock );
-
- var_Destroy( p_demux->p_input, "highlight" );
- var_Destroy( p_demux->p_input, "x-start" );
- var_Destroy( p_demux->p_input, "x-end" );
- var_Destroy( p_demux->p_input, "y-start" );
- var_Destroy( p_demux->p_input, "y-end" );
- var_Destroy( p_demux->p_input, "color" );
- var_Destroy( p_demux->p_input, "menu-palette" );
+ vlc_mutex_destroy( &p_sys->mouse_lock );
for( int i = 0; i < PS_TK_COUNT; i++ )
{
@@ -975,7 +962,14 @@ static int Demux( demux_t *p_demux )
if( tk->b_configured )
{
es_format_Clean( &tk->fmt );
- if( tk->es ) es_out_Del( p_demux->out, tk->es );
+ if( tk->es )
+ {
+ vlc_mutex_lock( &p_sys->mouse_lock );
+ if( tk->es == p_sys->video_es )
+ p_sys->video_es = NULL;
+ es_out_Del( p_demux->out, tk->es );
+ vlc_mutex_unlock( &p_sys->mouse_lock );
+ }
}
tk->b_configured = false;
}
@@ -1267,6 +1261,9 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
demux_sys_t *p_sys = p_demux->p_sys;
int32_t i_title, i_part;
+ if( !p_sys->video_es )
+ return;
+
dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part );
dvdnav_highlight_area_t hl;
@@ -1291,25 +1288,27 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
if( b_button_ok )
{
+ vlc_vout_highlight vout_hl = {
+ .x_start = hl.sx,
+ .x_end = hl.ex,
+ .y_start = hl.sy,
+ .y_end = hl.ey,
+ .has_palette = true
+ };
+
for( unsigned i = 0; i < 4; i++ )
{
uint32_t i_yuv = p_sys->clut[(hl.palette>>(16+i*4))&0x0f];
uint8_t i_alpha = ( (hl.palette>>(i*4))&0x0f ) * 0xff / 0xf;
- p_sys->palette[i][0] = (i_yuv >> 16) & 0xff;
- p_sys->palette[i][1] = (i_yuv >> 0) & 0xff;
- p_sys->palette[i][2] = (i_yuv >> 8) & 0xff;
- p_sys->palette[i][3] = i_alpha;
+ vout_hl.palette[i][0] = (i_yuv >> 16) & 0xff;
+ vout_hl.palette[i][1] = (i_yuv >> 0) & 0xff;
+ vout_hl.palette[i][2] = (i_yuv >> 8) & 0xff;
+ vout_hl.palette[i][3] = i_alpha;
}
- vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
- var_SetInteger( p_demux->p_input, "x-start", hl.sx );
- var_SetInteger( p_demux->p_input, "x-end", hl.ex );
- var_SetInteger( p_demux->p_input, "y-start", hl.sy );
- var_SetInteger( p_demux->p_input, "y-end", hl.ey );
-
- var_SetAddress( p_demux->p_input, "menu-palette", p_sys->palette );
- var_SetBool( p_demux->p_input, "highlight", true );
+ es_out_Control( p_demux->out, ES_OUT_SET_VOUT_HIGHLIGHT, p_sys->video_es,
+ &vout_hl );
msg_Dbg( p_demux, "buttonUpdate %d", i_button );
}
@@ -1318,11 +1317,9 @@ static void ButtonUpdate( demux_t *p_demux, bool b_mode )
msg_Dbg( p_demux, "buttonUpdate not done b=%d t=%d",
i_button, i_title );
- /* Show all */
- vlc_global_lock( VLC_HIGHLIGHT_MUTEX );
- var_SetBool( p_demux->p_input, "highlight", false );
+ es_out_Control( p_demux->out, ES_OUT_SET_VOUT_HIGHLIGHT, p_sys->video_es,
+ NULL );
}
- vlc_global_unlock( VLC_HIGHLIGHT_MUTEX );
}
static void ESSubtitleUpdate( demux_t *p_demux )
@@ -1571,13 +1568,20 @@ static void ESNew( demux_t *p_demux, int i_id )
tk->fmt.i_id = i_id;
tk->es = es_out_Add( p_demux->out, &tk->fmt );
+ if( tk->fmt.i_cat == VIDEO_ES )
if( b_select && tk->es )
{
es_out_Control( p_demux->out, ES_OUT_SET_ES, tk->es );
}
tk->b_configured = true;
- if( tk->fmt.i_cat == VIDEO_ES ) ButtonUpdate( p_demux, false );
+ if( tk->fmt.i_cat == VIDEO_ES )
+ {
+ vlc_mutex_lock( &p_sys->mouse_lock );
+ p_sys->video_es = tk->es;
+ ButtonUpdate( p_demux, false );
+ vlc_mutex_unlock( &p_sys->mouse_lock );
+ }
}
/*****************************************************************************
@@ -1613,7 +1617,9 @@ static int EventMouse( vlc_object_t *p_vout, char const *psz_var,
{
assert( psz_var[6] == 'c' ); /* mouse-clicked */
+ vlc_mutex_lock( &p_sys->mouse_lock );
ButtonUpdate( p_demux, true );
+ vlc_mutex_unlock( &p_sys->mouse_lock );
dvdnav_mouse_activate( p_sys->dvdnav, pci, x, y );
}
(void)p_vout;
--
2.18.0
More information about the vlc-devel
mailing list