7 #ifndef PACKAGER_MEDIA_FORMATS_WEBM_SEGMENTER_H_
8 #define PACKAGER_MEDIA_FORMATS_WEBM_SEGMENTER_H_
12 #include <mkvmuxer/mkvmuxer.h>
14 #include <packager/macros/classes.h>
15 #include <packager/media/base/range.h>
16 #include <packager/media/formats/webm/mkv_writer.h>
17 #include <packager/media/formats/webm/seek_head.h>
18 #include <packager/status.h>
25 class AudioStreamInfo;
28 class ProgressListener;
30 class VideoStreamInfo;
60 int64_t duration_timestamp,
62 int64_t segment_number) = 0;
75 virtual std::vector<Range> GetSegmentRanges() = 0;
94 void set_progress_target(uint64_t target) { progress_target_ = target; }
97 mkvmuxer::Cluster* cluster() {
return cluster_.get(); }
98 mkvmuxer::Cues* cues() {
return &cues_; }
99 MuxerListener* muxer_listener() {
return muxer_listener_; }
100 SeekHead* seek_head() {
return &seek_head_; }
102 int track_id()
const {
return track_id_; }
103 uint64_t segment_payload_pos()
const {
return segment_payload_pos_; }
105 int64_t duration()
const {
return duration_; }
107 virtual Status DoInitialize() = 0;
108 virtual Status DoFinalize() = 0;
111 Status InitializeAudioTrack(
const AudioStreamInfo& info,
112 mkvmuxer::AudioTrack* track);
113 Status InitializeVideoTrack(
const VideoStreamInfo& info,
114 mkvmuxer::VideoTrack* track);
117 Status WriteFrame(
bool write_duration);
123 virtual Status NewSegment(int64_t start_timestamp,
bool is_subsegment) = 0;
126 std::shared_ptr<const MediaSample> prev_sample_;
129 int64_t reference_frame_timestamp_ = 0;
131 const MuxerOptions& options_;
133 std::unique_ptr<mkvmuxer::Cluster> cluster_;
134 mkvmuxer::Cues cues_;
136 mkvmuxer::SegmentInfo segment_info_;
137 mkvmuxer::Tracks tracks_;
139 MuxerListener* muxer_listener_ =
nullptr;
140 ProgressListener* progress_listener_ =
nullptr;
141 uint64_t progress_target_ = 0;
142 uint64_t accumulated_progress_ = 0;
144 int64_t first_timestamp_ = 0;
145 int64_t sample_durations_[2] = {0, 0};
146 size_t num_samples_ = 0;
150 uint64_t segment_payload_pos_ = 0;
154 bool new_segment_ =
true;
156 bool new_subsegment_ =
false;
160 bool is_encrypted_ =
false;
161 int64_t time_scale_ = 0;
162 int64_t duration_ = 0;
164 DISALLOW_COPY_AND_ASSIGN(Segmenter);
All the methods that are virtual are virtual for mocking.