X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmeta_engine%2Fid3tag.c;h=45d33fc0482ee94c0f33e4ecc04698bb0c5f18b7;hb=0ad4e448d1d8b54a75415370c7e2b56764c2c92b;hp=805c1ccd51fd263224cb28c19620b4a846e39fb8;hpb=af96053dc68a62f09560d4628f67c092c06215ef;p=vlc diff --git a/modules/meta_engine/id3tag.c b/modules/meta_engine/id3tag.c index 805c1ccd51..45d33fc048 100644 --- a/modules/meta_engine/id3tag.c +++ b/modules/meta_engine/id3tag.c @@ -26,10 +26,13 @@ *****************************************************************************/ #include -#include /* malloc(), free() */ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include #include @@ -51,7 +54,7 @@ static int ParseTags ( vlc_object_t * ); * Module descriptor *****************************************************************************/ vlc_module_begin(); - set_description( _("ID3v1/2 and APEv1/2 tags parser" ) ); + set_description( N_("ID3v1/2 and APEv1/2 tags parser" ) ); set_capability( "meta reader", 70 ); set_callbacks( ParseTags, NULL ); vlc_module_end(); @@ -59,19 +62,21 @@ vlc_module_end(); /***************************************************************************** * ParseID3Tag : parse an id3tag into the info structures *****************************************************************************/ -static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) +static void ParseID3Tag( demux_t *p_demux, const uint8_t *p_data, int i_size ) { struct id3_tag *p_id3_tag; struct id3_frame *p_frame; - vlc_meta_t *p_meta = (vlc_meta_t *)p_demux->p_private; + demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; + vlc_meta_t *p_meta; int i; p_id3_tag = id3_tag_parse( p_data, i_size ); if( !p_id3_tag ) return; - if( !p_meta ) - p_demux->p_private = p_meta = vlc_meta_New(); + if( !p_demux_meta->p_meta ) + p_demux_meta->p_meta = vlc_meta_New(); + p_meta = p_demux_meta->p_meta; #define ID_IS( a ) (!strcmp( p_frame->id, a )) #define DESCR_IS( a) strstr( (char*)p_frame->description, a ) @@ -157,7 +162,7 @@ static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) for( i = 0; (p_frame = id3_tag_findframe( p_id3_tag, "T", i )) != NULL; i++ ) { int i_strings; - + /* Special case TXXX is not the same beast */ if( ID_IS( "TXXX" ) ) continue; @@ -241,10 +246,10 @@ static void ParseID3Tag( demux_t *p_demux, uint8_t *p_data, int i_size ) * APEv1/2 *****************************************************************************/ #define APE_TAG_HEADERSIZE (32) -static int GetAPEvXSize( const uint8_t *p_data, int i_data ) +static size_t GetAPEvXSize( const uint8_t *p_data, int i_data ) { uint32_t flags; - int i_body; + size_t i_body; if( i_data < APE_TAG_HEADERSIZE || ( GetDWLE( &p_data[8] ) != 1000 && GetDWLE( &p_data[8] ) != 2000 ) || /* v1/v2 only */ @@ -262,12 +267,13 @@ static int GetAPEvXSize( const uint8_t *p_data, int i_data ) /* it is the footer */ return i_body + ( (flags&(1<<31)) ? APE_TAG_HEADERSIZE : 0 ); } -static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) +static void ParseAPEvXTag( demux_t *p_demux, const uint8_t *p_data, int i_data ) { - vlc_meta_t *p_meta = (vlc_meta_t *)p_demux->p_private; - vlc_bool_t b_start; - vlc_bool_t b_end; - uint8_t *p_header = NULL; + demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; + vlc_meta_t *p_meta; + bool b_start; + bool b_end; + const uint8_t *p_header = NULL; int i_entry; if( i_data < APE_TAG_HEADERSIZE ) @@ -278,6 +284,10 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) if( !b_end && !b_start ) return; + if( !p_demux_meta->p_meta ) + p_demux_meta->p_meta = vlc_meta_New(); + p_meta = p_demux_meta->p_meta; + if( b_start ) { p_header = &p_data[0]; @@ -296,9 +306,6 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) if( i_entry <= 0 ) return; - if( !p_meta ) - p_demux->p_private = p_meta = vlc_meta_New(); - while( i_entry > 0 && i_data >= 10 ) { const int i_size = GetDWLE( &p_data[0] ); @@ -369,14 +376,14 @@ static void ParseAPEvXTag( demux_t *p_demux, uint8_t *p_data, int i_data ) static void CheckFooter( demux_t *p_demux ) { const int64_t i_pos = stream_Size( p_demux->s ); - const int i_peek = 128+APE_TAG_HEADERSIZE; - uint8_t *p_peek; - uint8_t *p_peek_id3; + const size_t i_peek = 128+APE_TAG_HEADERSIZE; + const uint8_t *p_peek; + const uint8_t *p_peek_id3; int64_t i_id3v2_pos = -1; int64_t i_apevx_pos = -1; int i_id3v2_size; int i_apevx_size; - int i_id3v1_size; + size_t i_id3v1_size; if( i_pos < i_peek ) return; @@ -445,7 +452,7 @@ static void CheckFooter( demux_t *p_demux ) } static void CheckHeader( demux_t *p_demux ) { - uint8_t *p_peek; + const uint8_t *p_peek; int i_size; if( stream_Seek( p_demux->s, 0 ) ) @@ -480,20 +487,21 @@ static void CheckHeader( demux_t *p_demux ) ****************************************************************************/ static int ParseTags( vlc_object_t *p_this ) { - demux_t *p_demux = (demux_t *)p_this; - vlc_bool_t b_seekable; - int64_t i_init; - - p_demux->p_private = NULL; + demux_t *p_demux = (demux_t *)p_this; + demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; + bool b_seekable; + int64_t i_init; msg_Dbg( p_demux, "checking for ID3v1/2 and APEv1/2 tags" ); - stream_Control( p_demux->s, STREAM_CAN_FASTSEEK, &b_seekable ); if( !b_seekable ) - return VLC_SUCCESS; + return VLC_EGENERIC; i_init = stream_Tell( p_demux->s ); + TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); + p_demux_meta->p_meta = NULL; + /* */ CheckFooter( p_demux ); @@ -505,5 +513,8 @@ static int ParseTags( vlc_object_t *p_this ) * for them */ stream_Seek( p_demux->s, i_init ); + if( !p_demux_meta->p_meta && p_demux_meta->i_attachments <= 0 ) + return VLC_EGENERIC; return VLC_SUCCESS; } +