the mp3 demux now parses id3 tags into the info structures if libid3tag

is available
parent 3dff442e
......@@ -133,6 +133,7 @@ qt_LDFLAGS = @qt_LDFLAGS@
qte_LDFLAGS = @qte_LDFLAGS@
rc_LDFLAGS = @rc_LDFLAGS@
sdl_LDFLAGS = @sdl_LDFLAGS@
audio_LDFLAGS = @audio_LDFLAGS@
ts_dvbpsi_LDFLAGS = @ts_dvbpsi_LDFLAGS@
vcd_LDFLAGS = @vcd_LDFLAGS@
vorbis_LDFLAGS = @vorbis_LDFLAGS@
......
This diff is collapsed.
......@@ -1016,6 +1016,11 @@ then
fi
fi
dnl
dnl libid3tag support
dnl
AC_CHECK_HEADERS(id3tag.h, [audio_LDFLAGS="${audio_LDFLAGS} -lz -lid3tag"])
dnl
dnl ffmpeg decoder plugin
dnl
......@@ -2087,6 +2092,7 @@ AC_SUBST(dvd_LDFLAGS)
AC_SUBST(dvdread_LDFLAGS)
AC_SUBST(dvdplay_LDFLAGS)
AC_SUBST(ts_dvbpsi_LDFLAGS)
AC_SUBST(audio_LDFLAGS)
AC_SUBST(esd_LDFLAGS)
AC_SUBST(familiar_LDFLAGS)
AC_SUBST(distort_LDFLAGS)
......
......@@ -2,7 +2,7 @@
* audio.c : mpeg audio Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: audio.c,v 1.5 2002/08/16 03:07:56 sam Exp $
* $Id: audio.c,v 1.6 2002/08/18 14:11:35 sigmunau Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -32,6 +32,11 @@
#include <sys/types.h>
#ifdef HAVE_ID3TAG_H
#include <id3tag.h>
#endif
#undef HAVE_ID3TAG_H
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -438,27 +443,69 @@ static void ExtractConfiguration( demux_sys_t *p_demux )
}
/****************************************************************************
* SkipID3Tag : check if an ID3 header is present and skip it
* ParseID3Tag : parse an id3tag into the info structures
****************************************************************************
*
* Author : Sigmund Augdal
*
****************************************************************************/
static int SkipID3Tag( input_thread_t *p_input )
' ****************************************************************************/
#ifdef HAVE_ID3TAG_H
static void ParseID3Tag( input_thread_t *p_input, u8 *p_data, int i_size )
{
struct id3_tag * p_id3_tag;
struct id3_frame * p_frame;
input_info_category_t * p_category;
int i_strings;
char * psz_temp;
int i;
p_id3_tag = id3_tag_parse( p_data, i_size );
p_category = input_InfoCategory( p_input, "ID3" );
i = 0;
while ( ( p_frame = id3_tag_findframe( p_id3_tag , "T", i ) ) )
{
i_strings = id3_field_getnstrings( &p_frame->fields[1] );
while ( i_strings > 0 )
{
psz_temp = id3_ucs4_latin1duplicate( id3_field_getstrings ( &p_frame->fields[1], --i_strings ) );
input_AddInfo( p_category, (char *)p_frame->description, psz_temp );
free( psz_temp );
}
i++;
}
id3_tag_delete( p_id3_tag );
}
#endif
/****************************************************************************
* ParseID3Tag : check if an ID3 header is present and parse and skip it
****************************************************************************
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
static int ParseID3Tags( input_thread_t *p_input )
{
int count;
u8 *p_peek;
int i_size;
#ifdef HAVE_ID3TAG_H
int i_size2;
stream_position_t * p_pos;
#else
u8 version, revision;
int b_footer;
int i_size;
#endif
msg_Dbg( p_input, "Checking for ID3 tag" );
/* get 10 byte id3 header */
if( ( count = input_Peek( p_input, &p_peek, 10 ) ) < 10 )
if( input_Peek( p_input, &p_peek, 10 ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( -1 );
}
#ifndef HAVE_ID3TAG_H
if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33)))
{
return( 0 );
......@@ -471,21 +518,91 @@ static int SkipID3Tag( input_thread_t *p_input )
i_size = (p_peek[6] << 21) +
(p_peek[7] << 14) +
(p_peek[8] << 7) +
p_peek[9]; /* Is this safe? */
p_peek[9];
if ( b_footer )
{
i_size += 10;
}
i_size += 10;
msg_Dbg( p_input, "ID3 tag found, skipping %d bytes", i_size );
#else
i_size = id3_tag_query( p_peek, 10 );
if ( p_input->stream.b_seekable )
{
/*look for a id3v1 tag at the end of the file*/
p_pos = malloc( sizeof( stream_position_t ) );
if ( p_pos == 0 )
{
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( -1 );
}
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( -1 );
}
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( -1 );
}
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 );
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 )
{
msg_Err( p_input, "cannot peek()" );
return( -1 );
}
ParseID3Tag( p_input, p_peek, i_size2 );
}
free( p_pos );
p_input->pf_seek( p_input, 0 );
input_AccessReinit( p_input );
}
if ( i_size <= 0 )
{
return 0;
}
#endif
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size ) < i_size )
{
msg_Err( p_input, "cannot peek()" );
return( -1 );
}
p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
#ifdef HAVE_ID3TAG_H
ParseID3Tag( p_input, p_peek, i_size );
#endif
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 */
return (0);
}
......@@ -549,7 +666,7 @@ static int Activate( vlc_object_t * p_this )
b_forced = 0;
}
if ( SkipID3Tag( p_input ) )
if ( ParseID3Tags( p_input ) )
{
return( -1 );
}
......
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