5 #ifndef MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_
13 #include "packager/base/memory/scoped_ptr.h"
14 #include "packager/media/base/media_parser.h"
15 #include "packager/media/base/media_sample.h"
16 #include "packager/media/formats/webm/webm_parser.h"
17 #include "packager/media/formats/webm/webm_tracks_parser.h"
19 namespace edash_packager {
47 int64_t default_duration,
51 int track_num()
const {
return track_num_; }
57 bool EmitBuffer(
const scoped_refptr<MediaSample>& buffer);
64 void ApplyDurationEstimateIfNeeded();
74 bool IsKeyframe(
const uint8_t* data,
int size)
const;
76 int64_t default_duration()
const {
return default_duration_; }
83 bool EmitBufferHelp(
const scoped_refptr<MediaSample>& buffer);
87 int64_t GetDurationEstimate();
91 int num_duration_estimates_ = 0;
99 scoped_refptr<MediaSample> last_added_buffer_missing_duration_;
102 int64_t default_duration_;
107 int64_t estimated_next_frame_duration_;
112 typedef std::map<int, Track> TextTrackMap;
117 int64_t audio_default_duration,
119 int64_t video_default_duration,
120 const WebMTracksParser::TextTracks& text_tracks,
121 const std::set<int64_t>& ignored_tracks,
122 const std::string& audio_encryption_key_id,
123 const std::string& video_encryption_key_id,
124 const AudioCodec audio_codec,
139 int Parse(
const uint8_t* buf,
int size);
141 int64_t cluster_start_time()
const {
return cluster_start_time_; }
149 bool OnListEnd(
int id)
override;
150 bool OnUInt(
int id, int64_t val)
override;
151 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
153 bool ParseBlock(
bool is_simple_block,
156 const uint8_t* additional,
159 int64_t discard_padding);
160 bool OnBlock(
bool is_simple_block,
167 const uint8_t* additional,
169 int64_t discard_padding);
172 void ResetTextTracks();
176 Track* FindTextTrack(
int track_num);
182 int64_t TryGetEncodedAudioDuration(
const uint8_t* data,
int size);
186 int64_t ReadOpusDuration(
const uint8_t* data,
int size);
190 int num_duration_errors_ = 0;
192 double timecode_multiplier_;
194 std::set<int64_t> ignored_tracks_;
195 std::string audio_encryption_key_id_;
196 std::string video_encryption_key_id_;
197 const AudioCodec audio_codec_;
201 int64_t last_block_timecode_ = -1;
202 scoped_ptr<uint8_t[]> block_data_;
203 int block_data_size_ = -1;
204 int64_t block_duration_ = -1;
205 int64_t block_add_id_ = -1;
207 scoped_ptr<uint8_t[]> block_additional_data_;
210 int block_additional_data_size_ = 0;
212 int64_t discard_padding_ = -1;
213 bool discard_padding_set_ =
false;
215 int64_t cluster_timecode_ = -1;
216 int64_t cluster_start_time_;
217 bool cluster_ended_ =
false;
221 TextTrackMap text_track_map_;
229 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_