[vlc-commits] demux: dash: replace duplicate tokens
Francois Cartegnie
git at videolan.org
Mon Aug 6 12:02:50 CEST 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Jul 31 09:01:21 2018 +0200| [e8529a76099134f7ca0f8b1f477cf3cbbe83181d] | committer: Francois Cartegnie
demux: dash: replace duplicate tokens
refs #20868
(cherry picked from commit 73acf3fec0bf49a11c9b0f7d912142bc91f8b02c)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=e8529a76099134f7ca0f8b1f477cf3cbbe83181d
---
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 d49af4df28..af2d2637b1 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