Commit 5f782bc3 authored by Laurent Aimar's avatar Laurent Aimar

* all: use es_format_t and es_out_*. (Not well tested yet...)

parent a7a7e709
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52.c : Raw a52 Stream input module for vlc * a52.c : Raw a52 Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: a52sys.c,v 1.6 2003/09/12 16:26:40 fenrir Exp $ * $Id: a52sys.c,v 1.7 2003/11/11 00:37:59 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -55,7 +55,7 @@ struct demux_sys_t ...@@ -55,7 +55,7 @@ struct demux_sys_t
{ {
mtime_t i_time; mtime_t i_time;
es_descriptor_t *p_es; es_out_id_t *p_es;
}; };
static inline int HeaderCheck( const uint8_t * p ) static inline int HeaderCheck( const uint8_t * p )
...@@ -76,7 +76,7 @@ static int HeaderInfo( const uint8_t * p, ...@@ -76,7 +76,7 @@ static int HeaderInfo( const uint8_t * p,
int *pi_frame_size ); int *pi_frame_size );
/***************************************************************************** /*****************************************************************************
* Open: initializes AAC demux structures * Open: initializes A52 demux structures
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t * p_this ) static int Open( vlc_object_t * p_this )
{ {
...@@ -88,6 +88,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -88,6 +88,8 @@ static int Open( vlc_object_t * p_this )
module_t *p_id3; module_t *p_id3;
es_format_t fmt;
if( p_input->psz_demux && !strncmp( p_input->psz_demux, "a52", 3 ) ) if( p_input->psz_demux && !strncmp( p_input->psz_demux, "a52", 3 ) )
{ {
...@@ -166,28 +168,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -166,28 +168,11 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "cannot init stream" ); msg_Err( p_input, "cannot init stream" );
goto error; 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_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( 'a', '5', '2', ' ' );
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 ); 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; return VLC_SUCCESS;
error: error:
...@@ -265,14 +250,8 @@ static int Demux( input_thread_t * p_input ) ...@@ -265,14 +250,8 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); p_sys->i_time * 9 / 100 );
if( !p_sys->p_es->p_decoder_fifo ) es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
{
msg_Err( p_input, "no audio decoder" );
input_DeletePES( p_input->p_method_data, p_pes );
return( -1 );
}
input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes );
p_sys->i_time += (mtime_t)1000000 * p_sys->i_time += (mtime_t)1000000 *
(mtime_t)1536 / (mtime_t)1536 /
(mtime_t)i_sample_rate; (mtime_t)i_sample_rate;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aac.c : Raw aac Stream input module for vlc * aac.c : Raw aac Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: aac.c,v 1.4 2003/09/12 16:26:40 fenrir Exp $ * $Id: aac.c,v 1.5 2003/11/11 00:37:59 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -56,7 +56,7 @@ struct demux_sys_t ...@@ -56,7 +56,7 @@ struct demux_sys_t
{ {
mtime_t i_time; mtime_t i_time;
es_descriptor_t *p_es; es_out_id_t *p_es;
}; };
static int i_aac_samplerate[16] = static int i_aac_samplerate[16] =
...@@ -100,6 +100,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -100,6 +100,8 @@ static int Open( vlc_object_t * p_this )
module_t *p_id3; module_t *p_id3;
es_format_t fmt;
if( p_input->psz_demux && !strncmp( p_input->psz_demux, "aac", 3 ) ) if( p_input->psz_demux && !strncmp( p_input->psz_demux, "aac", 3 ) )
{ {
...@@ -181,28 +183,12 @@ static int Open( vlc_object_t * p_this ) ...@@ -181,28 +183,12 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "cannot init stream" ); msg_Err( p_input, "cannot init stream" );
goto error; 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_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 ); 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; return VLC_SUCCESS;
error: error:
...@@ -279,14 +265,8 @@ static int Demux( input_thread_t * p_input ) ...@@ -279,14 +265,8 @@ static int Demux( input_thread_t * p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); p_sys->i_time * 9 / 100 );
if( !p_sys->p_es->p_decoder_fifo ) es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
{
msg_Err( p_input, "no audio decoder" );
input_DeletePES( p_input->p_method_data, p_pes );
return( -1 );
}
input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes );
p_sys->i_time += (mtime_t)1000000 * p_sys->i_time += (mtime_t)1000000 *
(mtime_t)AAC_FRAME_SAMPLES( h ) / (mtime_t)AAC_FRAME_SAMPLES( h ) /
(mtime_t)AAC_SAMPLE_RATE( h ); (mtime_t)AAC_SAMPLE_RATE( h );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc * asf.c : ASFv01 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2003 VideoLAN * Copyright (C) 2002-2003 VideoLAN
* $Id: asf.c,v 1.38 2003/09/12 16:26:40 fenrir Exp $ * $Id: asf.c,v 1.39 2003/11/11 00:37:59 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -54,7 +54,9 @@ static int Demux ( input_thread_t * ); ...@@ -54,7 +54,9 @@ static int Demux ( input_thread_t * );
typedef struct asf_stream_s typedef struct asf_stream_s
{ {
int i_cat; int i_cat;
es_descriptor_t *p_es;
es_out_id_t *p_es;
asf_object_stream_properties_t *p_sp; asf_object_stream_properties_t *p_sp;
mtime_t i_time; mtime_t i_time;
...@@ -93,7 +95,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -93,7 +95,6 @@ static int Open( vlc_object_t * p_this )
demux_sys_t *p_sys; demux_sys_t *p_sys;
unsigned int i_stream; unsigned int i_stream;
unsigned int i;
asf_object_content_description_t *p_cd; asf_object_content_description_t *p_cd;
vlc_bool_t b_seekable; vlc_bool_t b_seekable;
...@@ -148,7 +149,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -148,7 +149,6 @@ static int Open( vlc_object_t * p_this )
msg_Dbg( p_input, "found %d streams", p_sys->i_streams ); msg_Dbg( p_input, "found %d streams", p_sys->i_streams );
/* create one program */
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
if( input_InitStream( p_input, 0 ) == -1) if( input_InitStream( p_input, 0 ) == -1)
{ {
...@@ -156,13 +156,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -156,13 +156,6 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "cannot init stream" ); msg_Err( p_input, "cannot init stream" );
goto error; 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.p_selected_program = p_input->stream.pp_programs[0];
p_input->stream.i_mux_rate = 0 ; /* updated later */ p_input->stream.i_mux_rate = 0 ; /* updated later */
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
...@@ -184,109 +177,61 @@ static int Open( vlc_object_t * p_this ) ...@@ -184,109 +177,61 @@ static int Open( vlc_object_t * p_this )
p_stream->p_sp = p_sp; p_stream->p_sp = p_sp;
p_stream->p_es = NULL; p_stream->p_es = NULL;
if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) ) if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_audio ) &&
p_sp->i_type_specific_data_length >= sizeof( WAVEFORMATEX ) - 2 )
{ {
int i_codec; es_format_t fmt;
if( p_sp->p_type_specific_data ) uint8_t *p_data = p_sp->p_type_specific_data;
{
i_codec = GetWLE( p_sp->p_type_specific_data ); es_format_Init( &fmt, AUDIO_ES, 0 );
} wf_tag_to_fourcc( GetWLE( &p_data[0] ), &fmt.i_codec, NULL );
else fmt.audio.i_channels = GetWLE( &p_data[2] );
fmt.audio.i_samplerate = GetDWLE( &p_data[4] );
fmt.audio.i_bitrate = GetDWLE( &p_data[8] ) * 8;
fmt.audio.i_blockalign = GetWLE( &p_data[12] );
fmt.audio.i_bitspersample = GetWLE( &p_data[14] );
if( p_sp->i_type_specific_data_length > sizeof( WAVEFORMATEX ) )
{ {
i_codec = -1; fmt.i_extra_type = ES_EXTRA_TYPE_WAVEFORMATEX;
fmt.i_extra = __MIN( GetWLE( &p_data[16] ),
p_sp->i_type_specific_data_length - sizeof( WAVEFORMATEX ) );
fmt.p_extra = malloc( fmt.i_extra );
memcpy( fmt.p_extra, &p_data[sizeof( WAVEFORMATEX )], fmt.i_extra );
} }
p_stream->i_cat = AUDIO_ES; p_stream->i_cat = AUDIO_ES;
p_stream->p_es = input_AddES( p_input, p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt );
p_input->stream.p_selected_program,
p_sp->i_stream_number, AUDIO_ES, NULL, 0 );
msg_Dbg( p_input, msg_Dbg( p_input,
"adding new audio stream(codec:0x%x,ID:%d)", "added new audio stream(codec:0x%x,ID:%d)",
i_codec, GetWLE( p_data ), p_sp->i_stream_number );
p_sp->i_stream_number );
wf_tag_to_fourcc( i_codec, &p_stream->p_es->i_fourcc, NULL );
if( p_sp->i_type_specific_data_length > 0 )
{
WAVEFORMATEX *p_wf;
size_t i_size;
uint8_t *p_data;
i_size = p_sp->i_type_specific_data_length;
p_wf = malloc( i_size );
p_stream->p_es->p_waveformatex = (void*)p_wf;
p_data = p_sp->p_type_specific_data;
p_wf->wFormatTag = GetWLE( p_data );
p_wf->nChannels = GetWLE( p_data + 2 );
p_wf->nSamplesPerSec = GetDWLE( p_data + 4 );
p_wf->nAvgBytesPerSec = GetDWLE( p_data + 8 );
p_wf->nBlockAlign = GetWLE( p_data + 12 );
p_wf->wBitsPerSample = GetWLE( p_data + 14 );
p_wf->cbSize = __MIN( GetWLE( p_data + 16 ), i_size - sizeof( WAVEFORMATEX ));
if( p_wf->cbSize > 0 )
{
memcpy( &p_wf[1], p_data + sizeof( WAVEFORMATEX ), p_wf->cbSize );
}
}
} }
else else if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) &&
if( ASF_CmpGUID( &p_sp->i_stream_type, &asf_object_stream_type_video ) ) p_sp->i_type_specific_data_length >= 11 + sizeof( BITMAPINFOHEADER ) )
{ {
p_stream->i_cat = VIDEO_ES; es_format_t fmt;
p_stream->p_es = input_AddES( p_input, uint8_t *p_data = &p_sp->p_type_specific_data[11];
p_input->stream.p_selected_program,
p_sp->i_stream_number, VIDEO_ES, NULL, 0 );
msg_Dbg( p_input, "adding new video stream(ID:%d)", es_format_Init( &fmt, VIDEO_ES,
p_sp->i_stream_number ); VLC_FOURCC( p_data[16], p_data[17], p_data[18], p_data[19] ) );
if( p_sp->p_type_specific_data ) fmt.video.i_width = GetDWLE( p_data + 4 );
{ fmt.video.i_height= GetDWLE( p_data + 8 );
p_stream->p_es->i_fourcc =
VLC_FOURCC( p_sp->p_type_specific_data[27], if( p_sp->i_type_specific_data_length > 11 + sizeof( BITMAPINFOHEADER ) )
p_sp->p_type_specific_data[28],
p_sp->p_type_specific_data[29],
p_sp->p_type_specific_data[30] );
}
else
{ {
p_stream->p_es->i_fourcc = fmt.i_extra_type = ES_EXTRA_TYPE_BITMAPINFOHEADER;
VLC_FOURCC( 'u','n','d','f' ); fmt.i_extra = __MIN( GetDWLE( p_data ),
} p_sp->i_type_specific_data_length - 11 - sizeof( BITMAPINFOHEADER ) );
if( p_sp->i_type_specific_data_length > 11 ) fmt.p_extra = malloc( fmt.i_extra );
{ memcpy( fmt.p_extra, &p_data[sizeof( BITMAPINFOHEADER )], fmt.i_extra );
BITMAPINFOHEADER *p_bih;
size_t i_size;
uint8_t *p_data;
i_size = p_sp->i_type_specific_data_length - 11;
p_bih = malloc( i_size );
p_stream->p_es->p_bitmapinfoheader = (void*)p_bih;
p_data = p_sp->p_type_specific_data + 11;
p_bih->biSize = GetDWLE( p_data );
p_bih->biWidth = GetDWLE( p_data + 4 );
p_bih->biHeight = GetDWLE( p_data + 8 );
p_bih->biPlanes = GetDWLE( p_data + 12 );
p_bih->biBitCount = GetDWLE( p_data + 14 );
p_bih->biCompression= GetDWLE( p_data + 16 );
p_bih->biSizeImage = GetDWLE( p_data + 20 );
p_bih->biXPelsPerMeter = GetDWLE( p_data + 24 );
p_bih->biYPelsPerMeter = GetDWLE( p_data + 28 );
p_bih->biClrUsed = GetDWLE( p_data + 32 );
p_bih->biClrImportant = GetDWLE( p_data + 36 );
if( i_size > sizeof( BITMAPINFOHEADER ) )
{
memcpy( &p_bih[1],
p_data + sizeof( BITMAPINFOHEADER ),
i_size - sizeof( BITMAPINFOHEADER ) );
}
} }
p_stream->i_cat = VIDEO_ES;
p_stream->p_es = es_out_Add( p_input->p_es_out, &fmt );
msg_Dbg( p_input, "added new video stream(ID:%d)",
p_sp->i_stream_number );
} }
else else
{ {
...@@ -294,16 +239,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -294,16 +239,8 @@ static int Open( vlc_object_t * p_this )
msg_Dbg( p_input, "ignoring unknown stream(ID:%d)", msg_Dbg( p_input, "ignoring unknown stream(ID:%d)",
p_sp->i_stream_number ); p_sp->i_stream_number );
} }
vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_stream->p_es )
{
input_SelectES( p_input, p_stream->p_es );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
} }
p_sys->i_data_begin = p_sys->p_root->p_data->i_object_pos + 50; p_sys->i_data_begin = p_sys->p_root->p_data->i_object_pos + 50;
if( p_sys->p_root->p_data->i_object_size != 0 ) if( p_sys->p_root->p_data->i_object_size != 0 )
{ /* local file */ { /* local file */
...@@ -346,11 +283,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -346,11 +283,6 @@ static int Open( vlc_object_t * p_this )
} }
} }
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_program->b_is_ok = 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
/* We add all info about this stream */ /* We add all info about this stream */
p_cat = input_InfoCategory( p_input, "Asf" ); p_cat = input_InfoCategory( p_input, "Asf" );
if( p_sys->i_length > 0 ) if( p_sys->i_length > 0 )
...@@ -379,6 +311,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -379,6 +311,8 @@ static int Open( vlc_object_t * p_this )
input_AddInfo( p_cat, _("Rating"), p_cd->psz_rating ); 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++ ) for( i_stream = 0, i = 0; i < 128; i++ )
{ {
asf_stream_t *tk = p_sys->stream[i]; asf_stream_t *tk = p_sys->stream[i];
...@@ -420,17 +354,11 @@ static int Open( vlc_object_t * p_this ) ...@@ -420,17 +354,11 @@ static int Open( vlc_object_t * p_this )
input_AddInfo( p_cat, _("Resolution"), "%dx%d", input_AddInfo( p_cat, _("Resolution"), "%dx%d",
p_bih->biWidth, p_bih->biHeight ); p_bih->biWidth, p_bih->biHeight );
input_AddInfo( p_cat, _("Planes"), "%d", p_bih->biPlanes );
input_AddInfo( p_cat, _("Bits Per Pixel"), "%d", p_bih->biBitCount );
input_AddInfo( p_cat, _("Image Size"), "%d", p_bih->biSizeImage );
input_AddInfo( p_cat, _("X pixels per meter"), "%d",
p_bih->biXPelsPerMeter );
input_AddInfo( p_cat, _("Y pixels per meter"), "%d",
p_bih->biYPelsPerMeter );
} }
i_stream++; i_stream++;
} }
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -449,23 +377,6 @@ static int Demux( input_thread_t *p_input ) ...@@ -449,23 +377,6 @@ static int Demux( input_thread_t *p_input )
demux_sys_t *p_sys = p_input->p_demux_data; demux_sys_t *p_sys = p_input->p_demux_data;
vlc_bool_t b_play_audio; vlc_bool_t b_play_audio;
int i; int i;
vlc_bool_t b_stream;
b_stream = VLC_FALSE;
for( i = 0; i < 128; i++ )
{
if( p_sys->stream[i] &&
p_sys->stream[i]->p_es &&
p_sys->stream[i]->p_es->p_decoder_fifo )
{
b_stream = VLC_TRUE;
}
}
if( !b_stream )
{
msg_Warn( p_input, "no stream selected, exiting..." );
return( 0 );
}
/* catch seek from user */ /* catch seek from user */
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
...@@ -586,7 +497,7 @@ static mtime_t GetMoviePTS( demux_sys_t *p_sys ) ...@@ -586,7 +497,7 @@ static mtime_t GetMoviePTS( demux_sys_t *p_sys )
for( i_stream = 0; i_stream < 128 ; i_stream++ ) for( i_stream = 0; i_stream < 128 ; i_stream++ )
{ {
#define p_stream p_sys->stream[i_stream] #define p_stream p_sys->stream[i_stream]
if( p_stream && p_stream->p_es && p_stream->p_es->p_decoder_fifo && p_stream->i_time > 0) if( p_stream && p_stream->p_es && p_stream->i_time > 0)
{ {
if( i_time < 0 ) if( i_time < 0 )
{ {
...@@ -801,7 +712,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) ...@@ -801,7 +712,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
continue; // over payload continue; // over payload
} }
if( !p_stream->p_es || !p_stream->p_es->p_decoder_fifo ) if( !p_stream->p_es )
{ {
i_skip += i_payload_data_length; i_skip += i_payload_data_length;
continue; continue;
...@@ -832,19 +743,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) ...@@ -832,19 +743,7 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
/* send complete packet to decoder */ /* send complete packet to decoder */
if( p_stream->p_pes->i_pes_size > 0 ) if( p_stream->p_pes->i_pes_size > 0 )
{ {
if( p_stream->p_es->p_decoder_fifo && es_out_Send( p_input->p_es_out, p_stream->p_es, p_stream->p_pes );
( b_play_audio || p_stream->i_cat != AUDIO_ES ) )
{
p_stream->p_pes->i_rate =
p_input->stream.control.i_rate;
input_DecodePES( p_stream->p_es->p_decoder_fifo,
p_stream->p_pes );
}
else
{
input_DeletePES( p_input->p_method_data,
p_stream->p_pes );
}
p_stream->p_pes = NULL; p_stream->p_pes = NULL;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* au.c : au file input module for vlc * au.c : au file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * Copyright (C) 2001-2003 VideoLAN
* $Id: au.c,v 1.7 2003/09/12 16:26:40 fenrir Exp $ * $Id: au.c,v 1.8 2003/11/11 00:37:59 fenrir Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -93,11 +93,11 @@ typedef struct ...@@ -93,11 +93,11 @@ typedef struct
struct demux_sys_t struct demux_sys_t
{ {
au_t au; au_t au;
WAVEFORMATEX wf;
mtime_t i_time; mtime_t i_time;
es_descriptor_t *p_es; es_format_t fmt;
es_out_id_t *p_es;
int i_frame_size; int i_frame_size;
mtime_t i_frame_length; mtime_t i_frame_length;
...@@ -114,8 +114,6 @@ static int Open( vlc_object_t * p_this ) ...@@ -114,8 +114,6 @@ static int Open( vlc_object_t * p_this )
uint8_t *p_peek; uint8_t *p_peek;
vlc_fourcc_t i_fourcc;
int i_cat; int i_cat;
/* a little test to see if it's a au file */ /* a little test to see if it's a au file */
...@@ -170,105 +168,92 @@ static int Open( vlc_object_t * p_this ) ...@@ -170,105 +168,92 @@ static int Open( vlc_object_t * p_this )
} }
/* Create WAVEFORMATEX structure */ /* Create WAVEFORMATEX structure */
p_sys->wf.nChannels = p_sys->au.i_channels; es_format_Init( &p_sys->fmt, AUDIO_ES, 0 );
p_sys->wf.nSamplesPerSec= p_sys->au.i_sample_rate; p_sys->fmt.audio.i_channels = p_sys->au.i_channels;
p_sys->wf.cbSize = 0; p_sys->fmt.audio.i_samplerate = p_sys->au.i_sample_rate;
switch( p_sys->au.i_encoding ) switch( p_sys->au.i_encoding )
{ {
case AU_ALAW_8: /* 8-bit ISDN A-law */ case AU_ALAW_8: /* 8-bit ISDN A-law */
p_sys->wf.wFormatTag = WAVE_FORMAT_ALAW; // FIXME ?? p_sys->fmt.i_codec = VLC_FOURCC( 'a','l','a','w' );
p_sys->wf.wBitsPerSample = 8; p_sys->fmt.audio.i_bitspersample = 8;
p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a','l','a','w' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_MULAW_8: /* 8-bit ISDN u-law */ case AU_MULAW_8: /* 8-bit ISDN u-law */
p_sys->wf.wFormatTag = WAVE_FORMAT_MULAW; // FIXME ?? p_sys->fmt.i_codec = VLC_FOURCC( 'u','l','a','w' );
p_sys->wf.wBitsPerSample = 8; p_sys->fmt.audio.i_bitspersample = 8;
p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'u','l','a','w' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_LINEAR_8: /* 8-bit linear PCM */ case AU_LINEAR_8: /* 8-bit linear PCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' );
p_sys->wf.wBitsPerSample = 8; p_sys->fmt.audio.i_bitspersample = 8;
p_sys->wf.nBlockAlign = 1 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 1 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 't','w','o','s' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_LINEAR_16: /* 16-bit linear PCM */ case AU_LINEAR_16: /* 16-bit linear PCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' );
p_sys->wf.wBitsPerSample = 16; p_sys->fmt.audio.i_bitspersample = 16;
p_sys->wf.nBlockAlign = 2 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 2 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 't','w','o','s' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_LINEAR_24: /* 24-bit linear PCM */ case AU_LINEAR_24: /* 24-bit linear PCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' );
p_sys->wf.wBitsPerSample = 24; p_sys->fmt.audio.i_bitspersample = 24;
p_sys->wf.nBlockAlign = 3 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 3 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 't','w','o','s' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_LINEAR_32: /* 32-bit linear PCM */ case AU_LINEAR_32: /* 32-bit linear PCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_PCM; p_sys->fmt.i_codec = VLC_FOURCC( 't','w','o','s' );
p_sys->wf.wBitsPerSample = 32; p_sys->fmt.audio.i_bitspersample = 32;
p_sys->wf.nBlockAlign = 4 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 4 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 't','w','o','s' );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_FLOAT: /* 32-bit IEEE floating point */ case AU_FLOAT: /* 32-bit IEEE floating point */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT );
p_sys->wf.wBitsPerSample = 32; p_sys->fmt.audio.i_bitspersample = 32;
p_sys->wf.nBlockAlign = 4 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 4 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_FLOAT );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_DOUBLE: /* 64-bit IEEE floating point */ case AU_DOUBLE: /* 64-bit IEEE floating point */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE );
p_sys->wf.wBitsPerSample = 64; p_sys->fmt.audio.i_bitspersample = 64;
p_sys->wf.nBlockAlign = 8 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 8 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_DOUBLE );
i_cat = AU_CAT_PCM; i_cat = AU_CAT_PCM;
break; break;
case AU_ADPCM_G721: /* 4-bit CCITT g.721 ADPCM */ case AU_ADPCM_G721: /* 4-bit CCITT g.721 ADPCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 );
p_sys->wf.wBitsPerSample = 0; p_sys->fmt.audio.i_bitspersample = 0;
p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G721 );
i_cat = AU_CAT_ADPCM; i_cat = AU_CAT_ADPCM;
break; break;
case AU_ADPCM_G722: /* CCITT g.722 ADPCM */ case AU_ADPCM_G722: /* CCITT g.722 ADPCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 );
p_sys->wf.wBitsPerSample = 0; p_sys->fmt.audio.i_bitspersample = 0;
p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G722 );
i_cat = AU_CAT_ADPCM; i_cat = AU_CAT_ADPCM;
break; break;
case AU_ADPCM_G723_3: /* CCITT g.723 3-bit ADPCM */ case AU_ADPCM_G723_3: /* CCITT g.723 3-bit ADPCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 );
p_sys->wf.wBitsPerSample = 0; p_sys->fmt.audio.i_bitspersample = 0;
p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_3 );
i_cat = AU_CAT_ADPCM; i_cat = AU_CAT_ADPCM;
break; break;
case AU_ADPCM_G723_5: /* CCITT g.723 5-bit ADPCM */ case AU_ADPCM_G723_5: /* CCITT g.723 5-bit ADPCM */
p_sys->wf.wFormatTag = WAVE_FORMAT_UNKNOWN; p_sys->fmt.i_codec = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 );
p_sys->wf.wBitsPerSample = 0; p_sys->fmt.audio.i_bitspersample = 0;
p_sys->wf.nBlockAlign = 0 * p_sys->wf.nChannels; p_sys->fmt.audio.i_blockalign = 0 * p_sys->fmt.audio.i_channels;
i_fourcc = VLC_FOURCC( 'a', 'u', 0, AU_ADPCM_G723_5 );
i_cat = AU_CAT_ADPCM; i_cat = AU_CAT_ADPCM;
break; break;
...@@ -277,9 +262,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -277,9 +262,9 @@ static int Open( vlc_object_t * p_this )
i_cat = AU_CAT_UNKNOWN; i_cat = AU_CAT_UNKNOWN;
goto error; goto error;
} }
p_sys->wf.nAvgBytesPerSec = p_sys->wf.nSamplesPerSec * p_sys->wf.nChannels * p_sys->wf.wBitsPerSample / 8; p_sys->fmt.audio.i_bitrate = p_sys->fmt.audio.i_samplerate *
p_sys->fmt.audio.i_channels *
p_sys->fmt.audio.i_bitspersample;
if( i_cat == AU_CAT_UNKNOWN || i_cat == AU_CAT_ADPCM ) if( i_cat == AU_CAT_UNKNOWN || i_cat == AU_CAT_ADPCM )
{ {
...@@ -294,27 +279,26 @@ static int Open( vlc_object_t * p_this ) ...@@ -294,27 +279,26 @@ static int Open( vlc_object_t * p_this )
int i_samples, i_modulo; int i_samples, i_modulo;
/* read samples for 50ms of */ /* read samples for 50ms of */
i_samples = __MAX( p_sys->wf.nSamplesPerSec / 20, 1 ); i_samples = __MAX( p_sys->fmt.audio.i_samplerate / 20, 1 );
p_sys->i_frame_size = i_samples * p_sys->wf.nChannels * ( (p_sys->wf.wBitsPerSample + 7) / 8 ); p_sys->i_frame_size = i_samples * p_sys->fmt.audio.i_channels * ( (p_sys->fmt.audio.i_bitspersample + 7) / 8 );
if( p_sys->wf.nBlockAlign > 0 ) if( p_sys->fmt.audio.i_blockalign > 0 )
{ {
if( ( i_modulo = p_sys->i_frame_size % p_sys->wf.nBlockAlign ) != 0 ) if( ( i_modulo = p_sys->i_frame_size % p_sys->fmt.audio.i_blockalign ) != 0 )
{ {
p_sys->i_frame_size += p_sys->wf.nBlockAlign - i_modulo; p_sys->i_frame_size += p_sys->fmt.audio.i_blockalign - i_modulo;
} }
} }
p_sys->i_frame_length = (mtime_t)1000000 * p_sys->i_frame_length = (mtime_t)1000000 *
(mtime_t)i_samples / (mtime_t)i_samples /
(mtime_t)p_sys->wf.nSamplesPerSec; (mtime_t)p_sys->fmt.audio.i_samplerate;
p_input->pf_demux = DemuxPCM; p_input->pf_demux = DemuxPCM;
p_input->pf_demux_control = demux_vaControlDefault; p_input->pf_demux_control = demux_vaControlDefault;
} }
/* create one program */
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
if( input_InitStream( p_input, 0 ) == -1) if( input_InitStream( p_input, 0 ) == -1)
{ {
...@@ -322,29 +306,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -322,29 +306,10 @@ static int Open( vlc_object_t * p_this )
msg_Err( p_input, "cannot init stream" ); msg_Err( p_input, "cannot init stream" );
goto error; goto error;
} }
if( input_AddProgram( p_input, 0, 0) == NULL ) p_input->stream.i_mux_rate = p_sys->fmt.audio.i_bitrate / 50 / 8;
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
msg_Err( p_input, "cannot add program" );
goto error;
}
p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
p_input->stream.i_mux_rate = p_sys->wf.nAvgBytesPerSec / 50;
p_sys->p_es = input_AddES( p_input, p_input->stream.p_selected_program,
0x01, AUDIO_ES, NULL, 0 );
p_sys->p_es->i_stream_id = 0x01;
p_sys->p_es->i_fourcc = i_fourcc;
p_sys->p_es->p_waveformatex= malloc( sizeof( WAVEFORMATEX ) );
memcpy( p_sys->p_es->p_waveformatex, &p_sys->wf, sizeof( WAVEFORMATEX ) );
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 ); vlc_mutex_unlock( &p_input->stream.stream_lock );
p_sys->p_es = es_out_Add( p_input->p_es_out, &p_sys->fmt );
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -366,9 +331,9 @@ static int DemuxPCM( input_thread_t *p_input ) ...@@ -366,9 +331,9 @@ static int DemuxPCM( input_thread_t *p_input )
{ {
int64_t i_pos = stream_Tell( p_input->s ); int64_t i_pos = stream_Tell( p_input->s );
if( p_sys->wf.nBlockAlign != 0 ) if( p_sys->fmt.audio.i_blockalign != 0 )
{ {
i_pos += p_sys->wf.nBlockAlign - i_pos % p_sys->wf.nBlockAlign; i_pos += p_sys->fmt.audio.i_blockalign - i_pos % p_sys->fmt.audio.i_blockalign;
if( stream_Seek( p_input->s, i_pos ) ) if( stream_Seek( p_input->s, i_pos ) )
{ {
msg_Err( p_input, "Seek failed(cannot resync)" ); msg_Err( p_input, "Seek failed(cannot resync)" );
...@@ -390,15 +355,10 @@ static int DemuxPCM( input_thread_t *p_input ) ...@@ -390,15 +355,10 @@ static int DemuxPCM( input_thread_t *p_input )
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
p_sys->i_time * 9 / 100 ); p_sys->i_time * 9 / 100 );
if( !p_sys->p_es->p_decoder_fifo ) es_out_Send( p_input->p_es_out, p_sys->p_es, p_pes );
{
msg_Err( p_input, "no audio decoder" );
input_DeletePES( p_input->p_method_data, p_pes );
return( -1 );
}
input_DecodePES( p_sys->p_es->p_decoder_fifo, p_pes );
p_sys->i_time += p_sys->i_frame_length; p_sys->i_time += p_sys->i_frame_length;
return( 1 ); return( 1 );
} }
......
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