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

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: A thorough sign-ification 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..2c3a9e0cc9f6b9eb51225657383b194fc1f418a8
--- /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_
+
acolwell GONE FROM CHROMIUM 2012/06/08 16:10:38 lint nit: add #include<vector>
strobe_ 2012/06/11 18:44:21 Done.
+#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 {
+ int size;
+ TimeDelta duration;
+ TimeDelta cts_offset;
+ bool is_keyframe;
+};
+
+struct TrackRunInfo {
+ uint32 track_id;
+ std::vector<SampleInfo> samples;
+ TimeDelta start_dts;
+ int64 sample_start_offset;
+
+ bool is_encrypted;
+ int64 cenc_start_offset;
+ int 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() const;
+ bool SampleValid() const;
+
+ // 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, int 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).
+ int64 GetMaxClearOffset();
+
+ // Property of the current run. Reqiures RunValid().
+ uint32 track_id() const;
+ bool is_encrypted() const;
+ // Only valid if is_encrypted() is true.
+ int64 cenc_offset() const;
+ int cenc_size() const;
+
+ // Properties of the current sample. Requires SampleValid().
+ int64 offset() const;
+ int size() const;
+ TimeDelta dts() const;
+ TimeDelta cts() const;
+ TimeDelta duration() const;
+ bool is_keyframe() const;
+ // 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<int64> min_clear_offsets_;
+ std::vector<int64>::const_iterator min_clear_offset_itr_;
+
+ TimeDelta sample_dts_;
+ int64 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