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_CHUNK_INFO_ITERATOR_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_CHUNK_INFO_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
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-10-08 17:37:58 +00:00
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Sample to chunk box (STSC) iterator used to iterate through the compressed
|
|
|
|
/// table by sample/chunk. This class also provides a convenient function to
|
|
|
|
/// query total number of samples from start_chunk to end_chunk.
|
2013-10-08 17:37:58 +00:00
|
|
|
class ChunkInfoIterator {
|
|
|
|
public:
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Create ChunkInfoIterator from sample to chunk box.
|
2013-10-08 17:37:58 +00:00
|
|
|
explicit ChunkInfoIterator(const SampleToChunk& sample_to_chunk);
|
2014-02-26 23:55:01 +00:00
|
|
|
~ChunkInfoIterator();
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Advance to the next chunk.
|
|
|
|
/// @return true if not past the last chunk, false otherwise.
|
2013-10-08 17:37:58 +00:00
|
|
|
bool AdvanceChunk();
|
|
|
|
|
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 not past the last chunk/sample, false otherwise.
|
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 Current chunk.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t current_chunk() const { return current_chunk_; }
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Samples per chunk for current chunk.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t samples_per_chunk() const { return iterator_->samples_per_chunk; }
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Sample description index for current chunk.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t sample_description_index() const {
|
2013-10-08 17:37:58 +00:00
|
|
|
return iterator_->sample_description_index;
|
|
|
|
}
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Number of samples from start_chunk to end_chunk, both 1-based,
|
|
|
|
/// inclusive.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t NumSamples(uint32_t start_chunk, uint32_t end_chunk) const;
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return The last first_chunk in chunk_info_table.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t LastFirstChunk() const {
|
2014-02-21 02:09:35 +00:00
|
|
|
return chunk_info_table_.empty() ? 0
|
|
|
|
: chunk_info_table_.back().first_chunk;
|
2013-10-08 17:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t chunk_sample_index_;
|
|
|
|
uint32_t current_chunk_;
|
2013-10-08 17:37:58 +00:00
|
|
|
const std::vector<ChunkInfo>& chunk_info_table_;
|
|
|
|
std::vector<ChunkInfo>::const_iterator iterator_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ChunkInfoIterator);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-10-08 17:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_CHUNK_INFO_ITERATOR_H_
|