Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MP4_TRACK_RUN_ITERATOR_H_ | |
| 6 #define MEDIA_MP4_TRACK_RUN_ITERATOR_H_ | |
| 7 | |
|
acolwell GONE FROM CHROMIUM
2012/06/08 16:10:38
lint nit: add #include<vector>
strobe_
2012/06/11 18:44:21
Done.
| |
| 8 #include "base/time.h" | |
| 9 #include "media/mp4/box_definitions.h" | |
| 10 #include "media/mp4/cenc.h" | |
| 11 | |
| 12 namespace media { | |
| 13 namespace mp4 { | |
| 14 | |
| 15 using base::TimeDelta; | |
| 16 | |
| 17 base::TimeDelta TimeDeltaFromFrac(int64 numer, uint64 denom); | |
| 18 | |
| 19 struct SampleInfo { | |
| 20 int size; | |
| 21 TimeDelta duration; | |
| 22 TimeDelta cts_offset; | |
| 23 bool is_keyframe; | |
| 24 }; | |
| 25 | |
| 26 struct TrackRunInfo { | |
| 27 uint32 track_id; | |
| 28 std::vector<SampleInfo> samples; | |
| 29 TimeDelta start_dts; | |
| 30 int64 sample_start_offset; | |
| 31 | |
| 32 bool is_encrypted; | |
| 33 int64 cenc_start_offset; | |
| 34 int cenc_total_size; | |
| 35 uint8 default_cenc_size; | |
| 36 // Only valid if default_cenc_size == 0. (In this case, infer the sample count | |
| 37 // from the 'samples' parameter; they shall be the same.) | |
| 38 std::vector<uint8> cenc_sizes; | |
| 39 | |
| 40 TrackRunInfo(); | |
| 41 ~TrackRunInfo(); | |
| 42 }; | |
| 43 | |
| 44 class TrackRunIterator { | |
| 45 public: | |
| 46 TrackRunIterator(); | |
| 47 ~TrackRunIterator(); | |
| 48 | |
| 49 void Reset(); | |
| 50 | |
| 51 // Sets up the iterator to handle all the runs from the current fragment. | |
| 52 bool Init(const Movie& moov, const MovieFragment& moof); | |
| 53 | |
| 54 // Returns true if the properties of the current run or sample are valid. | |
| 55 bool RunValid() const; | |
| 56 bool SampleValid() const; | |
| 57 | |
| 58 // Advance the properties to refer to the next run or sample. Requires that | |
| 59 // the current sample be valid. | |
| 60 void AdvanceRun(); | |
| 61 void AdvanceSample(); | |
| 62 | |
| 63 // Returns true iff the track is encrypted and the common encryption sample | |
| 64 // auxiliary information has not yet been cached for the current track. | |
| 65 bool NeedsCENC(); | |
| 66 | |
| 67 // Cache the CENC data from the given buffer. | |
| 68 bool CacheCENC(const uint8* buf, int size); | |
| 69 | |
| 70 // Returns the maximum buffer location at which no data earlier in the stream | |
| 71 // will be required in order to read the current or any subsequent sample. You | |
| 72 // may clear all data up to this offset before reading the current sample | |
| 73 // safely. Result is in the same units as offset() (for Media Source this is | |
| 74 // in bytes past the the head of the MOOF box). | |
| 75 int64 GetMaxClearOffset(); | |
| 76 | |
| 77 // Property of the current run. Reqiures RunValid(). | |
| 78 uint32 track_id() const; | |
| 79 bool is_encrypted() const; | |
| 80 // Only valid if is_encrypted() is true. | |
| 81 int64 cenc_offset() const; | |
| 82 int cenc_size() const; | |
| 83 | |
| 84 // Properties of the current sample. Requires SampleValid(). | |
| 85 int64 offset() const; | |
| 86 int size() const; | |
| 87 TimeDelta dts() const; | |
| 88 TimeDelta cts() const; | |
| 89 TimeDelta duration() const; | |
| 90 bool is_keyframe() const; | |
| 91 // Only valid if is_encrypted() is true and NeedsCENC() is false. | |
| 92 const FrameCENCInfo& frame_cenc_info(); | |
| 93 | |
| 94 private: | |
| 95 void ResetRun(); | |
| 96 std::vector<TrackRunInfo> runs_; | |
| 97 std::vector<TrackRunInfo>::const_iterator run_itr_; | |
| 98 | |
| 99 std::vector<SampleInfo>::const_iterator sample_itr_; | |
| 100 std::vector<uint8> cenc_cache_; | |
| 101 | |
| 102 std::vector<int64> min_clear_offsets_; | |
| 103 std::vector<int64>::const_iterator min_clear_offset_itr_; | |
| 104 | |
| 105 TimeDelta sample_dts_; | |
| 106 int64 sample_offset_; | |
| 107 FrameCENCInfo frame_cenc_info_; | |
| 108 }; | |
| 109 | |
| 110 } // namespace mp4 | |
| 111 } // namespace media | |
| 112 | |
| 113 #endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_ | |
| OLD | NEW |