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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 Track(int track_num, | 42 Track(int track_num, |
43 bool is_video, | 43 bool is_video, |
44 base::TimeDelta default_duration, | 44 base::TimeDelta default_duration, |
45 const LogCB& log_cb); | 45 const LogCB& log_cb); |
46 ~Track(); | 46 ~Track(); |
47 | 47 |
48 int track_num() const { return track_num_; } | 48 int track_num() const { return track_num_; } |
49 | 49 |
50 // If a buffer is currently held aside pending duration calculation, returns | 50 // If a buffer is currently held aside pending duration calculation, returns |
51 // its decode timestamp. Otherwise, returns kInfiniteDuration(). | 51 // its decode timestamp. Otherwise, returns kInfiniteDuration(). |
52 base::TimeDelta GetReadyUpperBound(); | 52 DecodeTimestamp GetReadyUpperBound(); |
53 | 53 |
54 // Prepares |ready_buffers_| for retrieval. Prior to calling, | 54 // Prepares |ready_buffers_| for retrieval. Prior to calling, |
55 // |ready_buffers_| must be empty. Moves all |buffers_| with timestamp | 55 // |ready_buffers_| must be empty. Moves all |buffers_| with decode |
56 // before |before_timestamp| to |ready_buffers_|, preserving their order. | 56 // timestamp before |before_timestamp| to |ready_buffers_|, preserving their |
57 void ExtractReadyBuffers(const base::TimeDelta before_timestamp); | 57 // order. |
| 58 void ExtractReadyBuffers(const DecodeTimestamp before_timestamp); |
58 | 59 |
59 const BufferQueue& ready_buffers() const { return ready_buffers_; } | 60 const BufferQueue& ready_buffers() const { return ready_buffers_; } |
60 | 61 |
61 // If |last_added_buffer_missing_duration_| is set, updates its duration | 62 // If |last_added_buffer_missing_duration_| is set, updates its duration |
62 // relative to |buffer|'s timestamp, and adds it to |buffers_| and unsets | 63 // relative to |buffer|'s timestamp, and adds it to |buffers_| and unsets |
63 // |last_added_buffer_missing_duration_|. Then, if |buffer| is missing | 64 // |last_added_buffer_missing_duration_|. Then, if |buffer| is missing |
64 // duration, saves |buffer| into |last_added_buffer_missing_duration_|, or | 65 // duration, saves |buffer| into |last_added_buffer_missing_duration_|, or |
65 // otherwise adds |buffer| to |buffers_|. | 66 // otherwise adds |buffer| to |buffers_|. |
66 bool AddBuffer(const scoped_refptr<StreamParserBuffer>& buffer); | 67 bool AddBuffer(const scoped_refptr<StreamParserBuffer>& buffer); |
67 | 68 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // Helper method for Get{Audio,Video,Text}Buffers() that recomputes | 213 // Helper method for Get{Audio,Video,Text}Buffers() that recomputes |
213 // |ready_buffer_upper_bound_| and calls ExtractReadyBuffers() on each track. | 214 // |ready_buffer_upper_bound_| and calls ExtractReadyBuffers() on each track. |
214 // If |cluster_ended_| is true, first applies duration estimate if needed for | 215 // If |cluster_ended_| is true, first applies duration estimate if needed for |
215 // |audio_| and |video_| and sets |ready_buffer_upper_bound_| to | 216 // |audio_| and |video_| and sets |ready_buffer_upper_bound_| to |
216 // kInfiniteDuration(). Otherwise, sets |ready_buffer_upper_bound_| to the | 217 // kInfiniteDuration(). Otherwise, sets |ready_buffer_upper_bound_| to the |
217 // minimum upper bound across |audio_| and |video_|. (Text tracks can have no | 218 // minimum upper bound across |audio_| and |video_|. (Text tracks can have no |
218 // buffers missing duration, so they are not involved in calculating the upper | 219 // buffers missing duration, so they are not involved in calculating the upper |
219 // bound.) | 220 // bound.) |
220 // Parse() or Reset() must be called between calls to UpdateReadyBuffers() to | 221 // Parse() or Reset() must be called between calls to UpdateReadyBuffers() to |
221 // clear each track's ready buffers and to reset |ready_buffer_upper_bound_| | 222 // clear each track's ready buffers and to reset |ready_buffer_upper_bound_| |
222 // to kNoTimestamp(). | 223 // to kNoDecodeTimestamp(). |
223 void UpdateReadyBuffers(); | 224 void UpdateReadyBuffers(); |
224 | 225 |
225 // Search for the indicated track_num among the text tracks. Returns NULL | 226 // Search for the indicated track_num among the text tracks. Returns NULL |
226 // if that track num is not a text track. | 227 // if that track num is not a text track. |
227 Track* FindTextTrack(int track_num); | 228 Track* FindTextTrack(int track_num); |
228 | 229 |
229 double timecode_multiplier_; // Multiplier used to convert timecodes into | 230 double timecode_multiplier_; // Multiplier used to convert timecodes into |
230 // microseconds. | 231 // microseconds. |
231 std::set<int64> ignored_tracks_; | 232 std::set<int64> ignored_tracks_; |
232 std::string audio_encryption_key_id_; | 233 std::string audio_encryption_key_id_; |
(...skipping 18 matching lines...) Expand all Loading... |
251 Track audio_; | 252 Track audio_; |
252 Track video_; | 253 Track video_; |
253 TextTrackMap text_track_map_; | 254 TextTrackMap text_track_map_; |
254 | 255 |
255 // Subset of |text_track_map_| maintained by GetTextBuffers(), and cleared by | 256 // Subset of |text_track_map_| maintained by GetTextBuffers(), and cleared by |
256 // ClearTextTrackReadyBuffers(). Callers of GetTextBuffers() get a const-ref | 257 // ClearTextTrackReadyBuffers(). Callers of GetTextBuffers() get a const-ref |
257 // to this member. | 258 // to this member. |
258 TextBufferQueueMap text_buffers_map_; | 259 TextBufferQueueMap text_buffers_map_; |
259 | 260 |
260 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to | 261 // Limits the range of buffers returned by Get{Audio,Video,Text}Buffers() to |
261 // this exclusive upper bound. Set to kNoTimestamp(), meaning not yet | 262 // this exclusive upper bound. Set to kNoDecodeTimestamp(), meaning not yet |
262 // calculated, by Reset() and Parse(). If kNoTimestamp(), then | 263 // calculated, by Reset() and Parse(). If kNoDecodeTimestamp(), then |
263 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) | 264 // Get{Audio,Video,Text}Buffers() will calculate it to be the minimum (decode) |
264 // timestamp across all tracks' |last_buffer_missing_duration_|, or | 265 // timestamp across all tracks' |last_buffer_missing_duration_|, or |
265 // kInfiniteDuration() if no buffers are currently missing duration. | 266 // kInfiniteDuration() if no buffers are currently missing duration. |
266 base::TimeDelta ready_buffer_upper_bound_; | 267 DecodeTimestamp ready_buffer_upper_bound_; |
267 | 268 |
268 LogCB log_cb_; | 269 LogCB log_cb_; |
269 | 270 |
270 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 271 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
271 }; | 272 }; |
272 | 273 |
273 } // namespace media | 274 } // namespace media |
274 | 275 |
275 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ | 276 #endif // MEDIA_FORMATS_WEBM_WEBM_CLUSTER_PARSER_H_ |
OLD | NEW |