Commit 0fa3d858 authored by Francois Cartegnie's avatar Francois Cartegnie

demux: adaptative: fix timezone and add micro seconds

parent a572661b
...@@ -57,8 +57,8 @@ static int64_t vlc_timegm( int i_year, int i_month, int i_mday, int i_hour, int ...@@ -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) UTCTime::UTCTime(const std::string &str)
{ {
enum { YEAR = 0, MON, DAY, HOUR, MIN, SEC, TZ }; enum { YEAR = 0, MON, DAY, HOUR, MIN, SEC, MSEC, TZ };
int values[7] = {0}; int values[8] = {0};
std::istringstream in(str); std::istringstream in(str);
try try
...@@ -79,28 +79,50 @@ UTCTime::UTCTime(const std::string &str) ...@@ -79,28 +79,50 @@ UTCTime::UTCTime(const std::string &str)
in >> values[i]; in >> values[i];
} }
} }
if(!in.eof() && in.peek() == '.')
{
in.ignore(1);
in >> values[MSEC];
}
/* Timezone */ /* 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); in.ignore(1);
while(!in.eof()) if(!in.eof())
{ {
if(in.peek() == '+') in >> i;
continue; tz *= i;
in >> values[TZ]; in.ignore(1);
break; if(!in.eof())
{
in >> i;
tz += i;
}
values[TZ] = tz;
} }
} }
time = vlc_timegm( values[YEAR] - 1900, values[MON] - 1, values[DAY], t = vlc_timegm( values[YEAR] - 1900, values[MON] - 1, values[DAY],
values[HOUR], values[MIN], values[SEC] ); values[HOUR], values[MIN], values[SEC] );
time += values[TZ] * 3600; t += values[TZ] * 60;
t *= CLOCK_FREQ;
t += values[MSEC] * 1000;
} catch(int) { } 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;
} }
...@@ -42,10 +42,11 @@ class UTCTime ...@@ -42,10 +42,11 @@ class UTCTime
{ {
public: public:
UTCTime(const std::string&); UTCTime(const std::string&);
operator time_t() const; time_t time() const;
mtime_t mtime() const;
private: private:
time_t time; mtime_t t;
}; };
template<typename T> class Integer template<typename T> class Integer
......
...@@ -117,7 +117,7 @@ void IsoffMainParser::parseMPDAttributes (MPD *mpd, xml::Node *node) ...@@ -117,7 +117,7 @@ void IsoffMainParser::parseMPDAttributes (MPD *mpd, xml::Node *node)
it = attr.find("availabilityStartTime"); it = attr.find("availabilityStartTime");
if(it != attr.end()) if(it != attr.end())
mpd->availabilityStartTime.Set(UTCTime(it->second)); mpd->availabilityStartTime.Set(UTCTime(it->second).time());
it = attr.find("timeShiftBufferDepth"); it = attr.find("timeShiftBufferDepth");
if(it != attr.end()) if(it != attr.end())
......
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