From: RĂ©mi Duraffort Date: Thu, 30 Jul 2009 17:10:17 +0000 (+0200) Subject: podcast: set the duration of an input item when available. X-Git-Tag: 1.1.0-ff~4701 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c0b26a3e9c6624fe5d579a043f12e2e5ab3e4c32;p=vlc podcast: set the duration of an input item when available. --- diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c index 22cb60e13f..99bea8d64d 100644 --- a/modules/demux/playlist/podcast.c +++ b/modules/demux/playlist/podcast.c @@ -46,6 +46,7 @@ struct demux_sys_t *****************************************************************************/ static int Demux( demux_t *p_demux); static int Control( demux_t *p_demux, int i_query, va_list args ); +static mtime_t strTimeToMTime( const char *psz ); /***************************************************************************** * Import_podcast: main import function @@ -317,6 +318,11 @@ static int Demux( demux_t *p_demux ) ADD_INFO( "Podcast Summary", psz_item_summary ); ADD_INFO( "Podcast Type", psz_item_type ); #undef ADD_INFO + + /* Set the duration if available */ + if( psz_item_duration ) + input_item_SetDuration( p_input, strTimeToMTime( psz_item_duration ) ); + if( psz_item_size ) { input_item_AddInfo( p_input, @@ -368,3 +374,18 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args); return VLC_EGENERIC; } + +static mtime_t strTimeToMTime( const char *psz ) +{ + int h, m, s; + switch( sscanf( psz, "%u:%u:%u", &h, &m, &s ) ) + { + case 3: + return (mtime_t)( ( h*60 + m )*60 + s ) * 1000000; + case 2: + return (mtime_t)( h*60 + m ) * 1000000; + break; + default: + return -1; + } +}