Fixed seme seeking issues with http access module, fixed an error that

caused id3v2.4 tags at the end of the file to not work. Added checks to
avoid seeking off the ends of the file. Should close #325, please confirm
parent 62bd7089
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* id3tag.c: id3 tag parser/skipper based on libid3tag * id3tag.c: id3 tag parser/skipper based on libid3tag
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: id3tag.c,v 1.3 2003/01/05 21:03:58 sigmunau Exp $ * $Id: id3tag.c,v 1.4 2003/02/22 14:11:38 sigmunau Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -43,22 +43,18 @@ static int ParseID3Tags ( vlc_object_t * ); ...@@ -43,22 +43,18 @@ static int ParseID3Tags ( vlc_object_t * );
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_description( _("id3 tag parser using libid3tag" ) ); set_description( _("id3 tag parser using libid3tag" ) );
set_capability( "id3", 70 ); set_capability( "id3", 70 );
set_callbacks( ParseID3Tags, NULL ); set_callbacks( ParseID3Tags, NULL );
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
* Definitions of structures and functions used by this plugins * Definitions of structures and functions used by this plugins
*****************************************************************************/ *****************************************************************************/
/**************************************************************************** /*****************************************************************************
* ParseID3Tag : parse an id3tag into the info structures * ParseID3Tag : parse an id3tag into the info structures
**************************************************************************** *****************************************************************************/
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size ) static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size )
{ {
struct id3_tag * p_id3_tag; struct id3_tag * p_id3_tag;
...@@ -85,13 +81,10 @@ static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size ) ...@@ -85,13 +81,10 @@ static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size )
id3_tag_delete( p_id3_tag ); id3_tag_delete( p_id3_tag );
} }
/**************************************************************************** /*****************************************************************************
* ParseID3Tag : check if an ID3 header is present and parse and skip it * ParseID3Tags: check if ID3 tags at common locations. Parse them and skip it
**************************************************************************** * if it's at the start of the file
* ****************************************************************************/
* Author : Sigmund Augdal
*
' ****************************************************************************/
static int ParseID3Tags( vlc_object_t *p_this ) static int ParseID3Tags( vlc_object_t *p_this )
{ {
input_thread_t *p_input; input_thread_t *p_input;
...@@ -107,15 +100,7 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -107,15 +100,7 @@ static int ParseID3Tags( vlc_object_t *p_this )
p_input = (input_thread_t *)p_this; p_input = (input_thread_t *)p_this;
msg_Dbg( p_input, "Checking for ID3 tag" ); msg_Dbg( p_input, "Checking for ID3 tag" );
/* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
i_size = id3_tag_query( p_peek, 10 );
#if 0
if ( p_input->stream.b_seekable ) if ( p_input->stream.b_seekable )
{ {
/*look for a id3v1 tag at the end of the file*/ /*look for a id3v1 tag at the end of the file*/
...@@ -125,54 +110,67 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -125,54 +110,67 @@ static int ParseID3Tags( vlc_object_t *p_this )
msg_Err( p_input, "no mem" ); msg_Err( p_input, "no mem" );
} }
input_Tell( p_input, p_pos ); input_Tell( p_input, p_pos );
p_input->pf_seek( p_input, p_pos->i_size - 128 ); if ( p_pos->i_size >128 )
input_AccessReinit( p_input );
/* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
i_size2 = id3_tag_query( p_peek, 10 );
if ( i_size2 == 128 )
{ {
/* peek the entire tag */ input_AccessReinit( p_input );
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 ) p_input->pf_seek( p_input, p_pos->i_size - 128 );
/* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
ParseID3Tag( p_input, p_peek, i_size2 ); i_size2 = id3_tag_query( p_peek, 10 );
if ( i_size2 == 128 )
{
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
ParseID3Tag( p_input, p_peek, i_size2 );
}
} }
/* look for id3v2.4 tag at end of file */ /* look for id3v2.4 tag at end of file */
p_input->pf_seek( p_input, p_pos->i_size - 10 ); if ( p_pos->i_size > 10 )
input_AccessReinit( p_input );
/* get 10 byte id3 footer */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
i_size2 = id3_tag_query( p_peek, 10 );
if ( i_size2 < 0 ) /* id3v2.4 footer found */
{ {
p_input->pf_seek( p_input, p_pos->i_size - i_size2 );
input_AccessReinit( p_input ); input_AccessReinit( p_input );
/* peek the entire tag */ p_input->pf_seek( p_input, p_pos->i_size - 10 );
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 ) /* get 10 byte id3 footer */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
ParseID3Tag( p_input, p_peek, i_size2 ); i_size2 = id3_tag_query( p_peek, 10 );
if ( i_size2 < 0 && p_pos->i_size > -i_size2 )
{ /* id3v2.4 footer found */
input_AccessReinit( p_input );
p_input->pf_seek( p_input, p_pos->i_size + i_size2 );
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
ParseID3Tag( p_input, p_peek, i_size2 );
}
} }
free( p_pos ); free( p_pos );
p_input->pf_seek( p_input, 0 );
input_AccessReinit( p_input ); input_AccessReinit( p_input );
p_input->pf_seek( p_input, 0 );
} }
#endif /* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
i_size = id3_tag_query( p_peek, 10 );
if ( i_size <= 0 ) if ( i_size <= 0 )
{ {
return( VLC_SUCCESS ); return( VLC_SUCCESS );
...@@ -187,8 +185,6 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -187,8 +185,6 @@ static int ParseID3Tags( vlc_object_t *p_this )
ParseID3Tag( p_input, p_peek, i_size ); ParseID3Tag( p_input, p_peek, i_size );
msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size ); msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size );
p_input->pf_seek( p_input, i_size ); p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
input_AccessReinit( p_input );
// p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
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