7 #ifndef MEDIA_FORMATS_MP4_SEGMENTER_H_
8 #define MEDIA_FORMATS_MP4_SEGMENTER_H_
14 #include "packager/media/base/fourccs.h"
15 #include "packager/media/base/status.h"
16 #include "packager/media/formats/mp4/box_definitions.h"
21 struct EncryptionConfig;
28 class ProgressListener;
44 std::unique_ptr<FileType> ftyp,
45 std::unique_ptr<Movie> moov);
67 Status AddSample(
size_t stream_id, std::shared_ptr<MediaSample> sample);
74 std::shared_ptr<SegmentInfo> segment_info);
78 virtual bool GetInitRange(
size_t* offset,
size_t* size) = 0;
84 uint32_t GetReferenceTimeScale()
const;
100 FileType* ftyp() {
return ftyp_.get(); }
101 Movie* moov() {
return moov_.get(); }
102 BufferWriter* fragment_buffer() {
return fragment_buffer_.get(); }
103 SegmentIndex* sidx() {
return sidx_.get(); }
104 MuxerListener* muxer_listener() {
return muxer_listener_; }
105 uint64_t progress_target() {
return progress_target_; }
107 void set_progress_target(uint64_t progress_target) {
108 progress_target_ = progress_target;
112 virtual Status DoInitialize() = 0;
113 virtual Status DoFinalize() = 0;
114 virtual Status DoFinalizeSegment() = 0;
116 uint32_t GetReferenceStreamId();
118 void FinalizeFragmentForKeyRotation(
120 bool fragment_encrypted,
121 const EncryptionConfig& encryption_config);
123 const MuxerOptions& options_;
124 std::unique_ptr<FileType> ftyp_;
125 std::unique_ptr<Movie> moov_;
126 std::unique_ptr<MovieFragment> moof_;
127 std::unique_ptr<BufferWriter> fragment_buffer_;
128 std::unique_ptr<SegmentIndex> sidx_;
129 std::vector<std::unique_ptr<Fragmenter>> fragmenters_;
130 MuxerListener* muxer_listener_;
131 ProgressListener* progress_listener_;
132 uint64_t progress_target_;
133 uint64_t accumulated_progress_;
134 uint32_t sample_duration_;
136 DISALLOW_COPY_AND_ASSIGN(Segmenter);
143 #endif // MEDIA_FORMATS_MP4_SEGMENTER_H_