Commit ae780fe9 authored by Laurent Aimar's avatar Laurent Aimar

Added a ES_OUT_SET_META to es_out.

 It will allows to control the moment at which the meta are updated
to fix the delay introduced by timeshift and buffering.
 It will also simplify the way meta data are read by demuxers.
parent a86267a4
...@@ -82,6 +82,9 @@ enum es_out_query_e ...@@ -82,6 +82,9 @@ enum es_out_query_e
* XXX You SHALL call ES_OUT_RESET_PCR before any other es_out_Control/Send calls. */ * XXX You SHALL call ES_OUT_RESET_PCR before any other es_out_Control/Send calls. */
ES_OUT_GET_EMPTY, /* arg1=bool* res=cannot fail */ ES_OUT_GET_EMPTY, /* arg1=bool* res=cannot fail */
/* Set global meta data (The vlc_meta_t is not modified nor released) */
ES_OUT_SET_META, /* arg1=const vlc_meta_t * */
/* First value usable for private control */ /* First value usable for private control */
ES_OUT_PRIVATE_START = 0x10000, ES_OUT_PRIVATE_START = 0x10000,
}; };
...@@ -137,6 +140,11 @@ static inline void es_out_Delete( es_out_t *p_out ) ...@@ -137,6 +140,11 @@ static inline void es_out_Delete( es_out_t *p_out )
p_out->pf_destroy( p_out ); p_out->pf_destroy( p_out );
} }
static inline int es_out_ControlSetMeta( es_out_t *out, const vlc_meta_t *p_meta )
{
return es_out_Control( out, ES_OUT_SET_META, p_meta );
}
/** /**
* @} * @}
*/ */
......
...@@ -1373,6 +1373,58 @@ static void EsOutProgramUpdateScrambled( es_out_t *p_out, es_out_pgrm_t *p_pgrm ...@@ -1373,6 +1373,58 @@ static void EsOutProgramUpdateScrambled( es_out_t *p_out, es_out_pgrm_t *p_pgrm
input_SendEventProgramScrambled( p_input, p_pgrm->i_id, b_scrambled ); input_SendEventProgramScrambled( p_input, p_pgrm->i_id, b_scrambled );
} }
static void EsOutMeta( es_out_t *p_out, const vlc_meta_t *p_meta )
{
es_out_sys_t *p_sys = p_out->p_sys;
input_thread_t *p_input = p_sys->p_input;
input_item_t *p_item = input_GetItem( p_input );
char *psz_title = NULL;
char *psz_arturl = input_item_GetArtURL( p_item );
vlc_mutex_lock( &p_item->lock );
if( vlc_meta_Get( p_meta, vlc_meta_Title ) && !p_item->b_fixed_name )
psz_title = strdup( vlc_meta_Get( p_meta, vlc_meta_Title ) );
vlc_meta_Merge( p_item->p_meta, p_meta );
if( !psz_arturl || *psz_arturl == '\0' )
{
const char *psz_tmp = vlc_meta_Get( p_item->p_meta, vlc_meta_ArtworkURL );
if( psz_tmp )
psz_arturl = strdup( psz_tmp );
}
vlc_mutex_unlock( &p_item->lock );
if( psz_arturl && *psz_arturl )
{
input_item_SetArtURL( p_item, psz_arturl );
if( !strncmp( psz_arturl, "attachment://", strlen("attachment") ) )
{
/* Don't look for art cover if sout
* XXX It can change when sout has meta data support */
if( p_out->b_sout && !p_input->b_preparsing )
input_item_SetArtURL( p_item, "" );
else
input_ExtractAttachmentAndCacheArt( p_input );
}
}
free( psz_arturl );
if( psz_title )
{
input_item_SetName( p_item, psz_title );
free( psz_title );
}
input_item_SetPreparsed( p_item, true );
input_SendEventMeta( p_input );
/* TODO handle sout meta ? */
}
/* EsOutAdd: /* EsOutAdd:
* Add an es_out * Add an es_out
*/ */
...@@ -2401,6 +2453,14 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args ) ...@@ -2401,6 +2453,14 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
return EsOutProgramDel( out, i_group ); return EsOutProgramDel( out, i_group );
} }
case ES_OUT_SET_META:
{
const vlc_meta_t *p_meta = va_arg( args, const vlc_meta_t * );
EsOutMeta( out, p_meta );
return VLC_SUCCESS;
}
case ES_OUT_GET_WAKE_UP: case ES_OUT_GET_WAKE_UP:
{ {
mtime_t *pi_wakeup = (mtime_t*)va_arg( args, mtime_t* ); mtime_t *pi_wakeup = (mtime_t*)va_arg( args, mtime_t* );
......
...@@ -599,6 +599,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args ) ...@@ -599,6 +599,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_SET_GROUP_EPG: case ES_OUT_SET_GROUP_EPG:
case ES_OUT_SET_ES_SCRAMBLED_STATE: case ES_OUT_SET_ES_SCRAMBLED_STATE:
case ES_OUT_DEL_GROUP: case ES_OUT_DEL_GROUP:
case ES_OUT_SET_META:
case ES_OUT_SET_ES: case ES_OUT_SET_ES:
case ES_OUT_RESTART_ES: case ES_OUT_RESTART_ES:
case ES_OUT_SET_ES_DEFAULT: case ES_OUT_SET_ES_DEFAULT:
...@@ -1315,8 +1316,10 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co ...@@ -1315,8 +1316,10 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
case ES_OUT_RESET_PCR: /* no arg */ case ES_OUT_RESET_PCR: /* no arg */
break; break;
case ES_OUT_SET_META: /* arg1=const vlc_meta_t* */
case ES_OUT_SET_GROUP_META: /* arg1=int i_group arg2=const vlc_meta_t* */ case ES_OUT_SET_GROUP_META: /* arg1=int i_group arg2=const vlc_meta_t* */
{ {
if( i_query == ES_OUT_SET_GROUP_META )
p_cmd->control.int_meta.i_int = (int)va_arg( args, int ); p_cmd->control.int_meta.i_int = (int)va_arg( args, int );
const vlc_meta_t *p_meta = va_arg( args, const vlc_meta_t * ); const vlc_meta_t *p_meta = va_arg( args, const vlc_meta_t * );
...@@ -1461,6 +1464,9 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd ) ...@@ -1461,6 +1464,9 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
return es_out_Control( p_out, i_query, p_cmd->control.es_bool.p_es->p_es, return es_out_Control( p_out, i_query, p_cmd->control.es_bool.p_es->p_es,
p_cmd->control.es_bool.b_bool ); p_cmd->control.es_bool.b_bool );
case ES_OUT_SET_META: /* arg1=const vlc_meta_t* */
return es_out_Control( p_out, i_query, p_cmd->control.int_meta.p_meta );
/* Modified control */ /* Modified control */
case ES_OUT_SET_ES: /* arg1= es_out_id_t* */ case ES_OUT_SET_ES: /* arg1= es_out_id_t* */
case ES_OUT_RESTART_ES: /* arg1= es_out_id_t* */ case ES_OUT_RESTART_ES: /* arg1= es_out_id_t* */
...@@ -1490,7 +1496,8 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd ) ...@@ -1490,7 +1496,8 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
} }
static void CmdCleanControl( ts_cmd_t *p_cmd ) static void CmdCleanControl( ts_cmd_t *p_cmd )
{ {
if( p_cmd->control.i_query == ES_OUT_SET_GROUP_META && if( ( p_cmd->control.i_query == ES_OUT_SET_GROUP_META ||
p_cmd->control.i_query == ES_OUT_SET_META ) &&
p_cmd->control.int_meta.p_meta ) p_cmd->control.int_meta.p_meta )
{ {
vlc_meta_Delete( p_cmd->control.int_meta.p_meta ); vlc_meta_Delete( p_cmd->control.int_meta.p_meta );
......
...@@ -2914,54 +2914,8 @@ static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta ) ...@@ -2914,54 +2914,8 @@ static void InputMetaUser( input_thread_t *p_input, vlc_meta_t *p_meta )
*****************************************************************************/ *****************************************************************************/
static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta ) static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
{ {
input_item_t *p_item = p_input->p->p_item; es_out_ControlSetMeta( p_input->p->p_es_out, p_meta );
char *psz_title = NULL;
char *psz_arturl = input_item_GetArtURL( p_item );
vlc_mutex_lock( &p_item->lock );
if( vlc_meta_Get( p_meta, vlc_meta_Title ) && !p_item->b_fixed_name )
psz_title = strdup( vlc_meta_Get( p_meta, vlc_meta_Title ) );
vlc_meta_Merge( p_item->p_meta, p_meta );
vlc_meta_Delete( p_meta ); vlc_meta_Delete( p_meta );
if( !psz_arturl || *psz_arturl == '\0' )
{
const char *psz_tmp = vlc_meta_Get( p_item->p_meta, vlc_meta_ArtworkURL );
if( psz_tmp )
psz_arturl = strdup( psz_tmp );
}
vlc_mutex_unlock( &p_item->lock );
if( psz_arturl && *psz_arturl )
{
input_item_SetArtURL( p_item, psz_arturl );
if( !strncmp( psz_arturl, "attachment://", strlen("attachment") ) )
{
/* Don't look for art cover if sout
* XXX It can change when sout has meta data support */
if( p_input->p->p_sout && !p_input->b_preparsing )
input_item_SetArtURL( p_item, "" );
else
input_ExtractAttachmentAndCacheArt( p_input );
}
}
free( psz_arturl );
if( psz_title )
{
input_item_SetName( p_item, psz_title );
free( psz_title );
}
input_item_SetPreparsed( p_item, true );
input_SendEventMeta( p_input );
/** \todo handle sout meta */
} }
static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_attachment, static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_attachment,
......
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