Commit ab94829b authored by Gildas Bazin's avatar Gildas Bazin

* src/libvlc.h, src/input/input.c:

   + added --meta-title/author/artist/genre/copyright/description/date/url config options.
     This allows the user to specify/override metadata information for an input.

* include/vlc_meta.h:
   + vlc_meta_Merge( dest, src ) helper function.

* modules/demux/mp4/*:
   + Fixed a couple of mem-leaks.
   + Support for "description" metadata.
parent d0e495fb
...@@ -64,6 +64,7 @@ static inline vlc_meta_t *vlc_meta_New( void ) ...@@ -64,6 +64,7 @@ static inline vlc_meta_t *vlc_meta_New( void )
return m; return m;
} }
static inline void vlc_meta_Delete( vlc_meta_t *m ) static inline void vlc_meta_Delete( vlc_meta_t *m )
{ {
int i; int i;
...@@ -82,6 +83,7 @@ static inline void vlc_meta_Delete( vlc_meta_t *m ) ...@@ -82,6 +83,7 @@ static inline void vlc_meta_Delete( vlc_meta_t *m )
if( m->track ) free( m->track ); if( m->track ) free( m->track );
free( m ); free( m );
} }
static inline void vlc_meta_Add( vlc_meta_t *m, char *name, char *value ) static inline void vlc_meta_Add( vlc_meta_t *m, char *name, char *value )
{ {
int i_meta = m->i_meta; int i_meta = m->i_meta;
...@@ -109,5 +111,23 @@ static inline vlc_meta_t *vlc_meta_Duplicate( vlc_meta_t *src ) ...@@ -109,5 +111,23 @@ static inline vlc_meta_t *vlc_meta_Duplicate( vlc_meta_t *src )
return dst; return dst;
} }
#endif static inline void vlc_meta_Merge( vlc_meta_t *dst, vlc_meta_t *src )
{
int i, j;
for( i = 0; i < src->i_meta; i++ )
{
/* Check if dst contains the entry */
for( j = 0; j < dst->i_meta; j++ )
{
if( !strcmp( src->name[i], dst->name[j] ) ) break;
}
if( j < dst->i_meta )
{
if( dst->value[j] ) free( dst->value[j] );
dst->value[j] = strdup( src->value[i] );
}
else vlc_meta_Add( dst, src->name[i], src->value[i] );
}
}
#endif
...@@ -1105,9 +1105,17 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1105,9 +1105,17 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
/* /*
* XXX hack -> produce a copy of the nearly complete chunk * XXX hack -> produce a copy of the nearly complete chunk
*/ */
p_box->data.p_sample_soun->i_qt_description = i_read; if( i_read > 0 )
p_box->data.p_sample_soun->p_qt_description = malloc( i_read ); {
memcpy( p_box->data.p_sample_soun->p_qt_description, p_peek, i_read ); p_box->data.p_sample_soun->i_qt_description = i_read;
p_box->data.p_sample_soun->p_qt_description = malloc( i_read );
memcpy( p_box->data.p_sample_soun->p_qt_description, p_peek, i_read );
}
else
{
p_box->data.p_sample_soun->i_qt_description = 0;
p_box->data.p_sample_soun->p_qt_description = NULL;
}
MP4_GET2BYTES( p_box->data.p_sample_soun->i_qt_version ); MP4_GET2BYTES( p_box->data.p_sample_soun->i_qt_version );
MP4_GET2BYTES( p_box->data.p_sample_soun->i_qt_revision_level ); MP4_GET2BYTES( p_box->data.p_sample_soun->i_qt_revision_level );
...@@ -1175,6 +1183,8 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1175,6 +1183,8 @@ static int MP4_ReadBox_sample_soun( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
static void MP4_FreeBox_sample_soun( MP4_Box_t *p_box ) static void MP4_FreeBox_sample_soun( MP4_Box_t *p_box )
{ {
FREE( p_box->data.p_sample_soun->p_qt_description );
if( p_box->i_type == FOURCC_drms ) if( p_box->i_type == FOURCC_drms )
{ {
if( p_box->data.p_sample_soun->p_drms ) if( p_box->data.p_sample_soun->p_drms )
...@@ -1206,8 +1216,7 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1206,8 +1216,7 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
p_box->data.p_sample_vide->i_qt_image_description = i_read; p_box->data.p_sample_vide->i_qt_image_description = i_read;
p_box->data.p_sample_vide->p_qt_image_description = malloc( i_read ); p_box->data.p_sample_vide->p_qt_image_description = malloc( i_read );
memcpy( p_box->data.p_sample_vide->p_qt_image_description, memcpy( p_box->data.p_sample_vide->p_qt_image_description,
p_peek, p_peek, i_read );
i_read );
} }
else else
{ {
...@@ -1251,6 +1260,12 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) ...@@ -1251,6 +1260,12 @@ static int MP4_ReadBox_sample_vide( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
} }
static void MP4_FreeBox_sample_vide( MP4_Box_t *p_box )
{
FREE( p_box->data.p_sample_vide->p_qt_image_description );
}
static int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box ) static int MP4_ReadBox_stsd( MP4_Stream_t *p_stream, MP4_Box_t *p_box )
{ {
...@@ -2034,56 +2049,56 @@ static struct ...@@ -2034,56 +2049,56 @@ static struct
{ FOURCC_wide, MP4_ReadBoxSkip, MP4_FreeBox_Common }, { FOURCC_wide, MP4_ReadBoxSkip, MP4_FreeBox_Common },
/* for codecs */ /* for codecs */
{ FOURCC_soun, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_soun, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_ms02, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_ms02, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_ms11, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_ms11, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_ms55, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_ms55, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC__mp3, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC__mp3, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_mp4a, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_mp4a, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_twos, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_twos, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_sowt, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_sowt, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_QDMC, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_QDMC, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_QDM2, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_QDM2, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_ima4, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_ima4, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_IMA4, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_IMA4, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_dvi, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_dvi, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_alaw, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_alaw, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_ulaw, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_ulaw, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_raw, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_raw, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_MAC3, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_MAC3, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_MAC6, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_MAC6, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_Qclp, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_Qclp, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_samr, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_samr, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_OggS, MP4_ReadBox_sample_soun, MP4_FreeBox_Common }, { FOURCC_OggS, MP4_ReadBox_sample_soun, MP4_FreeBox_sample_soun },
{ FOURCC_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_vide, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mp4v, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_mp4v, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_SVQ1, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_SVQ1, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_SVQ3, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_SVQ3, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_ZyGo, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_ZyGo, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_DIVX, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_DIVX, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_h263, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_h263, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_s263, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_s263, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_cvid, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_cvid, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3IV1, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3IV1, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3iv1, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3iv1, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3IV2, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3IV2, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3iv2, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3iv2, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3IVD, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3IVD, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3ivd, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3ivd, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3VID, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3VID, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_3vid, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_3vid, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mjpa, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_mjpa, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mjpb, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_mjpb, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mjqt, NULL, NULL }, /* found in mjpa/b */ { FOURCC_mjqt, NULL, NULL }, /* found in mjpa/b */
{ FOURCC_mjht, NULL, NULL }, { FOURCC_mjht, NULL, NULL },
{ FOURCC_dvc, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_dvc, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_dvp, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_dvp, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_VP31, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_VP31, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_vp31, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_vp31, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_h264, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_h264, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_jpeg, MP4_ReadBox_sample_vide, MP4_FreeBox_Common }, { FOURCC_jpeg, MP4_ReadBox_sample_vide, MP4_FreeBox_sample_vide },
{ FOURCC_mp4s, NULL, MP4_FreeBox_Common }, { FOURCC_mp4s, NULL, MP4_FreeBox_Common },
...@@ -2124,6 +2139,7 @@ static struct ...@@ -2124,6 +2139,7 @@ static struct
{ FOURCC_0xa9cmt,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9cmt,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9req,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9req,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9day,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9day,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9des,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9fmt,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9fmt,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9prd,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9prd,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
{ FOURCC_0xa9prf,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx }, { FOURCC_0xa9prf,MP4_ReadBox_0xa9xxx, MP4_FreeBox_0xa9xxx },
...@@ -2580,4 +2596,3 @@ int MP4_BoxCount( MP4_Box_t *p_box, char *psz_fmt, ... ) ...@@ -2580,4 +2596,3 @@ int MP4_BoxCount( MP4_Box_t *p_box, char *psz_fmt, ... )
} }
return( i_count ); return( i_count );
} }
...@@ -170,6 +170,7 @@ ...@@ -170,6 +170,7 @@
#define FOURCC_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' ) #define FOURCC_0xa9cpy VLC_FOURCC( 0xa9, 'c', 'p', 'y' )
#define FOURCC_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' ) #define FOURCC_0xa9inf VLC_FOURCC( 0xa9, 'i', 'n', 'f' )
#define FOURCC_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' ) #define FOURCC_0xa9ART VLC_FOURCC( 0xa9, 'A', 'R', 'T' )
#define FOURCC_0xa9des VLC_FOURCC( 0xa9, 'd', 'e', 's' )
#define FOURCC_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' ) #define FOURCC_0xa9dir VLC_FOURCC( 0xa9, 'd', 'i', 'r' )
#define FOURCC_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' ) #define FOURCC_0xa9cmt VLC_FOURCC( 0xa9, 'c', 'm', 't' )
#define FOURCC_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' ) #define FOURCC_0xa9req VLC_FOURCC( 0xa9, 'r', 'e', 'q' )
......
...@@ -47,10 +47,6 @@ vlc_module_begin(); ...@@ -47,10 +47,6 @@ vlc_module_begin();
set_callbacks( Open, Close ); set_callbacks( Open, Close );
vlc_module_end(); vlc_module_end();
/* TODO:
* - DEMUX_GET_META and meta parsing
*/
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -651,40 +647,50 @@ static int Control( input_thread_t *p_input, int i_query, va_list args ) ...@@ -651,40 +647,50 @@ static int Control( input_thread_t *p_input, int i_query, va_list args )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
*pp_meta = meta = vlc_meta_New(); *pp_meta = meta = vlc_meta_New();
for( p_0xa9xxx = p_udta->p_first; p_0xa9xxx != NULL; p_0xa9xxx = p_0xa9xxx->p_next ) for( p_0xa9xxx = p_udta->p_first; p_0xa9xxx != NULL;
p_0xa9xxx = p_0xa9xxx->p_next )
{ {
switch( p_0xa9xxx->i_type ) switch( p_0xa9xxx->i_type )
{ {
case FOURCC_0xa9nam: case FOURCC_0xa9nam:
vlc_meta_Add( meta, VLC_META_TITLE, p_0xa9xxx->data.p_0xa9xxx->psz_text ); vlc_meta_Add( meta, VLC_META_TITLE,
break; p_0xa9xxx->data.p_0xa9xxx->psz_text );
case FOURCC_0xa9aut: break;
vlc_meta_Add( meta, VLC_META_AUTHOR, p_0xa9xxx->data.p_0xa9xxx->psz_text ); case FOURCC_0xa9aut:
break; vlc_meta_Add( meta, VLC_META_AUTHOR,
case FOURCC_0xa9ART: p_0xa9xxx->data.p_0xa9xxx->psz_text );
vlc_meta_Add( meta, VLC_META_ARTIST, p_0xa9xxx->data.p_0xa9xxx->psz_text ); break;
break; case FOURCC_0xa9ART:
case FOURCC_0xa9cpy: vlc_meta_Add( meta, VLC_META_ARTIST,
vlc_meta_Add( meta, VLC_META_COPYRIGHT, p_0xa9xxx->data.p_0xa9xxx->psz_text ); p_0xa9xxx->data.p_0xa9xxx->psz_text );
break; break;
case FOURCC_0xa9day: case FOURCC_0xa9cpy:
vlc_meta_Add( meta, VLC_META_DATE, p_0xa9xxx->data.p_0xa9xxx->psz_text ); vlc_meta_Add( meta, VLC_META_COPYRIGHT,
break; p_0xa9xxx->data.p_0xa9xxx->psz_text );
break;
case FOURCC_0xa9swr: case FOURCC_0xa9day:
case FOURCC_0xa9inf: vlc_meta_Add( meta, VLC_META_DATE,
case FOURCC_0xa9dir: p_0xa9xxx->data.p_0xa9xxx->psz_text );
case FOURCC_0xa9cmt: break;
case FOURCC_0xa9req: case FOURCC_0xa9des:
case FOURCC_0xa9fmt: vlc_meta_Add( meta, VLC_META_DESCRIPTION,
case FOURCC_0xa9prd: p_0xa9xxx->data.p_0xa9xxx->psz_text );
case FOURCC_0xa9prf: break;
case FOURCC_0xa9src:
/* TODO one day, but they aren't really meaningfull */ case FOURCC_0xa9swr:
break; case FOURCC_0xa9inf:
case FOURCC_0xa9dir:
default: case FOURCC_0xa9cmt:
break; case FOURCC_0xa9req:
case FOURCC_0xa9fmt:
case FOURCC_0xa9prd:
case FOURCC_0xa9prf:
case FOURCC_0xa9src:
/* TODO one day, but they aren't really meaningfull */
break;
default:
break;
} }
} }
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -560,7 +560,7 @@ static int RunThread( input_thread_t *p_input ) ...@@ -560,7 +560,7 @@ static int RunThread( input_thread_t *p_input )
*****************************************************************************/ *****************************************************************************/
static int InitThread( input_thread_t * p_input ) static int InitThread( input_thread_t * p_input )
{ {
vlc_meta_t *meta; vlc_meta_t *p_meta = NULL, *p_meta_user = NULL;
float f_fps; float f_fps;
playlist_t *p_playlist; playlist_t *p_playlist;
mtime_t i_length; mtime_t i_length;
...@@ -824,8 +824,56 @@ static int InitThread( input_thread_t * p_input ) ...@@ -824,8 +824,56 @@ static int InitThread( input_thread_t * p_input )
p_input->p_sys->i_stop_time = 0; p_input->p_sys->i_stop_time = 0;
/* get meta informations */ /* Get meta information from user */
if( !demux_Control( p_input, DEMUX_GET_META, &meta ) ) var_Create( p_input, "meta-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "meta-author", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "meta-artist", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "meta-genre", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "meta-copyright", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
var_Create( p_input, "meta-description", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
var_Create( p_input, "meta-date", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "meta-url", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
if( (p_meta_user = vlc_meta_New()) )
{
vlc_value_t val;
var_Get( p_input, "meta-title", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_TITLE, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-author", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_AUTHOR, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-artist", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_ARTIST, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-genre", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_GENRE, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-copyright", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_COPYRIGHT, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-description", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_DESCRIPTION, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-date", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_DATE, val.psz_string );
if( val.psz_string ) free( val.psz_string );
var_Get( p_input, "meta-url", &val );
if( val.psz_string && *val.psz_string )
vlc_meta_Add( p_meta_user, VLC_META_URL, val.psz_string );
if( val.psz_string ) free( val.psz_string );
}
/* Get meta informations from demuxer */
if( !demux_Control( p_input, DEMUX_GET_META, &p_meta ) ||
( p_meta_user && p_meta_user->i_meta ) )
{ {
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_input, playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_input,
VLC_OBJECT_PLAYLIST, FIND_PARENT); VLC_OBJECT_PLAYLIST, FIND_PARENT);
...@@ -833,6 +881,10 @@ static int InitThread( input_thread_t * p_input ) ...@@ -833,6 +881,10 @@ static int InitThread( input_thread_t * p_input )
input_info_category_t *p_cat; input_info_category_t *p_cat;
int i; int i;
/* Merge demux and user metadata */
if( !p_meta ){ p_meta = p_meta_user; p_meta_user = NULL; }
else if( p_meta && p_meta_user ) vlc_meta_Merge( p_meta, p_meta_user );
if( p_playlist ) if( p_playlist )
{ {
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
...@@ -845,32 +897,35 @@ static int InitThread( input_thread_t * p_input ) ...@@ -845,32 +897,35 @@ static int InitThread( input_thread_t * p_input )
} }
msg_Dbg( p_input, "meta informations:" ); msg_Dbg( p_input, "meta informations:" );
if( meta->i_meta > 0 ) if( p_meta->i_meta > 0 )
{ {
p_cat = input_InfoCategory( p_input, _("File") ); p_cat = input_InfoCategory( p_input, _("File") );
for( i = 0; i < meta->i_meta; i++ ) for( i = 0; i < p_meta->i_meta; i++ )
{ {
msg_Dbg( p_input, " - '%s' = '%s'", _(meta->name[i]), meta->value[i] ); msg_Dbg( p_input, " - '%s' = '%s'", _(p_meta->name[i]),
if( !strcmp( meta->name[i], VLC_META_TITLE ) ) p_meta->value[i] );
if( !strcmp( p_meta->name[i], VLC_META_TITLE ) )
{ {
playlist_ItemSetName( p_item, meta->value[i] ); playlist_ItemSetName( p_item, p_meta->value[i] );
} }
if( !strcmp( meta->name[i], VLC_META_AUTHOR ) ) if( !strcmp( p_meta->name[i], VLC_META_AUTHOR ) )
{ {
playlist_ItemAddInfo( p_item, _("General"), _("Author"), playlist_ItemAddInfo( p_item, _("General"), _("Author"),
meta->value[i] ); p_meta->value[i] );
} }
input_AddInfo( p_cat, _(meta->name[i]), "%s", meta->value[i] ); input_AddInfo( p_cat, _(p_meta->name[i]), "%s",
p_meta->value[i] );
if( p_item ) if( p_item )
{ {
playlist_ItemAddInfo( p_item, _("File"), playlist_ItemAddInfo( p_item, _("File"),
_(meta->name[i]), "%s", meta->value[i] ); _(p_meta->name[i]), "%s",
p_meta->value[i] );
} }
} }
} }
for( i = 0; i < meta->i_track; i++ ) for( i = 0; i < p_meta->i_track; i++ )
{ {
vlc_meta_t *tk = meta->track[i]; vlc_meta_t *tk = p_meta->track[i];
int j; int j;
msg_Dbg( p_input, " - track[%d]:", i ); msg_Dbg( p_input, " - track[%d]:", i );
...@@ -882,12 +937,13 @@ static int InitThread( input_thread_t * p_input ) ...@@ -882,12 +937,13 @@ static int InitThread( input_thread_t * p_input )
for( j = 0; j < tk->i_meta; j++ ) for( j = 0; j < tk->i_meta; j++ )
{ {
msg_Dbg( p_input, " - '%s' = '%s'", _(tk->name[j]), tk->value[j] ); msg_Dbg( p_input, " - '%s' = '%s'", _(tk->name[j]),
tk->value[j] );
input_AddInfo( p_cat, _(tk->name[j]), "%s", tk->value[j] ); input_AddInfo( p_cat, _(tk->name[j]), "%s", tk->value[j] );
if( p_item ) if( p_item )
{ {
playlist_ItemAddInfo( p_item, psz_cat, playlist_ItemAddInfo( p_item, psz_cat, _(tk->name[j]),
_(tk->name[j]), "%s", tk->value[j] ); "%s", tk->value[j] );
} }
} }
} }
...@@ -901,21 +957,24 @@ static int InitThread( input_thread_t * p_input ) ...@@ -901,21 +957,24 @@ static int InitThread( input_thread_t * p_input )
if( p_input->stream.p_sout && p_input->stream.p_sout->p_meta == NULL ) if( p_input->stream.p_sout && p_input->stream.p_sout->p_meta == NULL )
{ {
p_input->stream.p_sout->p_meta = meta; p_input->stream.p_sout->p_meta = p_meta;
} }
else else
{ {
vlc_meta_Delete( meta ); vlc_meta_Delete( p_meta );
} }
} }
if( p_meta_user ) vlc_meta_Delete( p_meta_user );
/* get length */ /* Get length */
if( !demux_Control( p_input, DEMUX_GET_LENGTH, &i_length ) && i_length > 0 ) if( !demux_Control( p_input, DEMUX_GET_LENGTH, &i_length ) &&
i_length > 0 )
{ {
input_info_category_t *p_cat = input_InfoCategory( p_input, _("File") ); input_info_category_t *p_cat =
p_playlist = (playlist_t*)vlc_object_find( p_input, input_InfoCategory( p_input, _("File") );
VLC_OBJECT_PLAYLIST, p_playlist =
FIND_PARENT ); (playlist_t*)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
FIND_PARENT );
if( p_playlist ) if( p_playlist )
{ {
playlist_SetDuration( p_playlist, -1 , i_length ); playlist_SetDuration( p_playlist, -1 , i_length );
...@@ -934,11 +993,12 @@ static int InitThread( input_thread_t * p_input ) ...@@ -934,11 +993,12 @@ static int InitThread( input_thread_t * p_input )
var_Get( p_input, "start-time", &val ); var_Get( p_input, "start-time", &val );
if( val.i_int > 0 ) if( val.i_int > 0 )
{ {
double f_pos = (double)( (int64_t)val.i_int * I64C(1000000) ) / (double)i_length; double f_pos = val.i_int * I64C(1000000) / (double)i_length;
if( f_pos >= 1.0 ) if( f_pos >= 1.0 )
{ {
msg_Warn( p_input, "invalid start-time, ignored (start-time >= media length)" ); msg_Warn( p_input, "invalid start-time, ignored (start-time "
">= media length)" );
} }
else else
{ {
...@@ -949,6 +1009,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -949,6 +1009,7 @@ static int InitThread( input_thread_t * p_input )
} }
} }
} }
/* Set stop-time and check validity */ /* Set stop-time and check validity */
var_Get( p_input, "stop-time", &val ); var_Get( p_input, "stop-time", &val );
if( val.i_int > 0 ) if( val.i_int > 0 )
...@@ -958,7 +1019,8 @@ static int InitThread( input_thread_t * p_input ) ...@@ -958,7 +1019,8 @@ static int InitThread( input_thread_t * p_input )
var_Get( p_input, "start-time", &start ); var_Get( p_input, "start-time", &start );
if( start.i_int >= val.i_int ) if( start.i_int >= val.i_int )
{ {
msg_Warn( p_input, "invalid stop-time, ignored (stop-time < start-time)" ); msg_Warn( p_input, "invalid stop-time, ignored (stop-time < "
"start-time)" );
} }
else else
{ {
...@@ -967,7 +1029,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -967,7 +1029,7 @@ static int InitThread( input_thread_t * p_input )
} }
} }