Commit 9d7819b9 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: hls: fix integer reading

parent 565dd315
...@@ -179,6 +179,7 @@ int HTTPConnection::parseReply() ...@@ -179,6 +179,7 @@ int HTTPConnection::parseReply()
return VLC_ENOOBJ; return VLC_ENOOBJ;
std::istringstream ss(line.substr(9)); std::istringstream ss(line.substr(9));
ss.imbue(std::locale("C"));
int replycode; int replycode;
ss >> replycode; ss >> replycode;
if (replycode != 200 && replycode != 206) if (replycode != 200 && replycode != 206)
...@@ -239,6 +240,7 @@ void HTTPConnection::onHeader(const std::string &key, ...@@ -239,6 +240,7 @@ void HTTPConnection::onHeader(const std::string &key,
if(key == "Content-Length") if(key == "Content-Length")
{ {
std::istringstream ss(value); std::istringstream ss(value);
ss.imbue(std::locale("C"));
size_t length; size_t length;
ss >> length; ss >> length;
contentLength = length; contentLength = length;
...@@ -264,6 +266,7 @@ std::string HTTPConnection::buildRequestHeader(const std::string &path) const ...@@ -264,6 +266,7 @@ std::string HTTPConnection::buildRequestHeader(const std::string &path) const
std::string HTTPConnection::extraRequestHeaders() const std::string HTTPConnection::extraRequestHeaders() const
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
if(bytesRange.isValid()) if(bytesRange.isValid())
{ {
ss << "Range: bytes=" << bytesRange.getStartByte() << "-"; ss << "Range: bytes=" << bytesRange.getStartByte() << "-";
......
...@@ -30,6 +30,7 @@ ID::ID(const std::string &id_) ...@@ -30,6 +30,7 @@ ID::ID(const std::string &id_)
ID::ID(uint64_t id_) ID::ID(uint64_t id_)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << "default_id#" << id_; ss << "default_id#" << id_;
id = ss.str(); id = ss.str();
} }
......
...@@ -123,6 +123,7 @@ size_t ISegment::getOffset() const ...@@ -123,6 +123,7 @@ size_t ISegment::getOffset() const
void ISegment::debug(vlc_object_t *obj, int indent) const void ISegment::debug(vlc_object_t *obj, int indent) const
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << std::string(indent, ' ') << debugName << " #" << getSequenceNumber(); ss << std::string(indent, ' ') << debugName << " #" << getSequenceNumber();
ss << " url=" << getUrlSegment().toString(); ss << " url=" << getUrlSegment().toString();
if(startByte!=endByte) if(startByte!=endByte)
......
...@@ -274,6 +274,7 @@ bool SegmentTimeline::Element::contains(stime_t time) const ...@@ -274,6 +274,7 @@ bool SegmentTimeline::Element::contains(stime_t time) const
void SegmentTimeline::Element::debug(vlc_object_t *obj, int indent) const void SegmentTimeline::Element::debug(vlc_object_t *obj, int indent) const
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << std::string(indent + 1, ' ') << "Element #" << number ss << std::string(indent + 1, ' ') << "Element #" << number
<< " d=" << d << " r=" << r << " @t=" << t; << " d=" << d << " r=" << r << " @t=" << t;
msg_Dbg(obj, "%s", ss.str().c_str()); msg_Dbg(obj, "%s", ss.str().c_str());
......
...@@ -96,6 +96,7 @@ UTCTime::UTCTime(const std::string &str) ...@@ -96,6 +96,7 @@ UTCTime::UTCTime(const std::string &str)
enum { UTCTIME_YEAR = 0, UTCTIME_MON, UTCTIME_DAY, UTCTIME_HOUR, UTCTIME_MIN, UTCTIME_SEC, UTCTIME_MSEC, UTCTIME_TZ }; enum { UTCTIME_YEAR = 0, UTCTIME_MON, UTCTIME_DAY, UTCTIME_HOUR, UTCTIME_MIN, UTCTIME_SEC, UTCTIME_MSEC, UTCTIME_TZ };
int values[8] = {0}; int values[8] = {0};
std::istringstream in(str); std::istringstream in(str);
in.imbue(std::locale("C"));
try try
{ {
......
...@@ -57,6 +57,7 @@ template<typename T> class Integer ...@@ -57,6 +57,7 @@ template<typename T> class Integer
try try
{ {
std::istringstream in(str); std::istringstream in(str);
in.imbue(std::locale("C"));
in >> value; in >> value;
} catch (int) { } catch (int) {
value = 0; value = 0;
......
...@@ -102,6 +102,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -102,6 +102,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(pos != std::string::npos) if(pos != std::string::npos)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << getScaledTimeBySegmentNumber(number, templ); ss << getScaledTimeBySegmentNumber(number, templ);
ret.replace(pos, std::string("$Time$").length(), ss.str()); ret.replace(pos, std::string("$Time$").length(), ss.str());
} }
...@@ -110,6 +111,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -110,6 +111,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(pos != std::string::npos) if(pos != std::string::npos)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << getLiveTemplateNumberOffset(number, templ); ss << getLiveTemplateNumberOffset(number, templ);
ret.replace(pos, std::string("$Number$").length(), ss.str()); ret.replace(pos, std::string("$Number$").length(), ss.str());
} }
...@@ -124,6 +126,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -124,6 +126,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(fmtend != std::string::npos) if(fmtend != std::string::npos)
{ {
std::istringstream iss(ret.substr(fmtstart, fmtend - fmtstart + 1)); std::istringstream iss(ret.substr(fmtstart, fmtend - fmtstart + 1));
iss.imbue(std::locale("C"));
try try
{ {
size_t width; size_t width;
...@@ -131,6 +134,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -131,6 +134,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if (iss.peek() != '$' && iss.peek() != 'd') if (iss.peek() != '$' && iss.peek() != 'd')
throw VLC_EGENERIC; throw VLC_EGENERIC;
std::stringstream oss; std::stringstream oss;
oss.imbue(std::locale("C"));
oss.width(width); /* set format string length */ oss.width(width); /* set format string length */
oss.fill('0'); oss.fill('0');
oss << getLiveTemplateNumberOffset(number, templ); oss << getLiveTemplateNumberOffset(number, templ);
...@@ -145,6 +149,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -145,6 +149,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(pos != std::string::npos) if(pos != std::string::npos)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << getBandwidth(); ss << getBandwidth();
ret.replace(pos, std::string("$Bandwidth$").length(), ss.str()); ret.replace(pos, std::string("$Bandwidth$").length(), ss.str());
} }
......
...@@ -136,6 +136,7 @@ void HLSSegment::setEncryption(SegmentEncryption &enc) ...@@ -136,6 +136,7 @@ void HLSSegment::setEncryption(SegmentEncryption &enc)
void HLSSegment::debug(vlc_object_t *obj, int indent) const void HLSSegment::debug(vlc_object_t *obj, int indent) const
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << std::string(indent, ' ') << debugName << ss << std::string(indent, ' ') << debugName <<
" #" << (getSequenceNumber() - Segment::SEQUENCE_FIRST) << " #" << (getSequenceNumber() - Segment::SEQUENCE_FIRST) <<
" url=" << getUrlSegment().toString(); " url=" << getUrlSegment().toString();
......
...@@ -37,6 +37,7 @@ Attribute::Attribute(const std::string &name_, const std::string &value_) ...@@ -37,6 +37,7 @@ Attribute::Attribute(const std::string &name_, const std::string &value_)
uint64_t Attribute::decimal() const uint64_t Attribute::decimal() const
{ {
std::istringstream is(value); std::istringstream is(value);
is.imbue(std::locale("C"));
uint64_t ret; uint64_t ret;
is >> ret; is >> ret;
return ret; return ret;
...@@ -72,6 +73,7 @@ std::pair<std::size_t,std::size_t> Attribute::getByteRange() const ...@@ -72,6 +73,7 @@ std::pair<std::size_t,std::size_t> Attribute::getByteRange() const
std::size_t length = 0; std::size_t length = 0;
std::size_t offset = 0; std::size_t offset = 0;
std::istringstream is(value); std::istringstream is(value);
is.imbue(std::locale("C"));
if(!is.eof()) if(!is.eof())
{ {
...@@ -92,6 +94,7 @@ std::pair<int, int> Attribute::getResolution() const ...@@ -92,6 +94,7 @@ std::pair<int, int> Attribute::getResolution() const
int w = 0, h = 0; int w = 0, h = 0;
std::istringstream is(value); std::istringstream is(value);
is.imbue(std::locale("C"));
if(!is.eof()) if(!is.eof())
{ {
is >> w; is >> w;
......
...@@ -56,6 +56,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -56,6 +56,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(pos != std::string::npos) if(pos != std::string::npos)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << templ->segmentTimeline.Get()->getScaledPlaybackTimeByElementNumber(number); ss << templ->segmentTimeline.Get()->getScaledPlaybackTimeByElementNumber(number);
ret.replace(pos, std::string("{start_time}").length(), ss.str()); ret.replace(pos, std::string("{start_time}").length(), ss.str());
} }
...@@ -67,6 +68,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp ...@@ -67,6 +68,7 @@ std::string Representation::contextualize(size_t number, const std::string &comp
if(pos != std::string::npos) if(pos != std::string::npos)
{ {
std::stringstream ss; std::stringstream ss;
ss.imbue(std::locale("C"));
ss << getBandwidth(); ss << getBandwidth();
ret.replace(pos, std::string("{bitrate}").length(), ss.str()); ret.replace(pos, std::string("{bitrate}").length(), ss.str());
} }
......
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