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();
70 int64_t default_duration()
const {
return default_duration_; }
77 bool EmitBufferHelp(
const scoped_refptr<MediaSample>& buffer);
81 int64_t GetDurationEstimate();
85 int num_duration_estimates_ = 0;
93 scoped_refptr<MediaSample> last_added_buffer_missing_duration_;
96 int64_t default_duration_;
101 int64_t estimated_next_frame_duration_;
106 typedef std::map<int, Track> TextTrackMap;
110 scoped_refptr<AudioStreamInfo> audio_stream_info,
111 scoped_refptr<VideoStreamInfo> video_stream_info,
112 int64_t audio_default_duration,
113 int64_t video_default_duration,
114 const WebMTracksParser::TextTracks& text_tracks,
115 const std::set<int64_t>& ignored_tracks,
116 const std::string& audio_encryption_key_id,
117 const std::string& video_encryption_key_id,
133 int Parse(
const uint8_t* buf,
int size);
135 int64_t cluster_start_time()
const {
return cluster_start_time_; }
143 bool OnListEnd(
int id)
override;
144 bool OnUInt(
int id, int64_t val)
override;
145 bool OnBinary(
int id,
const uint8_t* data,
int size)
override;
147 bool ParseBlock(
bool is_simple_block,
150 const uint8_t* additional,
153 int64_t discard_padding);
154 bool OnBlock(
bool is_simple_block,
161 const uint8_t* additional,
163 int64_t discard_padding);
166 void ResetTextTracks();
170 Track* FindTextTrack(
int track_num);
176 int64_t TryGetEncodedAudioDuration(
const uint8_t* data,
int size);
180 int64_t ReadOpusDuration(
const uint8_t* data,
int size);
184 int num_duration_errors_ = 0;
186 double timecode_multiplier_;
188 scoped_refptr<AudioStreamInfo> audio_stream_info_;
189 scoped_refptr<VideoStreamInfo> video_stream_info_;
190 std::set<int64_t> ignored_tracks_;
191 std::string audio_encryption_key_id_;
192 std::string video_encryption_key_id_;
202 int64_t last_block_timecode_ = -1;
203 scoped_ptr<uint8_t[]> block_data_;
204 int block_data_size_ = -1;
205 int64_t block_duration_ = -1;
206 int64_t block_add_id_ = -1;
208 scoped_ptr<uint8_t[]> block_additional_data_;
211 int block_additional_data_size_ = 0;
213 int64_t discard_padding_ = -1;
214 bool discard_padding_set_ =
false;
216 int64_t cluster_timecode_ = -1;
217 int64_t cluster_start_time_;
218 bool cluster_ended_ =
false;
222 TextTrackMap text_track_map_;
230 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_