7 #ifndef MEDIA_FORMATS_WEBM_SEGMENTER_H_
8 #define MEDIA_FORMATS_WEBM_SEGMENTER_H_
11 #include "packager/media/base/status.h"
12 #include "packager/media/formats/webm/encryptor.h"
13 #include "packager/media/formats/webm/mkv_writer.h"
14 #include "packager/media/formats/webm/seek_head.h"
15 #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
22 class AudioStreamInfo;
27 class ProgressListener;
29 class VideoStreamInfo;
63 uint32_t max_sd_pixels,
64 uint32_t max_hd_pixels,
65 uint32_t max_uhd1_pixels,
66 double clear_lead_in_seconds);
79 uint64_t duration_timescale,
80 bool is_subsegment) = 0;
108 void set_progress_target(uint64_t target) { progress_target_ = target; }
110 const MuxerOptions& options()
const {
return options_; }
111 mkvmuxer::Cluster* cluster() {
return cluster_.get(); }
112 mkvmuxer::Cues* cues() {
return &cues_; }
115 SeekHead* seek_head() {
return &seek_head_; }
117 int track_id()
const {
return track_id_; }
118 uint64_t segment_payload_pos()
const {
return segment_payload_pos_; }
120 virtual Status DoInitialize() = 0;
121 virtual Status DoFinalize() = 0;
126 Status InitializeEncryptor(
KeySource* key_source, uint32_t max_sd_pixels,
127 uint32_t max_hd_pixels, uint32_t max_uhd1_pixels);
130 Status WriteFrame(
bool write_duration);
136 virtual Status NewSegment(uint64_t start_timescale,
bool is_subsegment) = 0;
139 std::shared_ptr<MediaSample> prev_sample_;
142 uint64_t reference_frame_timestamp_ = 0;
145 std::unique_ptr<Encryptor> encryptor_;
146 double clear_lead_ = 0;
148 bool enable_encryption_ =
false;
150 std::unique_ptr<mkvmuxer::Cluster> cluster_;
151 mkvmuxer::Cues cues_;
153 mkvmuxer::SegmentInfo segment_info_;
154 mkvmuxer::Tracks tracks_;
159 uint64_t progress_target_ = 0;
160 uint64_t accumulated_progress_ = 0;
161 uint64_t first_timestamp_ = 0;
162 int64_t sample_duration_ = 0;
165 uint64_t segment_payload_pos_ = 0;
169 bool new_segment_ =
true;
171 bool new_subsegment_ =
false;
181 #endif // MEDIA_FORMATS_WEBM_SEGMENTER_H_