1 /*****************************************************************************
2 * id3.c: simple id3 tag skipper
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: id3.c,v 1.4 2003/07/13 12:52:40 sigmunau Exp $
7 * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
31 #include <vlc/input.h>
33 #include <sys/types.h>
35 /*****************************************************************************
37 *****************************************************************************/
38 static int SkipID3Tag ( vlc_object_t * );
40 /*****************************************************************************
42 *****************************************************************************/
44 set_description( _("Simple id3 tag skipper" ) );
45 set_capability( "id3", 50 );
46 set_callbacks( SkipID3Tag, NULL );
49 /****************************************************************************
50 * SkipID3Tag : check if an ID3 tag is present, and skip it if it is
51 ****************************************************************************/
52 static int SkipID3Tag( vlc_object_t *p_this )
54 input_thread_t *p_input;
60 if ( p_this->i_object_type != VLC_OBJECT_INPUT )
62 return( VLC_EGENERIC );
64 p_input = (input_thread_t *)p_this;
66 msg_Dbg( p_input, "Checking for ID3 tag" );
67 /* get 10 byte id3 header */
68 if( input_Peek( p_input, &p_peek, 10 ) < 10 )
70 msg_Err( p_input, "cannot peek()" );
71 return( VLC_EGENERIC );
74 if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33)))
76 return( VLC_SUCCESS );
79 version = p_peek[3]; /* These may become usfull later, */
80 revision = p_peek[4]; /* but we ignore them for now */
81 b_footer = p_peek[5] & 0x10;
82 i_size = (p_peek[6] << 21) +
92 /* peek the entire tag */
93 if ( input_Peek( p_input, &p_peek, i_size ) < i_size )
95 msg_Err( p_input, "cannot peek()" );
96 return( VLC_EGENERIC );
99 msg_Dbg( p_input, "ID3v2.%d revision %d tag found, skiping %d bytes",
100 version, revision, i_size );
101 p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
102 return ( VLC_SUCCESS );