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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: media/webm/webm_info_parser.cc
diff --git a/media/webm/webm_info_parser.cc b/media/webm/webm_info_parser.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6f9ef8c347ec99a9459ba8a340498ffa57b335bf
--- /dev/null
+++ b/media/webm/webm_info_parser.cc
@@ -0,0 +1,79 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/webm/webm_info_parser.h"
+
+#include "base/logging.h"
+#include "media/webm/webm_constants.h"
+
+namespace media {
+
+WebMInfoParser::WebMInfoParser()
+ : timecode_scale_(-1),
+ duration_(-1) {
+}
+
+WebMInfoParser::~WebMInfoParser() {}
+
+int WebMInfoParser::Parse(const uint8* buf, int size) {
+ return WebMParseListElement(buf, size, kWebMIdInfo, 1, this);
+}
+
+int64 WebMInfoParser::timecode_scale() const { return timecode_scale_; }
+
+double WebMInfoParser::duration() const { return duration_; }
+
+bool WebMInfoParser::OnListStart(int id) { return true; }
+
+bool WebMInfoParser::OnListEnd(int id) {
+ if (id == kWebMIdInfo && timecode_scale_ == -1) {
+ // Set timecode scale to default value if it isn't present in
+ // the Info element.
+ timecode_scale_ = kWebMDefaultTimecodeScale;
+ }
+ return true;
+}
+
+bool WebMInfoParser::OnUInt(int id, int64 val) {
+ if (id != kWebMIdTimecodeScale)
+ return true;
+
+ if (timecode_scale_ != -1) {
+ VLOG(1) << "Multiple values for id " << std::hex << id << " specified";
+ return false;
+ }
+
+ timecode_scale_ = val;
+ return true;
+}
+
+bool WebMInfoParser::OnFloat(int id, double val) {
+ if (id != kWebMIdDuration) {
+ VLOG(1) << "Unexpected float for id" << std::hex << id;
+ return false;
+ }
+
+ if (duration_ != -1) {
+ VLOG(1) << "Multiple values for duration.";
+ return false;
+ }
+
+ duration_ = val;
+ return true;
+}
+
+bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) {
+ return true;
+}
+
+bool WebMInfoParser::OnString(int id, const std::string& str) {
+ return true;
+}
+
+bool WebMInfoParser::OnSimpleBlock(int track_num, int timecode, int flags,
+ const uint8* data, int size) {
+ return false;
+}
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698