| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/android/access_unit_queue.h" | 5 #include "media/base/android/access_unit_queue.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "media/base/demuxer_stream.h" | 9 #include "media/base/demuxer_stream.h" |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 AccessUnitQueue::Info AccessUnitQueue::GetInfo() const { | 161 AccessUnitQueue::Info AccessUnitQueue::GetInfo() const { |
| 162 // Media thread, Decoder thread | 162 // Media thread, Decoder thread |
| 163 | 163 |
| 164 Info info; | 164 Info info; |
| 165 base::AutoLock lock(lock_); | 165 base::AutoLock lock(lock_); |
| 166 | 166 |
| 167 info.length = GetUnconsumedAccessUnitLength(); | 167 GetUnconsumedAccessUnitLength(&info.length, &info.data_length); |
| 168 |
| 168 info.has_eos = has_eos_; | 169 info.has_eos = has_eos_; |
| 169 info.front_unit = nullptr; | 170 info.front_unit = nullptr; |
| 170 info.configs = nullptr; | 171 info.configs = nullptr; |
| 171 | 172 |
| 172 if (info.length > 0) { | 173 if (info.length > 0) { |
| 173 DCHECK(current_chunk_ != chunks_.end()); | 174 DCHECK(current_chunk_ != chunks_.end()); |
| 174 DCHECK(index_in_chunk_ < (*current_chunk_)->access_units.size()); | 175 DCHECK(index_in_chunk_ < (*current_chunk_)->access_units.size()); |
| 175 info.front_unit = &(*current_chunk_)->access_units[index_in_chunk_]; | 176 info.front_unit = &(*current_chunk_)->access_units[index_in_chunk_]; |
| 176 | 177 |
| 177 if (info.front_unit->status == DemuxerStream::kConfigChanged) { | 178 if (info.front_unit->status == DemuxerStream::kConfigChanged) { |
| 178 DCHECK((*current_chunk_)->demuxer_configs.size() == 1); | 179 DCHECK((*current_chunk_)->demuxer_configs.size() == 1); |
| 179 info.configs = &(*current_chunk_)->demuxer_configs[0]; | 180 info.configs = &(*current_chunk_)->demuxer_configs[0]; |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 return info; | 183 return info; |
| 183 } | 184 } |
| 184 | 185 |
| 185 void AccessUnitQueue::SetHistorySizeForTesting(size_t history_chunks_amount) { | 186 void AccessUnitQueue::SetHistorySizeForTesting(size_t history_chunks_amount) { |
| 186 history_chunks_amount_ = history_chunks_amount; | 187 history_chunks_amount_ = history_chunks_amount; |
| 187 } | 188 } |
| 188 | 189 |
| 189 int AccessUnitQueue::GetUnconsumedAccessUnitLength() const { | 190 void AccessUnitQueue::GetUnconsumedAccessUnitLength(int* total_length, |
| 190 int result = 0; | 191 int* data_length) const { |
| 192 *total_length = *data_length = 0; |
| 193 |
| 191 DataChunkQueue::const_iterator chunk; | 194 DataChunkQueue::const_iterator chunk; |
| 192 for (chunk = current_chunk_; chunk != chunks_.end(); ++chunk) | 195 for (chunk = current_chunk_; chunk != chunks_.end(); ++chunk) { |
| 193 result += (*chunk)->access_units.size(); | 196 size_t chunk_size = (*chunk)->access_units.size(); |
| 197 *total_length += chunk_size; |
| 198 *data_length += chunk_size; |
| 194 | 199 |
| 195 result -= index_in_chunk_; | 200 // Do not count configuration changes for |data_length|. |
| 196 return result; | 201 if (!(*chunk)->demuxer_configs.empty()) { |
| 202 DCHECK((*chunk)->demuxer_configs.size() == 1); |
| 203 --(*data_length); |
| 204 } |
| 205 } |
| 206 |
| 207 *total_length -= index_in_chunk_; |
| 208 *data_length -= index_in_chunk_; |
| 197 } | 209 } |
| 198 | 210 |
| 199 } // namespace media | 211 } // namespace media |
| OLD | NEW |