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 <cstdint>
9#include <map>
10#include <memory>
11#include <vector>
12
13#include <packager/macros/classes.h>
14#include <packager/media/formats/mp4/box_definitions.h>
15
16namespace shaka {
17namespace media {
18
19class DecryptConfig;
20
21namespace mp4 {
22
23struct SampleInfo;
24struct TrackRunInfo;
25
27 public:
30 explicit TrackRunIterator(const Movie* moov);
32
39 bool Init();
40
43 bool Init(const MovieFragment& moof);
44
47 bool IsRunValid() const;
50 bool IsSampleValid() const;
51
54 void AdvanceRun();
57 void AdvanceSample();
58
62
67 bool CacheAuxInfo(const uint8_t* buf, int size);
68
75 int64_t GetMaxClearOffset();
76
79 uint32_t track_id() const;
80 int64_t aux_info_offset() const;
81 int aux_info_size() const;
82 bool is_encrypted() const;
83 bool is_audio() const;
84 bool is_video() const;
86
91
94 int64_t sample_offset() const;
95 int sample_size() const;
96 int64_t dts() const;
97 int64_t cts() const;
98 int64_t duration() const;
99 bool is_keyframe() const;
101
104 std::unique_ptr<DecryptConfig> GetDecryptConfig();
105
106 private:
107 void ResetRun();
108 const TrackEncryption& track_encryption() const;
109 int64_t GetTimestampAdjustment(const Movie& movie,
110 const Track& track,
111 const TrackFragment* traf);
112
113 const Movie* moov_;
114
115 std::vector<TrackRunInfo> runs_;
116 std::vector<TrackRunInfo>::const_iterator run_itr_;
117 std::vector<SampleInfo>::const_iterator sample_itr_;
118
119 // Track the start dts of the next segment, only useful if decode_time box is
120 // absent.
121 std::vector<int64_t> next_fragment_start_dts_;
122
123 int64_t sample_dts_;
124 int64_t sample_offset_;
125
126 // TrackId => adjustment map.
127 std::map<uint32_t, int64_t> timestamp_adjustment_map_;
128
129 DISALLOW_COPY_AND_ASSIGN(TrackRunIterator);
130};
131
132} // namespace mp4
133} // namespace media
134} // namespace shaka
135
136#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.