OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ | 5 #ifndef MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ |
6 #define MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ | 6 #define MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
13 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
14 #include "media/base/stream_parser_buffer.h" | 16 #include "media/base/stream_parser_buffer.h" |
15 #include "media/formats/mp4/box_definitions.h" | 17 #include "media/formats/mp4/box_definitions.h" |
16 #include "media/formats/mp4/cenc.h" | 18 #include "media/formats/mp4/cenc.h" |
17 | 19 |
18 namespace media { | 20 namespace media { |
19 | 21 |
20 class DecryptConfig; | 22 class DecryptConfig; |
21 | 23 |
22 namespace mp4 { | 24 namespace mp4 { |
23 | 25 |
24 base::TimeDelta MEDIA_EXPORT TimeDeltaFromRational(int64 numer, int64 denom); | 26 base::TimeDelta MEDIA_EXPORT TimeDeltaFromRational(int64_t numer, |
25 DecodeTimestamp MEDIA_EXPORT DecodeTimestampFromRational(int64 numer, | 27 int64_t denom); |
26 int64 denom); | 28 DecodeTimestamp MEDIA_EXPORT DecodeTimestampFromRational(int64_t numer, |
| 29 int64_t denom); |
27 | 30 |
28 struct SampleInfo; | 31 struct SampleInfo; |
29 struct TrackRunInfo; | 32 struct TrackRunInfo; |
30 | 33 |
31 class MEDIA_EXPORT TrackRunIterator { | 34 class MEDIA_EXPORT TrackRunIterator { |
32 public: | 35 public: |
33 // Create a new TrackRunIterator. A reference to |moov| will be retained for | 36 // Create a new TrackRunIterator. A reference to |moov| will be retained for |
34 // the lifetime of this object. | 37 // the lifetime of this object. |
35 TrackRunIterator(const Movie* moov, const scoped_refptr<MediaLog>& media_log); | 38 TrackRunIterator(const Movie* moov, const scoped_refptr<MediaLog>& media_log); |
36 ~TrackRunIterator(); | 39 ~TrackRunIterator(); |
(...skipping 10 matching lines...) Expand all Loading... |
47 void AdvanceRun(); | 50 void AdvanceRun(); |
48 void AdvanceSample(); | 51 void AdvanceSample(); |
49 | 52 |
50 // Returns true if this track run has auxiliary information and has not yet | 53 // Returns true if this track run has auxiliary information and has not yet |
51 // been cached. Only valid if IsRunValid(). | 54 // been cached. Only valid if IsRunValid(). |
52 bool AuxInfoNeedsToBeCached(); | 55 bool AuxInfoNeedsToBeCached(); |
53 | 56 |
54 // Caches the CENC data from the given buffer. |buf| must be a buffer starting | 57 // Caches the CENC data from the given buffer. |buf| must be a buffer starting |
55 // at the offset given by cenc_offset(), with a |size| of at least | 58 // at the offset given by cenc_offset(), with a |size| of at least |
56 // cenc_size(). Returns true on success, false on error. | 59 // cenc_size(). Returns true on success, false on error. |
57 bool CacheAuxInfo(const uint8* buf, int size); | 60 bool CacheAuxInfo(const uint8_t* buf, int size); |
58 | 61 |
59 // Returns the maximum buffer location at which no data earlier in the stream | 62 // Returns the maximum buffer location at which no data earlier in the stream |
60 // will be required in order to read the current or any subsequent sample. You | 63 // will be required in order to read the current or any subsequent sample. You |
61 // may clear all data up to this offset before reading the current sample | 64 // may clear all data up to this offset before reading the current sample |
62 // safely. Result is in the same units as offset() (for Media Source this is | 65 // safely. Result is in the same units as offset() (for Media Source this is |
63 // in bytes past the the head of the MOOF box). | 66 // in bytes past the the head of the MOOF box). |
64 int64 GetMaxClearOffset(); | 67 int64_t GetMaxClearOffset(); |
65 | 68 |
66 // Property of the current run. Only valid if IsRunValid(). | 69 // Property of the current run. Only valid if IsRunValid(). |
67 uint32 track_id() const; | 70 uint32_t track_id() const; |
68 int64 aux_info_offset() const; | 71 int64_t aux_info_offset() const; |
69 int aux_info_size() const; | 72 int aux_info_size() const; |
70 bool is_encrypted() const; | 73 bool is_encrypted() const; |
71 bool is_audio() const; | 74 bool is_audio() const; |
72 // Only one is valid, based on the value of is_audio(). | 75 // Only one is valid, based on the value of is_audio(). |
73 const AudioSampleEntry& audio_description() const; | 76 const AudioSampleEntry& audio_description() const; |
74 const VideoSampleEntry& video_description() const; | 77 const VideoSampleEntry& video_description() const; |
75 | 78 |
76 // Properties of the current sample. Only valid if IsSampleValid(). | 79 // Properties of the current sample. Only valid if IsSampleValid(). |
77 int64 sample_offset() const; | 80 int64_t sample_offset() const; |
78 int sample_size() const; | 81 int sample_size() const; |
79 DecodeTimestamp dts() const; | 82 DecodeTimestamp dts() const; |
80 base::TimeDelta cts() const; | 83 base::TimeDelta cts() const; |
81 base::TimeDelta duration() const; | 84 base::TimeDelta duration() const; |
82 bool is_keyframe() const; | 85 bool is_keyframe() const; |
83 | 86 |
84 // Only call when is_encrypted() is true and AuxInfoNeedsToBeCached() is | 87 // Only call when is_encrypted() is true and AuxInfoNeedsToBeCached() is |
85 // false. Result is owned by caller. | 88 // false. Result is owned by caller. |
86 scoped_ptr<DecryptConfig> GetDecryptConfig(); | 89 scoped_ptr<DecryptConfig> GetDecryptConfig(); |
87 | 90 |
88 private: | 91 private: |
89 void ResetRun(); | 92 void ResetRun(); |
90 const TrackEncryption& track_encryption() const; | 93 const TrackEncryption& track_encryption() const; |
91 | 94 |
92 uint32 GetGroupDescriptionIndex(uint32 sample_index) const; | 95 uint32_t GetGroupDescriptionIndex(uint32_t sample_index) const; |
93 | 96 |
94 // Sample encryption information. | 97 // Sample encryption information. |
95 bool IsSampleEncrypted(size_t sample_index) const; | 98 bool IsSampleEncrypted(size_t sample_index) const; |
96 uint8 GetIvSize(size_t sample_index) const; | 99 uint8_t GetIvSize(size_t sample_index) const; |
97 const std::vector<uint8>& GetKeyId(size_t sample_index) const; | 100 const std::vector<uint8_t>& GetKeyId(size_t sample_index) const; |
98 | 101 |
99 const Movie* moov_; | 102 const Movie* moov_; |
100 scoped_refptr<MediaLog> media_log_; | 103 scoped_refptr<MediaLog> media_log_; |
101 | 104 |
102 std::vector<TrackRunInfo> runs_; | 105 std::vector<TrackRunInfo> runs_; |
103 std::vector<TrackRunInfo>::const_iterator run_itr_; | 106 std::vector<TrackRunInfo>::const_iterator run_itr_; |
104 std::vector<SampleInfo>::const_iterator sample_itr_; | 107 std::vector<SampleInfo>::const_iterator sample_itr_; |
105 | 108 |
106 std::vector<FrameCENCInfo> cenc_info_; | 109 std::vector<FrameCENCInfo> cenc_info_; |
107 | 110 |
108 int64 sample_dts_; | 111 int64_t sample_dts_; |
109 int64 sample_offset_; | 112 int64_t sample_offset_; |
110 | 113 |
111 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator); | 114 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator); |
112 }; | 115 }; |
113 | 116 |
114 } // namespace mp4 | 117 } // namespace mp4 |
115 } // namespace media | 118 } // namespace media |
116 | 119 |
117 #endif // MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ | 120 #endif // MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_ |
OLD | NEW |