[vlc-devel] commit: podcast: set the duration of an input item when available. ( Rémi Duraffort )

git version control git at videolan.org
Thu Jul 30 19:11:01 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Jul 30 19:10:17 2009 +0200| [c0b26a3e9c6624fe5d579a043f12e2e5ab3e4c32] | committer: Rémi Duraffort 

podcast: set the duration of an input item when available.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c0b26a3e9c6624fe5d579a043f12e2e5ab3e4c32
---

 modules/demux/playlist/podcast.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index 22cb60e..99bea8d 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;
+    }
+}




More information about the vlc-devel mailing list