/*****************************************************************************
* flac.c : FLAC demux module for vlc
*****************************************************************************
- * Copyright (C) 2001-2003 the VideoLAN team
+ * Copyright (C) 2001-2007 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
#include <vlc_input.h>
#include <vlc_codec.h>
#include <assert.h>
+#include <vlc_charset.h>
/*****************************************************************************
* Module descriptor
demux_t *p_demux = (demux_t*)p_this;
module_t *p_id3;
demux_sys_t *p_sys;
- byte_t *p_peek;
+ const byte_t *p_peek;
uint8_t *p_streaminfo;
int i_streaminfo;
p_sys->p_meta = vlc_meta_New();
snprintf( psz_url, sizeof(psz_url), "attachment://%s",
p_sys->attachment[p_sys->i_cover_idx]->psz_name );
- vlc_meta_SetArtURL( p_sys->p_meta, psz_url );
+ vlc_meta_Set( p_sys->p_meta, vlc_meta_ArtworkURL, psz_url );
}
vlc_audio_replay_gain_MergeFromMeta( &p_sys->replay_gain, p_sys->p_meta );
return VLC_SUCCESS;
}
return i_length;
}
+
static int64_t ControlGetTime( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
return __MAX(p_sys->i_pts, p_sys->i_pts_start) + p_sys->i_time_offset;
}
+
static int ControlSetTime( demux_t *p_demux, int64_t i_time )
{
demux_sys_t *p_sys = p_demux->p_sys;
i_next_offset = stream_Size(p_demux->s)-p_sys->i_data_pos;
}
i_delta_time = i_time - p_sys->seekpoint[i]->i_time_offset;
- i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * i_delta_time /
+ i_delta_offset = (i_next_offset - p_sys->seekpoint[i]->i_byte_offset) * i_delta_time /
(p_sys->seekpoint[i+1]->i_time_offset-p_sys->seekpoint[i]->i_time_offset);
/* XXX We do exact seek if it's not too far away(45s) */
META_PICTURE = 6,
};
-static inline int Get24bBE( uint8_t *p )
+static inline int Get24bBE( const uint8_t *p )
{
return (p[0] << 16)|(p[1] << 8)|(p[2]);
}
static void ParseStreamInfo( demux_t *p_demux, int *pi_rate, int64_t *pi_count, uint8_t *p_data, int i_data );
-static void ParseSeekTable( demux_t *p_demux, uint8_t *p_data, int i_data, int i_sample_rate );
-static void ParseComment( demux_t *, uint8_t *p_data, int i_data );
-static void ParsePicture( demux_t *, uint8_t *p_data, int i_data );
+static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
+ int i_sample_rate );
+static void ParseComment( demux_t *, const uint8_t *p_data, int i_data );
+static void ParsePicture( demux_t *, const uint8_t *p_data, int i_data );
static int ReadMeta( demux_t *p_demux, uint8_t **pp_streaminfo, int *pi_streaminfo )
{
demux_sys_t *p_sys = p_demux->p_sys;
int i_peek;
- uint8_t *p_peek;
+ const uint8_t *p_peek;
vlc_bool_t b_last;
int i_sample_rate;
int64_t i_sample_count;
*pi_rate = GetDWBE(&p_data[i_skip+4+6]) >> 12;
*pi_count = GetQWBE(&p_data[i_skip+4+6]) & ((I64C(1)<<36)-1);
}
-static void ParseSeekTable( demux_t *p_demux, uint8_t *p_data, int i_data, int i_sample_rate )
+
+static void ParseSeekTable( demux_t *p_demux, const uint8_t *p_data, int i_data,
+ int i_sample_rate )
{
demux_sys_t *p_sys = p_demux->p_sys;
seekpoint_t *s;
}
/* TODO sort it by size and remove wrong seek entry (time not increasing) */
}
-static inline void astrcat( char **ppsz_dst, const char *psz_src )
-{
- char *psz_old = *ppsz_dst;
-
- if( !psz_src || !psz_src[0] )
- return;
-
- if( psz_old )
- {
- asprintf( ppsz_dst, "%s,%s", psz_old, psz_src );
- free( psz_old );
- }
- else
- {
- *ppsz_dst = strdup( psz_src );
- }
-}
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)
-static void ParseComment( demux_t *p_demux, uint8_t *p_data, int i_data )
+static void ParseComment( demux_t *p_demux, const uint8_t *p_data, int i_data )
{
demux_sys_t *p_sys = p_demux->p_sys;
int n;
EnsureUTF8( psz );
-#define IF_EXTRACT(txt,var) if( !strncasecmp(psz, txt, strlen(txt)) ) { astrcat( &p_sys->p_meta->var, &psz[strlen(txt)] ); }
- IF_EXTRACT("TITLE=", psz_title )
- else IF_EXTRACT("ALBUM=", psz_album )
- else IF_EXTRACT("TRACKNUMBER=", psz_tracknum )
- else IF_EXTRACT("ARTIST=", psz_artist )
- else IF_EXTRACT("COPYRIGHT=", psz_copyright )
- else IF_EXTRACT("DESCRIPTION=", psz_description )
- else IF_EXTRACT("GENRE=", psz_genre )
- else IF_EXTRACT("DATE=", psz_date )
+#define IF_EXTRACT(txt,var) \
+ if( !strncasecmp(psz, txt, strlen(txt)) ) \
+ { \
+ char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \
+ if( oldval ) \
+ { \
+ char * newval; \
+ asprintf( &newval, "%s,%s", oldval, &psz[strlen(txt)] ); \
+ vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, newval ); \
+ free( newval ); \
+ } \
+ else \
+ vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \
+ free( oldval ); \
+ }
+ IF_EXTRACT("TITLE=", Title )
+ else IF_EXTRACT("ALBUM=", Album )
+ else IF_EXTRACT("TRACKNUMBER=", TrackNumber )
+ else IF_EXTRACT("ARTIST=", Artist )
+ else IF_EXTRACT("COPYRIGHT=", Copyright )
+ else IF_EXTRACT("DESCRIPTION=", Description )
+ else IF_EXTRACT("GENRE=", Genre )
+ else IF_EXTRACT("DATE=", Date )
else if( strchr( psz, '=' ) )
{
/* generic (PERFORMER/LICENSE/ORGANIZATION/LOCATION/CONTACT/ISRC,
#undef RM
}
-static void ParsePicture( demux_t *p_demux, uint8_t *p_data, int i_data )
+static void ParsePicture( demux_t *p_demux, const uint8_t *p_data, int i_data )
{
static const int pi_cover_score[] = {
0, /* other */