Chromium Code Reviews| 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..219d93d78dee185614f07f280fcfc323a751ba0d |
| --- /dev/null |
| +++ b/media/base/encoded_bitstream_buffer.cc |
| @@ -0,0 +1,76 @@ |
| +// 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_(new base::SharedMemory(handle, true)), |
|
Ami GONE FROM CHROMIUM
2013/03/19 18:01:49
Why is this a pointer and not a regular member?
vmr
2013/03/20 12:09:14
No good reason. Changed to member variable.
|
| + size_(size), |
| + metadata_(metadata) { |
| + if (!shm_->Map(size_)) |
|
Ami GONE FROM CHROMIUM
2013/03/19 18:01:49
CHECK-fail instead?
vmr
2013/03/20 12:09:14
Done.
|
| + size_ = 0; |
| +} |
| + |
| +EncodedBitstreamBuffer::~EncodedBitstreamBuffer() { |
| +} |
| + |
| +const uint8* EncodedBitstreamBuffer::buffer() const { |
| + return static_cast<const uint8*>(shm_->memory()); |
|
Ami GONE FROM CHROMIUM
2013/03/19 18:01:49
s/static/reinterpret/
vmr
2013/03/20 12:09:14
Done.
|
| +} |
| + |
| +size_t EncodedBitstreamBuffer::size() const { |
| + return size_; |
| +} |
| + |
| +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)) |
| + 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: %.2f", |
|
Ami GONE FROM CHROMIUM
2013/03/19 18:01:49
nit: 0.3 gets you milliseconds; not sure if we hav
vmr
2013/03/20 12:09:14
Done.
|
| + 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 |
| + |