Commit 01e36efe authored by Francois Cartegnie's avatar Francois Cartegnie

demux: dash: simplify integer parsing using templates

parent 2860a192
...@@ -115,28 +115,13 @@ size_t IsoffMainParser::parseSegmentTemplate(Node *templateNode, SegmentInformat ...@@ -115,28 +115,13 @@ size_t IsoffMainParser::parseSegmentTemplate(Node *templateNode, SegmentInformat
mediaTemplate->setSourceUrl(mediaurl); mediaTemplate->setSourceUrl(mediaurl);
if(templateNode->hasAttribute("startNumber")) if(templateNode->hasAttribute("startNumber"))
{ mediaTemplate->setStartIndex(Integer<uint64_t>(templateNode->getAttributeValue("startNumber")));
std::istringstream in(templateNode->getAttributeValue("startNumber"));
size_t i;
in >> i;
mediaTemplate->setStartIndex(i);
}
if(templateNode->hasAttribute("duration")) if(templateNode->hasAttribute("duration"))
{ mediaTemplate->duration.Set(Integer<mtime_t>(templateNode->getAttributeValue("duration")));
std::istringstream in(templateNode->getAttributeValue("duration"));
size_t i;
in >> i;
mediaTemplate->duration.Set(i);
}
if(templateNode->hasAttribute("timescale")) if(templateNode->hasAttribute("timescale"))
{ mediaTemplate->timescale.Set(Integer<uint64_t>(templateNode->getAttributeValue("timescale")));
std::istringstream in(templateNode->getAttributeValue("timescale"));
size_t i;
in >> i;
mediaTemplate->timescale.Set(i);
}
InitSegmentTemplate *initTemplate = NULL; InitSegmentTemplate *initTemplate = NULL;
...@@ -164,12 +149,7 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation * ...@@ -164,12 +149,7 @@ size_t IsoffMainParser::parseSegmentInformation(Node *node, SegmentInformation *
if(node->hasAttribute("bitstreamSwitching")) if(node->hasAttribute("bitstreamSwitching"))
info->setBitstreamSwitching(node->getAttributeValue("bitstreamSwitching") == "true"); info->setBitstreamSwitching(node->getAttributeValue("bitstreamSwitching") == "true");
if(node->hasAttribute("timescale")) if(node->hasAttribute("timescale"))
{ info->timescale.Set(Integer<uint64_t>(node->getAttributeValue("timescale")));
std::istringstream in(node->getAttributeValue("timescale"));
uint64_t i;
in >> i;
info->timescale.Set(i);
}
return total; return total;
} }
......
...@@ -80,6 +80,29 @@ namespace dash ...@@ -80,6 +80,29 @@ namespace dash
private: private:
mtime_t time; mtime_t time;
}; };
template<typename T> class Integer
{
public:
Integer(const std::string &str)
{
try
{
std::istringstream in(str);
in >> value;
} catch (int) {
value = 0;
}
}
operator T() const
{
return value;
}
private:
T value;
};
} }
} }
......
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