[vlc-commits] demux: dash: replace duplicate tokens
Francois Cartegnie
git at videolan.org
Tue Jul 31 09:03:02 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 31 09:01:21 2018 +0200| [73acf3fec0bf49a11c9b0f7d912142bc91f8b02c] | committer: Francois Cartegnie
demux: dash: replace duplicate tokens
refs #20868
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=73acf3fec0bf49a11c9b0f7d912142bc91f8b02c
---
modules/demux/dash/mpd/Representation.cpp | 111 +++++++++++++++++-------------
1 file changed, 62 insertions(+), 49 deletions(-)
diff --git a/modules/demux/dash/mpd/Representation.cpp b/modules/demux/dash/mpd/Representation.cpp
index 8e5116b76a..8954d4a7c1 100644
--- a/modules/demux/dash/mpd/Representation.cpp
+++ b/modules/demux/dash/mpd/Representation.cpp
@@ -96,67 +96,80 @@ std::string Representation::contextualize(size_t number, const std::string &comp
const MediaSegmentTemplate *templ = dynamic_cast<const MediaSegmentTemplate *>(basetempl);
- if(templ)
+ bool replaced;
+ do
{
- pos = ret.find("$Time$");
- if(pos != std::string::npos)
+ replaced = false;
+ if(templ)
{
- std::stringstream ss;
- ss.imbue(std::locale("C"));
- ss << getScaledTimeBySegmentNumber(number, templ);
- ret.replace(pos, std::string("$Time$").length(), ss.str());
+ pos = ret.find("$Time$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss.imbue(std::locale("C"));
+ ss << getScaledTimeBySegmentNumber(number, templ);
+ ret.replace(pos, std::string("$Time$").length(), ss.str());
+ replaced = true;
+ }
+
+ pos = ret.find("$Number$");
+ if(pos != std::string::npos)
+ {
+ std::stringstream ss;
+ ss.imbue(std::locale("C"));
+ ss << number;
+ ret.replace(pos, std::string("$Number$").length(), ss.str());
+ replaced = true;
+ }
+ else
+ {
+ pos = ret.find("$Number%");
+ size_t tokenlength = std::string("$Number%").length();
+ size_t fmtstart = pos + tokenlength;
+ if(pos != std::string::npos && fmtstart < ret.length())
+ {
+ size_t fmtend = ret.find('$', fmtstart);
+ if(fmtend != std::string::npos)
+ {
+ std::istringstream iss(ret.substr(fmtstart, fmtend - fmtstart + 1));
+ iss.imbue(std::locale("C"));
+ try
+ {
+ size_t width;
+ iss >> width;
+ if (iss.peek() != '$' && iss.peek() != 'd')
+ throw VLC_EGENERIC;
+ std::stringstream oss;
+ oss.imbue(std::locale("C"));
+ oss.width(width); /* set format string length */
+ oss.fill('0');
+ oss << number;
+ ret.replace(pos, fmtend - pos + 1, oss.str());
+ replaced = true;
+ } catch(int) {}
+ }
+ }
+ }
}
- pos = ret.find("$Number$");
+ pos = ret.find("$Bandwidth$");
if(pos != std::string::npos)
{
std::stringstream ss;
ss.imbue(std::locale("C"));
- ss << number;
- ret.replace(pos, std::string("$Number$").length(), ss.str());
+ ss << getBandwidth();
+ ret.replace(pos, std::string("$Bandwidth$").length(), ss.str());
+ replaced = true;
}
- else
+
+ pos = ret.find("$RepresentationID$");
+ if(pos != std::string::npos)
{
- pos = ret.find("$Number%");
- size_t tokenlength = std::string("$Number%").length();
- size_t fmtstart = pos + tokenlength;
- if(pos != std::string::npos && fmtstart < ret.length())
- {
- size_t fmtend = ret.find('$', fmtstart);
- if(fmtend != std::string::npos)
- {
- std::istringstream iss(ret.substr(fmtstart, fmtend - fmtstart + 1));
- iss.imbue(std::locale("C"));
- try
- {
- size_t width;
- iss >> width;
- if (iss.peek() != '$' && iss.peek() != 'd')
- throw VLC_EGENERIC;
- std::stringstream oss;
- oss.imbue(std::locale("C"));
- oss.width(width); /* set format string length */
- oss.fill('0');
- oss << number;
- ret.replace(pos, fmtend - pos + 1, oss.str());
- } catch(int) {}
- }
- }
+ ret.replace(pos, std::string("$RepresentationID$").length(), id.str());
+ replaced = true;
}
- }
-
- pos = ret.find("$Bandwidth$");
- if(pos != std::string::npos)
- {
- std::stringstream ss;
- ss.imbue(std::locale("C"));
- ss << getBandwidth();
- ret.replace(pos, std::string("$Bandwidth$").length(), ss.str());
- }
- pos = ret.find("$RepresentationID$");
- if(pos != std::string::npos)
- ret.replace(pos, std::string("$RepresentationID$").length(), id.str());
+ } while(replaced);
return ret;
}
More information about the vlc-commits
mailing list