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

Unified Diff: media/base/encoded_bitstream_buffer.cc

Issue 12379011: Interfaces for encoded video sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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/base/encoded_bitstream_buffer.cc
diff --git a/media/base/encoded_bitstream_buffer.cc b/media/base/encoded_bitstream_buffer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62c73647f0ab5c44cf42a1e1c3291d0a11e70a75
--- /dev/null
+++ b/media/base/encoded_bitstream_buffer.cc
@@ -0,0 +1,75 @@
+// Copyright 2013 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/base/encoded_bitstream_buffer.h"
+
+#include <iomanip>
+
+#include "base/logging.h"
+#include "base/md5.h"
+#include "base/stringprintf.h"
+
+namespace media {
+
+EncodedBitstreamBuffer::EncodedBitstreamBuffer(
+ base::SharedMemoryHandle handle,
+ size_t size,
+ const media::BufferEncodingMetadata& metadata)
+ : shm_(handle, true),
+ size_(size),
+ metadata_(metadata) {
+ CHECK(shm_.Map(size_));
+}
+
+EncodedBitstreamBuffer::~EncodedBitstreamBuffer() {
+}
+
+const uint8* EncodedBitstreamBuffer::buffer() const {
+ return reinterpret_cast<const uint8*>(shm_.memory());
+}
+
+size_t EncodedBitstreamBuffer::size() const {
+ return size_;
+}
+
+const media::BufferEncodingMetadata& EncodedBitstreamBuffer::metadata() const {
+ return metadata_;
+}
+
+std::string EncodedBitstreamBuffer::ToDebugString() const {
+ std::string debug_string;
+ base::MD5Digest digest;
+ if (metadata_.frame_type_flags & media::kVP8KeyFrame) {
+ base::StringAppendF(&debug_string, "[I]");
+ } else {
+ base::StringAppendF(&debug_string, "[");
+ if (metadata_.frame_type_flags & media::kVP8GoldenFrame)
+ base::StringAppendF(&debug_string, "G");
+ if (metadata_.frame_type_flags & media::kVP8AltrefFrame)
+ base::StringAppendF(&debug_string, "A");
+ if (metadata_.droppable)
+ base::StringAppendF(&debug_string, "-");
+ if (!(metadata_.frame_type_flags & media::kVP8GoldenFrame) &&
+ !(metadata_.frame_type_flags & media::kVP8AltrefFrame) &&
+ !(metadata_.droppable))
tommi (sloooow) - chröme 2013/03/21 14:48:05 {}
+ base::StringAppendF(&debug_string, "P");
+ base::StringAppendF(&debug_string, "]");
+ }
+ base::StringAppendF(&debug_string, " tl: [%i", metadata_.temporal_layer_id);
+ if (metadata_.layer_sync)
+ base::StringAppendF(&debug_string, "S");
+ base::StringAppendF(&debug_string, "]");
+ base::StringAppendF(&debug_string,
+ " time: %.3f",
+ metadata_.timestamp.ToDoubleT());
+ base::StringAppendF(&debug_string, " (%lu bytes),", size());
+ base::MD5Sum(buffer(), size(), &digest);
+ base::StringAppendF(&debug_string,
+ " %s",
+ base::MD5DigestToBase16(digest).c_str());
+ return debug_string;
+}
+
+} // namespace media
+

Powered by Google App Engine
This is Rietveld 408576698