Changeset 5f782bc34f618ef58e01cd8fcba1f2fc0cb29402

Show
Ignore:
Timestamp:
11/11/03 01:37:59 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1068511079 +0000
git-parent:

[a7a7e7097451c2b7bb70dd7ad59eb1b050090d52]

git-author:
Laurent Aimar <fenrir@videolan.org> 1068511079 +0000
Message:
  • all: use es_format_t and es_out_*. (Not well tested yet...)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/a52sys.c

    r05ca109 r5f782bc  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: a52sys.c,v 1.6 2003/09/12 16:26:40 fenrir Exp $ 
     5 * $Id: a52sys.c,v 1.7 2003/11/11 00:37:59 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    5656    mtime_t         i_time; 
    5757 
    58     es_descriptor_t *p_es; 
     58    es_out_id_t    *p_es; 
    5959}; 
    6060 
     
    7777 
    7878/***************************************************************************** 
    79  * Open: initializes AAC demux structures 
     79 * Open: initializes A52 demux structures 
    8080 *****************************************************************************/ 
    8181static int Open( vlc_object_t * p_this ) 
     
    8989    module_t       *p_id3; 
    9090 
     91    es_format_t    fmt; 
     92 
    9193 
    9294    if( p_input->psz_demux && !strncmp( p_input->psz_demux, "a52", 3 ) ) 
     
    167169        goto error; 
    168170    } 
    169     if( input_AddProgram( p_input, 0, 0) == NULL ) 
    170     { 
    171         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    172         msg_Err( p_input, "cannot add program" ); 
    173         goto error; 
    174     } 
    175     p_input->stream.pp_programs[0]->b_is_ok = 0; 
    176     p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    177  
    178171    p_input->stream.i_mux_rate = 0 / 50; 
    179  
    180     p_sys->p_es = input_AddES( p_input, 
    181                                p_input->stream.p_selected_program, 
    182                                1 , AUDIO_ES, NULL, 0 ); 
    183  
    184     p_sys->p_es->i_stream_id = 1; 
    185     p_sys->p_es->i_fourcc = VLC_FOURCC( 'a', '5', '2', ' ' ); 
    186     input_SelectES( p_input, p_sys->p_es ); 
    187  
    188     p_input->stream.p_selected_program->b_is_ok = 1; 
    189172    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    190173 
     174    es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'a', '5', '2', ' ' ) ); 
     175    p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt ); 
    191176    return VLC_SUCCESS; 
    192177 
     
    266251                                     p_sys->i_time * 9 / 100 ); 
    267252 
    268     if( !p_sys->p_es->p_decoder_fifo ) 
    269     { 
    270         msg_Err( p_input, "no audio decoder" ); 
    271         input_DeletePES( p_input->p_method_data, p_pes ); 
    272         return( -1 ); 
    273     } 
    274  
    275     input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 
     253    es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 
     254 
    276255    p_sys->i_time += (mtime_t)1000000 * 
    277256                     (mtime_t)1536 / 
  • modules/demux/aac.c

    r05ca109 r5f782bc  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: aac.c,v 1.4 2003/09/12 16:26:40 fenrir Exp $ 
     5 * $Id: aac.c,v 1.5 2003/11/11 00:37:59 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    5757    mtime_t         i_time; 
    5858 
    59     es_descriptor_t *p_es; 
     59    es_out_id_t    *p_es; 
    6060}; 
    6161 
     
    101101    module_t       *p_id3; 
    102102 
     103    es_format_t    fmt; 
     104 
    103105 
    104106    if( p_input->psz_demux && !strncmp( p_input->psz_demux, "aac", 3 ) ) 
     
    182184        goto error; 
    183185    } 
    184     if( input_AddProgram( p_input, 0, 0) == NULL ) 
    185     { 
    186         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    187         msg_Err( p_input, "cannot add program" ); 
    188         goto error; 
    189     } 
    190     p_input->stream.pp_programs[0]->b_is_ok = 0; 
    191     p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    192  
    193186    p_input->stream.i_mux_rate = 0 / 50; 
    194  
    195     p_sys->p_es = input_AddES( p_input, 
    196                                p_input->stream.p_selected_program, 
    197                                1 , AUDIO_ES, NULL, 0 ); 
    198  
    199     p_sys->p_es->i_stream_id = 1; 
    200     p_sys->p_es->i_fourcc = VLC_FOURCC( 'm', 'p', '4', 'a' ); 
    201     input_SelectES( p_input, p_sys->p_es ); 
    202  
    203     p_input->stream.p_selected_program->b_is_ok = 1; 
    204187    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     188 
     189    es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) ); 
     190    p_sys->p_es = es_out_Add( p_input->p_es_out, &fmt ); 
    205191 
    206192    return VLC_SUCCESS; 
     
    280266                                     p_sys->i_time * 9 / 100 ); 
    281267 
    282     if( !p_sys->p_es->p_decoder_fifo ) 
    283     { 
    284         msg_Err( p_input, "no audio decoder" ); 
    285         input_DeletePES( p_input->p_method_data, p_pes ); 
    286         return( -1 ); 
    287     } 
    288  
    289     input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 
     268    es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 
     269 
    290270    p_sys->i_time += (mtime_t)1000000 * 
    291271                     (mtime_t)AAC_FRAME_SAMPLES( h ) / 
  • modules/demux/asf/asf.c

    r05ca109 r5f782bc  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002-2003 VideoLAN 
    5  * $Id: asf.c,v 1.38 2003/09/12 16:26:40 fenrir Exp $ 
     5 * $Id: asf.c,v 1.39 2003/11/11 00:37:59 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    5555{ 
    5656    int i_cat; 
    57     es_descriptor_t *p_es; 
     57 
     58    es_out_id_t     *p_es; 
     59 
    5860    asf_object_stream_properties_t *p_sp; 
    5961 
     
    9496    demux_sys_t     *p_sys; 
    9597    unsigned int    i_stream; 
    96     unsigned int    i; 
    9798    asf_object_content_description_t *p_cd; 
    9899 
     
    149150    msg_Dbg( p_input, "found %d streams", p_sys->i_streams ); 
    150151 
    151     /*  create one program */ 
    152152    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    153153    if( input_InitStream( p_input, 0 ) == -1) 
     
    157157        goto error; 
    158158    } 
    159     if( input_AddProgram( p_input, 0, 0) == NULL ) 
    160     { 
    161         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    162         msg_Err( p_input, "cannot add program" ); 
    163         goto error; 
    164     } 
    165     p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    166159    p_input->stream.i_mux_rate = 0 ; /* updated later */ 
    167160    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
     
    185178        p_stream->p_es = NULL; 
    186179 
    187         if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) ) 
    188         { 
    189             int i_codec; 
    190             if( p_sp->p_type_specific_data ) 
    191             { 
    192                 i_codec = GetWLE( p_sp->p_type_specific_data ); 
    193             } 
    194             else 
    195             { 
    196                 i_codec = -1; 
     180        if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) && 
     181            p_sp->i_type_specific_data_length >= sizeof( WAVEFORMATEX ) - 2 ) 
     182        { 
     183            es_format_t  fmt; 
     184            uint8_t      *p_data = p_sp->p_type_specific_data; 
     185 
     186            es_format_Init( &fmt, AUDIO_ES, 0 ); 
     187            wf_tag_to_fourcc( GetWLE( &p_data[0] ), &fmt.i_codec, NULL ); 
     188            fmt.audio.i_channels        = GetWLE(  &p_data[2] ); 
     189            fmt.audio.i_samplerate      = GetDWLE( &p_data[4] ); 
     190            fmt.audio.i_bitrate         = GetDWLE( &p_data[8] ) * 8; 
     191            fmt.audio.i_blockalign      = GetWLE(  &p_data[12] ); 
     192            fmt.audio.i_bitspersample   = GetWLE(  &p_data[14] ); 
     193 
     194            if( p_sp->i_type_specific_data_length > sizeof( WAVEFORMATEX ) ) 
     195            { 
     196                fmt.i_extra_type = ES_EXTRA_TYPE_WAVEFORMATEX; 
     197                fmt.i_extra = __MIN( GetWLE( &p_data[16] ), 
     198                                     p_sp->i_type_specific_data_length - sizeof( WAVEFORMATEX ) ); 
     199                fmt.p_extra = malloc( fmt.i_extra ); 
     200                memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )], fmt.i_extra ); 
    197201            } 
    198202 
    199203            p_stream->i_cat = AUDIO_ES; 
    200             p_stream->p_es = input_AddES( p_input, 
    201                          p_input->stream.p_selected_program, 
    202                          p_sp->i_stream_number, AUDIO_ES, NULL, 0 ); 
     204            p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt ); 
    203205 
    204206            msg_Dbg( p_input, 
    205                     "adding new audio stream(codec:0x%x,ID:%d)", 
    206                     i_codec, 
    207                     p_sp->i_stream_number ); 
    208             wf_tag_to_fourcc( i_codec, &p_stream->p_es->i_fourcc, NULL ); 
    209  
    210             if( p_sp->i_type_specific_data_length > 0 ) 
    211             { 
    212                 WAVEFORMATEX    *p_wf; 
    213                 size_t          i_size; 
    214                 uint8_t         *p_data; 
    215  
    216                 i_size = p_sp->i_type_specific_data_length; 
    217  
    218                 p_wf = malloc( i_size ); 
    219                 p_stream->p_es->p_waveformatex = (void*)p_wf; 
    220                 p_data = p_sp->p_type_specific_data; 
    221  
    222                 p_wf->wFormatTag        = GetWLE( p_data ); 
    223                 p_wf->nChannels         = GetWLE( p_data + 2 ); 
    224                 p_wf->nSamplesPerSec    = GetDWLE( p_data + 4 ); 
    225                 p_wf->nAvgBytesPerSec   = GetDWLE( p_data + 8 ); 
    226                 p_wf->nBlockAlign       = GetWLE( p_data + 12 ); 
    227                 p_wf->wBitsPerSample    = GetWLE( p_data + 14 ); 
    228                 p_wf->cbSize            = __MIN( GetWLE( p_data + 16 ), i_size - sizeof( WAVEFORMATEX )); 
    229                 if( p_wf->cbSize > 0 ) 
    230                 { 
    231                     memcpy( &p_wf[1], p_data + sizeof( WAVEFORMATEX ), p_wf->cbSize ); 
    232                 } 
    233             } 
    234         } 
    235         else 
    236         if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) ) 
    237         { 
     207                    "added new audio stream(codec:0x%x,ID:%d)", 
     208                    GetWLE( p_data ), p_sp->i_stream_number ); 
     209        } 
     210        else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) && 
     211                 p_sp->i_type_specific_data_length >= 11 + sizeof( BITMAPINFOHEADER ) ) 
     212        { 
     213            es_format_t  fmt; 
     214            uint8_t      *p_data = &p_sp->p_type_specific_data[11]; 
     215 
     216            es_format_Init( &fmt, VIDEO_ES, 
     217                            VLC_FOURCC( p_data[16], p_data[17], p_data[18], p_data[19] ) ); 
     218            fmt.video.i_width = GetDWLE( p_data + 4 ); 
     219            fmt.video.i_height= GetDWLE( p_data + 8 ); 
     220 
     221            if( p_sp->i_type_specific_data_length > 11 + sizeof( BITMAPINFOHEADER ) ) 
     222            { 
     223                fmt.i_extra_type = ES_EXTRA_TYPE_BITMAPINFOHEADER; 
     224                fmt.i_extra = __MIN( GetDWLE( p_data ), 
     225                                     p_sp->i_type_specific_data_length - 11 - sizeof( BITMAPINFOHEADER ) ); 
     226                fmt.p_extra = malloc( fmt.i_extra ); 
     227                memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], fmt.i_extra ); 
     228            } 
     229 
    238230            p_stream->i_cat = VIDEO_ES; 
    239             p_stream->p_es = input_AddES( p_input, 
    240                          p_input->stream.p_selected_program, 
    241                          p_sp->i_stream_number, VIDEO_ES, NULL, 0 ); 
    242  
    243             msg_Dbg( p_input, "adding new video stream(ID:%d)", 
     231            p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt ); 
     232 
     233            msg_Dbg( p_input, "added new video stream(ID:%d)", 
    244234                     p_sp->i_stream_number ); 
    245             if( p_sp->p_type_specific_data ) 
    246             { 
    247                 p_stream->p_es->i_fourcc = 
    248                     VLC_FOURCC( p_sp->p_type_specific_data[27], 
    249                                 p_sp->p_type_specific_data[28], 
    250                                 p_sp->p_type_specific_data[29], 
    251                                 p_sp->p_type_specific_data[30] ); 
    252             } 
    253             else 
    254             { 
    255                 p_stream->p_es->i_fourcc = 
    256                     VLC_FOURCC( 'u','n','d','f' ); 
    257             } 
    258             if( p_sp->i_type_specific_data_length > 11 ) 
    259             { 
    260                 BITMAPINFOHEADER *p_bih; 
    261                 size_t      i_size; 
    262                 uint8_t     *p_data; 
    263  
    264                 i_size = p_sp->i_type_specific_data_length - 11; 
    265  
    266                 p_bih = malloc( i_size ); 
    267                 p_stream->p_es->p_bitmapinfoheader = (void*)p_bih; 
    268                 p_data = p_sp->p_type_specific_data + 11; 
    269  
    270                 p_bih->biSize       = GetDWLE( p_data ); 
    271                 p_bih->biWidth      = GetDWLE( p_data + 4 ); 
    272                 p_bih->biHeight     = GetDWLE( p_data + 8 ); 
    273                 p_bih->biPlanes     = GetDWLE( p_data + 12 ); 
    274                 p_bih->biBitCount   = GetDWLE( p_data + 14 ); 
    275                 p_bih->biCompression= GetDWLE( p_data + 16 ); 
    276                 p_bih->biSizeImage  = GetDWLE( p_data + 20 ); 
    277                 p_bih->biXPelsPerMeter = GetDWLE( p_data + 24 ); 
    278                 p_bih->biYPelsPerMeter = GetDWLE( p_data + 28 ); 
    279                 p_bih->biClrUsed       = GetDWLE( p_data + 32 ); 
    280                 p_bih->biClrImportant  = GetDWLE( p_data + 36 ); 
    281  
    282                 if( i_size > sizeof( BITMAPINFOHEADER ) ) 
    283                 { 
    284                     memcpy( &p_bih[1], 
    285                             p_data + sizeof( BITMAPINFOHEADER ), 
    286                             i_size - sizeof( BITMAPINFOHEADER ) ); 
    287                 } 
    288             } 
    289  
    290235        } 
    291236        else 
     
    295240                     p_sp->i_stream_number ); 
    296241        } 
    297  
    298         vlc_mutex_lock( &p_input->stream.stream_lock ); 
    299         if( p_stream->p_es ) 
    300         { 
    301             input_SelectES( p_input, p_stream->p_es ); 
    302         } 
    303         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    304     } 
    305  
     242    } 
    306243 
    307244    p_sys->i_data_begin = p_sys->p_root->p_data->i_object_pos + 50; 
     
    346283        } 
    347284    } 
    348  
    349     vlc_mutex_lock( &p_input->stream.stream_lock ); 
    350     p_input->stream.p_selected_program->b_is_ok = 1; 
    351     vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    352  
    353285 
    354286    /* We add all info about this stream */ 
     
    380312    } 
    381313 
     314#if 0 
     315    /* FIXME to port to new way */ 
    382316    for( i_stream = 0, i = 0; i < 128; i++ ) 
    383317    { 
     
    421355            input_AddInfo( p_cat, _("Resolution"), "%dx%d", 
    422356                           p_bih->biWidth, p_bih->biHeight ); 
    423             input_AddInfo( p_cat, _("Planes"), "%d", p_bih->biPlanes ); 
    424             input_AddInfo( p_cat, _("Bits Per Pixel"), "%d", p_bih->biBitCount ); 
    425             input_AddInfo( p_cat, _("Image Size"), "%d", p_bih->biSizeImage ); 
    426             input_AddInfo( p_cat, _("X pixels per meter"), "%d", 
    427                            p_bih->biXPelsPerMeter ); 
    428             input_AddInfo( p_cat, _("Y pixels per meter"), "%d", 
    429                            p_bih->biYPelsPerMeter ); 
    430357        } 
    431358 
    432359        i_stream++; 
    433360    } 
     361#endif 
    434362 
    435363    return VLC_SUCCESS; 
     
    450378    vlc_bool_t b_play_audio; 
    451379    int i; 
    452     vlc_bool_t b_stream; 
    453  
    454     b_stream = VLC_FALSE; 
    455     for( i = 0; i < 128; i++ ) 
    456     { 
    457         if( p_sys->stream[i] && 
    458             p_sys->stream[i]->p_es && 
    459             p_sys->stream[i]->p_es->p_decoder_fifo ) 
    460         { 
    461             b_stream = VLC_TRUE; 
    462         } 
    463     } 
    464     if( !b_stream ) 
    465     { 
    466         msg_Warn( p_input, "no stream selected, exiting..." ); 
    467         return( 0 ); 
    468     } 
    469380 
    470381    /* catch seek from user */ 
     
    587498    { 
    588499#define p_stream p_sys->stream[i_stream] 
    589         if( p_stream && p_stream->p_es && p_stream->p_es->p_decoder_fifo && p_stream->i_time > 0) 
     500        if( p_stream && p_stream->p_es && p_stream->i_time > 0) 
    590501        { 
    591502            if( i_time < 0 ) 
     
    802713        } 
    803714 
    804         if( !p_stream->p_es || !p_stream->p_es->p_decoder_fifo
     715        if( !p_stream->p_es
    805716        { 
    806717            i_skip += i_payload_data_length; 
     
    833744                if( p_stream->p_pes->i_pes_size > 0 ) 
    834745                { 
    835                     if( p_stream->p_es->p_decoder_fifo && 
    836                         ( b_play_audio || p_stream->i_cat != AUDIO_ES ) ) 
    837                     { 
    838                         p_stream->p_pes->i_rate = 
    839                             p_input->stream.control.i_rate; 
    840                         input_DecodePES( p_stream->p_es->p_decoder_fifo, 
    841                                          p_stream->p_pes ); 
    842                     } 
    843                     else 
    844                     { 
    845                         input_DeletePES( p_input->p_method_data, 
    846                                          p_stream->p_pes ); 
    847                     } 
     746                    es_out_Send( p_input->p_es_out, p_stream->p_es, p_stream->p_pes ); 
    848747                    p_stream->p_pes = NULL; 
    849748                } 
  • modules/demux/au.c

    r05ca109 r5f782bc  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001-2003 VideoLAN 
    5  * $Id: au.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $ 
     5 * $Id: au.c,v 1.8 2003/11/11 00:37:59 fenrir Exp $ 
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     
    9494{ 
    9595    au_t            au; 
    96     WAVEFORMATEX    wf; 
    9796 
    9897    mtime_t         i_time; 
    9998 
    100     es_descriptor_t *p_es; 
     99    es_format_t     fmt; 
     100    es_out_id_t     *p_es; 
    101101 
    102102    int             i_frame_size; 
     
    114114 
    115115    uint8_t         *p_peek; 
    116  
    117     vlc_fourcc_t    i_fourcc; 
    118116 
    119117    int             i_cat; 
     
    171169 
    172170    /* Create WAVEFORMATEX structure */ 
    173     p_sys->wf.nChannels     = p_sys->au.i_channels; 
    174     p_sys->wf.nSamplesPerSec= p_sys->au.i_sample_rate; 
    175     p_sys->wf.cbSize        = 0; 
    176  
     171    es_format_Init( &p_sys->fmt, AUDIO_ES, 0 ); 
     172    p_sys->fmt.audio.i_channels   = p_sys->au.i_channels; 
     173    p_sys->fmt.audio.i_samplerate = p_sys->au.i_sample_rate; 
    177174    switch( p_sys->au.i_encoding ) 
    178175    { 
    179176        case AU_ALAW_8:        /* 8-bit ISDN A-law */ 
    180             p_sys->wf.wFormatTag     = WAVE_FORMAT_ALAW;   // FIXME ?? 
    181             p_sys->wf.wBitsPerSample = 8; 
    182             p_sys->wf.nBlockAlign    = 1 * p_sys->wf.nChannels; 
    183             i_fourcc                 = VLC_FOURCC( 'a','l','a','w' ); 
     177            p_sys->fmt.i_codec               = VLC_FOURCC( 'a','l','a','w' ); 
     178            p_sys->fmt.audio.i_bitspersample = 8; 
     179            p_sys->fmt.audio.i_blockalign    = 1 * p_sys->fmt.audio.i_channels; 
    184180            i_cat                    = AU_CAT_PCM; 
    185181            break; 
    186182 
    187183        case AU_MULAW_8:       /* 8-bit ISDN u-law */ 
    188             p_sys->wf.wFormatTag     = WAVE_FORMAT_MULAW;   // FIXME ?? 
    189             p_sys->wf.wBitsPerSample = 8; 
    190             p_sys->wf.nBlockAlign    = 1 * p_sys->wf.nChannels; 
    191             i_fourcc                 = VLC_FOURCC( 'u','l','a','w' ); 
     184            p_sys->fmt.i_codec               = VLC_FOURCC( 'u','l','a','w' ); 
     185            p_sys->fmt.audio.i_bitspersample = 8; 
     186            p_sys->fmt.audio.i_blockalign    = 1 * p_sys->fmt.audio.i_channels; 
    192187            i_cat                    = AU_CAT_PCM; 
    193188            break; 
    194189 
    195190        case AU_LINEAR_8:      /* 8-bit linear PCM */ 
    196             p_sys->wf.wFormatTag     = WAVE_FORMAT_PCM; 
    197             p_sys->wf.wBitsPerSample = 8; 
    198             p_sys->wf.nBlockAlign    = 1 * p_sys->wf.nChannels; 
    199             i_fourcc                 = VLC_FOURCC( 't','w','o','s' ); 
     191            p_sys->fmt.i_codec               = VLC_FOURCC( 't','w','o','s' ); 
     192            p_sys->fmt.audio.i_bitspersample = 8; 
     193            p_sys->fmt.audio.i_blockalign    = 1 * p_sys->fmt.audio.i_channels; 
    200194            i_cat                    = AU_CAT_PCM; 
    201195            break; 
    202196 
    203197        case AU_LINEAR_16:     /* 16-bit linear PCM */ 
    204             p_sys->wf.wFormatTag     = WAVE_FORMAT_PCM; 
    205             p_sys->wf.wBitsPerSample = 16; 
    206             p_sys->wf.nBlockAlign    = 2 * p_sys->wf.nChannels; 
    207             i_fourcc                 = VLC_FOURCC( 't','w','o','s' ); 
     198            p_sys->fmt.i_codec               = VLC_FOURCC( 't','w','o','s' ); 
     199            p_sys->fmt.audio.i_bitspersample = 16; 
     200            p_sys->fmt.audio.i_blockalign    = 2 * p_sys->fmt.audio.i_channels; 
    208201            i_cat                    = AU_CAT_PCM; 
    209202            break; 
    210203 
    211204        case AU_LINEAR_24:     /* 24-bit linear PCM */ 
    212             p_sys->wf.wFormatTag     = WAVE_FORMAT_PCM; 
    213             p_sys->wf.wBitsPerSample = 24; 
    214             p_sys->wf.nBlockAlign    = 3 * p_sys->wf.nChannels; 
    215             i_fourcc                 = VLC_FOURCC( 't','w','o','s' ); 
     205            p_sys->fmt.i_codec               = VLC_FOURCC( 't','w','o','s' ); 
     206            p_sys->fmt.audio.i_bitspersample = 24; 
     207            p_sys->fmt.audio.i_blockalign    = 3 * p_sys->fmt.audio.i_channels; 
    216208            i_cat                    = AU_CAT_PCM; 
    217209            break; 
    218210 
    219211        case AU_LINEAR_32:     /* 32-bit linear PCM */ 
    220             p_sys->wf.wFormatTag     = WAVE_FORMAT_PCM; 
    221             p_sys->wf.wBitsPerSample = 32; 
    222             p_sys->wf.nBlockAlign    = 4 * p_sys->wf.nChannels; 
    223             i_fourcc                 = VLC_FOURCC( 't','w','o','s' ); 
     212            p_sys->fmt.i_codec               = VLC_FOURCC( 't','w','o','s' ); 
     213            p_sys->fmt.audio.i_bitspersample = 32; 
     214            p_sys->fmt.audio.i_blockalign    = 4 * p_sys->fmt.audio.i_channels; 
    224215            i_cat                    = AU_CAT_PCM; 
    225216            break; 
    226217 
    227218        case AU_FLOAT:         /* 32-bit IEEE floating point */ 
    228             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    229             p_sys->wf.wBitsPerSample = 32; 
    230             p_sys->wf.nBlockAlign    = 4 * p_sys->wf.nChannels; 
    231             i_fourcc                  = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT ); 
     219            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT ); 
     220            p_sys->fmt.audio.i_bitspersample = 32; 
     221            p_sys->fmt.audio.i_blockalign    = 4 * p_sys->fmt.audio.i_channels; 
    232222            i_cat                    = AU_CAT_PCM; 
    233223            break; 
    234224 
    235225        case AU_DOUBLE:        /* 64-bit IEEE floating point */ 
    236             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    237             p_sys->wf.wBitsPerSample = 64; 
    238             p_sys->wf.nBlockAlign    = 8 * p_sys->wf.nChannels; 
    239             i_fourcc                 = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE ); 
     226            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE ); 
     227            p_sys->fmt.audio.i_bitspersample = 64; 
     228            p_sys->fmt.audio.i_blockalign    = 8 * p_sys->fmt.audio.i_channels; 
    240229            i_cat                    = AU_CAT_PCM; 
    241230            break; 
    242231 
    243232        case AU_ADPCM_G721:    /* 4-bit CCITT g.721 ADPCM */ 
    244             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    245             p_sys->wf.wBitsPerSample = 0; 
    246             p_sys->wf.nBlockAlign    = 0 * p_sys->wf.nChannels; 
    247             i_fourcc                 = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 ); 
     233            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 ); 
     234            p_sys->fmt.audio.i_bitspersample = 0; 
     235            p_sys->fmt.audio.i_blockalign    = 0 * p_sys->fmt.audio.i_channels; 
    248236            i_cat                    = AU_CAT_ADPCM; 
    249237            break; 
    250238 
    251239        case AU_ADPCM_G722:    /* CCITT g.722 ADPCM */ 
    252             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    253             p_sys->wf.wBitsPerSample = 0; 
    254             p_sys->wf.nBlockAlign    = 0 * p_sys->wf.nChannels; 
    255             i_fourcc                 = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 ); 
     240            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 ); 
     241            p_sys->fmt.audio.i_bitspersample = 0; 
     242            p_sys->fmt.audio.i_blockalign    = 0 * p_sys->fmt.audio.i_channels; 
    256243            i_cat                    = AU_CAT_ADPCM; 
    257244            break; 
    258245 
    259246        case AU_ADPCM_G723_3:  /* CCITT g.723 3-bit ADPCM */ 
    260             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    261             p_sys->wf.wBitsPerSample = 0; 
    262             p_sys->wf.nBlockAlign    = 0 * p_sys->wf.nChannels; 
    263             i_fourcc                 = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 ); 
     247            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 ); 
     248            p_sys->fmt.audio.i_bitspersample = 0; 
     249            p_sys->fmt.audio.i_blockalign    = 0 * p_sys->fmt.audio.i_channels; 
    264250            i_cat                    = AU_CAT_ADPCM; 
    265251            break; 
    266252 
    267253        case AU_ADPCM_G723_5:  /* CCITT g.723 5-bit ADPCM */ 
    268             p_sys->wf.wFormatTag     = WAVE_FORMAT_UNKNOWN; 
    269             p_sys->wf.wBitsPerSample = 0; 
    270             p_sys->wf.nBlockAlign    = 0 * p_sys->wf.nChannels; 
    271             i_fourcc                 = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 ); 
     254            p_sys->fmt.i_codec               = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 ); 
     255            p_sys->fmt.audio.i_bitspersample = 0; 
     256            p_sys->fmt.audio.i_blockalign    = 0 * p_sys->fmt.audio.i_channels; 
    272257            i_cat                    = AU_CAT_ADPCM; 
    273258            break; 
     
    278263            goto error; 
    279264    } 
    280     p_sys->wf.nAvgBytesPerSec        = p_sys->wf.nSamplesPerSec * p_sys->wf.nChannels * p_sys->wf.wBitsPerSample / 8; 
    281  
    282  
     265    p_sys->fmt.audio.i_bitrate = p_sys->fmt.audio.i_samplerate * 
     266                                 p_sys->fmt.audio.i_channels * 
     267                                 p_sys->fmt.audio.i_bitspersample; 
    283268 
    284269    if( i_cat == AU_CAT_UNKNOWN || i_cat == AU_CAT_ADPCM ) 
     
    295280 
    296281        /* read samples for 50ms of */ 
    297         i_samples = __MAX( p_sys->wf.nSamplesPerSec / 20, 1 ); 
    298  
    299         p_sys->i_frame_size = i_samples * p_sys->wf.nChannels * ( (p_sys->wf.wBitsPerSample + 7) / 8 ); 
    300  
    301         if( p_sys->wf.nBlockAlign > 0 ) 
     282        i_samples = __MAX( p_sys->fmt.audio.i_samplerate / 20, 1 ); 
     283 
     284        p_sys->i_frame_size = i_samples * p_sys->fmt.audio.i_channels * ( (p_sys->fmt.audio.i_bitspersample + 7) / 8 ); 
     285 
     286        if( p_sys->fmt.audio.i_blockalign > 0 ) 
    302287        { 
    303             if( ( i_modulo = p_sys->i_frame_size % p_sys->wf.nBlockAlign ) != 0 ) 
     288            if( ( i_modulo = p_sys->i_frame_size % p_sys->fmt.audio.i_blockalign ) != 0 ) 
    304289            { 
    305                 p_sys->i_frame_size += p_sys->wf.nBlockAlign - i_modulo; 
     290                p_sys->i_frame_size += p_sys->fmt.audio.i_blockalign - i_modulo; 
    306291            } 
    307292        } 
     
    309294        p_sys->i_frame_length = (mtime_t)1000000 * 
    310295                                (mtime_t)i_samples / 
    311                                 (mtime_t)p_sys->wf.nSamplesPerSec
     296                                (mtime_t)p_sys->fmt.audio.i_samplerate
    312297 
    313298        p_input->pf_demux = DemuxPCM; 
     
    315300    } 
    316301 
    317     /*  create one program */ 
    318302    vlc_mutex_lock( &p_input->stream.stream_lock ); 
    319303    if( input_InitStream( p_input, 0 ) == -1) 
     
    323307        goto error; 
    324308    } 
    325     if( input_AddProgram( p_input, 0, 0) == NULL ) 
    326     { 
    327         vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    328         msg_Err( p_input, "cannot add program" ); 
    329         goto error; 
    330     } 
    331  
    332     p_input->stream.p_selected_program = p_input->stream.pp_programs[0]; 
    333     p_input->stream.i_mux_rate =  p_sys->wf.nAvgBytesPerSec / 50; 
    334  
    335     p_sys->p_es = input_AddES( p_input, p_input->stream.p_selected_program, 
    336                                0x01, AUDIO_ES, NULL, 0 ); 
    337  
    338     p_sys->p_es->i_stream_id   = 0x01; 
    339     p_sys->p_es->i_fourcc      = i_fourcc; 
    340     p_sys->p_es->p_waveformatex= malloc( sizeof( WAVEFORMATEX ) ); 
    341     memcpy( p_sys->p_es->p_waveformatex, &p_sys->wf, sizeof( WAVEFORMATEX ) ); 
    342  
    343     input_SelectES( p_input, p_sys->p_es ); 
    344  
    345     p_input->stream.p_selected_program->b_is_ok = 1; 
     309    p_input->stream.i_mux_rate =  p_sys->fmt.audio.i_bitrate / 50 / 8; 
    346310    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    347311 
     312    p_sys->p_es = es_out_Add( p_input->p_es_out, &p_sys->fmt ); 
    348313    return VLC_SUCCESS; 
    349314 
     
    367332        int64_t i_pos = stream_Tell( p_input->s ); 
    368333 
    369         if( p_sys->wf.nBlockAlign != 0 ) 
     334        if( p_sys->fmt.audio.i_blockalign != 0 ) 
    370335        { 
    371             i_pos += p_sys->wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign; 
     336            i_pos += p_sys->fmt.audio.i_blockalign - i_pos % p_sys->fmt.audio.i_blockalign; 
    372337            if( stream_Seek( p_input->s, i_pos ) ) 
    373338            { 
     
    391356                                     p_sys->i_time * 9 / 100 ); 
    392357 
    393     if( !p_sys->p_es->p_decoder_fifo ) 
    394     { 
    395         msg_Err( p_input, "no audio decoder" ); 
    396         input_DeletePES( p_input->p_method_data, p_pes ); 
    397         return( -1 ); 
    398     } 
    399  
    400     input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes ); 
     358    es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes ); 
     359 
    401360    p_sys->i_time += p_sys->i_frame_length; 
     361 
    402362    return( 1 ); 
    403363}