Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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/base/encoded_bitstream_buffer.h" | |
| 6 | |
| 7 #include <iomanip> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/md5.h" | |
| 11 #include "base/stringprintf.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 EncodedBitstreamBuffer::EncodedBitstreamBuffer( | |
| 16 base::SharedMemoryHandle handle, | |
| 17 size_t size, | |
| 18 const media::BufferEncodingMetadata& metadata) | |
| 19 : 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.
| |
| 20 size_(size), | |
| 21 metadata_(metadata) { | |
| 22 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.
| |
| 23 size_ = 0; | |
| 24 } | |
| 25 | |
| 26 EncodedBitstreamBuffer::~EncodedBitstreamBuffer() { | |
| 27 } | |
| 28 | |
| 29 const uint8* EncodedBitstreamBuffer::buffer() const { | |
| 30 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.
| |
| 31 } | |
| 32 | |
| 33 size_t EncodedBitstreamBuffer::size() const { | |
| 34 return size_; | |
| 35 } | |
| 36 | |
| 37 media::BufferEncodingMetadata EncodedBitstreamBuffer::metadata() const { | |
| 38 return metadata_; | |
| 39 } | |
| 40 | |
| 41 std::string EncodedBitstreamBuffer::ToDebugString() const { | |
| 42 std::string debug_string; | |
| 43 base::MD5Digest digest; | |
| 44 if (metadata_.frame_type_flags & media::kVP8KeyFrame) { | |
| 45 base::StringAppendF(&debug_string, "[I]"); | |
| 46 } else { | |
| 47 base::StringAppendF(&debug_string, "["); | |
| 48 if (metadata_.frame_type_flags & media::kVP8GoldenFrame) | |
| 49 base::StringAppendF(&debug_string, "G"); | |
| 50 if (metadata_.frame_type_flags & media::kVP8AltrefFrame) | |
| 51 base::StringAppendF(&debug_string, "A"); | |
| 52 if (metadata_.droppable) | |
| 53 base::StringAppendF(&debug_string, "-"); | |
| 54 if (!(metadata_.frame_type_flags & media::kVP8GoldenFrame) && | |
| 55 !(metadata_.frame_type_flags & media::kVP8AltrefFrame) && | |
| 56 !(metadata_.droppable)) | |
| 57 base::StringAppendF(&debug_string, "P"); | |
| 58 base::StringAppendF(&debug_string, "]"); | |
| 59 } | |
| 60 base::StringAppendF(&debug_string, " tl: [%i", metadata_.temporal_layer_id); | |
| 61 if (metadata_.layer_sync) | |
| 62 base::StringAppendF(&debug_string, "S"); | |
| 63 base::StringAppendF(&debug_string, "]"); | |
| 64 base::StringAppendF(&debug_string, | |
| 65 " 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.
| |
| 66 metadata_.timestamp.ToDoubleT()); | |
| 67 base::StringAppendF(&debug_string, " (%lu bytes),", size()); | |
| 68 base::MD5Sum(buffer(), size(), &digest); | |
| 69 base::StringAppendF(&debug_string, | |
| 70 " %s", | |
| 71 base::MD5DigestToBase16(digest).c_str()); | |
| 72 return debug_string; | |
| 73 } | |
| 74 | |
| 75 } // namespace media | |
| 76 | |
| OLD | NEW |