2003-08-02 18:43:59 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* demux.c
|
|
|
|
*****************************************************************************
|
2005-07-09 08:17:09 +02:00
|
|
|
* Copyright (C) 1999-2004 the VideoLAN team
|
2004-03-19 17:27:52 +01:00
|
|
|
* $Id$
|
2003-08-02 18:43:59 +02:00
|
|
|
*
|
2003-12-22 15:32:57 +01:00
|
|
|
* Author: Laurent Aimar <fenrir@via.ecp.fr>
|
2003-08-02 18:43:59 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-01-13 00:10:04 +01:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2003-08-02 18:43:59 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2008-01-23 22:50:58 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 19:57:51 +02:00
|
|
|
#include "demux.h"
|
2008-10-13 20:20:54 +02:00
|
|
|
#include <libvlc.h>
|
|
|
|
#include <vlc_codec.h>
|
2008-12-05 10:47:31 +01:00
|
|
|
#include <vlc_meta.h>
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2008-04-14 00:08:29 +02:00
|
|
|
static bool SkipID3Tag( demux_t * );
|
|
|
|
static bool SkipAPETag( demux_t *p_demux );
|
2005-04-09 13:27:23 +02:00
|
|
|
|
2003-11-30 18:29:56 +01:00
|
|
|
/*****************************************************************************
|
2008-04-14 00:20:09 +02:00
|
|
|
* demux_New:
|
2004-06-22 21:29:57 +02:00
|
|
|
* if s is NULL then load a access_demux
|
2003-11-30 18:29:56 +01:00
|
|
|
*****************************************************************************/
|
2009-08-21 12:27:56 +02:00
|
|
|
demux_t *__demux_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
|
2006-11-06 18:58:08 +01:00
|
|
|
const char *psz_access, const char *psz_demux,
|
|
|
|
const char *psz_path,
|
2008-04-14 00:08:29 +02:00
|
|
|
stream_t *s, es_out_t *out, bool b_quick )
|
2003-11-30 18:29:56 +01:00
|
|
|
{
|
2008-06-15 18:34:40 +02:00
|
|
|
static const char typename[] = "demux";
|
|
|
|
demux_t *p_demux = vlc_custom_create( p_obj, sizeof( *p_demux ),
|
|
|
|
VLC_OBJECT_GENERIC, typename );
|
2006-10-21 20:40:30 +02:00
|
|
|
const char *psz_module;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2005-04-09 13:27:23 +02:00
|
|
|
if( p_demux == NULL ) return NULL;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2009-08-21 12:27:56 +02:00
|
|
|
p_demux->p_input = p_parent_input;
|
|
|
|
|
2003-11-30 18:29:56 +01:00
|
|
|
/* Parse URL */
|
2004-06-07 20:23:15 +02:00
|
|
|
p_demux->psz_access = strdup( psz_access );
|
|
|
|
p_demux->psz_demux = strdup( psz_demux );
|
|
|
|
p_demux->psz_path = strdup( psz_path );
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2004-11-05 13:42:32 +01:00
|
|
|
/* Take into account "demux" to be able to do :demux=dump */
|
2008-07-12 13:20:23 +02:00
|
|
|
if( p_demux->psz_demux && *p_demux->psz_demux == '\0' )
|
2004-08-08 03:58:59 +02:00
|
|
|
{
|
|
|
|
free( p_demux->psz_demux );
|
2007-09-16 11:15:27 +02:00
|
|
|
p_demux->psz_demux = var_GetNonEmptyString( p_obj, "demux" );
|
|
|
|
if( p_demux->psz_demux == NULL )
|
|
|
|
p_demux->psz_demux = strdup( "" );
|
2004-08-08 03:58:59 +02:00
|
|
|
}
|
|
|
|
|
2004-12-10 19:58:22 +01:00
|
|
|
if( !b_quick )
|
|
|
|
{
|
2005-03-11 08:52:18 +01:00
|
|
|
msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' path='%s'",
|
2004-12-10 19:58:22 +01:00
|
|
|
p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
|
|
|
|
}
|
2003-11-30 18:29:56 +01:00
|
|
|
|
|
|
|
p_demux->s = s;
|
|
|
|
p_demux->out = out;
|
|
|
|
|
|
|
|
p_demux->pf_demux = NULL;
|
|
|
|
p_demux->pf_control = NULL;
|
|
|
|
p_demux->p_sys = NULL;
|
2004-06-02 00:13:14 +02:00
|
|
|
p_demux->info.i_update = 0;
|
|
|
|
p_demux->info.i_title = 0;
|
|
|
|
p_demux->info.i_seekpoint = 0;
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2005-04-09 13:27:23 +02:00
|
|
|
if( s ) psz_module = p_demux->psz_demux;
|
|
|
|
else psz_module = p_demux->psz_access;
|
2004-06-22 21:29:57 +02:00
|
|
|
|
|
|
|
if( s && *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
|
2004-03-19 17:27:52 +01:00
|
|
|
{
|
2006-03-28 22:29:28 +02:00
|
|
|
/* XXX: add only file without any problem here and with strong detection.
|
|
|
|
* - no .mp3, .a52, ... (aac is added as it works only by file ext
|
|
|
|
* anyway
|
|
|
|
* - wav can't be added 'cause of a52 and dts in them as raw audio
|
2004-03-19 17:27:52 +01:00
|
|
|
*/
|
2007-01-05 11:32:23 +01:00
|
|
|
static const struct { char ext[5]; char demux[9]; } exttodemux[] =
|
2004-12-10 19:58:22 +01:00
|
|
|
{
|
2004-03-19 17:27:52 +01:00
|
|
|
{ "aac", "aac" },
|
|
|
|
{ "aiff", "aiff" },
|
|
|
|
{ "asf", "asf" }, { "wmv", "asf" }, { "wma", "asf" },
|
|
|
|
{ "avi", "avi" },
|
|
|
|
{ "au", "au" },
|
|
|
|
{ "flac", "flac" },
|
|
|
|
{ "dv", "dv" },
|
2009-05-07 14:54:58 +02:00
|
|
|
{ "drc", "dirac" },
|
2009-10-31 13:55:59 +01:00
|
|
|
{ "m3u", "m3u" },
|
|
|
|
{ "m3u8", "m3u8" },
|
2004-03-19 17:27:52 +01:00
|
|
|
{ "mkv", "mkv" }, { "mka", "mkv" }, { "mks", "mkv" },
|
|
|
|
{ "mp4", "mp4" }, { "m4a", "mp4" }, { "mov", "mp4" }, { "moov", "mp4" },
|
|
|
|
{ "nsv", "nsv" },
|
2009-01-11 10:26:44 +01:00
|
|
|
{ "ogg", "ogg" }, { "ogm", "ogg" }, /* legacy Ogg */
|
2009-01-11 10:40:37 +01:00
|
|
|
{ "oga", "ogg" }, { "spx", "ogg" }, { "ogv", "ogg" },
|
|
|
|
{ "ogx", "ogg" }, /*RFC5334*/
|
2004-03-19 17:27:52 +01:00
|
|
|
{ "pva", "pva" },
|
|
|
|
{ "rm", "rm" },
|
2006-10-06 00:01:01 +02:00
|
|
|
{ "m4v", "m4v" },
|
2008-09-27 11:00:10 +02:00
|
|
|
{ "h264", "h264" },
|
|
|
|
{ "voc", "voc" },
|
2009-01-11 10:14:58 +01:00
|
|
|
{ "mid", "smf" }, { "rmi", "smf" },
|
2007-01-05 11:32:23 +01:00
|
|
|
{ "", "" },
|
2004-03-19 17:27:52 +01:00
|
|
|
};
|
2004-12-10 19:58:22 +01:00
|
|
|
/* Here, we don't mind if it does not work, it must be quick */
|
2007-01-05 11:32:23 +01:00
|
|
|
static const struct { char ext[4]; char demux[5]; } exttodemux_quick[] =
|
2004-12-10 19:58:22 +01:00
|
|
|
{
|
|
|
|
{ "mp3", "mpga" },
|
|
|
|
{ "ogg", "ogg" },
|
|
|
|
{ "wma", "asf" },
|
2007-01-05 11:32:23 +01:00
|
|
|
{ "", "" }
|
2004-12-10 19:58:22 +01:00
|
|
|
};
|
2004-03-19 17:27:52 +01:00
|
|
|
|
2006-10-21 20:40:30 +02:00
|
|
|
const char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
|
2004-03-19 17:27:52 +01:00
|
|
|
int i;
|
|
|
|
|
2004-12-10 19:58:22 +01:00
|
|
|
if( !b_quick )
|
|
|
|
{
|
2007-01-05 11:32:23 +01:00
|
|
|
for( i = 0; exttodemux[i].ext[0]; i++ )
|
2004-12-10 19:58:22 +01:00
|
|
|
{
|
|
|
|
if( !strcasecmp( psz_ext, exttodemux[i].ext ) )
|
|
|
|
{
|
|
|
|
psz_module = exttodemux[i].demux;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-03-19 17:27:52 +01:00
|
|
|
{
|
2007-01-05 11:32:23 +01:00
|
|
|
for( i = 0; exttodemux_quick[i].ext[0]; i++ )
|
2004-03-19 17:27:52 +01:00
|
|
|
{
|
2004-12-10 19:58:22 +01:00
|
|
|
if( !strcasecmp( psz_ext, exttodemux_quick[i].ext ) )
|
|
|
|
{
|
|
|
|
psz_module = exttodemux_quick[i].demux;
|
|
|
|
break;
|
|
|
|
}
|
2004-03-19 17:27:52 +01:00
|
|
|
}
|
2004-12-10 19:58:22 +01:00
|
|
|
|
2004-03-19 17:27:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 13:58:57 +02:00
|
|
|
/* Before module_need (for var_Create...) */
|
2004-01-17 13:03:19 +01:00
|
|
|
vlc_object_attach( p_demux, p_obj );
|
2003-11-30 18:29:56 +01:00
|
|
|
|
2004-06-22 21:29:57 +02:00
|
|
|
if( s )
|
|
|
|
{
|
2007-10-12 22:33:39 +02:00
|
|
|
/* ID3/APE tags will mess-up demuxer probing so we skip it here.
|
|
|
|
* ID3/APE parsers will called later on in the demuxer to access the
|
2005-04-09 13:27:23 +02:00
|
|
|
* skipped info. */
|
2007-10-12 22:33:39 +02:00
|
|
|
if( !SkipID3Tag( p_demux ) )
|
|
|
|
SkipAPETag( p_demux );
|
2005-04-09 13:27:23 +02:00
|
|
|
|
2004-06-22 21:29:57 +02:00
|
|
|
p_demux->p_module =
|
2008-09-21 13:58:57 +02:00
|
|
|
module_need( p_demux, "demux", psz_module,
|
2010-01-28 19:50:49 +01:00
|
|
|
!strcmp( psz_module, p_demux->psz_demux ) );
|
2004-06-22 21:29:57 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p_demux->p_module =
|
2008-09-21 13:58:57 +02:00
|
|
|
module_need( p_demux, "access_demux", psz_module,
|
2010-01-28 19:50:49 +01:00
|
|
|
!strcmp( psz_module, p_demux->psz_access ) );
|
2004-06-22 21:29:57 +02:00
|
|
|
}
|
2004-03-19 17:27:52 +01:00
|
|
|
|
2003-11-30 18:29:56 +01:00
|
|
|
if( p_demux->p_module == NULL )
|
|
|
|
{
|
2004-01-17 13:03:19 +01:00
|
|
|
free( p_demux->psz_path );
|
|
|
|
free( p_demux->psz_demux );
|
|
|
|
free( p_demux->psz_access );
|
2008-02-26 01:29:12 +01:00
|
|
|
vlc_object_release( p_demux );
|
2003-11-30 18:29:56 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p_demux;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2008-04-14 00:20:09 +02:00
|
|
|
* demux_Delete:
|
2003-11-30 18:29:56 +01:00
|
|
|
*****************************************************************************/
|
2008-04-14 00:20:09 +02:00
|
|
|
void demux_Delete( demux_t *p_demux )
|
2003-11-30 18:29:56 +01:00
|
|
|
{
|
2008-09-21 13:58:57 +02:00
|
|
|
module_unneed( p_demux, p_demux->p_module );
|
2003-11-30 18:29:56 +01:00
|
|
|
|
|
|
|
free( p_demux->psz_path );
|
|
|
|
free( p_demux->psz_demux );
|
|
|
|
free( p_demux->psz_access );
|
|
|
|
|
2008-02-26 01:29:12 +01:00
|
|
|
vlc_object_release( p_demux );
|
2003-11-30 18:29:56 +01:00
|
|
|
}
|
2004-03-03 13:01:38 +01:00
|
|
|
|
2009-08-21 12:27:56 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* demux_GetParentInput:
|
|
|
|
*****************************************************************************/
|
|
|
|
input_thread_t * demux_GetParentInput( demux_t *p_demux )
|
|
|
|
{
|
|
|
|
return p_demux->p_input ? vlc_object_hold((vlc_object_t*)p_demux->p_input) : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-03 13:01:38 +01:00
|
|
|
/*****************************************************************************
|
2008-04-14 00:20:09 +02:00
|
|
|
* demux_vaControlHelper:
|
2004-03-03 13:01:38 +01:00
|
|
|
*****************************************************************************/
|
2008-04-14 00:20:09 +02:00
|
|
|
int demux_vaControlHelper( stream_t *s,
|
2004-03-03 13:01:38 +01:00
|
|
|
int64_t i_start, int64_t i_end,
|
2008-11-07 12:29:39 +01:00
|
|
|
int64_t i_bitrate, int i_align,
|
2004-03-03 13:01:38 +01:00
|
|
|
int i_query, va_list args )
|
|
|
|
{
|
|
|
|
int64_t i_tell;
|
|
|
|
double f, *pf;
|
|
|
|
int64_t i64, *pi64;
|
|
|
|
|
|
|
|
if( i_end < 0 ) i_end = stream_Size( s );
|
|
|
|
if( i_start < 0 ) i_start = 0;
|
|
|
|
if( i_align <= 0 ) i_align = 1;
|
|
|
|
i_tell = stream_Tell( s );
|
|
|
|
|
|
|
|
switch( i_query )
|
|
|
|
{
|
|
|
|
case DEMUX_GET_LENGTH:
|
|
|
|
pi64 = (int64_t*)va_arg( args, int64_t * );
|
|
|
|
if( i_bitrate > 0 && i_end > i_start )
|
|
|
|
{
|
2008-05-01 21:11:47 +02:00
|
|
|
*pi64 = INT64_C(8000000) * (i_end - i_start) / i_bitrate;
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_TIME:
|
|
|
|
pi64 = (int64_t*)va_arg( args, int64_t * );
|
2009-05-22 21:30:16 +02:00
|
|
|
if( i_bitrate > 0 && i_tell >= i_start )
|
2004-03-03 13:01:38 +01:00
|
|
|
{
|
2008-05-01 21:11:47 +02:00
|
|
|
*pi64 = INT64_C(8000000) * (i_tell - i_start) / i_bitrate;
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_POSITION:
|
|
|
|
pf = (double*)va_arg( args, double * );
|
|
|
|
if( i_start < i_end )
|
|
|
|
{
|
|
|
|
*pf = (double)( i_tell - i_start ) /
|
|
|
|
(double)( i_end - i_start );
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
|
|
|
|
case DEMUX_SET_POSITION:
|
|
|
|
f = (double)va_arg( args, double );
|
|
|
|
if( i_start < i_end && f >= 0.0 && f <= 1.0 )
|
|
|
|
{
|
|
|
|
int64_t i_block = (f * ( i_end - i_start )) / i_align;
|
|
|
|
|
|
|
|
if( stream_Seek( s, i_start + i_block * i_align ) )
|
|
|
|
{
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_SET_TIME:
|
|
|
|
i64 = (int64_t)va_arg( args, int64_t );
|
|
|
|
if( i_bitrate > 0 && i64 >= 0 )
|
|
|
|
{
|
2008-05-01 21:11:47 +02:00
|
|
|
int64_t i_block = i64 * i_bitrate / INT64_C(8000000) / i_align;
|
2004-03-03 13:01:38 +01:00
|
|
|
if( stream_Seek( s, i_start + i_block * i_align ) )
|
|
|
|
{
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
return VLC_SUCCESS;
|
|
|
|
}
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
case DEMUX_GET_FPS:
|
|
|
|
case DEMUX_GET_META:
|
2007-10-08 20:30:11 +02:00
|
|
|
case DEMUX_HAS_UNSUPPORTED_META:
|
2004-06-25 00:19:29 +02:00
|
|
|
case DEMUX_SET_NEXT_DEMUX_TIME:
|
|
|
|
case DEMUX_GET_TITLE_INFO:
|
2004-08-25 22:08:23 +02:00
|
|
|
case DEMUX_SET_GROUP:
|
2007-05-31 21:22:27 +02:00
|
|
|
case DEMUX_GET_ATTACHMENTS:
|
2008-08-26 12:54:18 +02:00
|
|
|
case DEMUX_CAN_RECORD:
|
|
|
|
case DEMUX_SET_RECORD_STATE:
|
2004-03-03 13:01:38 +01:00
|
|
|
return VLC_EGENERIC;
|
|
|
|
|
|
|
|
default:
|
|
|
|
msg_Err( s, "unknown query in demux_vaControlDefault" );
|
|
|
|
return VLC_EGENERIC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-09 13:27:23 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Utility functions
|
|
|
|
****************************************************************************/
|
2008-09-13 00:10:33 +02:00
|
|
|
decoder_t *demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char *psz_msg )
|
|
|
|
{
|
2010-01-27 19:16:58 +01:00
|
|
|
decoder_t *p_packetizer;
|
|
|
|
p_packetizer = vlc_custom_create( p_demux, sizeof( *p_packetizer ),
|
|
|
|
VLC_OBJECT_GENERIC, "demux packetizer" );
|
2008-09-13 00:10:33 +02:00
|
|
|
if( !p_packetizer )
|
|
|
|
{
|
|
|
|
es_format_Clean( p_fmt );
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-04-29 20:40:06 +02:00
|
|
|
p_fmt->b_packetized = false;
|
2008-09-13 00:10:33 +02:00
|
|
|
|
|
|
|
p_packetizer->pf_decode_audio = NULL;
|
|
|
|
p_packetizer->pf_decode_video = NULL;
|
|
|
|
p_packetizer->pf_decode_sub = NULL;
|
|
|
|
p_packetizer->pf_packetize = NULL;
|
|
|
|
|
|
|
|
p_packetizer->fmt_in = *p_fmt;
|
|
|
|
es_format_Init( &p_packetizer->fmt_out, UNKNOWN_ES, 0 );
|
|
|
|
|
2010-02-13 10:50:19 +01:00
|
|
|
vlc_object_attach( p_packetizer, p_demux );
|
2008-12-13 17:05:14 +01:00
|
|
|
p_packetizer->p_module = module_need( p_packetizer, "packetizer", NULL, false );
|
2008-09-13 00:10:33 +02:00
|
|
|
if( !p_packetizer->p_module )
|
|
|
|
{
|
|
|
|
es_format_Clean( p_fmt );
|
|
|
|
vlc_object_release( p_packetizer );
|
|
|
|
msg_Err( p_demux, "cannot find packetizer for %s", psz_msg );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return p_packetizer;
|
|
|
|
}
|
2009-05-23 17:32:28 +02:00
|
|
|
|
2008-09-13 00:10:33 +02:00
|
|
|
void demux_PacketizerDestroy( decoder_t *p_packetizer )
|
|
|
|
{
|
|
|
|
if( p_packetizer->p_module )
|
2008-09-21 13:58:57 +02:00
|
|
|
module_unneed( p_packetizer, p_packetizer->p_module );
|
2008-09-13 00:10:33 +02:00
|
|
|
es_format_Clean( &p_packetizer->fmt_in );
|
2008-12-05 10:47:31 +01:00
|
|
|
if( p_packetizer->p_description )
|
|
|
|
vlc_meta_Delete( p_packetizer->p_description );
|
2008-09-13 00:10:33 +02:00
|
|
|
vlc_object_release( p_packetizer );
|
|
|
|
}
|
|
|
|
|
2008-04-14 00:08:29 +02:00
|
|
|
static bool SkipID3Tag( demux_t *p_demux )
|
2005-04-09 13:27:23 +02:00
|
|
|
{
|
2007-07-20 16:22:54 +02:00
|
|
|
const uint8_t *p_peek;
|
2005-04-09 13:27:23 +02:00
|
|
|
uint8_t version, revision;
|
|
|
|
int i_size;
|
|
|
|
int b_footer;
|
|
|
|
|
2007-10-12 22:33:39 +02:00
|
|
|
if( !p_demux->s )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2005-04-09 13:27:23 +02:00
|
|
|
|
|
|
|
/* Get 10 byte id3 header */
|
2007-10-12 22:33:39 +02:00
|
|
|
if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2005-04-09 13:27:23 +02:00
|
|
|
|
2007-10-12 22:33:39 +02:00
|
|
|
if( memcmp( p_peek, "ID3", 3 ) )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2005-04-09 13:27:23 +02:00
|
|
|
|
|
|
|
version = p_peek[3];
|
|
|
|
revision = p_peek[4];
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* Skip the entire tag */
|
|
|
|
stream_Read( p_demux->s, NULL, i_size );
|
|
|
|
|
2006-04-01 13:27:40 +02:00
|
|
|
msg_Dbg( p_demux, "ID3v2.%d revision %d tag found, skipping %d bytes",
|
2005-04-09 13:27:23 +02:00
|
|
|
version, revision, i_size );
|
2008-04-14 00:08:29 +02:00
|
|
|
return true;
|
2007-10-12 22:33:39 +02:00
|
|
|
}
|
2008-04-14 00:08:29 +02:00
|
|
|
static bool SkipAPETag( demux_t *p_demux )
|
2007-10-12 22:33:39 +02:00
|
|
|
{
|
|
|
|
const uint8_t *p_peek;
|
|
|
|
int i_version;
|
|
|
|
int i_size;
|
|
|
|
uint32_t flags;
|
|
|
|
|
|
|
|
if( !p_demux->s )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2007-10-12 22:33:39 +02:00
|
|
|
|
|
|
|
/* Get 32 byte ape header */
|
|
|
|
if( stream_Peek( p_demux->s, &p_peek, 32 ) < 32 )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2007-10-12 22:33:39 +02:00
|
|
|
|
|
|
|
if( memcmp( p_peek, "APETAGEX", 8 ) )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2005-04-09 13:27:23 +02:00
|
|
|
|
2007-10-12 22:33:39 +02:00
|
|
|
i_version = GetDWLE( &p_peek[8] );
|
|
|
|
flags = GetDWLE( &p_peek[8+4+4] );
|
|
|
|
if( ( i_version != 1000 && i_version != 2000 ) || !( flags & (1<<29) ) )
|
2008-04-14 00:08:29 +02:00
|
|
|
return false;
|
2007-10-12 22:33:39 +02:00
|
|
|
|
|
|
|
i_size = GetDWLE( &p_peek[8+4] ) + ( (flags&(1<<30)) ? 32 : 0 );
|
|
|
|
|
|
|
|
/* Skip the entire tag */
|
|
|
|
stream_Read( p_demux->s, NULL, i_size );
|
|
|
|
|
|
|
|
msg_Dbg( p_demux, "AP2 v%d tag found, skipping %d bytes",
|
|
|
|
i_version/1000, i_size );
|
2008-04-14 00:08:29 +02:00
|
|
|
return true;
|
2005-04-09 13:27:23 +02:00
|
|
|
}
|
2007-10-12 22:33:39 +02:00
|
|
|
|