| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 5 #ifndef MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 6 #define MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Returns false if |buffer| failed sanity check and therefore was not added | 106 // Returns false if |buffer| failed sanity check and therefore was not added |
| 107 // to |buffers_|. Returns true otherwise. | 107 // to |buffers_|. Returns true otherwise. |
| 108 bool QueueBuffer(const scoped_refptr<StreamParserBuffer>& buffer); | 108 bool QueueBuffer(const scoped_refptr<StreamParserBuffer>& buffer); |
| 109 | 109 |
| 110 // Helper that calculates the buffer duration to use in | 110 // Helper that calculates the buffer duration to use in |
| 111 // ApplyDurationEstimateIfNeeded(). | 111 // ApplyDurationEstimateIfNeeded(). |
| 112 base::TimeDelta GetDurationEstimate(); | 112 base::TimeDelta GetDurationEstimate(); |
| 113 | 113 |
| 114 // Counts the number of estimated durations used in this track. Used to | 114 // Counts the number of estimated durations used in this track. Used to |
| 115 // prevent log spam for MEDIA_LOG()s about estimated duration. | 115 // prevent log spam for MEDIA_LOG()s about estimated duration. |
| 116 int num_duration_estimates_; | 116 int num_duration_estimates_ = 0; |
| 117 | 117 |
| 118 int track_num_; | 118 int track_num_; |
| 119 bool is_video_; | 119 bool is_video_; |
| 120 | 120 |
| 121 // Parsed track buffers, each with duration and in (decode) timestamp order, | 121 // Parsed track buffers, each with duration and in (decode) timestamp order, |
| 122 // that have not yet been extracted into |ready_buffers_|. Note that up to | 122 // that have not yet been extracted into |ready_buffers_|. Note that up to |
| 123 // one additional buffer missing duration may be tracked by | 123 // one additional buffer missing duration may be tracked by |
| 124 // |last_added_buffer_missing_duration_|. | 124 // |last_added_buffer_missing_duration_|. |
| 125 BufferQueue buffers_; | 125 BufferQueue buffers_; |
| 126 scoped_refptr<StreamParserBuffer> last_added_buffer_missing_duration_; | 126 scoped_refptr<StreamParserBuffer> last_added_buffer_missing_duration_; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // the next Cluster). Avoid calling if encrypted; may produce unexpected | 262 // the next Cluster). Avoid calling if encrypted; may produce unexpected |
| 263 // output. See implementation for supported codecs. | 263 // output. See implementation for supported codecs. |
| 264 base::TimeDelta TryGetEncodedAudioDuration(const uint8_t* data, int size); | 264 base::TimeDelta TryGetEncodedAudioDuration(const uint8_t* data, int size); |
| 265 | 265 |
| 266 // Reads Opus packet header to determine packet duration. Duration returned | 266 // Reads Opus packet header to determine packet duration. Duration returned |
| 267 // as TimeDelta or kNoTimestamp() upon failure to read duration from packet. | 267 // as TimeDelta or kNoTimestamp() upon failure to read duration from packet. |
| 268 base::TimeDelta ReadOpusDuration(const uint8_t* data, int size); | 268 base::TimeDelta ReadOpusDuration(const uint8_t* data, int size); |
| 269 | 269 |
| 270 // Tracks the number of MEDIA_LOGs made in process of reading encoded | 270 // Tracks the number of MEDIA_LOGs made in process of reading encoded |
| 271 // duration. Useful to prevent log spam. | 271 // duration. Useful to prevent log spam. |
| 272 int num_duration_errors_; | 272 int num_duration_errors_ = 0; |
| 273 | 273 |
| 274 double timecode_multiplier_; // Multiplier used to convert timecodes into | 274 double timecode_multiplier_; // Multiplier used to convert timecodes into |
| 275 // microseconds. | 275 // microseconds. |
| 276 std::set<int64> ignored_tracks_; | 276 std::set<int64> ignored_tracks_; |
| 277 std::string audio_encryption_key_id_; | 277 std::string audio_encryption_key_id_; |
| 278 std::string video_encryption_key_id_; | 278 std::string video_encryption_key_id_; |
| 279 const AudioCodec audio_codec_; | 279 const AudioCodec audio_codec_; |
| 280 | 280 |
| 281 WebMListParser parser_; | 281 WebMListParser parser_; |
| 282 | 282 |
| 283 int64 last_block_timecode_; | 283 int64 last_block_timecode_ = -1; |
| 284 scoped_ptr<uint8_t[]> block_data_; | 284 scoped_ptr<uint8_t[]> block_data_; |
| 285 int block_data_size_; | 285 int block_data_size_ = -1; |
| 286 int64 block_duration_; | 286 int64 block_duration_ = -1; |
| 287 int64 block_add_id_; | 287 int64 block_add_id_ = -1; |
| 288 | 288 |
| 289 scoped_ptr<uint8_t[]> block_additional_data_; | 289 scoped_ptr<uint8_t[]> block_additional_data_; |
| 290 // Must be 0 if |block_additional_data_| is null. Must be > 0 if | 290 // Must be 0 if |block_additional_data_| is null. Must be > 0 if |
| 291 // |block_additional_data_| is NOT null. | 291 // |block_additional_data_| is NOT null. |
| 292 int block_additional_data_size_; | 292 int block_additional_data_size_ = 0; |
| 293 | 293 |
| 294 int64 discard_padding_; | 294 int64 discard_padding_ = -1; |
| 295 bool discard_padding_set_; | 295 bool discard_padding_set_ = false; |
| 296 | 296 |
| 297 int64 cluster_timecode_; | 297 int64 cluster_timecode_ = -1; |
| 298 base::TimeDelta cluster_start_time_; | 298 base::TimeDelta cluster_start_time_; |
| 299 bool cluster_ended_; | 299 bool cluster_ended_ = false; |
| 300 | 300 |
| 301 Track audio_; | 301 Track audio_; |
| 302 Track video_; | 302 Track video_; |
| 303 TextTrackMap text_track_map_; | 303 TextTrackMap text_track_map_; |
| 304 | 304 |
| 305 // Subset of |text_track_map_| maintained by GetTextBuffers(), and cleared by | 305 // Subset of |text_track_map_| maintained by GetTextBuffers(), and cleared by |
| 306 // ClearTextTrackReadyBuffers(). Callers of GetTextBuffers() get a const-ref | 306 // ClearTextTrackReadyBuffers(). Callers of GetTextBuffers() get a const-ref |
| 307 // to this member. | 307 // to this member. |
| 308 TextBufferQueueMap text_buffers_map_; | 308 TextBufferQueueMap text_buffers_map_; |
| 309 | 309 |
| 310 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to | 310 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to |
| 311 // this exclusive upper bound. Set to kNoDecodeTimestamp(), meaning not yet | 311 // this exclusive upper bound. Set to kNoDecodeTimestamp(), meaning not yet |
| 312 // calculated, by Reset() and Parse(). If kNoDecodeTimestamp(), then | 312 // calculated, by Reset() and Parse(). If kNoDecodeTimestamp(), then |
| 313 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) | 313 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) |
| 314 // timestamp across all tracks' |last_buffer_missing_duration_|, or | 314 // timestamp across all tracks' |last_buffer_missing_duration_|, or |
| 315 // kInfiniteDuration() if no buffers are currently missing duration. | 315 // kInfiniteDuration() if no buffers are currently missing duration. |
| 316 DecodeTimestamp ready_buffer_upper_bound_; | 316 DecodeTimestamp ready_buffer_upper_bound_; |
| 317 | 317 |
| 318 scoped_refptr<MediaLog> media_log_; | 318 scoped_refptr<MediaLog> media_log_; |
| 319 | 319 |
| 320 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 320 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 } // namespace media | 323 } // namespace media |
| 324 | 324 |
| 325 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 325 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
| OLD | NEW |