- Representation *rep = new Representation;
- this->setSegmentBase(representations.at(i), rep);
- this->setSegmentList(representations.at(i), rep);
- rep->setBandwidth(atoi(representations.at(i)->getAttributeValue("bandwidth").c_str()));
- adaptationSet->addRepresentation(rep);
+ this->currentRepresentation = new Representation(adaptationSet, getMPD());
+ Node *repNode = representations.at(i);
+
+ std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL");
+ if(!baseUrls.empty())
+ currentRepresentation->setBaseUrl( new BaseUrl( baseUrls.front()->getText() ) );
+
+ if(repNode->hasAttribute("id"))
+ currentRepresentation->setId(repNode->getAttributeValue("id"));
+
+ if(repNode->hasAttribute("width"))
+ this->currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str()));
+
+ if(repNode->hasAttribute("height"))
+ this->currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str()));
+
+ if(repNode->hasAttribute("bandwidth"))
+ this->currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str()));
+
+ if(repNode->hasAttribute("mimeType"))
+ currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType"));
+
+ size_t totalmediasegments = parseSegmentInformation(repNode, currentRepresentation);
+ if(!totalmediasegments)
+ {
+ /* unranged & segment less representation, add fake segment */
+ SegmentList *list = new SegmentList();
+ Segment *seg = new Segment(currentRepresentation);
+ if(list && seg)
+ {
+ list->addSegment(seg);
+ currentRepresentation->setSegmentList(list);
+ }
+ else
+ {
+ delete seg;
+ delete list;
+ }
+ }
+
+ adaptationSet->addRepresentation(this->currentRepresentation);