Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / media / formats / mp4 / sample_to_group_iterator.cc
blob01c707292d7eef18eefec77bfce069af96f24122
1 // Copyright 2014 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.
5 #include "media/formats/mp4/sample_to_group_iterator.h"
7 #include "base/logging.h"
9 namespace media {
10 namespace mp4 {
12 SampleToGroupIterator::SampleToGroupIterator(
13 const SampleToGroup& sample_to_group)
14 : remaining_samples_(0),
15 sample_to_group_table_(sample_to_group.entries),
16 iterator_(sample_to_group_table_.begin()) {
17 // Handle the case that the table contains an entry with sample count 0.
18 while (iterator_ != sample_to_group_table_.end()) {
19 remaining_samples_ = iterator_->sample_count;
20 if (remaining_samples_ > 0)
21 break;
22 ++iterator_;
26 SampleToGroupIterator::~SampleToGroupIterator() {}
28 bool SampleToGroupIterator::Advance() {
29 DCHECK(IsValid());
31 --remaining_samples_;
32 // Handle the case that the table contains an entry with sample count 0.
33 while (remaining_samples_ == 0) {
34 ++iterator_;
35 if (iterator_ == sample_to_group_table_.end())
36 return false;
37 remaining_samples_ = iterator_->sample_count;
39 return true;
42 bool SampleToGroupIterator::IsValid() const {
43 return remaining_samples_ > 0;
46 } // namespace mp4
47 } // namespace media