void IsoffMainParser::setRepresentations (Node *adaptationSetNode, AdaptationSet *adaptationSet) { std::vector<Node *> representations = DOMHelper::getElementByTagName(adaptationSetNode, "Representation", false); for(size_t i = 0; i < representations.size(); i++) { Representation *currentRepresentation = new Representation(adaptationSet, getMPD()); Node *repNode = representations.at(i); std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL"); if(!baseUrls.empty()) currentRepresentation->baseUrl.Set(new Url(baseUrls.front()->getText())); if(repNode->hasAttribute("id")) currentRepresentation->setId(repNode->getAttributeValue("id")); if(repNode->hasAttribute("width")) currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str())); if(repNode->hasAttribute("height")) currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str())); if(repNode->hasAttribute("bandwidth")) currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str())); if(repNode->hasAttribute("mimeType")) currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType")); parseSegmentInformation(repNode, currentRepresentation); adaptationSet->addRepresentation(currentRepresentation); } }
void IsoffMainParser::setRepresentations (Node *adaptationSetNode, AdaptationSet *adaptationSet) { std::vector<Node *> representations = DOMHelper::getElementByTagName(adaptationSetNode, "Representation", false); uint64_t nextid = 0; for(size_t i = 0; i < representations.size(); i++) { Representation *currentRepresentation = new Representation(adaptationSet); Node *repNode = representations.at(i); std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL"); if(!baseUrls.empty()) currentRepresentation->baseUrl.Set(new Url(baseUrls.front()->getText())); if(repNode->hasAttribute("id")) currentRepresentation->setID(ID(repNode->getAttributeValue("id"))); if(repNode->hasAttribute("width")) currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str())); if(repNode->hasAttribute("height")) currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str())); if(repNode->hasAttribute("bandwidth")) currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str())); if(repNode->hasAttribute("mimeType")) currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType")); if(repNode->hasAttribute("codecs")) { std::list<std::string> list = Helper::tokenize(repNode->getAttributeValue("codecs"), ','); std::list<std::string>::const_iterator it; for(it=list.begin(); it!=list.end(); ++it) { std::size_t pos = (*it).find_first_of('.', 0); if(pos != std::string::npos) currentRepresentation->addCodec((*it).substr(0, pos)); else currentRepresentation->addCodec(*it); } } size_t i_total = parseSegmentInformation(repNode, currentRepresentation, &nextid); /* Empty Representation with just baseurl (ex: subtitles) */ if(i_total == 0 && (currentRepresentation->baseUrl.Get() && !currentRepresentation->baseUrl.Get()->empty()) && adaptationSet->getSegment(SegmentInformation::INFOTYPE_MEDIA, 0) == NULL) { SegmentBase *base = new (std::nothrow) SegmentBase(currentRepresentation); if(base) currentRepresentation->setSegmentBase(base); } adaptationSet->addRepresentation(currentRepresentation); } }
Representation * M3U8Parser::createRepresentation(BaseAdaptationSet *adaptSet, const AttributesTag * tag) { const Attribute *uriAttr = tag->getAttributeByName("URI"); const Attribute *bwAttr = tag->getAttributeByName("BANDWIDTH"); const Attribute *codecsAttr = tag->getAttributeByName("CODECS"); const Attribute *resAttr = tag->getAttributeByName("RESOLUTION"); Representation *rep = new (std::nothrow) Representation(adaptSet); if(rep) { if(uriAttr) { std::string uri; if(tag->getType() == AttributesTag::EXTXMEDIA) { uri = uriAttr->quotedString(); } else { uri = uriAttr->value; } rep->setID(uri); rep->setPlaylistUrl(uri); if(uri.find('/') != std::string::npos) { uri = Helper::getDirectoryPath(uri); if(!uri.empty()) rep->baseUrl.Set(new Url(uri.append("/"))); } } if(bwAttr) rep->setBandwidth(bwAttr->decimal()); if(codecsAttr) setFormatFromCodecs(rep, codecsAttr->quotedString()); if(resAttr) { std::pair<int, int> res = resAttr->getResolution(); if(res.first * res.second) { rep->setWidth(res.first); rep->setHeight(res.second); } } } return rep; }
void IsoffMainParser::setRepresentations (Node *adaptationSetNode, AdaptationSet *adaptationSet) { std::vector<Node *> representations = DOMHelper::getElementByTagName(adaptationSetNode, "Representation", false); for(size_t i = 0; i < representations.size(); i++) { Representation *currentRepresentation = new Representation(adaptationSet); Node *repNode = representations.at(i); std::vector<Node *> baseUrls = DOMHelper::getChildElementByTagName(repNode, "BaseURL"); if(!baseUrls.empty()) currentRepresentation->baseUrl.Set(new Url(baseUrls.front()->getText())); if(repNode->hasAttribute("id")) currentRepresentation->setId(repNode->getAttributeValue("id")); if(repNode->hasAttribute("width")) currentRepresentation->setWidth(atoi(repNode->getAttributeValue("width").c_str())); if(repNode->hasAttribute("height")) currentRepresentation->setHeight(atoi(repNode->getAttributeValue("height").c_str())); if(repNode->hasAttribute("bandwidth")) currentRepresentation->setBandwidth(atoi(repNode->getAttributeValue("bandwidth").c_str())); if(repNode->hasAttribute("mimeType")) currentRepresentation->setMimeType(repNode->getAttributeValue("mimeType")); if(repNode->hasAttribute("codecs")) { std::list<std::string> list = Helper::tokenize(repNode->getAttributeValue("codecs"), ','); std::list<std::string>::const_iterator it; for(it=list.begin(); it!=list.end(); ++it) { std::size_t pos = (*it).find_first_of('.', 0); if(pos != std::string::npos) currentRepresentation->addCodec((*it).substr(0, pos)); else currentRepresentation->addCodec(*it); } } parseSegmentInformation(repNode, currentRepresentation); adaptationSet->addRepresentation(currentRepresentation); } }