Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1244)

Unified Diff: media/mp4/track_run_iterator.h

Issue 10536014: Implement ISO BMFF support in Media Source. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/mp4/track_run_iterator.h
diff --git a/media/mp4/track_run_iterator.h b/media/mp4/track_run_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..e17227b2b38eaa180fb3fd91af852e7f3bb8142b
--- /dev/null
+++ b/media/mp4/track_run_iterator.h
@@ -0,0 +1,113 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_MP4_TRACK_RUN_ITERATOR_H_
+#define MEDIA_MP4_TRACK_RUN_ITERATOR_H_
+
+#include "base/time.h"
+#include "media/mp4/box_definitions.h"
+#include "media/mp4/cenc.h"
+
+namespace media {
+namespace mp4 {
+
+using base::TimeDelta;
+
+base::TimeDelta TimeDeltaFromFrac(int64 numer, uint64 denom);
+
+struct SampleInfo {
+ size_t size;
+ TimeDelta duration;
+ TimeDelta cts_offset;
+ bool is_keyframe;
+};
+
+struct TrackRunInfo {
+ uint32 track_id;
+ std::vector<SampleInfo> samples;
+ TimeDelta start_dts;
+ size_t sample_start_offset;
+
+ bool is_encrypted;
+ size_t cenc_start_offset;
+ size_t cenc_total_size;
+ uint8 default_cenc_size;
+ // Only valid if default_cenc_size == 0. (In this case, infer the sample count
+ // from the 'samples' parameter; they shall be the same.)
+ std::vector<uint8> cenc_sizes;
+
+ TrackRunInfo();
+ ~TrackRunInfo();
+};
+
+class TrackRunIterator {
+ public:
+ TrackRunIterator();
+ ~TrackRunIterator();
+
+ void Reset();
+
+ // Sets up the iterator to handle all the runs from the current fragment.
+ bool Init(const Movie& moov, const MovieFragment& moof);
+
+ // Returns true if the properties of the current run or sample are valid.
+ bool RunValid();
+ bool SampleValid();
+
+ // Advance the properties to refer to the next run or sample. Requires that
+ // the current sample be valid.
+ void AdvanceRun();
+ void AdvanceSample();
+
+ // Returns true iff the track is encrypted and the common encryption sample
+ // auxiliary information has not yet been cached for the current track.
+ bool NeedsCENC();
+
+ // Cache the CENC data from the given buffer.
+ bool CacheCENC(const uint8* buf, size_t size);
+
+ // Returns the maximum buffer location at which no data earlier in the stream
+ // will be required in order to read the current or any subsequent sample. You
+ // may clear all data up to this offset before reading the current sample
+ // safely. Result is in the same units as offset() (for Media Source this is
+ // in bytes past the the head of the MOOF box).
+ size_t GetMaxClearOffset();
+
+ // Property of the current run. Reqiures RunValid().
+ uint32 track_id() const { return run_itr_->track_id; }
acolwell GONE FROM CHROMIUM 2012/06/06 17:32:39 Move all these impls into cc file and add DCHECKS
strobe_ 2012/06/07 16:33:54 Done.
+ bool is_encrypted() const { return run_itr_->is_encrypted; }
+ // Only valid if is_encrypted() is true.
+ size_t cenc_offset() const { return run_itr_->cenc_start_offset; }
+ size_t cenc_size() const { return run_itr_->cenc_total_size; }
+
+ // Properties of the current sample. Requires SampleValid().
+ size_t offset() const { return sample_offset_; }
+ size_t size() const { return sample_itr_->size; }
+ TimeDelta dts() const { return sample_dts_; }
+ TimeDelta cts() const { return sample_dts_ + sample_itr_->cts_offset; }
+ TimeDelta duration() const { return sample_itr_->duration; }
+ bool is_keyframe() const { return sample_itr_->is_keyframe; }
+ // Only valid if is_encrypted() is true and NeedsCENC() is false.
+ const FrameCENCInfo& frame_cenc_info();
+
+ private:
+ void ResetRun();
+ std::vector<TrackRunInfo> runs_;
+ std::vector<TrackRunInfo>::const_iterator run_itr_;
+
+ std::vector<SampleInfo>::const_iterator sample_itr_;
+ std::vector<uint8> cenc_cache_;
+
+ std::vector<size_t> min_clear_offsets_;
+ std::vector<size_t>::const_iterator min_clear_offset_itr_;
+
+ TimeDelta sample_dts_;
+ size_t sample_offset_;
+ FrameCENCInfo frame_cenc_info_;
+};
+
+} // namespace mp4
+} // namespace media
+
+#endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698