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

Side by Side 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 unified diff | Download patch
OLDNEW
(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
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 size_t 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 size_t sample_start_offset;
31
32 bool is_encrypted;
33 size_t cenc_start_offset;
34 size_t 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();
56 bool SampleValid();
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, size_t 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 size_t GetMaxClearOffset();
76
77 // Property of the current run. Reqiures RunValid().
78 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.
79 bool is_encrypted() const { return run_itr_->is_encrypted; }
80 // Only valid if is_encrypted() is true.
81 size_t cenc_offset() const { return run_itr_->cenc_start_offset; }
82 size_t cenc_size() const { return run_itr_->cenc_total_size; }
83
84 // Properties of the current sample. Requires SampleValid().
85 size_t offset() const { return sample_offset_; }
86 size_t size() const { return sample_itr_->size; }
87 TimeDelta dts() const { return sample_dts_; }
88 TimeDelta cts() const { return sample_dts_ + sample_itr_->cts_offset; }
89 TimeDelta duration() const { return sample_itr_->duration; }
90 bool is_keyframe() const { return sample_itr_->is_keyframe; }
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<size_t> min_clear_offsets_;
103 std::vector<size_t>::const_iterator min_clear_offset_itr_;
104
105 TimeDelta sample_dts_;
106 size_t sample_offset_;
107 FrameCENCInfo frame_cenc_info_;
108 };
109
110 } // namespace mp4
111 } // namespace media
112
113 #endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698