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_;
109 int64_t estimated_next_frame_duration_;
114 typedef std::map<int, Track> TextTrackMap;
119 int64_t audio_default_duration,
121 int64_t video_default_duration,
122 const WebMTracksParser::TextTracks& text_tracks,
123 const std::set<int64_t>& ignored_tracks,
124 const std::string& audio_encryption_key_id,
125 const std::string& video_encryption_key_id,
126 const AudioCodec audio_codec,
137 int Parse(
const uint8_t* buf,
int size);
139 int64_t cluster_start_time()
const {
return cluster_start_time_; }
147 bool OnListEnd(
int id)
override;
148 bool OnUInt(
int id, int64_t val)
override;
149 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
151 bool ParseBlock(
bool is_simple_block,
154 const uint8_t* additional,
157 int64_t discard_padding);
158 bool OnBlock(
bool is_simple_block,
165 const uint8_t* additional,
167 int64_t discard_padding);
170 void ResetTextTracks();
174 Track* FindTextTrack(
int track_num);
180 int64_t TryGetEncodedAudioDuration(
const uint8_t* data,
int size);
184 int64_t ReadOpusDuration(
const uint8_t* data,
int size);
188 int num_duration_errors_ = 0;
190 double timecode_multiplier_;
192 std::set<int64_t> ignored_tracks_;
193 std::string audio_encryption_key_id_;
194 std::string video_encryption_key_id_;
195 const AudioCodec audio_codec_;
199 int64_t last_block_timecode_ = -1;
200 scoped_ptr<uint8_t[]> block_data_;
201 int block_data_size_ = -1;
202 int64_t block_duration_ = -1;
203 int64_t block_add_id_ = -1;
205 scoped_ptr<uint8_t[]> block_additional_data_;
208 int block_additional_data_size_ = 0;
210 int64_t discard_padding_ = -1;
211 bool discard_padding_set_ =
false;
213 int64_t cluster_timecode_ = -1;
214 int64_t cluster_start_time_;
215 bool cluster_ended_ =
false;
219 TextTrackMap text_track_map_;
227 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_