]> git.sesse.net Git - vlc/blobdiff - modules/demux/aac.c
modules/demux/playlist/playlist.c:
[vlc] / modules / demux / aac.c
index add45471399133028ac55d6455e71765172d4683..0e6be4ba4021bde7ec0801c73505305c1e014509 100644 (file)
@@ -2,7 +2,7 @@
  * aac.c : Raw aac Stream input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: aac.c,v 1.2 2003/08/01 00:40:05 fenrir Exp $
+ * $Id: aac.c,v 1.8 2003/11/21 00:38:01 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -29,8 +29,6 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 
-#include <ninput.h>
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -56,10 +54,9 @@ static int  Demux       ( input_thread_t * );
 
 struct demux_sys_t
 {
-    stream_t        *s;
     mtime_t         i_time;
 
-    es_descriptor_t *p_es;
+    es_out_id_t     *p_es;
 };
 
 static int i_aac_samplerate[16] =
@@ -103,6 +100,8 @@ static int Open( vlc_object_t * p_this )
 
     module_t       *p_id3;
 
+    es_format_t    fmt;
+
 
     if( p_input->psz_demux && !strncmp( p_input->psz_demux, "aac", 3 ) )
     {
@@ -136,18 +135,13 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_input->pf_demux = Demux;
+    p_input->pf_demux_control = demux_vaControlDefault;
 
     p_input->p_demux_data = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->i_time = 0;
 
-    if( ( p_sys->s = stream_OpenInput( p_input ) ) == NULL )
-    {
-        msg_Err( p_input, "cannot create stream" );
-        goto error;
-    }
-
     /* peek the begining (10 is for adts header) */
-    if( stream_Peek( p_sys->s, &p_peek, 10 ) < 10 )
+    if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 )
     {
         msg_Err( p_input, "cannot peek" );
         goto error;
@@ -159,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_rate = 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 );
@@ -189,35 +173,14 @@ static int Open( vlc_object_t * p_this )
         msg_Err( p_input, "cannot init stream" );
         goto error;
     }
-    if( input_AddProgram( p_input, 0, 0) == NULL )
-    {
-        vlc_mutex_unlock( &p_input->stream.stream_lock );
-        msg_Err( p_input, "cannot add program" );
-        goto error;
-    }
-    p_input->stream.pp_programs[0]->b_is_ok = 0;
-    p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
-
     p_input->stream.i_mux_rate = 0 / 50;
-
-    p_sys->p_es = input_AddES( p_input,
-                               p_input->stream.p_selected_program,
-                               1 , AUDIO_ES, NULL, 0 );
-
-    p_sys->p_es->i_stream_id = 1;
-    p_sys->p_es->i_fourcc = VLC_FOURCC( 'm', 'p', '4', 'a' );
-    input_SelectES( p_input, p_sys->p_es );
-
-    p_input->stream.p_selected_program->b_is_ok = 1;
     vlc_mutex_unlock( &p_input->stream.stream_lock );
 
+    p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt );
+
     return VLC_SUCCESS;
 
 error:
-    if( p_sys->s )
-    {
-        stream_Release( p_sys->s );
-    }
     free( p_sys );
     return VLC_EGENERIC;
 }
@@ -231,12 +194,12 @@ error:
 static int Demux( input_thread_t * p_input )
 {
     demux_sys_t  *p_sys = p_input->p_demux_data;
-    pes_packet_t *p_pes;
+    block_t *p_block;
 
     uint8_t      h[8];
     uint8_t      *p_peek;
 
-    if( stream_Peek( p_sys->s, &p_peek, 8 ) < 8 )
+    if( stream_Peek( p_input->s, &p_peek, 8 ) < 8 )
     {
         msg_Warn( p_input, "cannot peek" );
         return 0;
@@ -249,7 +212,7 @@ static int Demux( input_thread_t * p_input )
         int         i_skip = 0;
         int         i_peek;
 
-        i_peek = stream_Peek( p_sys->s, &p_peek, 8096 );
+        i_peek = stream_Peek( p_input->s, &p_peek, 8096 );
         if( i_peek < 8 )
         {
             msg_Warn( p_input, "cannot peek" );
@@ -270,7 +233,7 @@ static int Demux( input_thread_t * p_input )
         }
 
         msg_Warn( p_input, "garbage=%d bytes", i_skip );
-        stream_Read( p_sys->s, NULL, i_skip );
+        stream_Read( p_input->s, NULL, i_skip );
         return 1;
     }
 
@@ -280,25 +243,19 @@ static int Demux( input_thread_t * p_input )
                           p_input->stream.p_selected_program,
                           p_sys->i_time * 9 / 100 );
 
-    if( ( p_pes = stream_PesPacket( p_sys->s, AAC_FRAME_SIZE( h ) ) ) == NULL )
+    if( ( p_block = stream_Block( p_input->s, AAC_FRAME_SIZE( h ) ) ) == NULL )
     {
         msg_Warn( p_input, "cannot read data" );
         return 0;
     }
 
-    p_pes->i_dts =
-    p_pes->i_pts = input_ClockGetTS( p_input,
+    p_block->i_dts =
+    p_block->i_pts = input_ClockGetTS( p_input,
                                      p_input->stream.p_selected_program,
                                      p_sys->i_time * 9 / 100 );
 
-    if( !p_sys->p_es->p_decoder_fifo )
-    {
-        msg_Err( p_input, "no audio decoder" );
-        input_DeletePES( p_input->p_method_data, p_pes );
-        return( -1 );
-    }
+    es_out_Send( p_input->p_es_out, p_sys->p_es, p_block );
 
-    input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes );
     p_sys->i_time += (mtime_t)1000000 *
                      (mtime_t)AAC_FRAME_SAMPLES( h ) /
                      (mtime_t)AAC_SAMPLE_RATE( h );
@@ -313,10 +270,6 @@ static void Close( vlc_object_t * p_this )
     input_thread_t *p_input = (input_thread_t*)p_this;
     demux_sys_t    *p_sys = p_input->p_demux_data;
 
-    if( p_sys->s )
-    {
-        stream_Release( p_sys->s );
-    }
     free( p_sys );
 }