Commit 0db5f2a0 authored by Antoine Lejeune's avatar Antoine Lejeune Committed by Rémi Denis-Courmont

Ability to save and load input item options in xspf playlist as it is possible in m3u playlist.

Signed-off-by: default avatarRémi Denis-Courmont <rem@videolan.org>
parent 250db7be
......@@ -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} }
};
......
......@@ -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 */
......
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment