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 {
28 kDefaultAudioBufferDurationInMs = 23,
32 kDefaultVideoBufferDurationInMs = 63
39 static const uint16_t kOpusFrameDurationsMu[];
47 int64_t default_duration,
51 int track_num()
const {
return track_num_; }
58 bool AddBuffer(
const scoped_refptr<MediaSample>& buffer);
65 void ApplyDurationEstimateIfNeeded();
75 bool IsKeyframe(
const uint8_t* data,
int size)
const;
77 int64_t default_duration()
const {
return default_duration_; }
84 bool QueueBuffer(
const scoped_refptr<MediaSample>& buffer);
88 int64_t GetDurationEstimate();
92 int num_duration_estimates_ = 0;
101 scoped_refptr<MediaSample> last_added_buffer_missing_duration_;
104 int64_t default_duration_;
111 int64_t estimated_next_frame_duration_;
116 typedef std::map<int, Track> TextTrackMap;
121 int64_t audio_default_duration,
123 int64_t video_default_duration,
124 const WebMTracksParser::TextTracks& text_tracks,
125 const std::set<int64_t>& ignored_tracks,
126 const std::string& audio_encryption_key_id,
127 const std::string& video_encryption_key_id,
128 const AudioCodec audio_codec,
140 int Parse(
const uint8_t* buf,
int size);
142 int64_t cluster_start_time()
const {
return cluster_start_time_; }
145 bool cluster_ended()
const {
return cluster_ended_; }
150 bool OnListEnd(
int id)
override;
151 bool OnUInt(
int id, int64_t val)
override;
152 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
154 bool ParseBlock(
bool is_simple_block,
157 const uint8_t* additional,
160 int64_t discard_padding);
161 bool OnBlock(
bool is_simple_block,
168 const uint8_t* additional,
170 int64_t discard_padding);
173 void ResetTextTracks();
177 Track* FindTextTrack(
int track_num);
187 int64_t TryGetEncodedAudioDuration(
const uint8_t* data,
int size);
191 int64_t ReadOpusDuration(
const uint8_t* data,
int size);
195 int num_duration_errors_ = 0;
197 double timecode_multiplier_;
199 std::set<int64_t> ignored_tracks_;
200 std::string audio_encryption_key_id_;
201 std::string video_encryption_key_id_;
202 const AudioCodec audio_codec_;
206 int64_t last_block_timecode_ = -1;
207 scoped_ptr<uint8_t[]> block_data_;
208 int block_data_size_ = -1;
209 int64_t block_duration_ = -1;
210 int64_t block_add_id_ = -1;
212 scoped_ptr<uint8_t[]> block_additional_data_;
215 int block_additional_data_size_ = 0;
217 int64_t discard_padding_ = -1;
218 bool discard_padding_set_ =
false;
220 int64_t cluster_timecode_ = -1;
221 int64_t cluster_start_time_;
222 bool cluster_ended_ =
false;
226 TextTrackMap text_track_map_;
234 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_