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
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)
......
......@@ -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 *);
......
......@@ -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;
}
......@@ -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;
};
}
}
......
......@@ -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 );
......
......@@ -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;
};
......
......@@ -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) )
{
......
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