Ability to save and load input item options in xspf playlist as it is possible in...
authorAntoine Lejeune <phytos@videolan.org>
Wed, 23 Apr 2008 18:20:13 +0000 (20:20 +0200)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 26 Apr 2008 07:08:52 +0000 (10:08 +0300)
Signed-off-by: Rémi Denis-Courmont <rem@videolan.org>
modules/demux/playlist/xspf.c
modules/demux/playlist/xspf.h
modules/misc/playlist/xspf.c

index 5d90862..b0ac7b3 100644 (file)
@@ -410,7 +410,7 @@ static bool parse_track_node COMPLEX_INTERFACE
           {"duration",     SIMPLE_CONTENT,  {.smpl = set_item_info} },
           {"link",         SIMPLE_CONTENT,  {NULL} },
           {"meta",         SIMPLE_CONTENT,  {NULL} },
-          {"extension",    COMPLEX_CONTENT, {.cmplx = skip_element} },
+          {"extension",    COMPLEX_CONTENT, {.cmplx = parse_extension_node} },
           {NULL,           UNKNOWN_CONTENT, {NULL} }
         };
 
@@ -660,6 +660,22 @@ static bool set_item_info SIMPLE_INTERFACE
     return true;
 }
 
+/**
+ * \brief handles the <option> elements
+ */
+static bool set_option SIMPLE_INTERFACE
+{
+    /* exit if setting is impossible */
+    if( !psz_name || !psz_value || !p_input )
+        return false;
+
+    /* re-convert xml special characters inside psz_value */
+    resolve_xml_special_chars( psz_value );
+    
+    input_ItemAddOpt( p_input, psz_value, 0 );
+    
+    return true;
+}
 
 /**
  * \brief parse the extension node of a XSPF playlist
@@ -677,6 +693,7 @@ static bool parse_extension_node COMPLEX_INTERFACE
     xml_elem_hnd_t pl_elements[] =
         { {"node",  COMPLEX_CONTENT, {.cmplx = parse_extension_node} },
           {"item",  COMPLEX_CONTENT, {.cmplx = parse_extitem_node} },
+          {"option", SIMPLE_CONTENT, {.smpl = set_option} },
           {NULL,    UNKNOWN_CONTENT, {NULL} }
         };
 
index e452ae1..09d4ae6 100644 (file)
@@ -47,6 +47,7 @@ static bool parse_track_node COMPLEX_INTERFACE;
 static bool parse_extension_node COMPLEX_INTERFACE;
 static bool parse_extitem_node COMPLEX_INTERFACE;
 static bool set_item_info SIMPLE_INTERFACE;
+static bool set_option SIMPLE_INTERFACE;
 static bool skip_element COMPLEX_INTERFACE;
 
 /* datatypes */
index 3c130d8..64d45cb 100644 (file)
@@ -115,6 +115,7 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
 {
     char *psz;
     char *psz_temp;
+    int i;
     mtime_t i_duration;
 
     if( !p_item ) return;
@@ -225,6 +226,17 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
     }
     free( psz );
 
+    /* export the input's options (bookmarks, ...) in <extension> */
+    fprintf( p_file, "\t\t\t<extension application=\"http://www.videolan.org/vlc/playlist/0\">\n" );
+    for( i = 0; i < p_item->p_input->i_options; i++ )
+    {
+        fprintf( p_file, "\t\t\t\t<option>%s</option>\n",
+                 p_item->p_input->ppsz_options[i][0] == ':' ?
+                 p_item->p_input->ppsz_options[i] + 1 :
+                 p_item->p_input->ppsz_options[i] );
+    }
+    fprintf( p_file, "\t\t\t</extension>\n" );
+
 xspfexportitem_end:
     /* -> the duration */
     i_duration = input_item_GetDuration( p_item->p_input );