Commit 0fa42c75 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: add Initializable and parse SegmentList init segment

Fixes playback where Initilialization Segment is in SegmentList
parent aa9ccaaf
...@@ -251,18 +251,18 @@ void IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformatio ...@@ -251,18 +251,18 @@ void IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformatio
list->addSegment(seg); list->addSegment(seg);
info->setSegmentList(list); info->setSegmentList(list);
std::vector<Node *> initSeg = DOMHelper::getElementByTagName(segmentBaseNode, "Initialization", false); Node *initSeg = DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization");
if(!initSeg.empty()) if(initSeg)
{ {
SegmentBase *base = new SegmentBase(); SegmentBase *base = new SegmentBase();
setInitSegment(segmentBaseNode, base); parseInitSegment(initSeg, base);
info->setSegmentBase(base); info->setSegmentBase(base);
} }
} }
else else
{ {
SegmentBase *base = new SegmentBase(); SegmentBase *base = new SegmentBase();
setInitSegment(segmentBaseNode, base); parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base);
info->setSegmentBase(base); info->setSegmentBase(base);
} }
} }
...@@ -277,6 +277,8 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation ...@@ -277,6 +277,8 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
SegmentList *list; SegmentList *list;
if(!segments.empty() && (list = new (std::nothrow) SegmentList())) if(!segments.empty() && (list = new (std::nothrow) SegmentList()))
{ {
parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list);
if(segListNode->hasAttribute("duration")) if(segListNode->hasAttribute("duration"))
list->setDuration(Integer<mtime_t>(segListNode->getAttributeValue("duration"))); list->setDuration(Integer<mtime_t>(segListNode->getAttributeValue("duration")));
...@@ -320,27 +322,22 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation ...@@ -320,27 +322,22 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
return total; 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);
if(initSeg.size() > 0)
{
Segment *seg = new InitSegment( currentRepresentation ); Segment *seg = new InitSegment( currentRepresentation );
seg->setSourceUrl(initSeg.at(0)->getAttributeValue("sourceURL")); seg->setSourceUrl(initNode->getAttributeValue("sourceURL"));
if(initSeg.at(0)->hasAttribute("range")) if(initNode->hasAttribute("range"))
{ {
std::string range = initSeg.at(0)->getAttributeValue("range"); std::string range = initNode->getAttributeValue("range");
size_t pos = range.find("-"); size_t pos = range.find("-");
seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str())); seg->setByteRange(atoi(range.substr(0, pos).c_str()), atoi(range.substr(pos + 1, range.size()).c_str()));
} }
base->addInitSegment(seg); init->initialisationSegment.Set(seg);
}
} }
void IsoffMainParser::parseProgramInformation(Node * node, MPD *mpd) void IsoffMainParser::parseProgramInformation(Node * node, MPD *mpd)
......
...@@ -53,7 +53,7 @@ namespace dash ...@@ -53,7 +53,7 @@ namespace dash
void setMPDAttributes (); void setMPDAttributes ();
void setAdaptationSets (dash::xml::Node *periodNode, Period *period); void setAdaptationSets (dash::xml::Node *periodNode, Period *period);
void setRepresentations (dash::xml::Node *adaptationSetNode, AdaptationSet *adaptationSet); 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 *); void parsePeriods (dash::xml::Node *);
size_t parseSegmentInformation(dash::xml::Node *, SegmentInformation *); size_t parseSegmentInformation(dash::xml::Node *, SegmentInformation *);
void parseSegmentBase (dash::xml::Node *, SegmentInformation *); void parseSegmentBase (dash::xml::Node *, SegmentInformation *);
......
...@@ -31,18 +31,9 @@ ...@@ -31,18 +31,9 @@
using namespace dash::mpd; using namespace dash::mpd;
SegmentBase::SegmentBase () : SegmentBase::SegmentBase () :
initSeg (NULL) Initializable()
{ {
} }
SegmentBase::~SegmentBase () SegmentBase::~SegmentBase ()
{ {
} }
void SegmentBase::addInitSegment (Segment *seg)
{
this->initSeg = seg;
}
Segment* SegmentBase::getInitSegment ()
{
return this->initSeg;
}
...@@ -26,22 +26,17 @@ ...@@ -26,22 +26,17 @@
#define SEGMENTBASE_H_ #define SEGMENTBASE_H_
#include "mpd/Segment.h" #include "mpd/Segment.h"
#include "mpd/SegmentInfoCommon.h"
namespace dash namespace dash
{ {
namespace mpd namespace mpd
{ {
class SegmentBase class SegmentBase : public Initializable
{ {
public: public:
SegmentBase (); SegmentBase ();
virtual ~SegmentBase (); virtual ~SegmentBase ();
void addInitSegment (Segment *seg);
Segment* getInitSegment ();
private:
Segment *initSeg;
}; };
} }
} }
......
...@@ -33,11 +33,20 @@ ...@@ -33,11 +33,20 @@
using namespace dash::mpd; using namespace dash::mpd;
Initializable::Initializable()
{
initialisationSegment.Set(NULL);
}
Initializable::~Initializable()
{
delete initialisationSegment.Get();
}
SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) : SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
ICanonicalUrl( parent ), ICanonicalUrl( parent ), Initializable(),
duration( -1 ), duration( -1 ),
startIndex( 0 ), startIndex( 0 ),
initialisationSegment( NULL ),
segmentTimeline( NULL ) segmentTimeline( NULL )
{ {
} }
...@@ -45,7 +54,6 @@ SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) : ...@@ -45,7 +54,6 @@ SegmentInfoCommon::SegmentInfoCommon( ICanonicalUrl *parent ) :
SegmentInfoCommon::~SegmentInfoCommon() SegmentInfoCommon::~SegmentInfoCommon()
{ {
delete this->segmentTimeline; delete this->segmentTimeline;
delete this->initialisationSegment;
} }
time_t SegmentInfoCommon::getDuration() const time_t SegmentInfoCommon::getDuration() const
...@@ -70,17 +78,6 @@ void SegmentInfoCommon::setStartIndex(int startIndex) ...@@ -70,17 +78,6 @@ void SegmentInfoCommon::setStartIndex(int startIndex)
this->startIndex = 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) void SegmentInfoCommon::appendBaseURL(const std::string &url)
{ {
this->baseURLs.push_back( url ); this->baseURLs.push_back( url );
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <list> #include <list>
#include <ctime> #include <ctime>
#include "ICanonicalUrl.hpp" #include "ICanonicalUrl.hpp"
#include "Properties.hpp"
namespace dash namespace dash
{ {
...@@ -37,7 +38,16 @@ namespace dash ...@@ -37,7 +38,16 @@ namespace dash
class Segment; class Segment;
class SegmentTimeline; class SegmentTimeline;
class SegmentInfoCommon : public ICanonicalUrl class Initializable
{
public:
Initializable();
~Initializable();
Property<Segment *> initialisationSegment;
};
class SegmentInfoCommon : public ICanonicalUrl,
public Initializable
{ {
public: public:
SegmentInfoCommon( ICanonicalUrl *parent = NULL ); SegmentInfoCommon( ICanonicalUrl *parent = NULL );
...@@ -46,8 +56,6 @@ namespace dash ...@@ -46,8 +56,6 @@ namespace dash
void setDuration( time_t duration ); void setDuration( time_t duration );
int getStartIndex() const; int getStartIndex() const;
void setStartIndex( int startIndex ); void setStartIndex( int startIndex );
Segment* getInitialisationSegment() const;
void setInitialisationSegment( Segment* seg );
void appendBaseURL( const std::string& url ); void appendBaseURL( const std::string& url );
const SegmentTimeline* getSegmentTimeline() const; const SegmentTimeline* getSegmentTimeline() const;
void setSegmentTimeline( const SegmentTimeline *segTl ); void setSegmentTimeline( const SegmentTimeline *segTl );
...@@ -56,7 +64,6 @@ namespace dash ...@@ -56,7 +64,6 @@ namespace dash
private: private:
time_t duration; time_t duration;
int startIndex; int startIndex;
Segment* initialisationSegment;
std::list<std::string> baseURLs; std::list<std::string> baseURLs;
const SegmentTimeline* segmentTimeline; const SegmentTimeline* segmentTimeline;
}; };
......
...@@ -121,13 +121,13 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co ...@@ -121,13 +121,13 @@ ISegment * SegmentInformation::getSegment(SegmentInfoType type, uint64_t pos) co
switch(type) switch(type)
{ {
case INFOTYPE_INIT: 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) ) else if( inheritSegmentTemplate(INFOTYPE_INIT) )
{ {
......
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