Commit 06399606 authored by sigmunau's avatar sigmunau
Browse files

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 @@
* id3tag.c: id3 tag parser/skipper based on libid3tag
*****************************************************************************
* 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>
*
......@@ -43,22 +43,18 @@ static int ParseID3Tags ( vlc_object_t * );
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("id3 tag parser using libid3tag" ) );
set_capability( "id3", 70 );
set_callbacks( ParseID3Tags, NULL );
set_description( _("id3 tag parser using libid3tag" ) );
set_capability( "id3", 70 );
set_callbacks( ParseID3Tags, NULL );
vlc_module_end();
/*****************************************************************************
* Definitions of structures and functions used by this plugins
*****************************************************************************/
/****************************************************************************
/*****************************************************************************
* 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 )
{
struct id3_tag * p_id3_tag;
......@@ -85,13 +81,10 @@ static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size )
id3_tag_delete( p_id3_tag );
}
/****************************************************************************
* ParseID3Tag : check if an ID3 header is present and parse and skip it
****************************************************************************
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
/*****************************************************************************
* ParseID3Tags: check if ID3 tags at common locations. Parse them and skip it
* if it's at the start of the file
****************************************************************************/
static int ParseID3Tags( vlc_object_t *p_this )
{
input_thread_t *p_input;
......@@ -107,15 +100,7 @@ static int ParseID3Tags( vlc_object_t *p_this )
p_input = (input_thread_t *)p_this;
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 )
{
/*look for a id3v1 tag at the end of the file*/
......@@ -125,54 +110,67 @@ static int ParseID3Tags( vlc_object_t *p_this )
msg_Err( p_input, "no mem" );
}
input_Tell( p_input, p_pos );
p_input->pf_seek( p_input, 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 )
if ( p_pos->i_size >128 )
{
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 )
input_AccessReinit( p_input );
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()" );
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 */
p_input->pf_seek( p_input, 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 */
if ( p_pos->i_size > 10 )
{
p_input->pf_seek( p_input, p_pos->i_size - i_size2 );
input_AccessReinit( p_input );
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 )
p_input->pf_seek( p_input, p_pos->i_size - 10 );
/* get 10 byte id3 footer */
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
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 );
p_input->pf_seek( p_input, 0 );
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 )
{
return( VLC_SUCCESS );
......@@ -187,8 +185,6 @@ static int ParseID3Tags( vlc_object_t *p_this )
ParseID3Tag( p_input, p_peek, i_size );
msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size );
p_input->pf_seek( p_input, i_size );
input_AccessReinit( p_input );
// p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
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