cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / media / mp4 / track_run_iterator.h
bloba21c5ba0c2dd7ba263cbb4a42791e592417d4bd5
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.
5 #ifndef MEDIA_MP4_TRACK_RUN_ITERATOR_H_
6 #define MEDIA_MP4_TRACK_RUN_ITERATOR_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "media/base/media_export.h"
13 #include "media/base/media_log.h"
14 #include "media/mp4/box_definitions.h"
15 #include "media/mp4/cenc.h"
17 namespace media {
19 class DecryptConfig;
21 namespace mp4 {
23 using base::TimeDelta;
24 base::TimeDelta MEDIA_EXPORT TimeDeltaFromRational(int64 numer, int64 denom);
26 struct SampleInfo;
27 struct TrackRunInfo;
29 class MEDIA_EXPORT TrackRunIterator {
30 public:
31 // Create a new TrackRunIterator. A reference to |moov| will be retained for
32 // the lifetime of this object.
33 TrackRunIterator(const Movie* moov, const LogCB& log_cb);
34 ~TrackRunIterator();
36 // Sets up the iterator to handle all the runs from the current fragment.
37 bool Init(const MovieFragment& moof);
39 // Returns true if the properties of the current run or sample are valid.
40 bool IsRunValid() const;
41 bool IsSampleValid() const;
43 // Advance the properties to refer to the next run or sample. Requires that
44 // the current sample be valid.
45 void AdvanceRun();
46 void AdvanceSample();
48 // Returns true if this track run has auxiliary information and has not yet
49 // been cached. Only valid if IsRunValid().
50 bool AuxInfoNeedsToBeCached();
52 // Caches the CENC data from the given buffer. |buf| must be a buffer starting
53 // at the offset given by cenc_offset(), with a |size| of at least
54 // cenc_size(). Returns true on success, false on error.
55 bool CacheAuxInfo(const uint8* buf, int size);
57 // Returns the maximum buffer location at which no data earlier in the stream
58 // will be required in order to read the current or any subsequent sample. You
59 // may clear all data up to this offset before reading the current sample
60 // safely. Result is in the same units as offset() (for Media Source this is
61 // in bytes past the the head of the MOOF box).
62 int64 GetMaxClearOffset();
64 // Property of the current run. Only valid if IsRunValid().
65 uint32 track_id() const;
66 int64 aux_info_offset() const;
67 int aux_info_size() const;
68 bool is_encrypted() const;
69 bool is_audio() const;
70 // Only one is valid, based on the value of is_audio().
71 const AudioSampleEntry& audio_description() const;
72 const VideoSampleEntry& video_description() const;
74 // Properties of the current sample. Only valid if IsSampleValid().
75 int64 sample_offset() const;
76 int sample_size() const;
77 TimeDelta dts() const;
78 TimeDelta cts() const;
79 TimeDelta duration() const;
80 bool is_keyframe() const;
82 // Only call when is_encrypted() is true and AuxInfoNeedsToBeCached() is
83 // false. Result is owned by caller.
84 scoped_ptr<DecryptConfig> GetDecryptConfig();
86 private:
87 void ResetRun();
88 const TrackEncryption& track_encryption() const;
90 const Movie* moov_;
91 LogCB log_cb_;
93 std::vector<TrackRunInfo> runs_;
94 std::vector<TrackRunInfo>::const_iterator run_itr_;
95 std::vector<SampleInfo>::const_iterator sample_itr_;
97 std::vector<FrameCENCInfo> cenc_info_;
99 int64 sample_dts_;
100 int64 sample_offset_;
102 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator);
105 } // namespace mp4
106 } // namespace media
108 #endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_