[vlc-devel] commit: Ability to save and load input item options in xspf playlist as it is possible in m3u playlist . (Antoine Lejeune )
git version control
git at videolan.org
Sat Apr 26 09:13:30 CEST 2008
vlc | branch: master | Antoine Lejeune <phytos at videolan.org> | Wed Apr 23 20:20:13 2008 +0200| [0db5f2a07b883f92d95959221776423fcad85974]
Ability to save and load input item options in xspf playlist as it is possible in m3u playlist.
Signed-off-by: Rémi Denis-Courmont <rem at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0db5f2a07b883f92d95959221776423fcad85974
---
modules/demux/playlist/xspf.c | 19 ++++++++++++++++++-
modules/demux/playlist/xspf.h | 1 +
modules/misc/playlist/xspf.c | 12 ++++++++++++
3 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 5d90862..b0ac7b3 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -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} }
};
diff --git a/modules/demux/playlist/xspf.h b/modules/demux/playlist/xspf.h
index e452ae1..09d4ae6 100644
--- a/modules/demux/playlist/xspf.h
+++ b/modules/demux/playlist/xspf.h
@@ -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 */
diff --git a/modules/misc/playlist/xspf.c b/modules/misc/playlist/xspf.c
index 3c130d8..64d45cb 100644
--- a/modules/misc/playlist/xspf.c
+++ b/modules/misc/playlist/xspf.c
@@ -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 );
More information about the vlc-devel
mailing list