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

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

Issue 7203002: Adding ChunkDemuxer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed CR comments & split code out into separate files. Created 9 years, 6 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698