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

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

Issue 8921010: Revert 114030 - Adding support for incremental cluster parsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
« no previous file with comments | « media/webm/webm_constants.h ('k') | media/webm/webm_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/webm/webm_info_parser.h" 5 #include "media/webm/webm_info_parser.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/webm/webm_constants.h" 8 #include "media/webm/webm_constants.h"
9 9
10 namespace media { 10 namespace media {
11 11
12 WebMInfoParser::WebMInfoParser() 12 WebMInfoParser::WebMInfoParser()
13 : timecode_scale_(-1), 13 : timecode_scale_(-1),
14 duration_(-1) { 14 duration_(-1) {
15 } 15 }
16 16
17 WebMInfoParser::~WebMInfoParser() {} 17 WebMInfoParser::~WebMInfoParser() {}
18 18
19 int WebMInfoParser::Parse(const uint8* buf, int size) { 19 int WebMInfoParser::Parse(const uint8* buf, int size) {
20 timecode_scale_ = -1; 20 return WebMParseListElement(buf, size, kWebMIdInfo, 1, this);
21 duration_ = -1;
22
23 WebMListParser parser(kWebMIdInfo);
24 int result = parser.Parse(buf, size, this);
25
26 if (result <= 0)
27 return result;
28
29 // For now we do all or nothing parsing.
30 return parser.IsParsingComplete() ? result : 0;
31 } 21 }
32 22
33 bool WebMInfoParser::OnListStart(int id) { return true; } 23 bool WebMInfoParser::OnListStart(int id) { return true; }
34 24
35 bool WebMInfoParser::OnListEnd(int id) { 25 bool WebMInfoParser::OnListEnd(int id) {
36 if (id == kWebMIdInfo && timecode_scale_ == -1) { 26 if (id == kWebMIdInfo && timecode_scale_ == -1) {
37 // Set timecode scale to default value if it isn't present in 27 // Set timecode scale to default value if it isn't present in
38 // the Info element. 28 // the Info element.
39 timecode_scale_ = kWebMDefaultTimecodeScale; 29 timecode_scale_ = kWebMDefaultTimecodeScale;
40 } 30 }
41 return true; 31 return true;
42 } 32 }
43 33
44 bool WebMInfoParser::OnUInt(int id, int64 val) { 34 bool WebMInfoParser::OnUInt(int id, int64 val) {
45 if (id != kWebMIdTimecodeScale) 35 if (id != kWebMIdTimecodeScale)
46 return true; 36 return true;
47 37
48 if (timecode_scale_ != -1) { 38 if (timecode_scale_ != -1) {
49 DVLOG(1) << "Multiple values for id " << std::hex << id << " specified"; 39 VLOG(1) << "Multiple values for id " << std::hex << id << " specified";
50 return false; 40 return false;
51 } 41 }
52 42
53 timecode_scale_ = val; 43 timecode_scale_ = val;
54 return true; 44 return true;
55 } 45 }
56 46
57 bool WebMInfoParser::OnFloat(int id, double val) { 47 bool WebMInfoParser::OnFloat(int id, double val) {
58 if (id != kWebMIdDuration) { 48 if (id != kWebMIdDuration) {
59 DVLOG(1) << "Unexpected float for id" << std::hex << id; 49 VLOG(1) << "Unexpected float for id" << std::hex << id;
60 return false; 50 return false;
61 } 51 }
62 52
63 if (duration_ != -1) { 53 if (duration_ != -1) {
64 DVLOG(1) << "Multiple values for duration."; 54 VLOG(1) << "Multiple values for duration.";
65 return false; 55 return false;
66 } 56 }
67 57
68 duration_ = val; 58 duration_ = val;
69 return true; 59 return true;
70 } 60 }
71 61
72 bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) { 62 bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) {
73 return true; 63 return true;
74 } 64 }
75 65
76 bool WebMInfoParser::OnString(int id, const std::string& str) { 66 bool WebMInfoParser::OnString(int id, const std::string& str) {
77 return true; 67 return true;
78 } 68 }
79 69
80 bool WebMInfoParser::OnSimpleBlock(int track_num, int timecode, int flags, 70 bool WebMInfoParser::OnSimpleBlock(int track_num, int timecode, int flags,
81 const uint8* data, int size) { 71 const uint8* data, int size) {
82 return false; 72 return false;
83 } 73 }
84 74
85 } // namespace media 75 } // namespace media
OLDNEW
« no previous file with comments | « media/webm/webm_constants.h ('k') | media/webm/webm_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698