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

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: Build fixes 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..87602ad6220ee01096aa0c95bd36017abeb99d83
--- /dev/null
+++ b/media/base/encoded_bitstream_buffer.cc
@@ -0,0 +1,93 @@
+// Copyright (c) 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"
+
+namespace media {
+
+EncodedBitstreamBuffer::EncodedBitstreamBuffer(
+ const uint8* buffer,
+ size_t size,
+ const media::BufferEncodingMetadata& metadata)
+ : buffer_(new uint8[size]),
+ size_(size),
+ metadata_(metadata) {
+ memcpy(buffer_.get(), buffer, size);
+}
+
+EncodedBitstreamBuffer::~EncodedBitstreamBuffer() {
+}
+
+const uint8* EncodedBitstreamBuffer::buffer() const {
+ return buffer_.get();
+}
+
+size_t EncodedBitstreamBuffer::size() const {
+ return size_;
+}
+
+const base::Time EncodedBitstreamBuffer::timestamp() const {
+ return metadata_.timestamp;
+}
+
+int EncodedBitstreamBuffer::temporal_layer_id() const {
+ return metadata_.temporal_layer_id;
+}
+
+bool EncodedBitstreamBuffer::is_key_frame() const {
+ return metadata_.frame_type_flags & media::kVP8KeyFrame ? true : false;
Ami GONE FROM CHROMIUM 2013/03/18 22:53:45 FWIW, return !!x; is more concise than return x ?
+}
+
+bool EncodedBitstreamBuffer::is_altref_frame() const {
+ return metadata_.frame_type_flags & media::kVP8AltrefFrame ? true : false;
+}
+
+bool EncodedBitstreamBuffer::is_golden_frame() const {
+ return metadata_.frame_type_flags & media::kVP8GoldenFrame ? true : false;
+}
+
+bool EncodedBitstreamBuffer::is_droppable() const {
+ return metadata_.droppable;
+}
+
+bool EncodedBitstreamBuffer::is_layer_sync() const {
+ return metadata_.layer_sync;
+}
+
+} // namespace media
+
+std::ostream& operator<<(std::ostream& output,
+ const media::EncodedBitstreamBuffer& b) {
+ base::MD5Digest digest;
+ output << "[";
+ if (b.is_key_frame()) {
+ output << "I";
+ } else {
+ if (b.is_golden_frame())
+ output << "G";
+ if (b.is_altref_frame())
+ output << "A";
+ if (b.is_droppable())
+ output << "-";
+ if (!b.is_golden_frame() && !b.is_altref_frame() && !b.is_droppable())
+ output << "P";
+ }
+ output << "]";
+ output << " tl: [" << b.temporal_layer_id();
+ if (b.is_layer_sync())
+ output << "S";
+ output << "]";
+ output << " time: " << std::setprecision(2) << std::fixed
+ << b.timestamp().ToDoubleT();
+ output << " (" << b.size() << " bytes)";
+ base::MD5Sum(b.buffer(), b.size(), &digest);
+ output << " md5: " << base::MD5DigestToBase16(digest);
+ return output;
+}
+

Powered by Google App Engine
This is Rietveld 408576698