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

* src/input/input.c: es_out_Add automatically add informations

 (input_AddInfo) on the ES.
 * all: removed duplicated input_AddInfo.
parent e33dbc3f
......@@ -2,7 +2,7 @@
* a52.c : Raw a52 Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52sys.c,v 1.7 2003/11/11 00:37:59 fenrir Exp $
* $Id: a52sys.c,v 1.8 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -139,26 +139,15 @@ static int Open( vlc_object_t * p_this )
goto error;
}
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'a', '5', '2', ' ' ) );
if( HeaderCheck( p_peek ) )
{
int i_channels, i_sample_rate, i_frame_size;
input_info_category_t * p_category;
HeaderInfo( p_peek, &i_channels, &i_sample_rate, &i_frame_size );
msg_Dbg( p_input,
"a52 channels=%d sample_rate=%d",
i_channels, i_sample_rate );
vlc_mutex_lock( &p_input->stream.stream_lock );
int i_frame_size;
p_category = input_InfoCategory( p_input, _("A52") );
HeaderInfo( p_peek, &fmt.audio.i_channels, &fmt.audio.i_samplerate, &i_frame_size );
input_AddInfo( p_category, _("Input Type"), "A52" );
input_AddInfo( p_category, _("Channels"), "%d", i_channels );
input_AddInfo( p_category, _("Sample Rate"), "%dHz", i_sample_rate );
vlc_mutex_unlock( &p_input->stream.stream_lock );
msg_Dbg( p_input, "a52 channels=%d sample_rate=%d",
fmt.audio.i_channels, fmt.audio.i_samplerate );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......@@ -171,7 +160,6 @@ static int Open( vlc_object_t * p_this )
p_input->stream.i_mux_rate = 0 / 50;
vlc_mutex_unlock( &p_input->stream.stream_lock );
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'a', '5', '2', ' ' ) );
p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt );
return VLC_SUCCESS;
......
......@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aac.c,v 1.5 2003/11/11 00:37:59 fenrir Exp $
* $Id: aac.c,v 1.6 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -153,27 +153,17 @@ static int Open( vlc_object_t * p_this )
goto error;
}
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) );
if( HeaderCheck( p_peek ) )
{
input_info_category_t * p_category;
fmt.audio.i_channels = AAC_CHANNELS( p_peek );
fmt.audio.i_samplerate = AAC_SAMPLE_RATE( p_peek );
msg_Dbg( p_input,
"adts header: id=%d channels=%d sample_rate=%d",
AAC_ID( p_peek ),
AAC_CHANNELS( p_peek ),
AAC_SAMPLE_RATE( p_peek ) );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_category = input_InfoCategory( p_input, _("Aac") );
input_AddInfo( p_category, _("Input Type"), "MPEG-%d AAC",
AAC_ID( p_peek ) == 1 ? 2 : 4 );
input_AddInfo( p_category, _("Channels"), "%d",
AAC_CHANNELS( p_peek ) );
input_AddInfo( p_category, _("Sample Rate"), "%dHz",
AAC_SAMPLE_RATE( p_peek ) );
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......@@ -186,7 +176,6 @@ static int Open( vlc_object_t * p_this )
p_input->stream.i_mux_rate = 0 / 50;
vlc_mutex_unlock( &p_input->stream.stream_lock );
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) );
p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt );
return VLC_SUCCESS;
......
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2002-2003 VideoLAN
* $Id: asf.c,v 1.39 2003/11/11 00:37:59 fenrir Exp $
* $Id: asf.c,v 1.40 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -94,7 +94,7 @@ static int Open( vlc_object_t * p_this )
guid_t guid;
demux_sys_t *p_sys;
unsigned int i_stream;
unsigned int i_stream, i;
asf_object_content_description_t *p_cd;
vlc_bool_t b_seekable;
......@@ -311,54 +311,29 @@ static int Open( vlc_object_t * p_this )
input_AddInfo( p_cat, _("Rating"), p_cd->psz_rating );
}
#if 0
/* FIXME to port to new way */
for( i_stream = 0, i = 0; i < 128; i++ )
{
asf_stream_t *tk = p_sys->stream[i];
asf_object_codec_list_t *p_cl =
ASF_FindObject( p_sys->p_root->p_hdr,
&asf_object_codec_list_guid, 0 );
char psz_cat[sizeof(_("Stream "))+10];
if( p_sys->stream[i] == NULL )
{
continue;
}
sprintf( psz_cat, _("Stream %d"), i_stream );
p_cat = input_InfoCategory( p_input, psz_cat);
input_AddInfo( p_cat, _("Type"),
( tk->i_cat == AUDIO_ES ? _("Audio") : _("Video") ) );
input_AddInfo( p_cat, _("Codec"), "%.4s",
(char*)&tk->p_es->i_fourcc );
if( p_cl && i_stream < p_cl->i_codec_entries_count )
if( p_sys->stream[i] )
{
input_AddInfo( p_cat, _("Codec name"),
p_cl->codec[i_stream].psz_name );
input_AddInfo( p_cat, _("Codec description"),
p_cl->codec[i_stream].psz_description );
}
char psz_cat[sizeof(_("Stream "))+10];
sprintf( psz_cat, _("Stream %d"), i_stream );
p_cat = input_InfoCategory( p_input, psz_cat);
if( tk->i_cat == AUDIO_ES && tk->p_es->p_waveformatex )
{
WAVEFORMATEX *p_wf = tk->p_es->p_waveformatex;
input_AddInfo( p_cat, _("Channels"), "%d", p_wf->nChannels );
input_AddInfo( p_cat, _("Sample Rate"), "%d", p_wf->nSamplesPerSec );
input_AddInfo( p_cat, _("Avg. byterate"), "%d", p_wf->nAvgBytesPerSec );
input_AddInfo( p_cat, _("Bits Per Sample"), "%d", p_wf->wBitsPerSample );
}
else if( tk->i_cat == VIDEO_ES && tk->p_es->p_bitmapinfoheader )
{
BITMAPINFOHEADER *p_bih = tk->p_es->p_bitmapinfoheader;
input_AddInfo( p_cat, _("Resolution"), "%dx%d",
p_bih->biWidth, p_bih->biHeight );
if( p_cl && i_stream < p_cl->i_codec_entries_count )
{
input_AddInfo( p_cat, _("Codec name"),
p_cl->codec[i_stream].psz_name );
input_AddInfo( p_cat, _("Codec description"),
p_cl->codec[i_stream].psz_description );
}
i_stream++;
}
i_stream++;
}
#endif
return VLC_SUCCESS;
......
......@@ -2,7 +2,7 @@
* avi.c : AVI file Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: avi.c,v 1.65 2003/11/13 11:49:27 fenrir Exp $
* $Id: avi.c,v 1.66 2003/11/13 12:28:34 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -289,30 +289,6 @@ static int Open( vlc_object_t * p_this )
i,
p_auds->p_wf->wFormatTag, p_auds->p_wf->nChannels,
p_auds->p_wf->nSamplesPerSec, p_auds->p_wf->wBitsPerSample);
{
char psz_cat[ sizeof("Stream") + 10 ];
input_info_category_t *p_cat;
sprintf( psz_cat, _("Stream %d"), i );
p_cat = input_InfoCategory( p_input, psz_cat );
input_AddInfo( p_cat, _("Type"), "Audio(0x%x)",
p_auds->p_wf->wFormatTag );
input_AddInfo( p_cat, _("Codec"), "%4.4s",
(const char*)&(tk->i_codec) );
input_AddInfo( p_cat, _("FOURCC"), "0x%x",
tk->i_codec );
input_AddInfo( p_cat, _("Channels"), "%d",
p_auds->p_wf->nChannels );
input_AddInfo( p_cat, _("Sample Rate"), "%d",
p_auds->p_wf->nSamplesPerSec );
if( p_auds->p_wf->wBitsPerSample > 0 && tk->i_scale != 0 )
{
input_AddInfo( p_cat, _("Bits Per Sample"), "%d",
p_auds->p_wf->wBitsPerSample );
input_AddInfo( p_cat, _("Audio Bitrate"), "%d",
tk->i_samplesize * tk->i_rate
/ tk->i_scale );
}
}
break;
case( AVIFOURCC_vids ):
......@@ -337,22 +313,6 @@ static int Open( vlc_object_t * p_this )
p_vids->p_bih->biHeight,
p_vids->p_bih->biBitCount,
(float)tk->i_rate/(float)tk->i_scale );
{
char psz_cat[ sizeof("Stream") + 10 ];
input_info_category_t *p_cat;
sprintf( psz_cat, "Stream %d", i );
p_cat = input_InfoCategory( p_input, psz_cat );
input_AddInfo( p_cat, _("Type"), _("Video") );
input_AddInfo( p_cat, _("Codec"), "%4.4s",
(const char*)&(tk->i_codec) );
input_AddInfo( p_cat, _("FOURCC"), "0x%x",
tk->i_codec );
input_AddInfo( p_cat, _("Resolution"), "%dx%d",
p_vids->p_bih->biWidth,
p_vids->p_bih->biHeight );
input_AddInfo( p_cat, _("Frame Rate"), "%f",
(float)tk->i_rate/(float)tk->i_scale );
}
break;
default:
msg_Warn( p_input, "stream[%d] unknown type", i );
......
......@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.38 2003/11/11 01:33:18 fenrir Exp $
* $Id: mkv.cpp,v 1.39 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -2242,47 +2242,6 @@ static void InformationsCreate( input_thread_t *p_input )
{
input_AddInfo( p_cat, _("Codec Download"), "%s", tk.psz_codec_download_url );
}
switch( tk.fmt.i_cat )
{
case AUDIO_ES:
input_AddInfo( p_cat, _("Type"), _("Audio") );
input_AddInfo( p_cat, _("Codec"), "%.4s (%s)", (char*)&tk.fmt.i_codec, tk.psz_codec );
if( tk.fmt.audio.i_channels > 0 )
{
input_AddInfo( p_cat, _("Channels"), "%d", tk.fmt.audio.i_channels );
}
if( tk.fmt.audio.i_samplerate > 0 )
{
input_AddInfo( p_cat, _("Sample Rate"), "%d", tk.fmt.audio.i_samplerate );
}
if( tk.fmt.audio.i_bitspersample )
{
input_AddInfo( p_cat, _("Bits Per Sample"), "%d", tk.fmt.audio.i_bitspersample );
}
break;
case VIDEO_ES:
input_AddInfo( p_cat, _("Type"), _("Video") );
input_AddInfo( p_cat, _("Codec"), "%.4s (%s)", (char*)&tk.fmt.i_codec, tk.psz_codec );
if( tk.fmt.video.i_width > 0 && tk.fmt.video.i_height )
{
input_AddInfo( p_cat, _("Resolution"), "%dx%d", tk.fmt.video.i_width, tk.fmt.video.i_height );
}
if( tk.fmt.video.i_display_width > 0 && tk.fmt.video.i_display_height )
{
input_AddInfo( p_cat, _("Display Resolution"), "%dx%d", tk.fmt.video.i_display_width, tk.fmt.video.i_display_height );
}
if( tk.f_fps > 0.1 )
{
input_AddInfo( p_cat, _("Frame Per Second"), "%.3f", tk.f_fps );
}
break;
case SPU_ES:
input_AddInfo( p_cat, _("Type"), _("Subtitle") );
input_AddInfo( p_cat, _("Codec"), "%s", tk.psz_codec );
break;
}
#undef tk
}
......
......@@ -2,7 +2,7 @@
* mpga.c : MPEG-I/II Audio input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mpga.c,v 1.6 2003/09/13 17:42:16 fenrir Exp $
* $Id: mpga.c,v 1.7 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -57,9 +57,8 @@ struct demux_sys_t
mtime_t i_time;
int i_bitrate_avg; /* extracted from Xing header */
es_out_id_t *p_es;
//es_descriptor_t *p_es;
es_out_id_t *p_es;
};
static int HeaderCheck( uint32_t h )
......@@ -244,17 +243,13 @@ static int Open( vlc_object_t * p_this )
p_sys->i_time = 0;
p_sys->i_bitrate_avg = 0;
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', 'g', 'a' ) );
if( HeaderCheck( header ) )
{
int i_xing;
uint8_t *p_xing;
input_info_category_t * p_cat;
static char* mpga_mode[4] =
{
"stereo", "joint stereo", "dual channel", "mono"
};
p_sys->i_bitrate_avg = MPGA_BITRATE( header ) * 1000;
if( ( i_xing = stream_Peek( p_input->s, &p_xing, 1024 ) ) >= 21 )
{
......@@ -315,20 +310,9 @@ static int Open( vlc_object_t * p_this )
MPGA_CHANNELS( header ),
MPGA_SAMPLE_RATE( header ) );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_cat = input_InfoCategory( p_input, _("MPEG") );
input_AddInfo( p_cat, _("Input Type"), "Audio MPEG-%d",
MPGA_VERSION( header) + 1 );
input_AddInfo( p_cat, _("Layer"), "%d",
MPGA_LAYER( header ) + 1 );
input_AddInfo( p_cat, _("Mode"),
mpga_mode[MPGA_MODE( header )] );
input_AddInfo( p_cat, _("Sample Rate"), "%dHz",
MPGA_SAMPLE_RATE( header ) );
input_AddInfo( p_cat, _("Average Bitrate"), "%dKb/s",
p_sys->i_bitrate_avg / 1000 );
vlc_mutex_unlock( &p_input->stream.stream_lock );
fmt.audio.i_channels = MPGA_CHANNELS( header );
fmt.audio.i_samplerate = MPGA_SAMPLE_RATE( header );
fmt.audio.i_bitrate = p_sys->i_bitrate_avg;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
......@@ -341,7 +325,6 @@ static int Open( vlc_object_t * p_this )
p_input->stream.i_mux_rate = p_sys->i_bitrate_avg / 8 / 50;
vlc_mutex_unlock( &p_input->stream.stream_lock );
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', 'g', 'a' ) );
p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt );
return VLC_SUCCESS;
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.252 2003/11/05 17:57:29 gbazin Exp $
* $Id: input.c,v 1.253 2003/11/13 12:28:34 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -1029,6 +1029,8 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
input_thread_t *p_input = p_sys->p_input;
es_out_id_t *id = malloc( sizeof( es_out_id_t ) );
pgrm_descriptor_t *p_prgm = NULL;
char psz_cat[strlen( "Stream " ) + 10];
input_info_category_t *p_cat;
vlc_mutex_lock( &p_input->stream.stream_lock );
if( fmt->i_group >= 0 )
......@@ -1137,11 +1139,57 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
out->p_sys->i_video = fmt->i_priority;
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
sprintf( psz_cat, _("Stream %d"), out->p_sys->i_id );
if( ( p_cat = input_InfoCategory( p_input, psz_cat ) ) )
{
/* Add information */
switch( fmt->i_cat )
{
case AUDIO_ES:
input_AddInfo( p_cat, _("Type"), _("Audio") );
input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&fmt->i_codec );
if( fmt->audio.i_channels > 0 )
{
input_AddInfo( p_cat, _("Channels"), "%d", fmt->audio.i_channels );
}
if( fmt->audio.i_samplerate > 0 )
{
input_AddInfo( p_cat, _("Sample Rate"), "%d", fmt->audio.i_samplerate );
}
if( fmt->audio.i_bitrate > 0 )
{
input_AddInfo( p_cat, _("Bitrate"), "%d", fmt->audio.i_bitrate );
}
if( fmt->audio.i_bitspersample )
{
input_AddInfo( p_cat, _("Bits Per Sample"), "%d", fmt->audio.i_bitspersample );
}
break;
case VIDEO_ES:
input_AddInfo( p_cat, _("Type"), _("Video") );
input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&fmt->i_codec );
if( fmt->video.i_width > 0 && fmt->video.i_height > 0 )
{
input_AddInfo( p_cat, _("Resolution"), "%dx%d", fmt->video.i_width, fmt->video.i_height );
}
if( fmt->video.i_display_width > 0 && fmt->video.i_display_height > 0 )
{
input_AddInfo( p_cat, _("Display Resolution"), "%dx%d", fmt->video.i_display_width, fmt->video.i_display_height);
}
break;
case SPU_ES:
input_AddInfo( p_cat, _("Type"), _("Subtitle") );
input_AddInfo( p_cat, _("Codec"), "%.4s", (char*)&fmt->i_codec );
break;
default:
break;
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
TAB_APPEND( out->p_sys->i_id, out->p_sys->id, id );
return id;
}
static int EsOutSend( es_out_t *out, es_out_id_t *id, pes_packet_t *p_pes )
......
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