7 #ifndef MEDIA_FORMATS_MP4_SEGMENTER_H_
8 #define 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;
46 std::unique_ptr<FileType> ftyp,
47 std::unique_ptr<Movie> moov);
58 const std::vector<std::shared_ptr<const StreamInfo>>& streams,
82 virtual bool GetInitRange(
size_t* offset,
size_t* size) = 0;
91 virtual std::vector<Range> GetSegmentRanges() = 0;
93 uint32_t GetReferenceTimeScale()
const;
108 const MuxerOptions& options()
const {
return options_; }
109 FileType* ftyp() {
return ftyp_.get(); }
110 Movie* moov() {
return moov_.get(); }
111 BufferWriter* fragment_buffer() {
return fragment_buffer_.get(); }
112 SegmentIndex* sidx() {
return sidx_.get(); }
113 MuxerListener* muxer_listener() {
return muxer_listener_; }
114 uint64_t progress_target() {
return progress_target_; }
116 void set_progress_target(uint64_t progress_target) {
117 progress_target_ = progress_target;
121 virtual Status DoInitialize() = 0;
122 virtual Status DoFinalize() = 0;
123 virtual Status DoFinalizeSegment() = 0;
125 uint32_t GetReferenceStreamId();
127 void FinalizeFragmentForKeyRotation(
129 bool fragment_encrypted,
130 const EncryptionConfig& encryption_config);
132 const MuxerOptions& options_;
133 std::unique_ptr<FileType> ftyp_;
134 std::unique_ptr<Movie> moov_;
135 std::unique_ptr<MovieFragment> moof_;
136 std::unique_ptr<BufferWriter> fragment_buffer_;
137 std::unique_ptr<SegmentIndex> sidx_;
138 std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
139 MuxerListener* muxer_listener_ =
nullptr;
140 ProgressListener* progress_listener_ =
nullptr;
141 uint64_t progress_target_ = 0u;
142 uint64_t accumulated_progress_ = 0u;
143 uint32_t sample_duration_ = 0u;
144 std::vector<uint64_t> stream_durations_;
146 DISALLOW_COPY_AND_ASSIGN(Segmenter);
153 #endif // MEDIA_FORMATS_MP4_SEGMENTER_H_