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

Side by Side Diff: media/mp4/track_run_iterator.h

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

Powered by Google App Engine
This is Rietveld 408576698