OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/decoder_buffer.h" | 5 #include "media/base/decoder_buffer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "media/base/decrypt_config.h" | 8 #include "media/base/decrypt_config.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CHECK(side_data); | 63 CHECK(side_data); |
64 return make_scoped_refptr(new DecoderBuffer(data, data_size, | 64 return make_scoped_refptr(new DecoderBuffer(data, data_size, |
65 side_data, side_data_size)); | 65 side_data, side_data_size)); |
66 } | 66 } |
67 | 67 |
68 // static | 68 // static |
69 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { | 69 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { |
70 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); | 70 return make_scoped_refptr(new DecoderBuffer(NULL, 0, NULL, 0)); |
71 } | 71 } |
72 | 72 |
73 base::TimeDelta DecoderBuffer::GetTimestamp() const { | |
74 DCHECK(!IsEndOfStream()); | |
75 return timestamp_; | |
76 } | |
77 | |
78 void DecoderBuffer::SetTimestamp(const base::TimeDelta& timestamp) { | |
79 DCHECK(!IsEndOfStream()); | |
80 timestamp_ = timestamp; | |
81 } | |
82 | |
83 base::TimeDelta DecoderBuffer::GetDuration() const { | |
84 DCHECK(!IsEndOfStream()); | |
85 return duration_; | |
86 } | |
87 | |
88 void DecoderBuffer::SetDuration(const base::TimeDelta& duration) { | |
89 DCHECK(!IsEndOfStream()); | |
90 duration_ = duration; | |
91 } | |
92 | |
93 const uint8* DecoderBuffer::GetData() const { | |
94 DCHECK(!IsEndOfStream()); | |
95 return data_.get(); | |
96 } | |
97 | |
98 uint8* DecoderBuffer::GetWritableData() const { | |
99 DCHECK(!IsEndOfStream()); | |
100 return data_.get(); | |
101 } | |
102 | |
103 int DecoderBuffer::GetDataSize() const { | |
104 DCHECK(!IsEndOfStream()); | |
105 return size_; | |
106 } | |
107 | |
108 const uint8* DecoderBuffer::GetSideData() const { | |
109 DCHECK(!IsEndOfStream()); | |
110 return side_data_.get(); | |
111 } | |
112 | |
113 int DecoderBuffer::GetSideDataSize() const { | |
114 DCHECK(!IsEndOfStream()); | |
115 return side_data_size_; | |
116 } | |
117 | |
118 const DecryptConfig* DecoderBuffer::GetDecryptConfig() const { | |
119 DCHECK(!IsEndOfStream()); | |
120 return decrypt_config_.get(); | |
121 } | |
122 | |
123 void DecoderBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) { | |
124 DCHECK(!IsEndOfStream()); | |
125 decrypt_config_ = decrypt_config.Pass(); | |
126 } | |
127 | |
128 bool DecoderBuffer::IsEndOfStream() const { | |
129 return data_ == NULL; | |
130 } | |
131 | |
132 std::string DecoderBuffer::AsHumanReadableString() { | 73 std::string DecoderBuffer::AsHumanReadableString() { |
133 if (IsEndOfStream()) { | 74 if (end_of_stream()) { |
134 return "end of stream"; | 75 return "end of stream"; |
135 } | 76 } |
136 | 77 |
137 std::ostringstream s; | 78 std::ostringstream s; |
138 s << "timestamp: " << timestamp_.InMicroseconds() | 79 s << "timestamp: " << timestamp_.InMicroseconds() |
139 << " duration: " << duration_.InMicroseconds() | 80 << " duration: " << duration_.InMicroseconds() |
140 << " size: " << size_ | 81 << " size: " << size_ |
141 << " side_data_size: " << side_data_size_ | 82 << " side_data_size: " << side_data_size_ |
142 << " encrypted: " << (decrypt_config_ != NULL); | 83 << " encrypted: " << (decrypt_config_ != NULL); |
143 return s.str(); | 84 return s.str(); |
144 } | 85 } |
145 | 86 |
146 } // namespace media | 87 } // namespace media |
OLD | NEW |