OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "media/webm/webm_info_parser.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "media/webm/webm_constants.h" |
| 9 |
| 10 namespace media { |
| 11 |
| 12 WebMInfoParser::WebMInfoParser() |
| 13 : timecode_scale_(-1), |
| 14 duration_(-1) { |
| 15 } |
| 16 |
| 17 WebMInfoParser::~WebMInfoParser() {} |
| 18 |
| 19 int WebMInfoParser::Parse(const uint8* buf, int size) { |
| 20 return WebMParseListElement(buf, size, kWebMIdInfo, 1, this); |
| 21 } |
| 22 |
| 23 int64 WebMInfoParser::timecode_scale() const { return timecode_scale_; } |
| 24 |
| 25 double WebMInfoParser::duration() const { return duration_; } |
| 26 |
| 27 bool WebMInfoParser::OnListStart(int id) { return true; } |
| 28 |
| 29 bool WebMInfoParser::OnListEnd(int id) { |
| 30 if (id == kWebMIdInfo && timecode_scale_ == -1) { |
| 31 // Set timecode scale to default value if it isn't present in |
| 32 // the Info element. |
| 33 timecode_scale_ = kWebMDefaultTimecodeScale; |
| 34 } |
| 35 return true; |
| 36 } |
| 37 |
| 38 bool WebMInfoParser::OnUInt(int id, int64 val) { |
| 39 if (id != kWebMIdTimecodeScale) |
| 40 return true; |
| 41 |
| 42 if (timecode_scale_ != -1) { |
| 43 VLOG(1) << "Multiple values for id " << std::hex << id << " specified"; |
| 44 return false; |
| 45 } |
| 46 |
| 47 timecode_scale_ = val; |
| 48 return true; |
| 49 } |
| 50 |
| 51 bool WebMInfoParser::OnFloat(int id, double val) { |
| 52 if (id != kWebMIdDuration) { |
| 53 VLOG(1) << "Unexpected float for id" << std::hex << id; |
| 54 return false; |
| 55 } |
| 56 |
| 57 if (duration_ != -1) { |
| 58 VLOG(1) << "Multiple values for duration."; |
| 59 return false; |
| 60 } |
| 61 |
| 62 duration_ = val; |
| 63 return true; |
| 64 } |
| 65 |
| 66 bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) { |
| 67 return true; |
| 68 } |
| 69 |
| 70 bool WebMInfoParser::OnString(int id, const std::string& str) { |
| 71 return true; |
| 72 } |
| 73 |
| 74 bool WebMInfoParser::OnSimpleBlock(int track_num, int timecode, int flags, |
| 75 const uint8* data, int size) { |
| 76 return false; |
| 77 } |
| 78 |
| 79 } // namespace media |
OLD | NEW |