7 #include <packager/media/formats/mp4/chunk_info_iterator.h>
12 #include <absl/log/check.h>
13 #include <absl/log/log.h>
20 : chunk_sample_index_(0),
22 chunk_info_table_(sample_to_chunk.chunk_info),
23 iterator_(chunk_info_table_.begin()) {
24 if (iterator_ != chunk_info_table_.end())
25 current_chunk_ = iterator_->first_chunk;
27 ChunkInfoIterator::~ChunkInfoIterator() {}
31 if (iterator_ + 1 != chunk_info_table_.end()) {
32 if (current_chunk_ >= (iterator_ + 1)->first_chunk)
35 chunk_sample_index_ = 0;
40 ++chunk_sample_index_;
41 if (chunk_sample_index_ >= iterator_->samples_per_chunk)
47 return iterator_ != chunk_info_table_.end() &&
48 chunk_sample_index_ < iterator_->samples_per_chunk;
52 uint32_t end_chunk)
const {
53 DCHECK_LE(start_chunk, end_chunk);
55 uint32_t last_chunk = 0;
56 uint32_t num_samples = 0;
57 for (std::vector<ChunkInfo>::const_iterator it = chunk_info_table_.begin();
58 it != chunk_info_table_.end();
60 last_chunk = (it + 1 == chunk_info_table_.end())
61 ? std::numeric_limits<uint32_t>::max()
62 : (it + 1)->first_chunk - 1;
63 if (last_chunk >= start_chunk) {
64 num_samples += (std::min(end_chunk, last_chunk) -
65 std::max(start_chunk, it->first_chunk) + 1) *
66 it->samples_per_chunk;
67 if (last_chunk >= end_chunk)
All the methods that are virtual are virtual for mocking.