]> git.sesse.net Git - vlc/blobdiff - modules/demux/real.c
Finnally got rid of the old m3u module. RIP
[vlc] / modules / demux / real.c
index 67c9cde600d67093a07c3706947a0f8605351dbb..bafa920bb555afb7fb6586bbc4501378859edd44 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/input.h>
+#include "charset.h"
 
 /*****************************************************************************
  * Module descriptor
@@ -79,14 +80,20 @@ struct demux_sys_t
     uint32_t i_data_packets;
     int64_t  i_data_offset_next;
 
+    int  i_our_duration;
+    int  i_mux_rate;
+
+    char* psz_title;
+    char* psz_artist;
+    char* psz_copyright;
+    char* psz_description;
+
     int          i_track;
     real_track_t **track;
 
     uint8_t buffer[65536];
 
     int64_t     i_pcr;
-    
-    vlc_meta_t *p_meta;
 };
 
 static int Demux( demux_t *p_demux );
@@ -595,8 +602,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     demux_sys_t *p_sys = p_demux->p_sys;
 #if 0
     double f, *pf;
-    int64_t i64, *pi64;
+    int64_t i64;
 #endif
+    int64_t *pi64;
 
     switch( i_query )
     {
@@ -613,6 +621,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 *pf = 0.0;
             }
             return VLC_SUCCESS;
+
         case DEMUX_SET_POSITION:
             f = (double) va_arg( args, double );
             i64 = stream_Size( p_demux->s );
@@ -630,22 +639,42 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             }
             *pi64 = 0;
             return VLC_EGENERIC;
+#endif
 
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            if( p_sys->i_mux_rate > 0 )
+            
+            /* the commented following lines are fen's implementation, which doesn't seem to
+             * work for one reason or another -- FK */
+            /*if( p_sys->i_mux_rate > 0 )
             {
                 *pi64 = (int64_t)1000000 * ( stream_Size( p_demux->s ) / 50 ) / p_sys->i_mux_rate;
+                return VLC_SUCCESS;
+            }*/
+            if( p_sys->i_our_duration > 0 )
+            {
+                /* our stored duration is in ms, so... */
+                *pi64 = (int64_t)1000 * p_sys->i_our_duration;
+                
                 return VLC_SUCCESS;
             }
             *pi64 = 0;
             return VLC_EGENERIC;
-#endif
 
         case DEMUX_GET_META:
         {
-            vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
-            *pp_meta = p_sys->p_meta;
+            vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t* );
+
+            /* the core will crash if we provide NULL strings, so check 
+             * every string first */
+            if( p_sys->psz_title )
+                vlc_meta_SetTitle( p_meta, p_sys->psz_title );
+            if( p_sys->psz_artist )
+                vlc_meta_SetArtist( p_meta, p_sys->psz_artist );
+            if( p_sys->psz_copyright )
+                vlc_meta_SetCopyright( p_meta, p_sys->psz_copyright );
+            if( p_sys->psz_description )
+                vlc_meta_SetDescription( p_meta, p_sys->psz_description );
             return VLC_SUCCESS;
         }
 
@@ -669,8 +698,6 @@ static int HeaderRead( demux_t *p_demux )
     uint32_t    i_size;
     int64_t     i_skip;
     int         i_version;
-    
-    p_sys->p_meta = vlc_meta_New();
 
     for( ;; )
     {
@@ -717,6 +744,10 @@ static int HeaderRead( demux_t *p_demux )
             msg_Dbg( p_demux, "    - index offset=%d", GetDWBE(&header[28]) );
             msg_Dbg( p_demux, "    - data offset=%d", GetDWBE(&header[32]) );
             msg_Dbg( p_demux, "    - num streams=%d", GetWBE(&header[36]) );
+            
+            /* set the duration for export in control */
+            p_sys->i_our_duration = (int)GetDWBE(&header[20]);
+            
             i_flags = GetWBE(&header[38]);
             msg_Dbg( p_demux, "    - flags=0x%x %s%s%s",
                      i_flags,
@@ -742,7 +773,7 @@ static int HeaderRead( demux_t *p_demux )
 
                 msg_Dbg( p_demux, "    - title=`%s'", psz );
                 EnsureUTF8( psz );
-                vlc_meta_Add( p_sys->p_meta, VLC_META_TITLE, psz );
+                asprintf( &p_sys->psz_title, psz );
                 free( psz );
                 i_skip -= i_len;
             }
@@ -757,7 +788,7 @@ static int HeaderRead( demux_t *p_demux )
 
                 msg_Dbg( p_demux, "    - author=`%s'", psz );
                 EnsureUTF8( psz );
-                vlc_meta_Add( p_sys->p_meta, VLC_META_AUTHOR, psz );
+                asprintf( &p_sys->psz_artist, psz );
                 free( psz );
                 i_skip -= i_len;
             }
@@ -772,7 +803,7 @@ static int HeaderRead( demux_t *p_demux )
 
                 msg_Dbg( p_demux, "    - copyright=`%s'", psz );
                 EnsureUTF8( psz );
-                vlc_meta_Add( p_sys->p_meta, VLC_META_COPYRIGHT, psz );
+                asprintf( &p_sys->psz_copyright, psz );
                 free( psz );
                 i_skip -= i_len;
             }
@@ -787,7 +818,7 @@ static int HeaderRead( demux_t *p_demux )
 
                 msg_Dbg( p_demux, "    - comment=`%s'", psz );
                 EnsureUTF8( psz );
-                vlc_meta_Add( p_sys->p_meta, VLC_META_DESCRIPTION, psz );
+                asprintf( &p_sys->psz_description, psz );
                 free( psz );
                 i_skip -= i_len;
             }
@@ -810,6 +841,7 @@ static int HeaderRead( demux_t *p_demux )
             msg_Dbg( p_demux, "    - start time=%d", GetDWBE(&header[18]) );
             msg_Dbg( p_demux, "    - preroll=%d", GetDWBE(&header[22]) );
             msg_Dbg( p_demux, "    - duration=%d", GetDWBE(&header[26]) );
+            
             i_skip -= 30;
 
             stream_Read( p_demux->s, header, 1 );