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

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

Issue 10651006: Add Common Encryption support to BMFF, including subsample decryption. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Satisfy mac_rel buildbot Created 8 years, 5 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
« no previous file with comments | « media/mp4/mp4_stream_parser_unittest.cc ('k') | media/mp4/track_run_iterator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_MP4_TRACK_RUN_ITERATOR_H_ 5 #ifndef MEDIA_MP4_TRACK_RUN_ITERATOR_H_
6 #define MEDIA_MP4_TRACK_RUN_ITERATOR_H_ 6 #define MEDIA_MP4_TRACK_RUN_ITERATOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 #include "media/mp4/box_definitions.h" 13 #include "media/mp4/box_definitions.h"
14 #include "media/mp4/cenc.h"
14 15
15 namespace media { 16 namespace media {
17
18 class DecryptConfig;
19
16 namespace mp4 { 20 namespace mp4 {
17 21
18 using base::TimeDelta; 22 using base::TimeDelta;
19 base::TimeDelta MEDIA_EXPORT TimeDeltaFromFrac(int64 numer, int64 denom); 23 base::TimeDelta MEDIA_EXPORT TimeDeltaFromRational(int64 numer, int64 denom);
20 24
21 struct SampleInfo; 25 struct SampleInfo;
22 struct TrackRunInfo; 26 struct TrackRunInfo;
23 27
24 class MEDIA_EXPORT TrackRunIterator { 28 class MEDIA_EXPORT TrackRunIterator {
25 public: 29 public:
26 // Create a new TrackRunIterator. A reference to |moov| will be retained for 30 // Create a new TrackRunIterator. A reference to |moov| will be retained for
27 // the lifetime of this object. 31 // the lifetime of this object.
28 explicit TrackRunIterator(const Movie* moov); 32 explicit TrackRunIterator(const Movie* moov);
29 ~TrackRunIterator(); 33 ~TrackRunIterator();
30 34
31 void Reset(); 35 void Reset();
32 36
33 // Sets up the iterator to handle all the runs from the current fragment. 37 // Sets up the iterator to handle all the runs from the current fragment.
34 bool Init(const MovieFragment& moof); 38 bool Init(const MovieFragment& moof);
35 39
36 // Returns true if the properties of the current run or sample are valid. 40 // Returns true if the properties of the current run or sample are valid.
37 bool RunIsValid() const; 41 bool IsRunValid() const;
38 bool SampleIsValid() const; 42 bool IsSampleValid() const;
39 43
40 // Advance the properties to refer to the next run or sample. Requires that 44 // Advance the properties to refer to the next run or sample. Requires that
41 // the current sample be valid. 45 // the current sample be valid.
42 void AdvanceRun(); 46 void AdvanceRun();
43 void AdvanceSample(); 47 void AdvanceSample();
44 48
49 // Returns true if this track run has auxiliary information and has not yet
50 // been cached. Only valid if IsRunValid().
51 bool AuxInfoNeedsToBeCached();
52
53 // Caches the CENC data from the given buffer. |buf| must be a buffer starting
54 // at the offset given by cenc_offset(), with a |size| of at least
55 // cenc_size(). Returns true on success, false on error.
56 bool CacheAuxInfo(const uint8* buf, int size);
57
45 // Returns the maximum buffer location at which no data earlier in the stream 58 // Returns the maximum buffer location at which no data earlier in the stream
46 // will be required in order to read the current or any subsequent sample. You 59 // will be required in order to read the current or any subsequent sample. You
47 // may clear all data up to this offset before reading the current sample 60 // may clear all data up to this offset before reading the current sample
48 // safely. Result is in the same units as offset() (for Media Source this is 61 // safely. Result is in the same units as offset() (for Media Source this is
49 // in bytes past the the head of the MOOF box). 62 // in bytes past the the head of the MOOF box).
50 int64 GetMaxClearOffset(); 63 int64 GetMaxClearOffset();
51 64
52 // Returns the minimum timestamp (or kInfiniteDuration if no runs present). 65 // Returns the minimum timestamp (or kInfiniteDuration if no runs present).
53 TimeDelta GetMinDecodeTimestamp(); 66 TimeDelta GetMinDecodeTimestamp();
54 67
55 // Property of the current run. Only valid if RunIsValid(). 68 // Property of the current run. Only valid if IsRunValid().
56 uint32 track_id() const; 69 uint32 track_id() const;
70 int64 aux_info_offset() const;
71 int aux_info_size() const;
57 bool is_encrypted() const; 72 bool is_encrypted() const;
58 bool is_audio() const; 73 bool is_audio() const;
59 // Only one is valid, based on the value of is_audio(). 74 // Only one is valid, based on the value of is_audio().
60 const AudioSampleEntry& audio_description() const; 75 const AudioSampleEntry& audio_description() const;
61 const VideoSampleEntry& video_description() const; 76 const VideoSampleEntry& video_description() const;
62 77
63 // Properties of the current sample. Only valid if SampleIsValid(). 78 // Properties of the current sample. Only valid if IsSampleValid().
64 int64 sample_offset() const; 79 int64 sample_offset() const;
65 int sample_size() const; 80 int sample_size() const;
66 TimeDelta dts() const; 81 TimeDelta dts() const;
67 TimeDelta cts() const; 82 TimeDelta cts() const;
68 TimeDelta duration() const; 83 TimeDelta duration() const;
69 bool is_keyframe() const; 84 bool is_keyframe() const;
70 85
86 // Only call when is_encrypted() is true and AuxInfoNeedsToBeCached() is
87 // false. Result is owned by caller.
88 scoped_ptr<DecryptConfig> GetDecryptConfig();
89
71 private: 90 private:
72 void ResetRun(); 91 void ResetRun();
92 const TrackEncryption& track_encryption() const;
73 93
74 const Movie* moov_; 94 const Movie* moov_;
75 95
76 std::vector<TrackRunInfo> runs_; 96 std::vector<TrackRunInfo> runs_;
77 std::vector<TrackRunInfo>::const_iterator run_itr_; 97 std::vector<TrackRunInfo>::const_iterator run_itr_;
78 std::vector<SampleInfo>::const_iterator sample_itr_; 98 std::vector<SampleInfo>::const_iterator sample_itr_;
79 99
100 std::vector<FrameCENCInfo> cenc_info_;
101
80 int64 sample_dts_; 102 int64 sample_dts_;
81 int64 sample_offset_; 103 int64 sample_offset_;
82 104
83 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator); 105 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator);
84 }; 106 };
85 107
86 } // namespace mp4 108 } // namespace mp4
87 } // namespace media 109 } // namespace media
88 110
89 #endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_ 111 #endif // MEDIA_MP4_TRACK_RUN_ITERATOR_H_
OLDNEW
« no previous file with comments | « media/mp4/mp4_stream_parser_unittest.cc ('k') | media/mp4/track_run_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698