Shaka Packager SDK
Loading...
Searching...
No Matches
track_run_iterator.h
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 PACKAGER_MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_
6#define PACKAGER_MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_
7
8#include <map>
9#include <memory>
10#include <vector>
11
12#include <packager/macros/classes.h>
13#include <packager/media/formats/mp4/box_definitions.h>
14
15namespace shaka {
16namespace media {
17
18class DecryptConfig;
19
20namespace mp4 {
21
22struct SampleInfo;
23struct TrackRunInfo;
24
26 public:
29 explicit TrackRunIterator(const Movie* moov);
31
38 bool Init();
39
42 bool Init(const MovieFragment& moof);
43
46 bool IsRunValid() const;
49 bool IsSampleValid() const;
50
53 void AdvanceRun();
56 void AdvanceSample();
57
61
66 bool CacheAuxInfo(const uint8_t* buf, int size);
67
74 int64_t GetMaxClearOffset();
75
78 uint32_t track_id() const;
79 int64_t aux_info_offset() const;
80 int aux_info_size() const;
81 bool is_encrypted() const;
82 bool is_audio() const;
83 bool is_video() const;
85
90
93 int64_t sample_offset() const;
94 int sample_size() const;
95 int64_t dts() const;
96 int64_t cts() const;
97 int64_t duration() const;
98 bool is_keyframe() const;
100
103 std::unique_ptr<DecryptConfig> GetDecryptConfig();
104
105 private:
106 void ResetRun();
107 const TrackEncryption& track_encryption() const;
108 int64_t GetTimestampAdjustment(const Movie& movie,
109 const Track& track,
110 const TrackFragment* traf);
111
112 const Movie* moov_;
113
114 std::vector<TrackRunInfo> runs_;
115 std::vector<TrackRunInfo>::const_iterator run_itr_;
116 std::vector<SampleInfo>::const_iterator sample_itr_;
117
118 // Track the start dts of the next segment, only useful if decode_time box is
119 // absent.
120 std::vector<int64_t> next_fragment_start_dts_;
121
122 int64_t sample_dts_;
123 int64_t sample_offset_;
124
125 // TrackId => adjustment map.
126 std::map<uint32_t, int64_t> timestamp_adjustment_map_;
127
128 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator);
129};
130
131} // namespace mp4
132} // namespace media
133} // namespace shaka
134
135#endif // PACKAGER_MEDIA_FORMATS_MP4_TRACK_RUN_ITERATOR_H_
const VideoSampleEntry & video_description() const
Only valid if is_video() is true.
const AudioSampleEntry & audio_description() const
Only valid if is_audio() is true.
bool CacheAuxInfo(const uint8_t *buf, int size)
std::unique_ptr< DecryptConfig > GetDecryptConfig()
All the methods that are virtual are virtual for mocking.