Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1158)

Side by Side Diff: media/formats/webm/webm_info_parser.cc

Issue 231283005: Add live mode detection in WebM MediaSource parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 const int kDateUTCSize = 8;
79 if (size != kDateUTCSize) {
80 DVLOG(1) << "Invalid DateUTC size: " << size;
81 return false;
82 }
83
84 // Parse 64-bit big-endian integer.
85 int64 date_value = 0;
86 for (int i = 0; i < kDateUTCSize; ++i) {
87 date_value = (date_value << 8) | data[i];
88 }
89
90 // DateUTC is specified in nanoseconds from 0:00 on January 1st, 2001.
91 base::Time::Exploded millennium_exploded;
92 memset(&millennium_exploded, 0, sizeof(millennium_exploded));
93 millennium_exploded.year = 2001;
94 millennium_exploded.month = 1;
95 millennium_exploded.day_of_month = 1;
96 date_utc_ = base::Time::FromUTCExploded(millennium_exploded) +
97 base::TimeDelta::FromMicroseconds(date_value / 1000LL);
98 }
77 return true; 99 return true;
78 } 100 }
79 101
80 bool WebMInfoParser::OnString(int id, const std::string& str) { 102 bool WebMInfoParser::OnString(int id, const std::string& str) {
81 return true; 103 return true;
82 } 104 }
83 105
84 } // namespace media 106 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698