Commit 3d7cbf17 authored by Laurent Aimar's avatar Laurent Aimar

Display codec meta data.

parent d81aac69
......@@ -39,6 +39,7 @@
#include <vlc_sout.h>
#include <vlc_codec.h>
#include <vlc_osd.h>
#include <vlc_meta.h>
#include <vlc_interface.h>
#include "audio_output/aout_internal.h"
......@@ -103,6 +104,7 @@ struct decoder_owner_sys_t
/* */
bool b_fmt_description;
es_format_t fmt_description;
vlc_meta_t *p_description;
/* fifo */
block_fifo_t *p_fifo;
......@@ -600,7 +602,7 @@ void input_DecoderFrameNext( decoder_t *p_dec, mtime_t *pi_duration )
vlc_mutex_unlock( &p_owner->lock );
}
bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt )
bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_meta_t **pp_meta )
{
decoder_owner_sys_t *p_owner = p_dec->p_owner;
bool b_changed;
......@@ -611,6 +613,17 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt )
{
if( p_fmt )
es_format_Copy( p_fmt, &p_owner->fmt_description );
if( pp_meta )
{
*pp_meta = NULL;
if( p_owner->p_description )
{
*pp_meta = vlc_meta_New();
if( *pp_meta )
vlc_meta_Merge( *pp_meta, p_owner->p_description );
}
}
p_owner->b_fmt_description = false;
}
vlc_mutex_unlock( &p_owner->lock );
......@@ -799,6 +812,7 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
p_owner->b_fmt_description = false;
es_format_Init( &p_owner->fmt_description, UNKNOWN_ES, 0 );
p_owner->p_description = NULL;
p_owner->b_paused = false;
p_owner->pause.i_date = 0;
......@@ -2058,6 +2072,8 @@ static void DeleteDecoder( decoder_t * p_dec )
if( p_dec->p_description )
vlc_meta_Delete( p_dec->p_description );
es_format_Clean( &p_owner->fmt_description );
if( p_owner->p_description )
vlc_meta_Delete( p_owner->p_description );
if( p_owner->p_packetizer )
{
......@@ -2088,10 +2104,17 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
vlc_assert_locked( &p_owner->lock );
es_format_Clean( &p_owner->fmt_description );
p_owner->b_fmt_description = true;
/* Copy es_format */
es_format_Clean( &p_owner->fmt_description );
es_format_Copy( &p_owner->fmt_description, &p_dec->fmt_out );
/* Move p_description */
if( p_owner->p_description && p_dec->p_description )
vlc_meta_Delete( p_owner->p_description );
p_owner->p_description = p_dec->p_description;
p_dec->p_description = NULL;
}
static vout_thread_t *aout_request_vout( void *p_private,
vout_thread_t *p_vout, video_format_t *p_fmt )
......
......@@ -90,11 +90,13 @@ void input_DecoderIsCcPresent( decoder_t *, bool pb_present[4] );
void input_DecoderFrameNext( decoder_t *p_dec, mtime_t *pi_duration );
/**
* This function will return true if the ES format has changed since the last call
* and will do a copy of the current es_format_t if p_fmt is not NULL. This copy
* MUST be free by es_format_Clean.
* Otherwise it will return false and will not initialize p_fmt.
* This function will return true if the ES format or meta data have changed since
* the last call. In which case, it will do a copy of the current es_format_t if p_fmt
* is not NULL and will do a copy of the current description if pp_meta is non NULL.
* The es_format_t MUST be freed by es_format_Clean and *pp_meta MUST be freed by
* vlc_meta_Delete.
* Otherwise it will return false and will not initialize p_fmt and *pp_meta.
*/
bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt );
bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_meta_t **pp_meta );
#endif
......@@ -169,7 +169,7 @@ static int EsOutControl( es_out_t *, int i_query, va_list );
static void EsOutDelete ( es_out_t * );
static void EsOutSelect( es_out_t *, es_out_id_t *es, bool b_force );
static void EsOutUpdateInfo( es_out_t *, es_out_id_t *es, const es_format_t * );
static void EsOutUpdateInfo( es_out_t *, es_out_id_t *es, const es_format_t *, const vlc_meta_t * );
static int EsOutSetRecord( es_out_t *, bool b_record );
static bool EsIsSelected( es_out_id_t *es );
......@@ -1443,7 +1443,7 @@ static es_out_id_t *EsOutAdd( es_out_t *out, const es_format_t *fmt )
break;
}
EsOutUpdateInfo( out, es, &es->fmt );
EsOutUpdateInfo( out, es, &es->fmt, NULL );
vlc_mutex_unlock( &p_sys->lock );
......@@ -1849,10 +1849,14 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
input_DecoderDecode( es->p_dec, p_block );
es_format_t fmt_dsc;
if( input_DecoderHasFormatChanged( es->p_dec, &fmt_dsc ) )
vlc_meta_t *p_meta_dsc;
if( input_DecoderHasFormatChanged( es->p_dec, &fmt_dsc, &p_meta_dsc ) )
{
EsOutUpdateInfo( out, es, &fmt_dsc );
EsOutUpdateInfo( out, es, &fmt_dsc, p_meta_dsc );
es_format_Clean( &fmt_dsc );
if( p_meta_dsc )
vlc_meta_Delete( p_meta_dsc );
}
/* Check CC status */
......@@ -2530,7 +2534,7 @@ static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang )
* EsOutUpdateInfo:
* - add meta info to the playlist item
****************************************************************************/
static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *fmt )
static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *fmt, const vlc_meta_t *p_meta )
{
es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input;
......@@ -2671,5 +2675,21 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
break;
}
/* Append generic meta */
if( p_meta )
{
char **ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
for( int i = 0; ppsz_all_keys && ppsz_all_keys[i]; i++ )
{
char *psz_key = ppsz_all_keys[i];
char *psz_value = vlc_dictionary_value_for_key( &p_meta->extra_tags, psz_key );
if( psz_value )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(psz_key), _(psz_value) );
free( psz_key );
}
free( ppsz_all_keys );
}
free( psz_cat );
}
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