5 #ifndef PACKAGER_MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
6 #define PACKAGER_MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
14 #include <packager/macros/classes.h>
15 #include <packager/media/base/decryptor_source.h>
16 #include <packager/media/base/media_parser.h>
17 #include <packager/media/base/media_sample.h>
18 #include <packager/media/formats/webm/webm_parser.h>
19 #include <packager/media/formats/webm/webm_tracks_parser.h>
43 int64_t default_duration,
47 int track_num()
const {
return track_num_; }
53 bool EmitBuffer(
const std::shared_ptr<MediaSample>& buffer);
59 bool ApplyDurationEstimateIfNeeded();
70 bool EmitBufferHelp(
const std::shared_ptr<MediaSample>& buffer);
74 int64_t GetDurationEstimate();
82 std::shared_ptr<MediaSample> last_added_buffer_missing_duration_;
85 int64_t default_duration_;
90 int64_t estimated_next_frame_duration_;
95 typedef std::map<int, Track> TextTrackMap;
123 std::shared_ptr<AudioStreamInfo> audio_stream_info,
124 std::shared_ptr<VideoStreamInfo> video_stream_info,
125 const VPCodecConfigurationRecord& vp_config,
126 int64_t audio_default_duration,
127 int64_t video_default_duration,
128 const WebMTracksParser::TextTracks& text_tracks,
129 const std::set<int64_t>& ignored_tracks,
130 const std::string& audio_encryption_key_id,
131 const std::string& video_encryption_key_id,
134 KeySource* decryption_key_source);
143 [[nodiscard]]
bool Flush();
149 int Parse(
const uint8_t* buf,
int size);
151 int64_t cluster_start_time()
const {
return cluster_start_time_; }
159 bool OnListEnd(
int id)
override;
160 bool OnUInt(
int id, int64_t val)
override;
161 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
163 bool ParseBlock(
bool is_simple_block,
166 const uint8_t* additional,
169 int64_t discard_padding,
170 bool reference_block_set);
171 bool OnBlock(
bool is_simple_block,
177 const uint8_t* additional,
179 int64_t discard_padding,
183 void ResetTextTracks();
187 Track* FindTextTrack(
int track_num);
190 double timecode_multiplier_;
192 std::shared_ptr<AudioStreamInfo> audio_stream_info_;
193 std::shared_ptr<VideoStreamInfo> video_stream_info_;
195 std::set<int64_t> ignored_tracks_;
197 std::unique_ptr<DecryptorSource> decryptor_source_;
198 std::string audio_encryption_key_id_;
199 std::string video_encryption_key_id_;
209 int64_t last_block_timecode_ = -1;
210 std::unique_ptr<uint8_t[]> block_data_;
211 int block_data_size_ = -1;
212 int64_t block_duration_ = -1;
213 int64_t block_add_id_ = -1;
215 std::unique_ptr<uint8_t[]> block_additional_data_;
218 int block_additional_data_size_ = 0;
220 int64_t discard_padding_ = -1;
221 bool discard_padding_set_ =
false;
223 bool reference_block_set_ =
false;
225 int64_t cluster_timecode_ = -1;
226 int64_t cluster_start_time_;
227 bool cluster_ended_ =
false;
231 TextTrackMap text_track_map_;
All the methods that are virtual are virtual for mocking.