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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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
12 namespace media {
13
14 EncodedBitstreamBuffer::EncodedBitstreamBuffer(
15 const uint8* buffer,
16 size_t size,
17 const media::BufferEncodingMetadata& metadata)
18 : buffer_(new uint8[size]),
19 size_(size),
20 metadata_(metadata) {
21 memcpy(buffer_.get(), buffer, size);
22 }
23
24 EncodedBitstreamBuffer::~EncodedBitstreamBuffer() {
25 }
26
27 const uint8* EncodedBitstreamBuffer::buffer() const {
28 return buffer_.get();
29 }
30
31 size_t EncodedBitstreamBuffer::size() const {
32 return size_;
33 }
34
35 const base::Time EncodedBitstreamBuffer::timestamp() const {
36 return metadata_.timestamp;
37 }
38
39 int EncodedBitstreamBuffer::temporal_layer_id() const {
40 return metadata_.temporal_layer_id;
41 }
42
43 bool EncodedBitstreamBuffer::is_key_frame() const {
44 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 ?
45 }
46
47 bool EncodedBitstreamBuffer::is_altref_frame() const {
48 return metadata_.frame_type_flags & media::kVP8AltrefFrame ? true : false;
49 }
50
51 bool EncodedBitstreamBuffer::is_golden_frame() const {
52 return metadata_.frame_type_flags & media::kVP8GoldenFrame ? true : false;
53 }
54
55 bool EncodedBitstreamBuffer::is_droppable() const {
56 return metadata_.droppable;
57 }
58
59 bool EncodedBitstreamBuffer::is_layer_sync() const {
60 return metadata_.layer_sync;
61 }
62
63 } // namespace media
64
65 std::ostream& operator<<(std::ostream& output,
66 const media::EncodedBitstreamBuffer& b) {
67 base::MD5Digest digest;
68 output << "[";
69 if (b.is_key_frame()) {
70 output << "I";
71 } else {
72 if (b.is_golden_frame())
73 output << "G";
74 if (b.is_altref_frame())
75 output << "A";
76 if (b.is_droppable())
77 output << "-";
78 if (!b.is_golden_frame() && !b.is_altref_frame() && !b.is_droppable())
79 output << "P";
80 }
81 output << "]";
82 output << " tl: [" << b.temporal_layer_id();
83 if (b.is_layer_sync())
84 output << "S";
85 output << "]";
86 output << " time: " << std::setprecision(2) << std::fixed
87 << b.timestamp().ToDoubleT();
88 output << " (" << b.size() << " bytes)";
89 base::MD5Sum(b.buffer(), b.size(), &digest);
90 output << " md5: " << base::MD5DigestToBase16(digest);
91 return output;
92 }
93
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698