Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
82c2d527
Commit
82c2d527
authored
Jun 14, 2006
by
Yoann Peronneau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* demux/playlist/xspf: skeleton for XSPF tree playlist import
parent
6bc1500f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
242 additions
and
5 deletions
+242
-5
modules/demux/playlist/xspf.c
modules/demux/playlist/xspf.c
+240
-5
modules/demux/playlist/xspf.h
modules/demux/playlist/xspf.h
+2
-0
No files found.
modules/demux/playlist/xspf.c
View file @
82c2d527
/*******************************************************************************
/*******************************************************************************
* Copyright (C) 2006 Daniel Stränger <vlc at schmaller dot de>
* xspf.c : XSPF playlist import functions
*******************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
*
* Authors: Daniel Stränger <vlc at schmaller dot de>
* Yoann Peronneau <yoann@videolan.org>
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by
...
@@ -33,6 +39,8 @@ struct demux_sys_t
...
@@ -33,6 +39,8 @@ struct demux_sys_t
{
{
playlist_item_t
*
p_item_in_category
;
playlist_item_t
*
p_item_in_category
;
int
i_parent_id
;
int
i_parent_id
;
input_item_t
**
pp_tracklist
;
int
i_tracklist_entries
;
};
};
/**
/**
...
@@ -76,6 +84,8 @@ int xspf_import_Demux( demux_t *p_demux )
...
@@ -76,6 +84,8 @@ int xspf_import_Demux( demux_t *p_demux )
INIT_PLAYLIST_STUFF
;
INIT_PLAYLIST_STUFF
;
p_demux
->
p_sys
->
p_item_in_category
=
p_item_in_category
;
p_demux
->
p_sys
->
p_item_in_category
=
p_item_in_category
;
p_demux
->
p_sys
->
i_parent_id
=
i_parent_id
;
p_demux
->
p_sys
->
i_parent_id
=
i_parent_id
;
p_demux
->
p_sys
->
pp_tracklist
=
NULL
;
p_demux
->
p_sys
->
i_tracklist_entries
=
0
;
/* create new xml parser from stream */
/* create new xml parser from stream */
p_xml
=
xml_Create
(
p_demux
);
p_xml
=
xml_Create
(
p_demux
);
...
@@ -161,7 +171,7 @@ static vlc_bool_t parse_playlist_node COMPLEX_INTERFACE
...
@@ -161,7 +171,7 @@ static vlc_bool_t parse_playlist_node COMPLEX_INTERFACE
{
"attribution"
,
COMPLEX_CONTENT
,
{.
cmplx
=
skip_element
}
},
{
"attribution"
,
COMPLEX_CONTENT
,
{.
cmplx
=
skip_element
}
},
{
"link"
,
SIMPLE_CONTENT
,
{
NULL
}
},
{
"link"
,
SIMPLE_CONTENT
,
{
NULL
}
},
{
"meta"
,
SIMPLE_CONTENT
,
{
NULL
}
},
{
"meta"
,
SIMPLE_CONTENT
,
{
NULL
}
},
{
"extension"
,
COMPLEX_CONTENT
,
{.
cmplx
=
skip_element
}
},
{
"extension"
,
COMPLEX_CONTENT
,
{.
cmplx
=
parse_extension_node
}
},
{
"trackList"
,
COMPLEX_CONTENT
,
{.
cmplx
=
parse_tracklist_node
}
},
{
"trackList"
,
COMPLEX_CONTENT
,
{.
cmplx
=
parse_tracklist_node
}
},
{
NULL
,
UNKNOWN_CONTENT
,
{
NULL
}
}
{
NULL
,
UNKNOWN_CONTENT
,
{
NULL
}
}
};
};
...
@@ -474,10 +484,14 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
...
@@ -474,10 +484,14 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
{
{
FREE_ATT
();
FREE_ATT
();
/* Add it */
/* Add it */
playlist_AddWhereverNeeded
(
p_playlist
,
p_new_input
,
/*
playlist_AddWhereverNeeded( p_playlist, p_new_input,
p_item, p_demux->p_sys->p_item_in_category,
p_item, p_demux->p_sys->p_item_in_category,
(p_demux->p_sys->i_parent_id >0 ) ? VLC_TRUE:
(p_demux->p_sys->i_parent_id >0 ) ? VLC_TRUE:
VLC_FALSE
,
PLAYLIST_APPEND
);
VLC_FALSE, PLAYLIST_APPEND );*/
INSERT_ELEM
(
p_demux
->
p_sys
->
pp_tracklist
,
p_demux
->
p_sys
->
i_tracklist_entries
,
p_demux
->
p_sys
->
i_tracklist_entries
,
p_new_input
);
return
VLC_TRUE
;
return
VLC_TRUE
;
}
}
/* there MUST have been a start tag for that element name */
/* there MUST have been a start tag for that element name */
...
@@ -521,6 +535,9 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
...
@@ -521,6 +535,9 @@ static vlc_bool_t parse_track_node COMPLEX_INTERFACE
return
VLC_FALSE
;
return
VLC_FALSE
;
}
}
}
}
else
if
(
!
strcmp
(
p_handler
->
name
,
"identifier"
)
)
{
}
else
else
{
{
/* there MUST be an item */
/* there MUST be an item */
...
@@ -594,6 +611,224 @@ static vlc_bool_t set_item_info SIMPLE_INTERFACE
...
@@ -594,6 +611,224 @@ static vlc_bool_t set_item_info SIMPLE_INTERFACE
return
VLC_TRUE
;
return
VLC_TRUE
;
}
}
/**
* \brief parse the extension node of a XSPF playlist
*/
static
vlc_bool_t
parse_extension_node
COMPLEX_INTERFACE
{
char
*
psz_name
=
NULL
;
char
*
psz_value
=
NULL
;
int
i_node
;
xml_elem_hnd_t
*
p_handler
=
NULL
;
xml_elem_hnd_t
pl_elements
[]
=
{
{
"title"
,
SIMPLE_CONTENT
,
{.
cmplx
=
skip_element
}
},
{
"node"
,
COMPLEX_CONTENT
,
{.
cmplx
=
parse_extension_node
}
},
{
"item"
,
COMPLEX_CONTENT
,
{.
cmplx
=
parse_extitem_node
}
},
{
NULL
,
UNKNOWN_CONTENT
,
{
NULL
}
}
};
fprintf
(
stderr
,
" <node>
\n
"
);
/* parse the child elements */
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
{
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
psz_name
||
!*
psz_name
)
{
msg_Err
(
p_demux
,
"invalid xml stream"
);
FREE_ATT
();
return
VLC_FALSE
;
}
/* choose handler */
for
(
p_handler
=
pl_elements
;
p_handler
->
name
&&
strcmp
(
psz_name
,
p_handler
->
name
);
p_handler
++
);
if
(
!
p_handler
->
name
)
{
msg_Err
(
p_demux
,
"unexpected element <%s>"
,
psz_name
);
FREE_ATT
();
return
VLC_FALSE
;
}
FREE_NAME
();
/* complex content is parsed in a separate function */
if
(
p_handler
->
type
==
COMPLEX_CONTENT
)
{
if
(
p_handler
->
pf_handler
.
cmplx
(
p_demux
,
p_playlist
,
p_item
,
NULL
,
p_xml_reader
,
p_handler
->
name
)
)
{
p_handler
=
NULL
;
FREE_ATT
();
}
else
{
FREE_ATT
();
return
VLC_FALSE
;
}
}
break
;
case
XML_READER_TEXT
:
/* simple element content */
FREE_ATT
();
psz_value
=
xml_ReaderValue
(
p_xml_reader
);
if
(
!
psz_value
)
{
msg_Err
(
p_demux
,
"invalid xml stream"
);
FREE_ATT
();
return
VLC_FALSE
;
}
break
;
case
XML_READER_ENDELEM
:
/* element end tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
psz_name
)
{
msg_Err
(
p_demux
,
"invalid xml stream"
);
FREE_ATT
();
return
VLC_FALSE
;
}
/* leave if the current parent node is terminated */
if
(
!
strcmp
(
psz_name
,
psz_element
)
)
{
fprintf
(
stderr
,
" </node>
\n
"
);
FREE_ATT
();
return
VLC_TRUE
;
}
/* there MUST have been a start tag for that element name */
if
(
!
p_handler
||
!
p_handler
->
name
||
strcmp
(
p_handler
->
name
,
psz_name
))
{
msg_Err
(
p_demux
,
"there's no open element left for <%s>"
,
psz_name
);
FREE_ATT
();
return
VLC_FALSE
;
}
if
(
p_handler
->
pf_handler
.
smpl
)
{
p_handler
->
pf_handler
.
smpl
(
p_item
,
NULL
,
p_handler
->
name
,
psz_value
);
}
FREE_ATT
();
p_handler
=
NULL
;
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
FREE_ATT
();
return
VLC_FALSE
;
}
FREE_NAME
();
}
return
VLC_FALSE
;
}
/**
* \brief parse the extension item node of a XSPF playlist
*/
static
vlc_bool_t
parse_extitem_node
COMPLEX_INTERFACE
{
char
*
psz_name
=
NULL
;
char
*
psz_value
=
NULL
;
int
i_node
;
int
i_href
=
-
1
;
/* read all playlist attributes */
while
(
xml_ReaderNextAttr
(
p_xml_reader
)
==
VLC_SUCCESS
)
{
psz_name
=
xml_ReaderName
(
p_xml_reader
);
psz_value
=
xml_ReaderValue
(
p_xml_reader
);
if
(
!
psz_name
||
!
psz_value
)
{
msg_Err
(
p_demux
,
"invalid xml stream @ <item>"
);
FREE_ATT
();
return
VLC_FALSE
;
}
/* attribute: href */
if
(
!
strcmp
(
psz_name
,
"href"
)
)
{
i_href
=
atoi
(
psz_value
);
}
/* unknown attribute */
else
msg_Warn
(
p_demux
,
"invalid <item> attribute:
\"
%s
\"
"
,
psz_name
);
FREE_ATT
();
}
/* attribute href is mandatory */
if
(
i_href
<
0
)
{
msg_Warn
(
p_demux
,
"<item> requires
\"
href
\"
attribute"
);
return
VLC_FALSE
;
}
if
(
i_href
>
p_demux
->
p_sys
->
i_tracklist_entries
)
{
msg_Warn
(
p_demux
,
"invalid
\"
href
\"
attribute"
);
return
VLC_FALSE
;
}
fprintf
(
stderr
,
" %s
\n
"
,
p_demux
->
p_sys
->
pp_tracklist
[
i_href
]
->
psz_name
);
/* parse the child elements */
while
(
xml_ReaderRead
(
p_xml_reader
)
==
1
)
{
i_node
=
xml_ReaderNodeType
(
p_xml_reader
);
switch
(
i_node
)
{
case
XML_READER_NONE
:
break
;
case
XML_READER_STARTELEM
:
/* element start tag */
case
XML_READER_TEXT
:
/* simple element content */
msg_Err
(
p_demux
,
"invalid xml stream"
);
return
VLC_FALSE
;
case
XML_READER_ENDELEM
:
/* element end tag */
psz_name
=
xml_ReaderName
(
p_xml_reader
);
if
(
!
psz_name
)
{
msg_Err
(
p_demux
,
"invalid xml stream"
);
FREE_ATT
();
return
VLC_FALSE
;
}
/* leave if the current parent node is terminated */
if
(
!
strcmp
(
psz_name
,
psz_element
)
)
{
FREE_ATT
();
return
VLC_TRUE
;
}
FREE_ATT
();
break
;
default:
/* unknown/unexpected xml node */
msg_Err
(
p_demux
,
"unexpected xml node %i"
,
i_node
);
FREE_ATT
();
return
VLC_FALSE
;
}
FREE_NAME
();
}
return
VLC_FALSE
;
}
/**
/**
* \brief skips complex element content that we can't manage
* \brief skips complex element content that we can't manage
*/
*/
...
...
modules/demux/playlist/xspf.h
View file @
82c2d527
...
@@ -47,6 +47,8 @@ int xspf_import_Control( demux_t *, int, va_list );
...
@@ -47,6 +47,8 @@ int xspf_import_Control( demux_t *, int, va_list );
static
vlc_bool_t
parse_playlist_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_playlist_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_tracklist_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_tracklist_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_track_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_track_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_extension_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
parse_extitem_node
COMPLEX_INTERFACE
;
static
vlc_bool_t
set_item_info
SIMPLE_INTERFACE
;
static
vlc_bool_t
set_item_info
SIMPLE_INTERFACE
;
static
vlc_bool_t
skip_element
COMPLEX_INTERFACE
;
static
vlc_bool_t
skip_element
COMPLEX_INTERFACE
;
static
vlc_bool_t
insert_new_item
(
playlist_t
*
,
playlist_item_t
*
,
playlist_item_t
**
,
char
*
);
static
vlc_bool_t
insert_new_item
(
playlist_t
*
,
playlist_item_t
*
,
playlist_item_t
**
,
char
*
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment