moved id3 related code to a separate utility module since several

demuxers need it
parent 3b08fd1d
......@@ -145,6 +145,7 @@ waveout_LDFLAGS = @waveout_LDFLAGS@
x11_LDFLAGS = @x11_LDFLAGS@
xosd_LDFLAGS = @xosd_LDFLAGS@
xvideo_LDFLAGS = @xvideo_LDFLAGS@
id3tag_LDFLAGS = @id3tag_LDFLAGS@
#
# Other special cases
......
This diff is collapsed.
......@@ -454,7 +454,7 @@ PLUGINS="${PLUGINS} audio_mixer/trivial audio_mixer/spdif"
PLUGINS="${PLUGINS} audio_output/file"
#PLUGINS="${PLUGINS} visualization/scope/scope"
PLUGINS="${PLUGINS} video_chroma/i420_rgb video_chroma/i420_yuy2 video_chroma/i422_yuy2 video_chroma/i420_ymga"
PLUGINS="${PLUGINS} demux/util/id3"
dnl
dnl Network modules
dnl
......@@ -1022,7 +1022,9 @@ fi
dnl
dnl libid3tag support
dnl
AC_CHECK_HEADERS(id3tag.h, [audio_LDFLAGS="${audio_LDFLAGS} -lz -lid3tag"])
AC_CHECK_HEADERS(id3tag.h, [
id3tag_LDFLAGS="${id3tag_LDFLAGS} -lz -lid3tag"
PLUGINS="${PLUGINS} demux/util/id3tag"])
dnl
dnl ffmpeg decoder plugin
......@@ -2163,6 +2165,7 @@ AC_SUBST(waveout_LDFLAGS)
AC_SUBST(x11_LDFLAGS)
AC_SUBST(xvideo_LDFLAGS)
AC_SUBST(xosd_LDFLAGS)
AC_SUBST(id3tag_LDFLAGS)
AC_OUTPUT([Makefile.config Makefile.opts po/Makefile.in vlc-config])
chmod a+x vlc-config
......
......@@ -2,7 +2,7 @@
* demux.c : Raw aac Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: demux.c,v 1.1 2002/08/12 16:59:15 fenrir Exp $
* $Id: demux.c,v 1.2 2002/08/24 21:35:31 sigmunau Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -371,59 +371,6 @@ static void ExtractConfiguration( demux_sys_t *p_aac )
*/
}
/****************************************************************************
* SkipID3Tag : check if an ID3 header is present and skip it
****************************************************************************
*
* Author : Sigmund Augdal
*
****************************************************************************/
static int SkipID3Tag( input_thread_t *p_input )
{
int i_count;
byte_t *p_peek;
byte_t version, revision;
int b_footer;
int i_size;
/* get 10 byte id3 header */
if( ( i_count = input_Peek( p_input, &p_peek, 10 ) ) < 10 )
{
msg_Err( p_input, "cannot peek()" );
return( -1 );
}
if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33)))
{
return( 0 );
}
version = p_peek[3]; /* These may become usfull later, */
revision = p_peek[4]; /* but we ignore them for now */
b_footer = p_peek[5] & 0x10;
i_size = (p_peek[6] << 21) +
(p_peek[7] << 14) +
(p_peek[8] << 7) +
p_peek[9]; /* Is this safe? */
if ( b_footer )
{
i_size += 10;
}
i_size += 10;
msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size );
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 */
return (0);
}
/****************************************************************************
* CheckPS : check if this stream could be some ps,
* yes it's ugly ... but another idea ?
......@@ -458,6 +405,7 @@ static int Activate( vlc_object_t * p_this )
input_thread_t * p_input = (input_thread_t *)p_this;
demux_sys_t * p_aac;
input_info_category_t * p_category;
module_t * p_id3;
int i_skip;
int b_forced;
......@@ -482,10 +430,11 @@ static int Activate( vlc_object_t * p_this )
}
/* skip possible id3 header */
if ( SkipID3Tag( p_input ) )
{
return -1;
p_id3 = module_Need( p_input, "id3", NULL );
if ( p_id3 ) {
module_Unneed( p_input, p_id3 );
}
/* allocate p_aac */
if( !( p_aac = malloc( sizeof( demux_sys_t ) ) ) )
{
......
......@@ -2,7 +2,7 @@
* audio.c : mpeg audio Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: audio.c,v 1.7 2002/08/18 14:33:00 sigmunau Exp $
* $Id: audio.c,v 1.8 2002/08/24 21:35:31 sigmunau Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -32,10 +32,6 @@
#include <sys/types.h>
#ifdef HAVE_ID3TAG_H
#include <id3tag.h>
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -441,170 +437,6 @@ static void ExtractConfiguration( demux_sys_t *p_demux )
}
}
/****************************************************************************
* ParseID3Tag : parse an id3tag into the info structures
****************************************************************************
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
#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 )
{
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;
#endif
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( -1 );
}
#ifndef HAVE_ID3TAG_H
if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33)))
{
return( 0 );
}
version = p_peek[3]; /* These may become usfull later, */
revision = p_peek[4]; /* but we ignore them for now */
b_footer = p_peek[5] & 0x10;
i_size = (p_peek[6] << 21) +
(p_peek[7] << 14) +
(p_peek[8] << 7) +
p_peek[9];
if ( b_footer )
{
i_size += 10;
}
i_size += 10;
#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 );
}
#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);
}
/****************************************************************************
* CheckPS : check if this stream could be some ps,
* yes it's ugly ... but another idea ?
......@@ -639,6 +471,7 @@ static int Activate( vlc_object_t * p_this )
input_thread_t * p_input = (input_thread_t *)p_this;
demux_sys_t * p_demux;
input_info_category_t * p_category;
module_t * p_id3;
int i_found;
int b_forced;
......@@ -664,10 +497,9 @@ static int Activate( vlc_object_t * p_this )
{
b_forced = 0;
}
if ( ParseID3Tags( p_input ) )
{
return( -1 );
p_id3 = module_Need( p_input, "id3", NULL );
if ( p_id3 ) {
module_Unneed( p_input, p_id3 );
}
/* create p_demux and init it */
......
.dep
*.lo
*.o.*
*.lo.*
id3_SOURCES = id3.c
id3tag_SOURCES = id3tag.c
/*****************************************************************************
* audio.c : mpeg audio Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: id3.c,v 1.1 2002/08/24 21:35:31 sigmunau Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <sys/types.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int SkipID3Tag ( vlc_object_t * );
/* TODO: support MPEG-2.5, not difficult, but I need somes samples... */
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("Simple id3 tag skipper" ) );
set_capability( "id3", 50 );
set_callbacks( SkipID3Tag, NULL );
vlc_module_end();
/*****************************************************************************
* Definitions of structures and functions used by this plugins
*****************************************************************************/
/****************************************************************************
* ParseID3Tag : check if an ID3 header is present and parse and skip it
****************************************************************************
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
static int SkipID3Tag( vlc_object_t *p_this )
{
input_thread_t *p_input;
u8 *p_peek;
int i_size;
u8 version, revision;
int b_footer;
if ( p_this->i_object_type != VLC_OBJECT_INPUT )
{
return( VLC_EGENERIC );
}
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 );
}
if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33)))
{
return( VLC_SUCCESS );
}
version = p_peek[3]; /* These may become usfull later, */
revision = p_peek[4]; /* but we ignore them for now */
b_footer = p_peek[5] & 0x10;
i_size = (p_peek[6] << 21) +
(p_peek[7] << 14) +
(p_peek[8] << 7) +
p_peek[9];
if ( b_footer )
{
i_size += 10;
}
i_size += 10;
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size ) < i_size )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size );
p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
return ( VLC_SUCCESS );
}
/*****************************************************************************
* audio.c : mpeg audio Stream input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: id3tag.c,v 1.1 2002/08/24 21:35:31 sigmunau Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <sys/types.h>
#include <id3tag.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
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 );
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;
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 );
}
/****************************************************************************
* ParseID3Tag : check if an ID3 header is present and parse and skip it
****************************************************************************
*
* Author : Sigmund Augdal
*
' ****************************************************************************/
static int ParseID3Tags( vlc_object_t *p_this )
{
input_thread_t *p_input;
u8 *p_peek;
int i_size;
int i_size2;
stream_position_t * p_pos;
if ( p_this->i_object_type != VLC_OBJECT_INPUT )
{
return( VLC_EGENERIC );
}
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 ( 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( VLC_EGENERIC );
}
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 */
{
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( VLC_EGENERIC );
}
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( VLC_SUCCESS );
}
/* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size ) < i_size )
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
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 */
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