7 #ifndef PACKAGER_MEDIA_FORMATS_MP4_SEGMENTER_H_
8 #define PACKAGER_MEDIA_FORMATS_MP4_SEGMENTER_H_
14 #include "packager/base/optional.h"
15 #include "packager/media/base/fourccs.h"
16 #include "packager/media/base/range.h"
17 #include "packager/media/formats/mp4/box_definitions.h"
18 #include "packager/status.h"
23 struct EncryptionConfig;
30 class ProgressListener;
47 std::unique_ptr<FileType> ftyp,
48 std::unique_ptr<Movie> moov);
59 const std::vector<std::shared_ptr<const StreamInfo>>& streams,
83 virtual bool GetInitRange(
size_t* offset,
size_t* size) = 0;
92 virtual std::vector<Range> GetSegmentRanges() = 0;
94 uint32_t GetReferenceTimeScale()
const;
109 const MuxerOptions& options()
const {
return options_; }
110 FileType* ftyp() {
return ftyp_.get(); }
111 Movie* moov() {
return moov_.get(); }
112 BufferWriter* fragment_buffer() {
return fragment_buffer_.get(); }
113 SegmentIndex* sidx() {
return sidx_.get(); }
114 MuxerListener* muxer_listener() {
return muxer_listener_; }
115 uint64_t progress_target() {
return progress_target_; }
116 const std::vector<KeyFrameInfo>& key_frame_infos()
const {
117 return key_frame_infos_;
120 void set_progress_target(uint64_t progress_target) {
121 progress_target_ = progress_target;
125 virtual Status DoInitialize() = 0;
126 virtual Status DoFinalize() = 0;
127 virtual Status DoFinalizeSegment() = 0;
129 uint32_t GetReferenceStreamId();
131 void FinalizeFragmentForKeyRotation(
133 bool fragment_encrypted,
134 const EncryptionConfig& encryption_config);
136 const MuxerOptions& options_;
137 std::unique_ptr<FileType> ftyp_;
138 std::unique_ptr<Movie> moov_;
139 std::unique_ptr<MovieFragment> moof_;
140 std::unique_ptr<BufferWriter> fragment_buffer_;
141 std::unique_ptr<SegmentIndex> sidx_;
142 std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
143 MuxerListener* muxer_listener_ =
nullptr;
144 ProgressListener* progress_listener_ =
nullptr;
145 uint64_t progress_target_ = 0u;
146 uint64_t accumulated_progress_ = 0u;
147 uint32_t sample_duration_ = 0u;
148 std::vector<uint64_t> stream_durations_;
149 std::vector<KeyFrameInfo> key_frame_infos_;
151 DISALLOW_COPY_AND_ASSIGN(Segmenter);
158 #endif // PACKAGER_MEDIA_FORMATS_MP4_SEGMENTER_H_