// Copyright (c) 2013 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. #include "media/mp4/sync_sample_iterator.h" #include namespace media { namespace mp4 { SyncSampleIterator::SyncSampleIterator(const SyncSample& sync_sample) : sample_number_(1), sync_sample_vector_(sync_sample.sample_number), iterator_(sync_sample_vector_.begin()), is_empty_(iterator_ == sync_sample_vector_.end()) { } bool SyncSampleIterator::AdvanceSample() { if (iterator_ != sync_sample_vector_.end() && sample_number_ == *iterator_) ++iterator_; ++sample_number_; return true; } bool SyncSampleIterator::IsSyncSample() { // If the sync sample box is not present, every sample is a sync sample. if (is_empty_) return true; return iterator_ != sync_sample_vector_.end() && sample_number_ == *iterator_; } bool SyncSampleIterator::IsSyncSample(uint32 sample) { // If the sync sample box is not present, every sample is a sync sample. if (is_empty_) return true; return std::binary_search(sync_sample_vector_.begin(), sync_sample_vector_.end(), sample); } } // namespace mp4 } // namespace media