Skip to content

Commit

Permalink
demux: dash: fix parent context for init segments
Browse files Browse the repository at this point in the history
  • Loading branch information
fcartegnie committed Apr 30, 2015
1 parent 51e7ebd commit eb1dd71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
23 changes: 11 additions & 12 deletions modules/demux/dash/mpd/IsoffMainParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ IsoffMainParser::IsoffMainParser (Node *root_, stream_t *stream)
{
root = root_;
mpd = NULL;
currentRepresentation = NULL;
p_stream = stream;
}

Expand Down Expand Up @@ -229,7 +228,7 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation

for(size_t i = 0; i < representations.size(); i++)
{
this->currentRepresentation = new Representation(adaptationSet, getMPD());
Representation *currentRepresentation = new Representation(adaptationSet, getMPD());
Node *repNode = representations.at(i);

std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL");
Expand All @@ -240,13 +239,13 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation
currentRepresentation->setId(repNode->getAttributeValue("id"));

if(repNode->hasAttribute("width"))
this->currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str()));
currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str()));

if(repNode->hasAttribute("height"))
this->currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str()));
currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str()));

if(repNode->hasAttribute("bandwidth"))
this->currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str()));
currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str()));

if(repNode->hasAttribute("mimeType"))
currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType"));
Expand All @@ -269,7 +268,7 @@ void IsoffMainParser::setRepresentations (Node *adaptationSetNode, Adaptation
}
}

adaptationSet->addRepresentation(this->currentRepresentation);
adaptationSet->addRepresentation(currentRepresentation);
}
}
size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformation *info)
Expand Down Expand Up @@ -307,14 +306,14 @@ size_t IsoffMainParser::parseSegmentBase(Node * segmentBaseNode, SegmentInformat
if(initSeg)
{
SegmentBase *base = new SegmentBase();
parseInitSegment(initSeg, base);
parseInitSegment(initSeg, base, info);
info->setSegmentBase(base);
}
}
else
{
SegmentBase *base = new SegmentBase();
parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base);
parseInitSegment(DOMHelper::getFirstChildElementByName(segmentBaseNode, "Initialization"), base, info);
info->setSegmentBase(base);
}

Expand All @@ -329,9 +328,9 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
{
std::vector<Node *> segments = DOMHelper::getElementByTagName(segListNode, "SegmentURL", false);
SegmentList *list;
if(!segments.empty() && (list = new (std::nothrow) SegmentList()))
if((list = new (std::nothrow) SegmentList()))
{
parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list);
parseInitSegment(DOMHelper::getFirstChildElementByName(segListNode, "Initialization"), list, info);

if(segListNode->hasAttribute("duration"))
list->setDuration(Integer<mtime_t>(segListNode->getAttributeValue("duration")));
Expand Down Expand Up @@ -376,12 +375,12 @@ size_t IsoffMainParser::parseSegmentList(Node * segListNode, SegmentInformation
return total;
}

void IsoffMainParser::parseInitSegment(Node *initNode, Initializable<Segment> *init)
void IsoffMainParser::parseInitSegment(Node *initNode, Initializable<Segment> *init, SegmentInformation *parent)
{
if(!initNode)
return;

Segment *seg = new InitSegment( currentRepresentation );
Segment *seg = new InitSegment( parent );
seg->setSourceUrl(initNode->getAttributeValue("sourceURL"));

if(initNode->hasAttribute("range"))
Expand Down
4 changes: 1 addition & 3 deletions modules/demux/dash/mpd/IsoffMainParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ namespace dash
{
class Period;
class AdaptationSet;
class Representation;
class MPD;

using namespace adaptative::playlist;
Expand All @@ -76,7 +75,7 @@ namespace dash
void setMPDAttributes ();
void setAdaptationSets (xml::Node *periodNode, Period *period);
void setRepresentations (xml::Node *adaptationSetNode, AdaptationSet *adaptationSet);
void parseInitSegment (xml::Node *, Initializable<Segment> *);
void parseInitSegment (xml::Node *, Initializable<Segment> *, SegmentInformation *);
void parseTimeline (xml::Node *, MediaSegmentTemplate *);
void parsePeriods (xml::Node *);
size_t parseSegmentInformation(xml::Node *, SegmentInformation *);
Expand All @@ -88,7 +87,6 @@ namespace dash
xml::Node *root;
MPD *mpd;
stream_t *p_stream;
Representation *currentRepresentation;
};

class IsoTime
Expand Down

0 comments on commit eb1dd71

Please sign in to comment.