Commit 68d6b61e authored by Laurent Aimar's avatar Laurent Aimar

Used INPUT_REPLACE_INFOS/INPUT_MERGE_INFOS in es_out (close #3070).

parent 68fe87d7
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "decoder.h" #include "decoder.h"
#include "es_out.h" #include "es_out.h"
#include "event.h" #include "event.h"
#include "info.h"
#include "../stream_output/stream_output.h" #include "../stream_output/stream_output.h"
...@@ -1166,7 +1167,6 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me ...@@ -1166,7 +1167,6 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
es_out_pgrm_t *p_pgrm; es_out_pgrm_t *p_pgrm;
input_thread_t *p_input = p_sys->p_input; input_thread_t *p_input = p_sys->p_input;
char *psz_cat;
const char *psz_title = NULL; const char *psz_title = NULL;
const char *psz_provider = NULL; const char *psz_provider = NULL;
int i; int i;
...@@ -1228,27 +1228,40 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me ...@@ -1228,27 +1228,40 @@ static void EsOutProgramMeta( es_out_t *out, int i_group, const vlc_meta_t *p_me
} }
} }
psz_cat = EsOutProgramGetMetaName( p_pgrm ); /* */
if( psz_provider ) char **ppsz_all_keys = vlc_meta_CopyExtraNames(p_meta );
info_category_t *p_cat = NULL;
if( psz_provider || *ppsz_all_keys[0] )
{ {
if( p_sys->p_pgrm == p_pgrm ) char *psz_cat = EsOutProgramGetMetaName( p_pgrm );
{ if( psz_cat )
input_item_SetPublisher( p_input->p->p_item, psz_provider ); p_cat = info_category_New( psz_cat );
input_SendEventMeta( p_input ); free( psz_cat );
}
input_Control( p_input, INPUT_ADD_INFO, psz_cat, vlc_meta_TypeToLocalizedString(vlc_meta_Publisher), psz_provider );
} }
char ** ppsz_all_keys = vlc_meta_CopyExtraNames(p_meta );
for( i = 0; ppsz_all_keys[i]; i++ ) for( i = 0; ppsz_all_keys[i]; i++ )
{ {
input_Control( p_input, INPUT_ADD_INFO, psz_cat, if( p_cat )
vlc_gettext(ppsz_all_keys[i]), info_category_AddInfo( p_cat, vlc_gettext(ppsz_all_keys[i]), "%s",
vlc_meta_GetExtra( p_meta, ppsz_all_keys[i] ) ); vlc_meta_GetExtra( p_meta, ppsz_all_keys[i] ) );
free( ppsz_all_keys[i] ); free( ppsz_all_keys[i] );
} }
free( ppsz_all_keys ); free( ppsz_all_keys );
free( psz_cat ); if( psz_provider )
{
if( p_sys->p_pgrm == p_pgrm )
{
input_item_SetPublisher( p_input->p->p_item, psz_provider );
input_SendEventMeta( p_input );
}
if( p_cat )
info_category_AddInfo( p_cat, vlc_meta_TypeToLocalizedString(vlc_meta_Publisher),
"%s",psz_provider );
}
if( p_cat )
input_Control( p_input, INPUT_MERGE_INFOS, p_cat );
} }
static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg ) static void EsOutProgramEpg( es_out_t *out, int i_group, const vlc_epg_t *p_epg )
...@@ -2789,16 +2802,15 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2789,16 +2802,15 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
es_out_sys_t *p_sys = out->p_sys; es_out_sys_t *p_sys = out->p_sys;
input_thread_t *p_input = p_sys->p_input; input_thread_t *p_input = p_sys->p_input;
const es_format_t *p_fmt_es = &es->fmt; const es_format_t *p_fmt_es = &es->fmt;
char *psz_cat;
lldiv_t div; lldiv_t div;
/* Create category name */ /* Create category */
if( asprintf( &psz_cat, _("Stream %d"), es->i_meta_id ) == -1 ) char psz_cat[128];
snprintf( psz_cat, sizeof(psz_cat),_("Stream %d"), es->i_meta_id );
info_category_t *p_cat = info_category_New( psz_cat );
if( !p_cat )
return; return;
/* Remove previous information */
input_Control( p_input, INPUT_DEL_INFO, psz_cat, NULL );
/* Add informations */ /* Add informations */
const char *psz_type; const char *psz_type;
switch( fmt->i_cat ) switch( fmt->i_cat )
...@@ -2818,46 +2830,45 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2818,46 +2830,45 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
} }
if( psz_type ) if( psz_type )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Type"), psz_type ); info_category_AddInfo( p_cat, _("Type"), "%s", psz_type );
if( es->i_meta_id != es->i_id ) if( es->i_meta_id != es->i_id )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Original ID"), info_category_AddInfo( p_cat, _("Original ID"),
"%d", es->i_id ); "%d", es->i_id );
const char *psz_codec_description = const char *psz_codec_description =
vlc_fourcc_GetDescription( p_fmt_es->i_cat, p_fmt_es->i_codec ); vlc_fourcc_GetDescription( p_fmt_es->i_cat, p_fmt_es->i_codec );
const vlc_fourcc_t i_codec_fourcc = p_fmt_es->i_original_fourcc ?: p_fmt_es->i_codec; const vlc_fourcc_t i_codec_fourcc = p_fmt_es->i_original_fourcc ?: p_fmt_es->i_codec;
if( psz_codec_description ) if( psz_codec_description )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"), info_category_AddInfo( p_cat, _("Codec"), "%s (%.4s)",
"%s (%.4s)", psz_codec_description, (char*)&i_codec_fourcc ); psz_codec_description, (char*)&i_codec_fourcc );
else else
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"), info_category_AddInfo( p_cat, _("Codec"), "%.4s",
"%.4s", (char*)&i_codec_fourcc ); (char*)&i_codec_fourcc );
if( es->psz_language && *es->psz_language ) if( es->psz_language && *es->psz_language )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"), info_category_AddInfo( p_cat, _("Language"), "%s",
"%s", es->psz_language ); es->psz_language );
if( fmt->psz_description && *fmt->psz_description ) if( fmt->psz_description && *fmt->psz_description )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Description"), info_category_AddInfo( p_cat, _("Description"), "%s",
"%s", fmt->psz_description ); fmt->psz_description );
switch( fmt->i_cat ) switch( fmt->i_cat )
{ {
case AUDIO_ES: case AUDIO_ES:
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Type"), _("Audio") );
_("Type"), _("Audio") );
if( fmt->audio.i_physical_channels & AOUT_CHAN_PHYSMASK ) if( fmt->audio.i_physical_channels & AOUT_CHAN_PHYSMASK )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"), info_category_AddInfo( p_cat, _("Channels"), "%s",
"%s", _( aout_FormatPrintChannels( &fmt->audio ) ) ); _( aout_FormatPrintChannels( &fmt->audio ) ) );
else if( fmt->audio.i_channels > 0 ) else if( fmt->audio.i_channels > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"), info_category_AddInfo( p_cat, _("Channels"), "%u",
"%u", fmt->audio.i_channels ); fmt->audio.i_channels );
if( fmt->audio.i_rate > 0 ) if( fmt->audio.i_rate > 0 )
{ {
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"), info_category_AddInfo( p_cat, _("Sample rate"), _("%u Hz"),
_("%u Hz"), fmt->audio.i_rate ); fmt->audio.i_rate );
/* FIXME that should be removed or improved ! (used by text/strings.c) */ /* FIXME that should be removed or improved ! (used by text/strings.c) */
var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate ); var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate );
} }
...@@ -2866,14 +2877,13 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2866,14 +2877,13 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
if( i_bitspersample <= 0 ) if( i_bitspersample <= 0 )
i_bitspersample = aout_BitsPerSample( p_fmt_es->i_codec ); i_bitspersample = aout_BitsPerSample( p_fmt_es->i_codec );
if( i_bitspersample > 0 ) if( i_bitspersample > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Bits per sample"), "%u",
_("Bits per sample"), "%u", i_bitspersample );
i_bitspersample );
if( fmt->i_bitrate > 0 ) if( fmt->i_bitrate > 0 )
{ {
input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"), info_category_AddInfo( p_cat, _("Bitrate"), _("%u kb/s"),
_("%u kb/s"), fmt->i_bitrate / 1000 ); fmt->i_bitrate / 1000 );
/* FIXME that should be removed or improved ! (used by text/strings.c) */ /* FIXME that should be removed or improved ! (used by text/strings.c) */
var_SetInteger( p_input, "bit-rate", fmt->i_bitrate ); var_SetInteger( p_input, "bit-rate", fmt->i_bitrate );
} }
...@@ -2887,26 +2897,23 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2887,26 +2897,23 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
psz_name = _("Track replay gain"); psz_name = _("Track replay gain");
else else
psz_name = _("Album replay gain"); psz_name = _("Album replay gain");
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, psz_name, _("%.2f dB"),
psz_name, _("%.2f dB"), p_rg->pf_gain[i] ); p_rg->pf_gain[i] );
} }
break; break;
case VIDEO_ES: case VIDEO_ES:
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Type"), _("Video") );
_("Type"), _("Video") );
if( fmt->video.i_width > 0 && fmt->video.i_height > 0 ) if( fmt->video.i_width > 0 && fmt->video.i_height > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Resolution"), "%ux%u",
_("Resolution"), "%ux%u", fmt->video.i_width, fmt->video.i_height );
fmt->video.i_width, fmt->video.i_height );
if( fmt->video.i_visible_width > 0 && if( fmt->video.i_visible_width > 0 &&
fmt->video.i_visible_height > 0 ) fmt->video.i_visible_height > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Display resolution"), "%ux%u",
_("Display resolution"), "%ux%u", fmt->video.i_visible_width,
fmt->video.i_visible_width, fmt->video.i_visible_height);
fmt->video.i_visible_height);
if( fmt->video.i_frame_rate > 0 && if( fmt->video.i_frame_rate > 0 &&
fmt->video.i_frame_rate_base > 0 ) fmt->video.i_frame_rate_base > 0 )
{ {
...@@ -2914,18 +2921,16 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2914,18 +2921,16 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
fmt->video.i_frame_rate_base * 1000000, fmt->video.i_frame_rate_base * 1000000,
1000000 ); 1000000 );
if( div.rem > 0 ) if( div.rem > 0 )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Frame rate"), "%"PRId64".%06u",
_("Frame rate"), "%"PRId64".%06u", div.quot, (unsigned int )div.rem );
div.quot, (unsigned int )div.rem );
else else
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Frame rate"), "%"PRId64,
_("Frame rate"), "%"PRId64, div.quot ); div.quot );
} }
break; break;
case SPU_ES: case SPU_ES:
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, _("Type"), _("Subtitle") );
_("Type"), _("Subtitle") );
break; break;
default: default:
...@@ -2942,12 +2947,13 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t * ...@@ -2942,12 +2947,13 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
const char *psz_value = vlc_meta_GetExtra( p_meta, psz_key ); const char *psz_value = vlc_meta_GetExtra( p_meta, psz_key );
if( psz_value ) if( psz_value )
input_Control( p_input, INPUT_ADD_INFO, psz_cat, info_category_AddInfo( p_cat, vlc_gettext(psz_key), "%s",
vlc_gettext(psz_key), vlc_gettext(psz_value) ); vlc_gettext(psz_value) );
free( psz_key ); free( psz_key );
} }
free( ppsz_all_keys ); free( ppsz_all_keys );
} }
/* */
free( psz_cat ); input_Control( p_input, INPUT_REPLACE_INFOS, p_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