Roll ANGLE e754fb8..6ffeb74
[chromium-blink-merge.git] / media / formats / mp4 / sample_to_group_iterator.h
blobc2ea60f827e6b508ea3153571ae3915b57acb9b0
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 #ifndef MEDIA_FORMATS_MP4_SAMPLE_TO_GROUP_ITERATOR_H_
6 #define MEDIA_FORMATS_MP4_SAMPLE_TO_GROUP_ITERATOR_H_
8 #include <vector>
10 #include "media/formats/mp4/box_definitions.h"
12 namespace media {
13 namespace mp4 {
15 // Sample To Group Box ('sbgp') can be used to find the group that a sample
16 // belongs to and the associated description of that sample group. It is
17 // compactly coded though. This class implements the iterator to iterate
18 // through the compressed table to get the associated sample group description
19 // index.
20 class MEDIA_EXPORT SampleToGroupIterator {
21 public:
22 explicit SampleToGroupIterator(const SampleToGroup& sample_to_group);
23 ~SampleToGroupIterator();
25 // Advances the iterator to refer to the next sample. Return status
26 // indicating whether the sample is still valid.
27 bool Advance();
29 // Returns whether the current sample is valid.
30 bool IsValid() const;
32 // Returns group description index for current sample.
33 uint32 group_description_index() const {
34 return iterator_->group_description_index;
37 private:
38 // Track how many samples remaining for current table entry.
39 uint32 remaining_samples_;
40 const std::vector<SampleToGroupEntry>& sample_to_group_table_;
41 std::vector<SampleToGroupEntry>::const_iterator iterator_;
43 DISALLOW_COPY_AND_ASSIGN(SampleToGroupIterator);
46 } // namespace mp4
47 } // namespace media
49 #endif // MEDIA_FORMATS_MP4_SAMPLE_TO_GROUP_ITERATOR_H_