Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
53beda0a
Commit
53beda0a
authored
Dec 24, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: dash: fix and debug DOM Parsing
parent
98df0fd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
37 deletions
+73
-37
modules/stream_filter/dash/xml/DOMParser.cpp
modules/stream_filter/dash/xml/DOMParser.cpp
+56
-24
modules/stream_filter/dash/xml/Node.cpp
modules/stream_filter/dash/xml/Node.cpp
+16
-12
modules/stream_filter/dash/xml/Node.h
modules/stream_filter/dash/xml/Node.h
+1
-1
No files found.
modules/stream_filter/dash/xml/DOMParser.cpp
View file @
53beda0a
...
...
@@ -29,6 +29,7 @@
#include "../Helper.h"
#include <vector>
#include <stack>
#include <vlc_xml.h>
#include <vlc_stream.h>
...
...
@@ -68,43 +69,74 @@ bool DOMParser::parse ()
if
(
!
this
->
vlc_reader
)
return
false
;
this
->
root
=
this
->
processNode
();
if
(
this
->
root
==
NULL
)
root
=
processNode
();
if
(
root
==
NULL
)
return
false
;
return
true
;
}
Node
*
DOMParser
::
processNode
()
Node
*
DOMParser
::
processNode
()
{
const
char
*
data
;
int
type
=
xml_ReaderNextNode
(
this
->
vlc_reader
,
&
data
);
if
(
type
!=
-
1
&&
type
!=
XML_READER_NONE
&&
type
!=
XML_READER_ENDELEM
)
int
type
;
std
::
stack
<
Node
*>
lifo
;
while
(
(
type
=
xml_ReaderNextNode
(
vlc_reader
,
&
data
))
>
0
)
{
switch
(
type
)
{
case
XML_READER_STARTELEM
:
{
bool
empty
=
xml_ReaderIsEmptyElement
(
vlc_reader
);
Node
*
node
=
new
(
std
::
nothrow
)
Node
();
if
(
node
)
{
Node
*
node
=
new
Node
();
node
->
setType
(
type
);
if
(
!
lifo
.
empty
())
lifo
.
top
()
->
addSubNode
(
node
);
lifo
.
push
(
node
);
if
(
type
!=
XML_READER_TEXT
)
node
->
setName
(
std
::
string
(
data
));
addAttributesToNode
(
node
);
}
if
(
empty
)
lifo
.
pop
();
break
;
}
case
XML_READER_TEXT
:
{
std
::
string
name
=
data
;
bool
isEmpty
=
xml_ReaderIsEmptyElement
(
this
->
vlc_reader
);
node
->
setName
(
name
);
if
(
!
lifo
.
empty
())
lifo
.
top
()
->
setText
(
std
::
string
(
data
));
break
;
}
this
->
addAttributesToNode
(
node
);
case
XML_READER_ENDELEM
:
{
if
(
lifo
.
empty
())
return
NULL
;
if
(
isEmpty
)
Node
*
node
=
lifo
.
top
();
lifo
.
pop
();
if
(
lifo
.
empty
())
return
node
;
}
Node
*
subnode
=
NULL
;
while
((
subnode
=
this
->
processNode
())
!=
NULL
)
node
->
addSubNode
(
subnode
);
default:
break
;
}
else
node
->
setText
(
data
);
return
node
;
}
while
(
lifo
.
size
()
>
1
)
lifo
.
pop
();
if
(
!
lifo
.
empty
())
delete
lifo
.
top
();
return
NULL
;
}
void
DOMParser
::
addAttributesToNode
(
Node
*
node
)
{
const
char
*
attrValue
;
...
...
modules/stream_filter/dash/xml/Node.cpp
View file @
53beda0a
...
...
@@ -94,20 +94,9 @@ std::vector<std::string> Node::getAttributeKeys () const
return
keys
;
}
bool
Node
::
hasText
()
const
{
return
false
;
}
const
std
::
string
&
Node
::
getText
()
const
{
if
(
this
->
type
==
XML_READER_TEXT
)
return
this
->
text
;
else
{
assert
(
this
->
subNodes
.
size
()
==
1
);
return
this
->
subNodes
[
0
]
->
getText
();
}
return
text
;
}
void
Node
::
setText
(
const
std
::
string
&
text
)
...
...
@@ -129,3 +118,18 @@ void Node::setType(int type)
{
this
->
type
=
type
;
}
std
::
vector
<
std
::
string
>
Node
::
toString
(
int
indent
)
const
{
std
::
vector
<
std
::
string
>
ret
;
std
::
string
text
(
indent
,
' '
);
text
.
append
(
getName
());
ret
.
push_back
(
text
);
std
::
vector
<
Node
*>::
const_iterator
l
;
for
(
l
=
subNodes
.
begin
();
l
<
subNodes
.
end
();
l
++
)
{
std
::
vector
<
std
::
string
>
sub
=
(
*
l
)
->
toString
(
indent
+
1
);
ret
.
insert
(
ret
.
end
(),
sub
.
begin
(),
sub
.
end
());
}
return
ret
;
}
modules/stream_filter/dash/xml/Node.h
View file @
53beda0a
...
...
@@ -48,12 +48,12 @@ namespace dash
void
addAttribute
(
const
std
::
string
&
key
,
const
std
::
string
&
value
);
const
std
::
string
&
getAttributeValue
(
const
std
::
string
&
key
)
const
;
std
::
vector
<
std
::
string
>
getAttributeKeys
()
const
;
bool
hasText
()
const
;
const
std
::
string
&
getText
()
const
;
void
setText
(
const
std
::
string
&
text
);
const
std
::
map
<
std
::
string
,
std
::
string
>&
getAttributes
()
const
;
int
getType
()
const
;
void
setType
(
int
type
);
std
::
vector
<
std
::
string
>
toString
(
int
)
const
;
private:
static
const
std
::
string
EmptyString
;
...
...
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