]> git.sesse.net Git - vlc/blobdiff - modules/misc/playlist/xspf.c
mediacodec: factorize release_output_buffer
[vlc] / modules / misc / playlist / xspf.c
index f59e2036df45a6032abb80ef7ed391ec3e8da124..e41cd258dd7e855b217e8a34efc01f6435ab273d 100644 (file)
 
 #include <assert.h>
 
-static void xspf_export_item( playlist_item_t *, FILE *, int * );
-static void xspf_extension_item( playlist_item_t *, FILE *, int * );
 int xspf_export_playlist( vlc_object_t *p_this );
 
-/**
- * \brief Prints the XSPF header to file, writes each item by xspf_export_item()
- * and closes the open xml elements
- * \param p_this the VLC playlist object
- * \return VLC_SUCCESS if some memory is available, otherwise VLC_ENONMEM
- */
-int xspf_export_playlist( vlc_object_t *p_this )
-{
-    const playlist_export_t *p_export = (playlist_export_t *)p_this;
-    int               i, i_count;
-    char             *psz_temp;
-    playlist_item_t  *p_node = p_export->p_root;
-
-    /* write XSPF XML header */
-    fprintf( p_export->p_file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
-    fprintf( p_export->p_file,
-             "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\" " \
-             "xmlns:vlc=\"http://www.videolan.org/vlc/playlist/ns/0/\">\n" );
-
-    if( !p_node ) return VLC_SUCCESS;
-
-    /* save name of the playlist node */
-    psz_temp = convert_xml_special_chars( p_node->p_input->psz_name );
-    if( *psz_temp )
-    {
-        fprintf(  p_export->p_file, "\t<title>%s</title>\n", psz_temp );
-    }
-    free( psz_temp );
-
-    /* export all items in a flat format */
-    fprintf( p_export->p_file, "\t<trackList>\n" );
-    i_count = 0;
-    for( i = 0; i < p_node->i_children; i++ )
-    {
-        xspf_export_item( p_node->pp_children[i], p_export->p_file,
-                          &i_count );
-    }
-    fprintf( p_export->p_file, "\t</trackList>\n" );
-
-    /* export the tree structure in <extension> */
-    fprintf( p_export->p_file, "\t<extension application=\"" \
-             "http://www.videolan.org/vlc/playlist/0\">\n" );
-    i_count = 0;
-    for( i = 0; i < p_node->i_children; i++ )
-    {
-        xspf_extension_item( p_node->pp_children[i], p_export->p_file,
-                             &i_count );
-    }
-    fprintf( p_export->p_file, "\t</extension>\n" );
-
-    /* close the header elements */
-    fprintf( p_export->p_file, "</playlist>\n" );
-
-    return VLC_SUCCESS;
-}
-
 static char *input_xml( input_item_t *p_item, char *(*func)(input_item_t *) )
 {
     char *tmp = func( p_item );
@@ -185,6 +127,11 @@ static void xspf_export_item( playlist_item_t *p_item, FILE *p_file,
         fprintf( p_file, "\t\t\t<annotation>%s</annotation>\n", psz );
     free( psz );
 
+    psz = input_xml( p_input, input_item_GetURL );
+    if( psz && *psz )
+        fprintf( p_file, "\t\t\t<info>%s</info>\n", psz );
+    free( psz );
+
     psz = input_xml( p_input, input_item_GetArtURL );
     if( psz && *psz )
         fprintf( p_file, "\t\t\t<image>%s</image>\n", psz );
@@ -258,8 +205,65 @@ static void xspf_extension_item( playlist_item_t *p_item, FILE *p_file,
 
 
     /* print leaf and increase the counter */
-    fprintf( p_file, "\t\t\t<vlc:item tid=\"%i\" />\n", *p_i_count );
+    fprintf( p_file, "\t\t\t<vlc:item tid=\"%i\"/>\n", *p_i_count );
     ( *p_i_count )++;
 
     return;
 }
+
+/**
+ * \brief Prints the XSPF header to file, writes each item by xspf_export_item()
+ * and closes the open xml elements
+ * \param p_this the VLC playlist object
+ * \return VLC_SUCCESS if some memory is available, otherwise VLC_ENONMEM
+ */
+int xspf_export_playlist( vlc_object_t *p_this )
+{
+    const playlist_export_t *p_export = (playlist_export_t *)p_this;
+    int               i, i_count;
+    char             *psz_temp;
+    playlist_item_t  *p_node = p_export->p_root;
+
+    /* write XSPF XML header */
+    fprintf( p_export->p_file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
+    fprintf( p_export->p_file,
+             "<playlist xmlns=\"http://xspf.org/ns/0/\" " \
+              "xmlns:vlc=\"http://www.videolan.org/vlc/playlist/ns/0/\" " \
+              "version=\"1\">\n" );
+
+    if( !p_node ) return VLC_SUCCESS;
+
+    /* save name of the playlist node */
+    psz_temp = convert_xml_special_chars( p_node->p_input->psz_name );
+    if( *psz_temp )
+    {
+        fprintf(  p_export->p_file, "\t<title>%s</title>\n", psz_temp );
+    }
+    free( psz_temp );
+
+    /* export all items in a flat format */
+    fprintf( p_export->p_file, "\t<trackList>\n" );
+    i_count = 0;
+    for( i = 0; i < p_node->i_children; i++ )
+    {
+        xspf_export_item( p_node->pp_children[i], p_export->p_file,
+                          &i_count );
+    }
+    fprintf( p_export->p_file, "\t</trackList>\n" );
+
+    /* export the tree structure in <extension> */
+    fprintf( p_export->p_file, "\t<extension application=\"" \
+             "http://www.videolan.org/vlc/playlist/0\">\n" );
+    i_count = 0;
+    for( i = 0; i < p_node->i_children; i++ )
+    {
+        xspf_extension_item( p_node->pp_children[i], p_export->p_file,
+                             &i_count );
+    }
+    fprintf( p_export->p_file, "\t</extension>\n" );
+
+    /* close the header elements */
+    fprintf( p_export->p_file, "</playlist>\n" );
+
+    return VLC_SUCCESS;
+}