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
|
|
|
|
|
|
|
#ifndef MEDIA_MP4_DECODING_TIME_ITERATOR_H_
|
|
|
|
#define MEDIA_MP4_DECODING_TIME_ITERATOR_H_
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "media/mp4/box_definitions.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Decoding time to sample box (STTS) iterator used to iterate through the
|
|
|
|
/// compressed table. This class also provides convenient functions to query
|
|
|
|
/// total number of samples and the duration from start_sample to end_sample.
|
2013-10-08 17:37:58 +00:00
|
|
|
class DecodingTimeIterator {
|
|
|
|
public:
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Create DecodingTimeIterator from decoding time to sample box.
|
2013-10-08 17:37:58 +00:00
|
|
|
explicit DecodingTimeIterator(
|
|
|
|
const DecodingTimeToSample& decoding_time_to_sample);
|
2014-02-26 23:55:01 +00:00
|
|
|
~DecodingTimeIterator();
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Advance 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 delta for current sample.
|
2014-02-21 02:09:35 +00:00
|
|
|
uint32 sample_delta() const { return iterator_->sample_delta; }
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Duration from start_sample to end_sample, both 1-based, inclusive.
|
2014-02-21 02:09:35 +00:00
|
|
|
uint64 Duration(uint32 start_sample, uint32 end_sample) const;
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Total number of samples in the table.
|
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<DecodingTime>& decoding_time_table_;
|
|
|
|
std::vector<DecodingTime>::const_iterator iterator_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(DecodingTimeIterator);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
|
|
|
|
|
|
|
#endif // MEDIA_MP4_DECODING_TIME_ITERATOR_H_
|