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
7219b037
Commit
7219b037
authored
Nov 17, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream_filter: dash: deduplicate parser code
parent
84bff07d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
106 deletions
+90
-106
modules/stream_filter/Makefile.am
modules/stream_filter/Makefile.am
+1
-0
modules/stream_filter/dash/mpd/BasicCMParser.cpp
modules/stream_filter/dash/mpd/BasicCMParser.cpp
+4
-40
modules/stream_filter/dash/mpd/BasicCMParser.h
modules/stream_filter/dash/mpd/BasicCMParser.h
+1
-13
modules/stream_filter/dash/mpd/IMPDParser.cpp
modules/stream_filter/dash/mpd/IMPDParser.cpp
+60
-0
modules/stream_filter/dash/mpd/IMPDParser.h
modules/stream_filter/dash/mpd/IMPDParser.h
+15
-2
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
+9
-35
modules/stream_filter/dash/mpd/IsoffMainParser.h
modules/stream_filter/dash/mpd/IsoffMainParser.h
+0
-16
No files found.
modules/stream_filter/Makefile.am
View file @
7219b037
...
...
@@ -44,6 +44,7 @@ libdash_plugin_la_SOURCES = \
stream_filter/dash/mpd/ContentDescription.h
\
stream_filter/dash/mpd/IMPDManager.h
\
stream_filter/dash/mpd/IMPDManager.cpp
\
stream_filter/dash/mpd/IMPDParser.cpp
\
stream_filter/dash/mpd/IMPDParser.h
\
stream_filter/dash/mpd/IsoffMainParser.cpp
\
stream_filter/dash/mpd/IsoffMainParser.h
\
...
...
modules/stream_filter/dash/mpd/BasicCMParser.cpp
View file @
7219b037
...
...
@@ -30,23 +30,18 @@
#include "mpd/SegmentInfoDefault.h"
#include "mpd/SegmentTemplate.h"
#include "mpd/SegmentTimeline.h"
#include "xml/DOMHelper.h"
#include <cstdlib>
#include <sstream>
#include <sstream>
#include <vlc_common.h>
#include <vlc_stream.h>
#include <vlc_strings.h>
using
namespace
dash
::
mpd
;
using
namespace
dash
::
xml
;
BasicCMParser
::
BasicCMParser
(
Node
*
root
,
stream_t
*
p_stream
)
:
root
(
root
),
mpd
(
NULL
),
p_stream
(
p_stream
),
currentRepresentation
(
NULL
)
BasicCMParser
::
BasicCMParser
(
Node
*
root_
,
stream_t
*
p_stream
)
:
IMPDParser
(
root_
,
NULL
,
p_stream
,
NULL
)
{
this
->
url
=
p_stream
->
psz_access
;
this
->
url
+=
"://"
;
...
...
@@ -65,10 +60,6 @@ BasicCMParser::~BasicCMParser ()
}
bool
BasicCMParser
::
parse
()
{
return
this
->
setMPD
();
}
bool
BasicCMParser
::
setMPD
()
{
const
std
::
map
<
std
::
string
,
std
::
string
>
attr
=
this
->
root
->
getAttributes
();
this
->
mpd
=
new
MPD
;
...
...
@@ -136,28 +127,6 @@ bool BasicCMParser::setMPD()
this
->
mpd
->
setProgramInformation
(
this
->
parseProgramInformation
()
);
return
true
;
}
void
BasicCMParser
::
setMPDBaseUrl
(
Node
*
root
)
{
std
::
vector
<
Node
*>
baseUrls
=
DOMHelper
::
getChildElementByTagName
(
root
,
"BaseURL"
);
for
(
size_t
i
=
0
;
i
<
baseUrls
.
size
();
i
++
)
{
BaseUrl
*
url
=
new
BaseUrl
(
baseUrls
.
at
(
i
)
->
getText
());
this
->
mpd
->
addBaseUrl
(
url
);
}
}
void
BasicCMParser
::
setPeriods
(
Node
*
root
)
{
std
::
vector
<
Node
*>
periods
=
DOMHelper
::
getElementByTagName
(
root
,
"Period"
,
false
);
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
Period
*
period
=
new
Period
();
this
->
setAdaptationSet
(
periods
.
at
(
i
),
period
);
this
->
mpd
->
addPeriod
(
period
);
}
}
void
BasicCMParser
::
parseSegmentTimeline
(
Node
*
node
,
SegmentInfoCommon
*
segmentInfo
)
{
...
...
@@ -243,7 +212,7 @@ void BasicCMParser::parseSegmentInfoDefault(Node *node, AdaptationSet *group)
}
}
void
BasicCMParser
::
setAdaptationSet
(
Node
*
root
,
Period
*
period
)
void
BasicCMParser
::
setAdaptationSet
s
(
Node
*
root
,
Period
*
period
)
{
std
::
vector
<
Node
*>
adaptSets
=
DOMHelper
::
getElementByTagName
(
root
,
"AdaptationSet"
,
false
);
if
(
adaptSets
.
size
()
==
0
)
//In some old file, AdaptationSet may still be called Group
...
...
@@ -519,11 +488,6 @@ bool BasicCMParser::resolveUrlTemplates( std::string &url, bool &containRunti
return
true
;
}
MPD
*
BasicCMParser
::
getMPD
()
{
return
this
->
mpd
;
}
void
BasicCMParser
::
parseContentDescriptor
(
Node
*
node
,
const
std
::
string
&
name
,
void
(
CommonAttributesElements
::*
addPtr
)(
ContentDescription
*
),
CommonAttributesElements
*
self
)
const
{
std
::
vector
<
Node
*>
descriptors
=
DOMHelper
::
getChildElementByTagName
(
node
,
name
);
...
...
modules/stream_filter/dash/mpd/BasicCMParser.h
View file @
7219b037
...
...
@@ -26,12 +26,8 @@
#define BASICCMPARSER_H_
#include "xml/Node.h"
#include "xml/DOMHelper.h"
#include "mpd/IMPDParser.h"
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/AdaptationSet.h"
#include "mpd/Representation.h"
#include "mpd/BaseUrl.h"
#include "mpd/SegmentInfo.h"
#include "mpd/Segment.h"
...
...
@@ -49,25 +45,21 @@ namespace dash
virtual
~
BasicCMParser
();
bool
parse
();
MPD
*
getMPD
();
private:
void
handleDependencyId
(
Representation
*
rep
,
const
AdaptationSet
*
adaptationSet
,
const
std
::
string
&
dependencyId
);
private:
bool
setMPD
();
void
setPeriods
(
dash
::
xml
::
Node
*
root
);
void
parseSegmentTimeline
(
xml
::
Node
*
node
,
SegmentInfoCommon
*
segmentInfo
);
void
parseSegmentInfoCommon
(
xml
::
Node
*
node
,
SegmentInfoCommon
*
segmentInfo
);
void
parseSegmentInfoDefault
(
xml
::
Node
*
node
,
AdaptationSet
*
group
);
void
setAdaptationSet
(
dash
::
xml
::
Node
*
root
,
Period
*
period
);
void
setAdaptationSet
s
(
dash
::
xml
::
Node
*
root
,
Period
*
period
);
void
parseTrickMode
(
dash
::
xml
::
Node
*
node
,
Representation
*
repr
);
void
setRepresentations
(
dash
::
xml
::
Node
*
root
,
AdaptationSet
*
group
);
bool
setSegmentInfo
(
dash
::
xml
::
Node
*
root
,
Representation
*
rep
);
void
setInitSegment
(
dash
::
xml
::
Node
*
root
,
SegmentInfoCommon
*
info
);
bool
setSegments
(
dash
::
xml
::
Node
*
root
,
SegmentInfo
*
info
);
bool
resolveUrlTemplates
(
std
::
string
&
url
,
bool
&
containRuntimeToken
);
void
setMPDBaseUrl
(
dash
::
xml
::
Node
*
root
);
void
parseContentDescriptor
(
xml
::
Node
*
node
,
const
std
::
string
&
name
,
void
(
CommonAttributesElements
::*
addPtr
)(
ContentDescription
*
),
CommonAttributesElements
*
self
)
const
;
...
...
@@ -78,11 +70,7 @@ namespace dash
ProgramInformation
*
parseProgramInformation
();
private:
dash
::
xml
::
Node
*
root
;
MPD
*
mpd
;
std
::
string
url
;
stream_t
*
p_stream
;
Representation
*
currentRepresentation
;
};
}
}
...
...
modules/stream_filter/dash/mpd/IMPDParser.cpp
0 → 100644
View file @
7219b037
/*
* IMPDParser.cpp
*****************************************************************************
* Copyright (C) 2010 - 2014 VideoLAN Authors
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "IMPDParser.h"
#include "xml/DOMHelper.h"
using
namespace
dash
::
mpd
;
using
namespace
dash
::
xml
;
IMPDParser
::
IMPDParser
(
Node
*
root_
,
MPD
*
mpd_
,
stream_t
*
stream
,
Representation
*
rep
)
{
root
=
root_
;
mpd
=
mpd_
;
currentRepresentation
=
rep
;
p_stream
=
stream
;
}
void
IMPDParser
::
setMPDBaseUrl
(
Node
*
root
)
{
std
::
vector
<
Node
*>
baseUrls
=
DOMHelper
::
getChildElementByTagName
(
root
,
"BaseURL"
);
for
(
size_t
i
=
0
;
i
<
baseUrls
.
size
();
i
++
)
{
BaseUrl
*
url
=
new
BaseUrl
(
baseUrls
.
at
(
i
)
->
getText
());
mpd
->
addBaseUrl
(
url
);
}
}
void
IMPDParser
::
setPeriods
(
Node
*
root_
)
{
std
::
vector
<
Node
*>
periods
=
DOMHelper
::
getElementByTagName
(
root_
,
"Period"
,
false
);
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
Period
*
period
=
new
Period
();
setAdaptationSets
(
periods
.
at
(
i
),
period
);
mpd
->
addPeriod
(
period
);
}
}
MPD
*
IMPDParser
::
getMPD
()
{
return
mpd
;
}
modules/stream_filter/dash/mpd/IMPDParser.h
View file @
7219b037
...
...
@@ -26,6 +26,9 @@
#define IMPDPARSER_H_
#include "mpd/MPD.h"
#include "xml/DOMParser.h"
#include <vlc_common.h>
namespace
dash
{
...
...
@@ -34,9 +37,19 @@ namespace dash
class
IMPDParser
{
public:
virtual
bool
parse
()
=
0
;
virtual
MPD
*
getMPD
()
=
0
;
IMPDParser
(
dash
::
xml
::
Node
*
,
MPD
*
,
stream_t
*
,
Representation
*
);
virtual
~
IMPDParser
(){}
virtual
bool
parse
()
=
0
;
virtual
MPD
*
getMPD
();
virtual
void
setMPDBaseUrl
(
dash
::
xml
::
Node
*
root
);
virtual
void
setAdaptationSets
(
dash
::
xml
::
Node
*
periodNode
,
Period
*
period
)
=
0
;
virtual
void
setPeriods
(
dash
::
xml
::
Node
*
root
);
protected:
dash
::
xml
::
Node
*
root
;
MPD
*
mpd
;
stream_t
*
p_stream
;
Representation
*
currentRepresentation
;
};
}
}
...
...
modules/stream_filter/dash/mpd/IsoffMainParser.cpp
View file @
7219b037
...
...
@@ -27,15 +27,14 @@
#endif
#include "IsoffMainParser.h"
#include "xml/DOMHelper.h"
#include <vlc_strings.h>
using
namespace
dash
::
mpd
;
using
namespace
dash
::
xml
;
IsoffMainParser
::
IsoffMainParser
(
Node
*
root
,
stream_t
*
p_stream
)
:
root
(
root
),
p_stream
(
p_stream
),
mpd
(
NULL
),
currentRepresentation
(
NULL
)
IMPDParser
(
root
,
NULL
,
p_stream
,
NULL
)
{
}
IsoffMainParser
::~
IsoffMainParser
()
...
...
@@ -44,19 +43,14 @@ IsoffMainParser::~IsoffMainParser ()
bool
IsoffMainParser
::
parse
()
{
this
->
mpd
=
new
MPD
();
this
->
setMPDAttributes
();
this
->
setMPDBaseUrl
();
this
->
setPeriods
();
this
->
print
();
mpd
=
new
MPD
();
setMPDAttributes
();
setMPDBaseUrl
(
root
);
setPeriods
(
root
);
print
();
return
true
;
}
MPD
*
IsoffMainParser
::
getMPD
()
{
return
this
->
mpd
;
}
void
IsoffMainParser
::
setMPDAttributes
()
{
const
std
::
map
<
std
::
string
,
std
::
string
>
attr
=
this
->
root
->
getAttributes
();
...
...
@@ -72,27 +66,7 @@ void IsoffMainParser::setMPDAttributes ()
this
->
mpd
->
setMinBufferTime
(
str_duration
(
it
->
second
.
c_str
()));
}
void
IsoffMainParser
::
setMPDBaseUrl
()
{
std
::
vector
<
Node
*>
baseUrls
=
DOMHelper
::
getChildElementByTagName
(
this
->
root
,
"BaseURL"
);
for
(
size_t
i
=
0
;
i
<
baseUrls
.
size
();
i
++
)
{
BaseUrl
*
url
=
new
BaseUrl
(
baseUrls
.
at
(
i
)
->
getText
());
this
->
mpd
->
addBaseUrl
(
url
);
}
}
void
IsoffMainParser
::
setPeriods
()
{
std
::
vector
<
Node
*>
periods
=
DOMHelper
::
getElementByTagName
(
this
->
root
,
"Period"
,
false
);
for
(
size_t
i
=
0
;
i
<
periods
.
size
();
i
++
)
{
Period
*
period
=
new
Period
();
this
->
setAdaptationSets
(
periods
.
at
(
i
),
period
);
this
->
mpd
->
addPeriod
(
period
);
}
}
void
IsoffMainParser
::
setAdaptationSets
(
Node
*
periodNode
,
Period
*
period
)
{
std
::
vector
<
Node
*>
adaptationSets
=
DOMHelper
::
getElementByTagName
(
periodNode
,
"AdaptationSet"
,
false
);
...
...
modules/stream_filter/dash/mpd/IsoffMainParser.h
View file @
7219b037
...
...
@@ -26,12 +26,8 @@
#define ISOFFMAINPARSER_H_
#include "xml/Node.h"
#include "xml/DOMHelper.h"
#include "mpd/IMPDParser.h"
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/AdaptationSet.h"
#include "mpd/Representation.h"
#include "mpd/BaseUrl.h"
#include "mpd/SegmentBase.h"
#include "mpd/SegmentList.h"
...
...
@@ -40,10 +36,6 @@
#include <cstdlib>
#include <sstream>
#include <vlc_common.h>
#include <vlc_stream.h>
#include <vlc_strings.h>
namespace
dash
{
namespace
mpd
...
...
@@ -55,18 +47,10 @@ namespace dash
virtual
~
IsoffMainParser
();
bool
parse
();
MPD
*
getMPD
();
void
print
();
private:
dash
::
xml
::
Node
*
root
;
stream_t
*
p_stream
;
MPD
*
mpd
;
Representation
*
currentRepresentation
;
void
setMPDAttributes
();
void
setMPDBaseUrl
();
void
setPeriods
();
void
setAdaptationSets
(
dash
::
xml
::
Node
*
periodNode
,
Period
*
period
);
void
setRepresentations
(
dash
::
xml
::
Node
*
adaptationSetNode
,
AdaptationSet
*
adaptationSet
);
void
setSegmentBase
(
dash
::
xml
::
Node
*
repNode
,
Representation
*
rep
);
...
...
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