#include <vlc_codecs.h>
#include <vlc_bits.h>
#include "xiph.h"
-#include "vorbis.h"
-#include "kate_categories.h"
+#include "xiph_metadata.h"
#include "ogg.h"
#include "oggseek.h"
/* */
static void Ogg_ExtractMeta( demux_t *p_demux, vlc_fourcc_t i_codec, const uint8_t *p_headers, int i_headers );
-static int64_t Ogg_GetLastPacket( demux_t *p_demux, logical_stream_t *p_stream, ogg_packet *p_oggpacket, double f_rate );
+static int64_t Ogg_GetLastPacket( demux_t *p_demux, logical_stream_t *p_stream, double f_rate );
/* Logical bitstream headers */
static void Ogg_ReadTheoraHeader( demux_t *, logical_stream_t *, ogg_packet * );
return 1;
}
+static void Ogg_ResetStreamHelper( demux_sys_t *p_sys )
+{
+ for( int i = 0; i < p_sys->i_streams; i++ )
+ {
+ logical_stream_t *p_stream = p_sys->pp_stream[i];
+
+ /* we'll trash all the data until we find the next pcr */
+ p_stream->b_reinit = true;
+ p_stream->i_pcr = -1;
+ p_stream->i_interpolated_pcr = -1;
+ p_stream->i_previous_granulepos = -1;
+ ogg_stream_reset( &p_stream->os );
+ }
+ ogg_sync_reset( &p_sys->oy );
+}
+
/*****************************************************************************
* Control:
*****************************************************************************/
vlc_meta_t *p_meta;
int64_t *pi64;
bool *pb_bool;
- int i;
switch( i_query )
{
return VLC_EGENERIC;
}
- for( i = 0; i < p_sys->i_streams; i++ )
- {
- logical_stream_t *p_stream = p_sys->pp_stream[i];
-
- /* we'll trash all the data until we find the next pcr */
- p_stream->b_reinit = true;
- p_stream->i_pcr = -1;
- p_stream->i_interpolated_pcr = -1;
- p_stream->i_previous_granulepos = -1;
- ogg_stream_reset( &p_stream->os );
- }
- ogg_sync_reset( &p_sys->oy );
+ Ogg_ResetStreamHelper( p_sys );
return demux_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
1, i_query, args );
case DEMUX_GET_LENGTH:
return VLC_EGENERIC;
}
- for( i = 0; i < p_sys->i_streams; i++ )
- {
- logical_stream_t *p_stream = p_sys->pp_stream[i];
-
- /* we'll trash all the data until we find the next pcr */
- p_stream->b_reinit = true;
- p_stream->i_pcr = -1;
- p_stream->i_interpolated_pcr = -1;
- p_stream->i_previous_granulepos = -1;
- ogg_stream_reset( &p_stream->os );
- }
- ogg_sync_reset( &p_sys->oy );
+ Ogg_ResetStreamHelper( p_sys );
int64_t i_block = p_sys->pp_seekpoints[i_seekpoint]->i_time_offset * p_sys->i_bitrate / INT64_C(8000000);
if( stream_Seek( p_demux->s, i_block ) )
return VLC_EGENERIC;
/* We need to get rid of the header packet */
ogg_stream_packetout( &p_stream->os, &oggpacket );
- msg_Dbg( p_demux, "found text subtitles header" );
+ msg_Dbg( p_demux, "found text subtitle header" );
p_stream->fmt.i_cat = SPU_ES;
p_stream->fmt.i_codec = VLC_CODEC_SUBT;
p_stream->f_rate = 1000; /* granulepos is in millisec */
/* TODO how to handle multiple comments properly ? */
if( i_count >= 2 && pi_size[1] > i_skip )
+ {
+ int i_cover_score = 0;
+ int i_cover_idx = 0;
vorbis_ParseComment( &p_ogg->p_meta, (uint8_t*)pp_data[1] + i_skip, pi_size[1] - i_skip,
&p_ogg->i_attachments, &p_ogg->attachments,
+ &i_cover_score, &i_cover_idx,
&p_ogg->i_seekpoints, &p_ogg->pp_seekpoints );
+ if( p_ogg->p_meta != NULL && i_cover_idx < p_ogg->i_attachments )
+ {
+ char psz_url[128];
+ snprintf( psz_url, sizeof(psz_url), "attachment://%s",
+ p_ogg->attachments[i_cover_idx]->psz_name );
+ vlc_meta_Set( p_ogg->p_meta, vlc_meta_ArtworkURL, psz_url );
+ }
+ }
if( p_ogg->i_seekpoints > 1 )
{
}
static int64_t Ogg_GetLastPacket( demux_t *p_demux, logical_stream_t *p_stream,
- ogg_packet *p_oggpacket, double f_rate )
+ double f_rate )
{
int64_t last_packet = oggseek_get_last_frame( p_demux, p_stream );
- /*
- * Since there's quite a good chance that ogg_stream_packetout was called,
- * the given p_oggpacket may point to invalid data. Fill it with some valid ones
- */
- ogg_stream_packetpeek( &p_stream->os, p_oggpacket );
-
return ( last_packet >= 0 ) ? last_packet / f_rate : -1;
}
}
if ( p_demux->p_sys->i_length < 0 )
{
- int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_oggpacket, p_stream->f_rate );
+ int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_stream->f_rate );
if ( last_packet >= 0 )
p_demux->p_sys->i_length = last_packet;
}
if ( p_demux->p_sys->i_length < 0 )
{
- int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_oggpacket, p_stream->f_rate );
+ int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_stream->f_rate );
if ( last_packet >= 0 )
p_demux->p_sys->i_length = last_packet;
}
if ( p_demux->p_sys->i_length < 0 )
{
- int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_oggpacket, p_stream->f_rate );
+ int64_t last_packet = Ogg_GetLastPacket( p_demux, p_stream, p_stream->f_rate );
if ( last_packet >= 0 )
p_demux->p_sys->i_length = last_packet;
}
bs_init( &s, p_oggpacket->packet, p_oggpacket->bytes );
bs_read( &s, 1 );
- if( p_oggpacket->bytes > 0 && bs_read( &s, 7 ) == 0 )
+ if( p_oggpacket->bytes > 0 && bs_read( &s, 7 ) != 0 )
{
- if( bs_read( &s, 24 ) >= 34 /*size STREAMINFO*/ )
- {
- bs_skip( &s, 80 );
- p_stream->f_rate = p_stream->fmt.audio.i_rate = bs_read( &s, 20 );
- p_stream->fmt.audio.i_channels = bs_read( &s, 3 ) + 1;
+ msg_Dbg( p_demux, "Invalid FLAC STREAMINFO metadata" );
+ return;
+ }
- msg_Dbg( p_demux, "FLAC header, channels: %i, rate: %i",
- p_stream->fmt.audio.i_channels, (int)p_stream->f_rate );
- }
- else
- {
- msg_Dbg( p_demux, "FLAC STREAMINFO metadata too short" );
- }
+ if( bs_read( &s, 24 ) >= 34 /*size STREAMINFO*/ )
+ {
+ bs_skip( &s, 80 );
+ p_stream->f_rate = p_stream->fmt.audio.i_rate = bs_read( &s, 20 );
+ p_stream->fmt.audio.i_channels = bs_read( &s, 3 ) + 1;
- /* Fake this as the last metadata block */
- *((uint8_t*)p_oggpacket->packet) |= 0x80;
+ msg_Dbg( p_demux, "FLAC header, channels: %i, rate: %i",
+ p_stream->fmt.audio.i_channels, (int)p_stream->f_rate );
}
else
{
- /* This ain't a STREAMINFO metadata */
- msg_Dbg( p_demux, "Invalid FLAC STREAMINFO metadata" );
+ msg_Dbg( p_demux, "FLAC STREAMINFO metadata too short" );
}
+
+ /* Fake this as the last metadata block */
+ *((uint8_t*)p_oggpacket->packet) |= 0x80;
}
static void Ogg_ReadKateHeader( logical_stream_t *p_stream,
minor_version = oggpack_read( &opb, 2*8 ); /* minor version */
timebase_numerator = GetQWLE( &p_oggpacket->packet[16] );
timebase_denominator = GetQWLE( &p_oggpacket->packet[24] );
+
+ msg_Dbg( p_demux, "Annodex info: version %"PRIu16".%"PRIu16" "
+ "Timebase %"PRId64" / %"PRId64,
+ major_version, minor_version,
+ timebase_numerator, timebase_denominator );
}
else if( p_oggpacket->bytes >= 42 &&
!memcmp( p_oggpacket->packet, "AnxData", 7 ) )