]> git.sesse.net Git - vlc/commitdiff
* src/input/input.c: es_out_Add automatically add informations
authorLaurent Aimar <fenrir@videolan.org>
Thu, 13 Nov 2003 12:28:34 +0000 (12:28 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 13 Nov 2003 12:28:34 +0000 (12:28 +0000)
 (input_AddInfo) on the ES.
 * all: removed duplicated input_AddInfo.

modules/demux/a52sys.c
modules/demux/aac.c
modules/demux/asf/asf.c
modules/demux/avi/avi.c
modules/demux/mkv.cpp
modules/demux/mpeg/mpga.c
src/input/input.c

index 41c024180d1f77b7a6be60defad185cf124c9076..3a26238d8b90cd1522816801abb30e154297dfde 100644 (file)
@@ -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;
 
index 97f0cbb7d5bb7c0c80a576acea38be03edd86315..916632f209ca394eab42f2df43de4e96673823ce 100644 (file)
@@ -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;
index 702f2980036727b3078f5ec965b28cb40caf06eb..1873b11bdc618c03cbfc90ef9f663c0280563b03 100644 (file)
@@ -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;
 
index ca6cda534266d1455d1358391a5e159d8426e1f1..737da858cfc044d3145239e099858f08cf540143 100644 (file)
@@ -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 );
index 4989f1e39b68b33f3288fc7a84a4a48feba203fc..f59a0012cfe72d361dc000cc6f4ffea17e25f327 100644 (file)
@@ -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
     }
 
index 25719c4269814ca804a1326a0d436e8c134b7238..ba84043b1d2b5a8a30944a2079905d77030e0cc4 100644 (file)
@@ -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;
 
index 7b22f909b0c10ca5aa61e3808ffed36a2f9b8ccd..7037d63740f5ebf8304aea0ac51b43fbb3f371dc 100644 (file)
@@ -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 )