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 {
41 int64_t default_duration,
45 int track_num()
const {
return track_num_; }
51 bool EmitBuffer(
const scoped_refptr<MediaSample>& buffer);
57 void ApplyDurationEstimateIfNeeded();
68 bool EmitBufferHelp(
const scoped_refptr<MediaSample>& buffer);
72 int64_t GetDurationEstimate();
80 scoped_refptr<MediaSample> last_added_buffer_missing_duration_;
83 int64_t default_duration_;
88 int64_t estimated_next_frame_duration_;
93 typedef std::map<int, Track> TextTrackMap;
96 WebMClusterParser(int64_t timecode_scale,
97 scoped_refptr<AudioStreamInfo> audio_stream_info,
98 scoped_refptr<VideoStreamInfo> video_stream_info,
99 int64_t audio_default_duration,
100 int64_t video_default_duration,
101 const WebMTracksParser::TextTracks& text_tracks,
102 const std::set<int64_t>& ignored_tracks,
103 const std::string& audio_encryption_key_id,
104 const std::string& video_encryption_key_id,
107 ~WebMClusterParser()
override;
120 int Parse(
const uint8_t* buf,
int size);
122 int64_t cluster_start_time()
const {
return cluster_start_time_; }
130 bool OnListEnd(
int id)
override;
131 bool OnUInt(
int id, int64_t val)
override;
132 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
134 bool ParseBlock(
bool is_simple_block,
137 const uint8_t* additional,
140 int64_t discard_padding);
141 bool OnBlock(
bool is_simple_block,
148 const uint8_t* additional,
150 int64_t discard_padding);
153 void ResetTextTracks();
157 Track* FindTextTrack(
int track_num);
160 double timecode_multiplier_;
162 scoped_refptr<AudioStreamInfo> audio_stream_info_;
163 scoped_refptr<VideoStreamInfo> video_stream_info_;
164 std::set<int64_t> ignored_tracks_;
165 std::string audio_encryption_key_id_;
166 std::string video_encryption_key_id_;
176 int64_t last_block_timecode_ = -1;
177 scoped_ptr<uint8_t[]> block_data_;
178 int block_data_size_ = -1;
179 int64_t block_duration_ = -1;
180 int64_t block_add_id_ = -1;
182 scoped_ptr<uint8_t[]> block_additional_data_;
185 int block_additional_data_size_ = 0;
187 int64_t discard_padding_ = -1;
188 bool discard_padding_set_ =
false;
190 int64_t cluster_timecode_ = -1;
191 int64_t cluster_start_time_;
192 bool cluster_ended_ =
false;
196 TextTrackMap text_track_map_;
204 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_