* ogg.c : ogg stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: ogg.c,v 1.16 2002/12/19 23:23:24 sigmunau Exp $
+ * $Id: ogg.c,v 1.25 2003/05/05 22:23:34 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
/* program clock reference (in units of 90kHz) derived from the pcr of
* the sub-streams */
mtime_t i_pcr;
+ mtime_t i_old_pcr;
- mtime_t i_length;
int b_seekable;
int b_reinit;
};
* Module descriptor
*****************************************************************************/
vlc_module_begin();
- set_description( _("ogg stream demux" ) );
+ set_description( _("ogg stream demuxer" ) );
set_capability( "demux", 50 );
set_callbacks( Activate, Deactivate );
add_shortcut( "ogg" );
input_DeletePES( p_input->p_method_data, p_pes );
return;
}
+ p_data->p_payload_end = p_data->p_payload_start + p_oggpacket->bytes;
/* Convert the pcr into a pts */
if( p_stream->i_cat != SPU_ES )
if( p_stream->i_fourcc != VLC_FOURCC( 'v','o','r','b' ) &&
p_stream->i_fourcc != VLC_FOURCC( 't','a','r','k' ) &&
- p_stream->i_fourcc != VLC_FOURCC( 't','h','e','o' ) &&
- p_stream->i_fourcc != VLC_FOURCC( 'o','f','l','c') )
+ p_stream->i_fourcc != VLC_FOURCC( 't','h','e','o' ) )
{
/* Remove the header from the packet */
i_header_len = (*p_oggpacket->packet & PACKET_LEN_BITS01) >> 6;
/* FIXME: check return value */
ogg_stream_packetpeek( &p_stream->os, &oggpacket );
- msg_Dbg( p_input, "found string: %s", strndup( &oggpacket.packet[0], 6 ) );
- msg_Dbg( p_input, "oggpacket.bytes is %d", oggpacket.bytes );
- if( oggpacket.bytes >= 4 &&
- ! strncmp( &oggpacket.packet[0], "fLaC", 4 ) )
- {
- oggpack_buffer opb;
-
- msg_Dbg( p_input, "found flac header" );
- p_stream->i_cat = AUDIO_ES;
- p_stream->i_fourcc = VLC_FOURCC( 'o','f','l','c' );
-#if 0
- /* Signal that we want to keep a backup of the vorbis
- * stream headers. They will be used when switching between
- * audio streams. */
- p_stream->b_force_backup = 1;
-
- /* Cheat and get additionnal info ;) */
- oggpack_readinit( &opb, oggpacket.packet, oggpacket.bytes);
- oggpack_adv( &opb, 96 );
- p_stream->f_rate = oggpack_read( &opb, 32 );
- oggpack_adv( &opb, 32 );
- p_stream->i_bitrate = oggpack_read( &opb, 32 );
-#endif
- }
-
/* Check for Vorbis header */
- else if( oggpacket.bytes >= 7 &&
+ if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "vorbis", 6 ) )
{
oggpack_buffer opb;
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Audio" );
- input_AddInfo( p_cat, "Codec", "vorbis" );
- input_AddInfo( p_cat, "Sample Rate", "%f",
+ input_AddInfo( p_cat, _("Type"), _("Audio") );
+ input_AddInfo( p_cat, _("Codec"), _("Vorbis") );
+ input_AddInfo( p_cat, _("Sample Rate"), "%f",
p_stream->f_rate );
- input_AddInfo( p_cat, "Bit Rate", "%d",
+ input_AddInfo( p_cat, _("Bit Rate"), "%d",
p_stream->i_bitrate );
}
}
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Video" );
- input_AddInfo( p_cat, "Codec", "theora" );
- input_AddInfo( p_cat, "Frame Rate", "%f",
+ input_AddInfo( p_cat, _("Type"), _("Video") );
+ input_AddInfo( p_cat, _("Codec"), _("Theora") );
+ input_AddInfo( p_cat, _("Frame Rate"), "%f",
p_stream->f_rate );
- input_AddInfo( p_cat, "Bit Rate", "%d",
+ input_AddInfo( p_cat, _("Bit Rate"), "%d",
p_stream->i_bitrate );
}
#else /* HAVE_OGGPACKB */
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Video" );
- input_AddInfo( p_cat, "Codec", "tarkin" );
- input_AddInfo( p_cat, "Sample Rate", "%f",
+ input_AddInfo( p_cat, _("Type"), _("Video") );
+ input_AddInfo( p_cat, _("Codec"), _("tarkin") );
+ input_AddInfo( p_cat, _("Sample Rate"), "%f",
p_stream->f_rate );
- input_AddInfo( p_cat, "Bit Rate", "%d",
+ input_AddInfo( p_cat, _("Bit Rate"), "%d",
p_stream->i_bitrate );
}
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Video" );
- input_AddInfo( p_cat, "Codec", "%.4s",
+ input_AddInfo( p_cat, _("Type"), _("Video") );
+ input_AddInfo( p_cat, _("Codec"), "%.4s",
(char *)&p_stream->i_fourcc );
- input_AddInfo( p_cat, "Frame Rate", "%f",
+ input_AddInfo( p_cat, _("Frame Rate"), "%f",
p_stream->f_rate );
- input_AddInfo( p_cat, "Bit Count", "%d",
+ input_AddInfo( p_cat, _("Bit Count"), "%d",
p_stream->p_bih->biBitCount );
- input_AddInfo( p_cat, "Width", "%d",
+ input_AddInfo( p_cat, _("Width"), "%d",
p_stream->p_bih->biWidth );
- input_AddInfo( p_cat, "Height", "%d",
+ input_AddInfo( p_cat, _("Height"), "%d",
p_stream->p_bih->biHeight );
}
p_stream->i_bitrate = 0;
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Audio" );
- input_AddInfo( p_cat, "Codec", "%.4s",
+ input_AddInfo( p_cat, _("Type"), _("Audio") );
+ input_AddInfo( p_cat, _("Codec"), "%.4s",
(char *)&p_stream->i_fourcc );
- input_AddInfo( p_cat, "Sample Rate", "%d",
+ input_AddInfo( p_cat, _("Sample Rate"), "%d",
p_stream->p_wf->nSamplesPerSec );
- input_AddInfo( p_cat, "Bit Rate", "%d",
+ input_AddInfo( p_cat, _("Bit Rate"), "%d",
p_stream->p_wf->nAvgBytesPerSec * 8
/ 1024 );
- input_AddInfo( p_cat, "Channels", "%d",
+ input_AddInfo( p_cat, _("Channels"), "%d",
p_stream->p_wf->nChannels );
- input_AddInfo( p_cat, "Bits per Sample", "%d",
+ input_AddInfo( p_cat, _("Bits per Sample"), "%d",
p_stream->p_wf->wBitsPerSample );
}
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Video" );
- input_AddInfo( p_cat, "Codec", "%.4s",
+ input_AddInfo( p_cat, _("Type"), _("Video") );
+ input_AddInfo( p_cat, _("Codec"), "%.4s",
(char *)&p_stream->i_fourcc );
- input_AddInfo( p_cat, "Frame Rate", "%f",
+ input_AddInfo( p_cat, _("Frame Rate"), "%f",
p_stream->f_rate );
- input_AddInfo( p_cat, "Bit Count", "%d",
+ input_AddInfo( p_cat, _("Bit Count"), "%d",
p_stream->p_bih->biBitCount );
- input_AddInfo( p_cat, "Width", "%d",
+ input_AddInfo( p_cat, _("Width"), "%d",
p_stream->p_bih->biWidth );
- input_AddInfo( p_cat, "Height", "%d",
+ input_AddInfo( p_cat, _("Height"), "%d",
p_stream->p_bih->biHeight );
}
p_stream->i_bitrate = 0;
input_info_category_t *p_cat;
sprintf( title, "Stream %d", p_ogg->i_streams );
p_cat = input_InfoCategory( p_input, title );
- input_AddInfo( p_cat, "Type", "Audio" );
- input_AddInfo( p_cat, "Codec", "%.4s",
+ input_AddInfo( p_cat, _("Type"), _("Audio") );
+ input_AddInfo( p_cat, _("Codec"), "%.4s",
(char *)&p_stream->i_fourcc );
- input_AddInfo( p_cat, "Sample Rate", "%d",
+ input_AddInfo( p_cat, _("Sample Rate"), "%d",
p_stream->p_wf->nSamplesPerSec );
- input_AddInfo( p_cat, "Bit Rate", "%d",
+ input_AddInfo( p_cat, _("Bit Rate"), "%d",
p_stream->p_wf->nAvgBytesPerSec * 8
/ 1024 );
- input_AddInfo( p_cat, "Channels", "%d",
+ input_AddInfo( p_cat, _("Channels"), "%d",
p_stream->p_wf->nChannels );
- input_AddInfo( p_cat, "Bits per Sample", "%d",
+ input_AddInfo( p_cat, _("Bits per Sample"), "%d",
p_stream->p_wf->wBitsPerSample );
}
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_stream->p_es = input_AddES( p_input,
p_input->stream.p_selected_program,
- p_ogg->i_streams + 1, 0 );
+ i_stream,
+ p_stream->i_cat, NULL, 0 );
p_input->stream.i_mux_rate += (p_stream->i_bitrate / ( 8 * 50 ));
vlc_mutex_unlock( &p_input->stream.stream_lock );
- p_stream->p_es->i_stream_id = p_stream->p_es->i_id = i_stream;
+ p_stream->p_es->i_stream_id = i_stream;
p_stream->p_es->i_fourcc = p_stream->i_fourcc;
- p_stream->p_es->i_cat = p_stream->i_cat;
- p_stream->p_es->p_demux_data = p_stream->p_bih ?
- (void *)p_stream->p_bih : (void *)p_stream->p_wf;
+ p_stream->p_es->p_waveformatex = (void*)p_stream->p_wf;
+ p_stream->p_es->p_bitmapinfoheader = (void*)p_stream->p_bih;
#undef p_stream
}
}
i_stream = 0;
+ p_ogg->i_old_pcr = p_ogg->i_pcr;
p_ogg->i_pcr = p_stream->i_interpolated_pcr;
for( ; i_stream < p_ogg->i_streams; i_stream++ )
{
if( p_stream->i_cat == SPU_ES )
continue;
- if( p_stream->i_interpolated_pcr < p_ogg->i_pcr )
+ if( p_stream->i_interpolated_pcr > 0
+ && p_stream->i_interpolated_pcr < p_ogg->i_pcr )
p_ogg->i_pcr = p_stream->i_interpolated_pcr;
}
#undef p_stream
+ /* Sanity check for streams where the granulepos of the header packets
+ * don't match these of the data packets (eg. ogg web radios). */
+ if( p_ogg->i_old_pcr == 0 && p_ogg->i_pcr > 1000000 )
+ p_input->stream.p_selected_program->i_synchro_state = SYNCHRO_REINIT;
/* Call the pace control */
input_ClockManageRef( p_input, p_input->stream.p_selected_program,