[vlc-commits] demux: dash: add Initializable and parse SegmentList init segment
Francois Cartegnie
git at videolan.org
Fri Jan 2 19:27:51 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jan 2 19:26:51 2015 +0100| [0fa42c7522be513f644d714206ff90bcaf196f20] | committer: Francois Cartegnie
demux: dash: add Initializable and parse SegmentList init segment
Fixes playback where Initilialization Segment is in SegmentList
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0fa42c7522be513f644d714206ff90bcaf196f20
---
modules/demux/dash/mpd/IsoffMainParser.cpp | 37 ++++++++++++-------------
modules/demux/dash/mpd/IsoffMainParser.h | 2 +-
modules/demux/dash/mpd/SegmentBase.cpp | 11 +-------
modules/demux/dash/mpd/SegmentBase.h | 9 ++----
modules/demux/dash/mpd/SegmentInfoCommon.cpp | 25 ++++++++---------
modules/demux/dash/mpd/SegmentInfoCommon.h | 15 +++++++---
modules/demux/dash/mpd/SegmentInformation.cpp | 8 +++---
7 files changed, 47 insertions(+), 60 deletions(-)
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index ed5aea8..7fd99a7 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -251,18 +251,18 @@ void IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformatio
list->addSegment(seg);
info->setSegmentList(list);
- std::vector<Node *> initSeg = DOMHelper::getElementByTagName(segmentBaseNode, "Initialization", false);
- if(!initSeg.empty())
+ Node *initSeg = DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization");
+ if(initSeg)
{
SegmentBase *base = new SegmentBase();
- setInitSegment(segmentBaseNode, base);
+ parseInitSegment(initSeg, base);
info->setSegmentBase(base);
}
}
else
{
SegmentBase *base = new SegmentBase();
- setInitSegment(segmentBaseNode, base);
+ parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base);
info->setSegmentBase(base);
}
}
@@ -277,6 +277,8 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
SegmentList *list;
if(!segments.empty() && (list = new (std::nothrow) SegmentList()))
{
+ parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list);
+
if(segListNode->hasAttribute("duration"))
list->setDuration(Integer<mtime_t>(segListNode->getAttributeValue("duration")));
@@ -320,27 +322,22 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
return total;
}
-void IsoffMainParser::setInitSegment (dash::xml::Node *segBaseNode, SegmentBase *base)
+void IsoffMainParser::parseInitSegment(Node *initNode, Initializable *init)
{
- std::vector<Node *> initSeg = DOMHelper::getElementByTagName(segBaseNode, "Initialisation", false);
+ if(!initNode)
+ return;
- if(initSeg.size() == 0)
- initSeg = DOMHelper::getElementByTagName(segBaseNode, "Initialization", false);
+ Segment *seg = new InitSegment( currentRepresentation );
+ seg->setSourceUrl(initNode->getAttributeValue("sourceURL"));
- if(initSeg.size() > 0)
+ if(initNode->hasAttribute("range"))
{
- Segment *seg = new InitSegment( currentRepresentation );
- seg->setSourceUrl(initSeg.at(0)->getAttributeValue("sourceURL"));
-
- if(initSeg.at(0)->hasAttribute("range"))
- {
- std::string range = initSeg.at(0)->getAttributeValue("range");
- size_t pos = range.find("-");
- seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str()));
- }
-
- base->addInitSegment(seg);
+ std::string range = initNode->getAttributeValue("range");
+ size_t pos = range.find("-");
+ seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str()));
}
+
+ init->initialisationSegment.Set(seg);
}
void IsoffMainParser::parseProgramInformation(Node * node, MPD *mpd)
diff --git a/modules/demux/dash/mpd/IsoffMainParser.h b/modules/demux/dash/mpd/IsoffMainParser.h
index 0c98b46..8ae86cf 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.h
+++ b/modules/demux/dash/mpd/IsoffMainParser.h
@@ -53,7 +53,7 @@ namespace dash
void setMPDAttributes ();
void setAdaptationSets (dash::xml::Node *periodNode, Period *period);
void setRepresentations (dash::xml::Node *adaptationSetNode, AdaptationSet *adaptationSet);
- void setInitSegment (dash::xml::Node *segBaseNode, SegmentBase *base);
+ void parseInitSegment (dash::xml::Node *, Initializable *);
void parsePeriods (dash::xml::Node *);
size_t parseSegmentInformation(dash::xml::Node *, SegmentInformation *);
void parseSegmentBase (dash::xml::Node *, SegmentInformation *);
diff --git a/modules/demux/dash/mpd/SegmentBase.cpp b/modules/demux/dash/mpd/SegmentBase.cpp
index add6b62..3ec5e94 100644
--- a/modules/demux/dash/mpd/SegmentBase.cpp
+++ b/modules/demux/dash/mpd/SegmentBase.cpp
@@ -31,18 +31,9 @@
using namespace dash::mpd;
SegmentBase::SegmentBase () :
- initSeg (NULL)
+ Initializable()
{
}
SegmentBase::~SegmentBase ()
{
}
-
-void SegmentBase::addInitSegment (Segment *seg)
-{
- this->initSeg = seg;
-}
-Segment* SegmentBase::getInitSegment ()
-{
- return this->initSeg;
-}
diff --git a/modules/demux/dash/mpd/SegmentBase.h b/modules/demux/dash/mpd/SegmentBase.h
index f9bd9fc..2a1a3df 100644
--- a/modules/demux/dash/mpd/SegmentBase.h
+++ b/modules/demux/dash/mpd/SegmentBase.h
@@ -26,22 +26,17 @@
#define SEGMENTBASE_H_
#include "mpd/Segment.h"
+#include "mpd/SegmentInfoCommon.h"
namespace dash
{
namespace mpd
{
- class SegmentBase
+ class SegmentBase : public Initializable
{
public:
SegmentBase ();
virtual ~SegmentBase ();
-
- void addInitSegment (Segment *seg);
- Segment* getInitSegment ();
-
- private:
- Segment *initSeg;
};
}
}
diff --git a/modules/demux/dash/mpd/SegmentInfoCommon.cpp b/modules/demux/dash/mpd/SegmentInfoCommon.cpp
index 8cb0112..743d00b 100644
--- a/modules/demux/dash/mpd/SegmentInfoCommon.cpp
+++ b/modules/demux/dash/mpd/SegmentInfoCommon.cpp
@@ -33,11 +33,20 @@
using namespace dash::mpd;
+Initializable::Initializable()
+{
+ initialisationSegment.Set(NULL);
+}
+
+Initializable::~Initializable()
+{
+ delete initialisationSegment.Get();
+}
+
SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
- ICanonicalUrl( parent ),
+ ICanonicalUrl( parent ), Initializable(),
duration( -1 ),
startIndex( 0 ),
- initialisationSegment( NULL ),
segmentTimeline( NULL )
{
}
@@ -45,7 +54,6 @@ SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
SegmentInfoCommon::~SegmentInfoCommon()
{
delete this->segmentTimeline;
- delete this->initialisationSegment;
}
time_t SegmentInfoCommon::getDuration() const
@@ -70,17 +78,6 @@ void SegmentInfoCommon::setStartIndex(int startIndex)
this->startIndex = startIndex;
}
-Segment* SegmentInfoCommon::getInitialisationSegment() const
-{
- return this->initialisationSegment;
-}
-
-void SegmentInfoCommon::setInitialisationSegment(Segment *seg)
-{
- if ( seg != NULL )
- this->initialisationSegment = seg;
-}
-
void SegmentInfoCommon::appendBaseURL(const std::string &url)
{
this->baseURLs.push_back( url );
diff --git a/modules/demux/dash/mpd/SegmentInfoCommon.h b/modules/demux/dash/mpd/SegmentInfoCommon.h
index 2e4dbda..ec0e853 100644
--- a/modules/demux/dash/mpd/SegmentInfoCommon.h
+++ b/modules/demux/dash/mpd/SegmentInfoCommon.h
@@ -29,6 +29,7 @@
#include <list>
#include <ctime>
#include "ICanonicalUrl.hpp"
+#include "Properties.hpp"
namespace dash
{
@@ -37,7 +38,16 @@ namespace dash
class Segment;
class SegmentTimeline;
- class SegmentInfoCommon : public ICanonicalUrl
+ class Initializable
+ {
+ public:
+ Initializable();
+ ~Initializable();
+ Property<Segment *> initialisationSegment;
+ };
+
+ class SegmentInfoCommon : public ICanonicalUrl,
+ public Initializable
{
public:
SegmentInfoCommon( ICanonicalUrl *parent = NULL );
@@ -46,8 +56,6 @@ namespace dash
void setDuration( time_t duration );
int getStartIndex() const;
void setStartIndex( int startIndex );
- Segment* getInitialisationSegment() const;
- void setInitialisationSegment( Segment* seg );
void appendBaseURL( const std::string& url );
const SegmentTimeline* getSegmentTimeline() const;
void setSegmentTimeline( const SegmentTimeline *segTl );
@@ -56,7 +64,6 @@ namespace dash
private:
time_t duration;
int startIndex;
- Segment* initialisationSegment;
std::list<std::string> baseURLs;
const SegmentTimeline* segmentTimeline;
};
diff --git a/modules/demux/dash/mpd/SegmentInformation.cpp b/modules/demux/dash/mpd/SegmentInformation.cpp
index 53ff8c7..8bbc2d6 100644
--- a/modules/demux/dash/mpd/SegmentInformation.cpp
+++ b/modules/demux/dash/mpd/SegmentInformation.cpp
@@ -121,13 +121,13 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
switch(type)
{
case INFOTYPE_INIT:
- if( segBase && segBase->getInitSegment() )
+ if( segBase && segBase->initialisationSegment.Get() )
{
- segment = segBase->getInitSegment();
+ segment = segBase->initialisationSegment.Get();
}
- else if( segList && segList->getInitialisationSegment() )
+ else if( segList && segList->initialisationSegment.Get() )
{
- segment = segList->getInitialisationSegment();
+ segment = segList->initialisationSegment.Get();
}
else if( inheritSegmentTemplate(INFOTYPE_INIT) )
{
More information about the vlc-commits
mailing list