[vlc-devel] commit: Export: add support for normal M3U, move UTF-8 mode to M3U8 ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Oct 31 13:59:17 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 31 14:52:57 2009 +0200| [b4c56206503cfc5959cdef344cbbf1c809a8e731] | committer: Rémi Denis-Courmont 

Export: add support for normal M3U, move UTF-8 mode to M3U8

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

 modules/misc/playlist/export.c |    7 +++++++
 modules/misc/playlist/m3u.c    |   40 ++++++++++++++++++++++++++++------------
 2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/modules/misc/playlist/export.c b/modules/misc/playlist/export.c
index 4c236cb..1d87827 100644
--- a/modules/misc/playlist/export.c
+++ b/modules/misc/playlist/export.c
@@ -35,6 +35,7 @@
  * Prototypes
  ***************************************************************************/
 int Export_M3U    ( vlc_object_t *p_intf );
+int Export_M3U8   ( vlc_object_t *p_intf );
 int Export_Old    ( vlc_object_t *p_intf );
 int Export_HTML   ( vlc_object_t *p_intf );
 int xspf_export_playlist( vlc_object_t *p_intf );
@@ -53,6 +54,12 @@ vlc_module_begin ()
         set_callbacks( Export_M3U , NULL )
 
     add_submodule ()
+        set_description( N_("M3U8 playlist export") )
+        add_shortcut( "export-m3u8" )
+        set_capability( "playlist export" , 0 )
+        set_callbacks( Export_M3U , NULL )
+
+    add_submodule ()
         set_description( N_("Old playlist export") )
         add_shortcut( "export-old" )
         set_capability( "playlist export" , 0 )
diff --git a/modules/misc/playlist/m3u.c b/modules/misc/playlist/m3u.c
index 1050c5f..a5af0ac 100644
--- a/modules/misc/playlist/m3u.c
+++ b/modules/misc/playlist/m3u.c
@@ -33,6 +33,7 @@
 #include <vlc_playlist.h>
 #include <vlc_input.h>
 #include <vlc_meta.h>
+#include <vlc_charset.h>
 
 #include <assert.h>
 
@@ -40,11 +41,13 @@
  * Local prototypes
  *****************************************************************************/
 int Export_M3U ( vlc_object_t * );
+int Export_M3U8( vlc_object_t * );
 
 /*****************************************************************************
  * Export_M3U: main export function
  *****************************************************************************/
-static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
+static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root,
+                        int (*pf_fprintf) (FILE *, const char *, ...) )
 {
     int i, j;
 
@@ -59,7 +62,7 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
 
         if( p_current->i_children >= 0 )
         {
-            DoChildren( p_export, p_current );
+            DoChildren( p_export, p_current, pf_fprintf );
             continue;
         }
 
@@ -78,14 +81,14 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
             if( psz_artist && *psz_artist )
             {
                 /* write EXTINF with artist */
-                fprintf( p_export->p_file, "#EXTINF:%i,%s - %s\n",
-                          (int)( i_duration / 1000000 ), psz_artist, psz_name);
+                pf_fprintf( p_export->p_file, "#EXTINF:%"PRIu64",%s - %s\n",
+                            i_duration / CLOCK_FREQ, psz_artist, psz_name);
             }
             else
             {
                 /* write EXTINF without artist */
-                fprintf( p_export->p_file, "#EXTINF:%i,%s\n",
-                         (int)( i_duration / 1000000 ), psz_name);
+                pf_fprintf( p_export->p_file, "#EXTINF:%"PRIu64",%s\n",
+                            i_duration / CLOCK_FREQ, psz_name);
             }
             free( psz_artist );
         }
@@ -95,10 +98,10 @@ static void DoChildren( playlist_export_t *p_export, playlist_item_t *p_root )
         vlc_mutex_lock( &p_current->p_input->lock );
         for( j = 0; j < p_current->p_input->i_options; j++ )
         {
-            fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
-                     p_current->p_input->ppsz_options[j][0] == ':' ?
-                     p_current->p_input->ppsz_options[j] + 1 :
-                     p_current->p_input->ppsz_options[j] );
+            pf_fprintf( p_export->p_file, "#EXTVLCOPT:%s\n",
+                        p_current->p_input->ppsz_options[j][0] == ':' ?
+                        p_current->p_input->ppsz_options[j] + 1 :
+                        p_current->p_input->ppsz_options[j] );
         }
         vlc_mutex_unlock( &p_current->p_input->lock );
 
@@ -114,8 +117,21 @@ int Export_M3U( vlc_object_t *p_this )
     msg_Dbg( p_export, "saving using M3U format");
 
     /* Write header */
-    fprintf( p_export->p_file, "#EXTM3U\n" );
+    fputs( "#EXTM3U\n", p_export->p_file );
 
-    DoChildren( p_export, p_export->p_root );
+    DoChildren( p_export, p_export->p_root, utf8_fprintf );
+    return VLC_SUCCESS;
+}
+
+int Export_M3U8( vlc_object_t *p_this )
+{
+    playlist_export_t *p_export = (playlist_export_t *)p_this;
+
+    msg_Dbg( p_export, "saving using M3U8 format");
+
+    /* Write header */
+    fputs( "#EXTM3U\n", p_export->p_file );
+
+    DoChildren( p_export, p_export->p_root, fprintf );
     return VLC_SUCCESS;
 }




More information about the vlc-devel mailing list