5 #ifndef MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
14 #include "packager/base/compiler_specific.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;
121 std::shared_ptr<AudioStreamInfo> audio_stream_info,
122 std::shared_ptr<VideoStreamInfo> video_stream_info,
123 int64_t audio_default_duration,
124 int64_t video_default_duration,
125 const WebMTracksParser::TextTracks& text_tracks,
126 const std::set<int64_t>& ignored_tracks,
127 const std::string& audio_encryption_key_id,
128 const std::string& video_encryption_key_id,
131 KeySource* decryption_key_source);
140 bool Flush() WARN_UNUSED_RESULT;
146 int Parse(const uint8_t* buf,
int size);
148 int64_t cluster_start_time()
const {
return cluster_start_time_; }
156 bool OnListEnd(
int id)
override;
157 bool OnUInt(
int id, int64_t val)
override;
158 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
160 bool ParseBlock(
bool is_simple_block,
163 const uint8_t* additional,
166 int64_t discard_padding,
167 bool reference_block_set);
168 bool OnBlock(
bool is_simple_block,
174 const uint8_t* additional,
176 int64_t discard_padding,
180 void ResetTextTracks();
184 Track* FindTextTrack(
int track_num);
187 double timecode_multiplier_;
189 std::shared_ptr<AudioStreamInfo> audio_stream_info_;
190 std::shared_ptr<VideoStreamInfo> video_stream_info_;
191 std::set<int64_t> ignored_tracks_;
193 std::unique_ptr<DecryptorSource> decryptor_source_;
194 std::string audio_encryption_key_id_;
195 std::string video_encryption_key_id_;
205 int64_t last_block_timecode_ = -1;
206 std::unique_ptr<uint8_t[]> block_data_;
207 int block_data_size_ = -1;
208 int64_t block_duration_ = -1;
209 int64_t block_add_id_ = -1;
211 std::unique_ptr<uint8_t[]> block_additional_data_;
214 int block_additional_data_size_ = 0;
216 int64_t discard_padding_ = -1;
217 bool discard_padding_set_ =
false;
219 bool reference_block_set_ =
false;
221 int64_t cluster_timecode_ = -1;
222 int64_t cluster_start_time_;
223 bool cluster_ended_ =
false;
227 TextTrackMap text_track_map_;
235 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_