7 #ifndef PACKAGER_MEDIA_FORMATS_MP4_SEGMENTER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP4_SEGMENTER_H_
15 #include <packager/macros/classes.h>
16 #include <packager/media/base/fourccs.h>
17 #include <packager/media/base/range.h>
18 #include <packager/media/formats/mp4/box_definitions.h>
19 #include <packager/status.h>
24 struct EncryptionConfig;
31 class ProgressListener;
48 std::unique_ptr<FileType> ftyp,
49 std::unique_ptr<Movie> moov);
60 const std::vector<std::shared_ptr<const StreamInfo>>& streams,
93 virtual std::vector<Range> GetSegmentRanges() = 0;
95 int32_t GetReferenceTimeScale()
const;
103 return sample_durations_[num_samples_ < 2 ? 0 : 1];
112 const MuxerOptions& options()
const {
return options_; }
113 FileType* ftyp() {
return ftyp_.get(); }
114 Movie* moov() {
return moov_.get(); }
115 BufferWriter* fragment_buffer() {
return fragment_buffer_.get(); }
116 SegmentIndex* sidx() {
return sidx_.get(); }
117 MuxerListener* muxer_listener() {
return muxer_listener_; }
118 uint64_t progress_target() {
return progress_target_; }
119 const std::vector<KeyFrameInfo>& key_frame_infos()
const {
120 return key_frame_infos_;
123 void set_progress_target(uint64_t progress_target) {
124 progress_target_ = progress_target;
128 virtual Status DoInitialize() = 0;
129 virtual Status DoFinalize() = 0;
130 virtual Status DoFinalizeSegment(int64_t segment_number) = 0;
131 virtual Status DoFinalizeChunk(int64_t segment_number) {
return Status::OK; }
133 uint32_t GetReferenceStreamId();
135 void FinalizeFragmentForKeyRotation(
137 bool fragment_encrypted,
138 const EncryptionConfig& encryption_config);
140 const MuxerOptions& options_;
141 std::unique_ptr<FileType> ftyp_;
142 std::unique_ptr<Movie> moov_;
143 std::unique_ptr<MovieFragment> moof_;
144 std::unique_ptr<BufferWriter> fragment_buffer_;
145 std::unique_ptr<SegmentIndex> sidx_;
146 std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
147 MuxerListener* muxer_listener_ =
nullptr;
148 ProgressListener* progress_listener_ =
nullptr;
149 uint64_t progress_target_ = 0u;
150 uint64_t accumulated_progress_ = 0u;
151 int64_t sample_durations_[2] = {0, 0};
152 size_t num_samples_ = 0;
153 std::vector<uint64_t> stream_durations_;
154 std::vector<KeyFrameInfo> key_frame_infos_;
156 DISALLOW_COPY_AND_ASSIGN(Segmenter);
All the methods that are virtual are virtual for mocking.