[vlc-commits] demux: adaptative: fix timezone and add micro seconds
Francois Cartegnie
git at videolan.org
Mon Nov 23 22:36:15 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 23 18:59:53 2015 +0100| [0fa3d8589957cb4f0bb3a6589ccb35f657521c2b] | committer: Francois Cartegnie
demux: adaptative: fix timezone and add micro seconds
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0fa3d8589957cb4f0bb3a6589ccb35f657521c2b
---
modules/demux/adaptative/tools/Conversions.cpp | 50 +++++++++++++++++-------
modules/demux/adaptative/tools/Conversions.hpp | 5 ++-
modules/demux/dash/mpd/IsoffMainParser.cpp | 2 +-
3 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/modules/demux/adaptative/tools/Conversions.cpp b/modules/demux/adaptative/tools/Conversions.cpp
index 5151f3e..9065da3 100644
--- a/modules/demux/adaptative/tools/Conversions.cpp
+++ b/modules/demux/adaptative/tools/Conversions.cpp
@@ -57,8 +57,8 @@ static int64_t vlc_timegm( int i_year, int i_month, int i_mday, int i_hour, int
UTCTime::UTCTime(const std::string &str)
{
- enum { YEAR = 0, MON, DAY, HOUR, MIN, SEC, TZ };
- int values[7] = {0};
+ enum { YEAR = 0, MON, DAY, HOUR, MIN, SEC, MSEC, TZ };
+ int values[8] = {0};
std::istringstream in(str);
try
@@ -79,28 +79,50 @@ UTCTime::UTCTime(const std::string &str)
in >> values[i];
}
}
+ if(!in.eof() && in.peek() == '.')
+ {
+ in.ignore(1);
+ in >> values[MSEC];
+ }
/* Timezone */
- if (!in.eof() && in.peek() == 'Z')
+ if(!in.eof() && in.peek() == 'Z')
+ {
+ in.ignore(1);
+ }
+ else if (!in.eof() && (in.peek() == '+' || in.peek() == '-'))
{
+ int i, tz = (in.peek() == '+') ? -60 : +60;
in.ignore(1);
- while(!in.eof())
+ if(!in.eof())
{
- if(in.peek() == '+')
- continue;
- in >> values[TZ];
- break;
+ in >> i;
+ tz *= i;
+ in.ignore(1);
+ if(!in.eof())
+ {
+ in >> i;
+ tz += i;
+ }
+ values[TZ] = tz;
}
}
- time = vlc_timegm( values[YEAR] - 1900, values[MON] - 1, values[DAY],
- values[HOUR], values[MIN], values[SEC] );
- time += values[TZ] * 3600;
+ t = vlc_timegm( values[YEAR] - 1900, values[MON] - 1, values[DAY],
+ values[HOUR], values[MIN], values[SEC] );
+ t += values[TZ] * 60;
+ t *= CLOCK_FREQ;
+ t += values[MSEC] * 1000;
} catch(int) {
- time = 0;
+ t = 0;
}
}
-UTCTime::operator time_t () const
+time_t UTCTime::time() const
{
- return time;
+ return t / CLOCK_FREQ;
+}
+
+mtime_t UTCTime::mtime() const
+{
+ return t;
}
diff --git a/modules/demux/adaptative/tools/Conversions.hpp b/modules/demux/adaptative/tools/Conversions.hpp
index 542629c..9068445 100644
--- a/modules/demux/adaptative/tools/Conversions.hpp
+++ b/modules/demux/adaptative/tools/Conversions.hpp
@@ -42,10 +42,11 @@ class UTCTime
{
public:
UTCTime(const std::string&);
- operator time_t() const;
+ time_t time() const;
+ mtime_t mtime() const;
private:
- time_t time;
+ mtime_t t;
};
template<typename T> class Integer
diff --git a/modules/demux/dash/mpd/IsoffMainParser.cpp b/modules/demux/dash/mpd/IsoffMainParser.cpp
index de278bc..37402c7 100644
--- a/modules/demux/dash/mpd/IsoffMainParser.cpp
+++ b/modules/demux/dash/mpd/IsoffMainParser.cpp
@@ -117,7 +117,7 @@ void IsoffMainParser::parseMPDAttributes (MPD *mpd, xml::Node *node)
it = attr.find("availabilityStartTime");
if(it != attr.end())
- mpd->availabilityStartTime.Set(UTCTime(it->second));
+ mpd->availabilityStartTime.Set(UTCTime(it->second).time());
it = attr.find("timeShiftBufferDepth");
if(it != attr.end())
More information about the vlc-commits
mailing list