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

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: Changed Client to be accessed through WeakPtr 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(size_t size,
15 base::Time timestamp,
16 int temporal_layer)
17 : size_(size), timestamp_(timestamp), key_frame_(false),
18 temporal_layer_(temporal_layer), altref_frame_(false),
19 golden_frame_(false), droppable_(false), layer_sync_(false) {
wjia(left Chromium) 2013/02/28 18:46:26 one on each line. refer to http://google-styleguid
vmr 2013/03/01 14:24:00 Done.
20 ptr_ = new uint8[size_];
21 DCHECK(ptr_);
wjia(left Chromium) 2013/02/28 18:46:26 no need to DCHECK.
vmr 2013/03/01 14:24:00 Done.
22 }
23
24 EncodedBitstreamBuffer::EncodedBitstreamBuffer(uint8* ptr, size_t size,
25 base::Time timestamp,
26 int temporal_layer)
27 : size_(size), timestamp_(timestamp), key_frame_(false),
28 temporal_layer_(temporal_layer), altref_frame_(false),
29 golden_frame_(false) {
wjia(left Chromium) 2013/02/28 18:46:26 ditto.
vmr 2013/03/01 14:24:00 Done.
30 ptr_ = new uint8[size_];
31 DCHECK(ptr_);
wjia(left Chromium) 2013/02/28 18:46:26 ditto.
vmr 2013/03/01 14:24:00 Done.
32 memcpy(ptr_, ptr, size);
33 }
34
35 EncodedBitstreamBuffer::~EncodedBitstreamBuffer() {
36 delete[] ptr_;
wjia(left Chromium) 2013/02/28 18:46:26 You don't need this when using scoped_ptr.
vmr 2013/03/01 14:24:00 Done.
37 }
38
39 uint8* EncodedBitstreamBuffer::ptr() const {
40 return ptr_;
41 }
42
43 size_t EncodedBitstreamBuffer::size() const {
44 return size_;
45 }
46
47 base::Time EncodedBitstreamBuffer::timestamp() const {
48 return timestamp_;
49 }
50
51 int EncodedBitstreamBuffer::temporal_layer() const {
52 return temporal_layer_;
53 }
54
55 bool EncodedBitstreamBuffer::key_frame() const {
56 return key_frame_;
57 }
58
59 bool EncodedBitstreamBuffer::altref_frame() const {
60 return altref_frame_;
61 }
62
63 bool EncodedBitstreamBuffer::golden_frame() const {
64 return golden_frame_;
65 }
66
67 bool EncodedBitstreamBuffer::droppable() const {
68 return droppable_;
69 }
70
71 bool EncodedBitstreamBuffer::layer_sync() const {
72 return layer_sync_;
73 }
74
75 void EncodedBitstreamBuffer::MarkKeyFrame() {
76 key_frame_ = true;
77 altref_frame_ = true;
78 golden_frame_ = true;
79 }
80
81 void EncodedBitstreamBuffer::MarkAltRef() {
82 altref_frame_ = true;
83 }
84
85 void EncodedBitstreamBuffer::MarkGolden() {
86 golden_frame_ = true;
87 }
88
89 void EncodedBitstreamBuffer::MarkDroppable() {
90 droppable_ = true;
91 }
92
93 void EncodedBitstreamBuffer::MarkLayerSync() {
94 layer_sync_ = true;
95 }
96
97 } // namespace media
98
99 std::ostream& operator<<(std::ostream& output,
100 const media::EncodedBitstreamBuffer& b) {
101 base::MD5Digest digest;
102 output << "[";
103 if (b.key_frame()) {
104 output << "I";
105 } else {
106 if (b.golden_frame())
107 output << "G";
108 if (b.altref_frame())
109 output << "A";
110 if (b.droppable())
111 output << "-";
112 if (!b.golden_frame() && !b.altref_frame() && !b.droppable())
113 output << "P";
114 }
115 output << "]";
116 output << " tl: [" << b.temporal_layer();
117 if (b.layer_sync())
118 output << "S";
119 output << "]";
120 output << " time: " << std::setprecision(2) << std::fixed
121 << b.timestamp().ToDoubleT();
122 output << " (" << b.size() << " bytes)";
123 base::MD5Sum(b.ptr(), b.size(), &digest);
124 output << " md5: " << base::MD5DigestToBase16(digest);
125 return output;
126 }
127
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698