| 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_FILTERS_SOURCE_BUFFER_RANGE_H_ | 5 #ifndef MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| 6 #define MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ | 6 #define MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // Adds all buffers which overlap [start, end) to the end of |buffers|. If | 200 // Adds all buffers which overlap [start, end) to the end of |buffers|. If |
| 201 // no buffers exist in the range returns false, true otherwise. | 201 // no buffers exist in the range returns false, true otherwise. |
| 202 bool GetBuffersInRange(DecodeTimestamp start, DecodeTimestamp end, | 202 bool GetBuffersInRange(DecodeTimestamp start, DecodeTimestamp end, |
| 203 BufferQueue* buffers); | 203 BufferQueue* buffers); |
| 204 | 204 |
| 205 int size_in_bytes() const { return size_in_bytes_; } | 205 int size_in_bytes() const { return size_in_bytes_; } |
| 206 | 206 |
| 207 private: | 207 private: |
| 208 typedef std::map<DecodeTimestamp, int> KeyframeMap; | 208 typedef std::map<DecodeTimestamp, int> KeyframeMap; |
| 209 | 209 |
| 210 // Called during AppendBuffersToEnd to adjust estimated duration at the |
| 211 // end of the last append to match the delta in timestamps between |
| 212 // the last append and the upcoming append. This is a workaround for |
| 213 // WebM media where a duration is not always specified. |
| 214 void AdjustEstimatedDurationForNewAppend(const BufferQueue& new_buffers); |
| 215 |
| 210 // Seeks the range to the next keyframe after |timestamp|. If | 216 // Seeks the range to the next keyframe after |timestamp|. If |
| 211 // |skip_given_timestamp| is true, the seek will go to a keyframe with a | 217 // |skip_given_timestamp| is true, the seek will go to a keyframe with a |
| 212 // timestamp strictly greater than |timestamp|. | 218 // timestamp strictly greater than |timestamp|. |
| 213 void SeekAhead(DecodeTimestamp timestamp, bool skip_given_timestamp); | 219 void SeekAhead(DecodeTimestamp timestamp, bool skip_given_timestamp); |
| 214 | 220 |
| 215 // Returns an iterator in |buffers_| pointing to the buffer at |timestamp|. | 221 // Returns an iterator in |buffers_| pointing to the buffer at |timestamp|. |
| 216 // If |skip_given_timestamp| is true, this returns the first buffer with | 222 // If |skip_given_timestamp| is true, this returns the first buffer with |
| 217 // timestamp greater than |timestamp|. | 223 // timestamp greater than |timestamp|. |
| 218 BufferQueue::iterator GetBufferItrAt( | 224 BufferQueue::iterator GetBufferItrAt( |
| 219 DecodeTimestamp timestamp, bool skip_given_timestamp); | 225 DecodeTimestamp timestamp, bool skip_given_timestamp); |
| 220 | 226 |
| 221 // Returns an iterator in |keyframe_map_| pointing to the next keyframe after | 227 // Returns an iterator in |keyframe_map_| pointing to the next keyframe after |
| 222 // |timestamp|. If |skip_given_timestamp| is true, this returns the first | 228 // |timestamp|. If |skip_given_timestamp| is true, this returns the first |
| 223 // keyframe with a timestamp strictly greater than |timestamp|. | 229 // keyframe with a timestamp strictly greater than |timestamp|. |
| 224 KeyframeMap::iterator GetFirstKeyframeAt( | 230 KeyframeMap::iterator GetFirstKeyframeAt( |
| 225 DecodeTimestamp timestamp, bool skip_given_timestamp); | 231 DecodeTimestamp timestamp, bool skip_given_timestamp); |
| 226 | 232 |
| 227 // Returns an iterator in |keyframe_map_| pointing to the first keyframe | 233 // Returns an iterator in |keyframe_map_| pointing to the first keyframe |
| 228 // before or at |timestamp|. | 234 // before or at |timestamp|. |
| 229 KeyframeMap::iterator GetFirstKeyframeBefore(DecodeTimestamp timestamp); | 235 KeyframeMap::iterator GetFirstKeyframeAtOrBefore(DecodeTimestamp timestamp); |
| 230 | 236 |
| 231 // Helper method to delete buffers in |buffers_| starting at | 237 // Helper method to delete buffers in |buffers_| starting at |
| 232 // |starting_point|, an iterator in |buffers_|. | 238 // |starting_point|, an iterator in |buffers_|. |
| 233 // Returns true if everything in the range was removed. Returns | 239 // Returns true if everything in the range was removed. Returns |
| 234 // false if the range still contains buffers. | 240 // false if the range still contains buffers. |
| 235 bool TruncateAt(const BufferQueue::iterator& starting_point, | 241 bool TruncateAt(const BufferQueue::iterator& starting_point, |
| 236 BufferQueue* deleted_buffers); | 242 BufferQueue* deleted_buffers); |
| 237 | 243 |
| 238 // Frees the buffers in |buffers_| from [|start_point|,|ending_point|) and | 244 // Frees the buffers in |buffers_| from [|start_point|,|ending_point|) and |
| 239 // updates the |size_in_bytes_| accordingly. Does not update |keyframe_map_|. | 245 // updates the |size_in_bytes_| accordingly. Does not update |keyframe_map_|. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 286 |
| 281 // Stores the amount of memory taken up by the data in |buffers_|. | 287 // Stores the amount of memory taken up by the data in |buffers_|. |
| 282 int size_in_bytes_; | 288 int size_in_bytes_; |
| 283 | 289 |
| 284 DISALLOW_COPY_AND_ASSIGN(SourceBufferRange); | 290 DISALLOW_COPY_AND_ASSIGN(SourceBufferRange); |
| 285 }; | 291 }; |
| 286 | 292 |
| 287 } // namespace media | 293 } // namespace media |
| 288 | 294 |
| 289 #endif // MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ | 295 #endif // MEDIA_FILTERS_SOURCE_BUFFER_RANGE_H_ |
| OLD | NEW |