2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_COMPOSITION_OFFSET_ITERATOR_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_COMPOSITION_OFFSET_ITERATOR_H_
|
2013-10-08 17:37:58 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#include "media/formats/mp4/box_definitions.h"
|
2013-10-08 17:37:58 +00:00
|
|
|
|
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Composition time to sample box (CTTS) iterator used to iterate through the
|
|
|
|
/// compressed table. This class also provides convenient functions to query
|
|
|
|
/// total number of samples and the composition offset for a particular sample.
|
2013-10-08 17:37:58 +00:00
|
|
|
class CompositionOffsetIterator {
|
|
|
|
public:
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Create CompositionOffsetIterator from composition time to sample box.
|
2013-10-08 17:37:58 +00:00
|
|
|
explicit CompositionOffsetIterator(
|
|
|
|
const CompositionTimeToSample& composition_time_to_sample);
|
2014-02-26 23:55:01 +00:00
|
|
|
~CompositionOffsetIterator();
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Advance the iterator to the next sample.
|
|
|
|
/// @return true if not past the last sample, false otherwise.
|
2013-10-08 17:37:58 +00:00
|
|
|
bool AdvanceSample();
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return true if the iterator is still valid, false if past the last
|
|
|
|
/// sample.
|
2014-02-21 02:09:35 +00:00
|
|
|
bool IsValid() const;
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Sample offset for current sample.
|
2014-03-21 17:26:49 +00:00
|
|
|
int32 sample_offset() const { return iterator_->sample_offset; }
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Sample offset @a sample, 1-based.
|
2014-03-21 17:26:49 +00:00
|
|
|
int32 SampleOffset(uint32 sample) const;
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Total number of samples.
|
2014-02-21 02:09:35 +00:00
|
|
|
uint32 NumSamples() const;
|
2013-10-08 17:37:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint32 sample_index_;
|
|
|
|
const std::vector<CompositionOffset>& composition_offset_table_;
|
|
|
|
std::vector<CompositionOffset>::const_iterator iterator_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CompositionOffsetIterator);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_COMPOSITION_OFFSET_ITERATOR_H_
|