OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/formats/webm/webm_info_parser.h" | 5 #include "media/formats/webm/webm_info_parser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/formats/webm/webm_constants.h" | 8 #include "media/formats/webm/webm_constants.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (duration_ != -1) { | 67 if (duration_ != -1) { |
68 DVLOG(1) << "Multiple values for duration."; | 68 DVLOG(1) << "Multiple values for duration."; |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 duration_ = val; | 72 duration_ = val; |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) { | 76 bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) { |
| 77 if (id == kWebMIdDateUTC) { |
| 78 if (size != 8) |
| 79 return false; |
| 80 |
| 81 int64 date_in_nanoseconds = 0; |
| 82 for (int i = 0; i < size; ++i) |
| 83 date_in_nanoseconds = (date_in_nanoseconds << 8) | data[i]; |
| 84 |
| 85 base::Time::Exploded exploded_epoch; |
| 86 exploded_epoch.year = 2001; |
| 87 exploded_epoch.month = 1; |
| 88 exploded_epoch.day_of_month = 1; |
| 89 exploded_epoch.hour = 0; |
| 90 exploded_epoch.minute = 0; |
| 91 exploded_epoch.second = 0; |
| 92 exploded_epoch.millisecond = 0; |
| 93 date_utc_ = base::Time::FromUTCExploded(exploded_epoch) + |
| 94 base::TimeDelta::FromMicroseconds(date_in_nanoseconds / 1000); |
| 95 } |
77 return true; | 96 return true; |
78 } | 97 } |
79 | 98 |
80 bool WebMInfoParser::OnString(int id, const std::string& str) { | 99 bool WebMInfoParser::OnString(int id, const std::string& str) { |
81 return true; | 100 return true; |
82 } | 101 } |
83 | 102 |
84 } // namespace media | 103 } // namespace media |
OLD | NEW |