Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: media/filters/source_buffer_range.cc

Issue 1692403002: MSE - Fix crash caused by incorrect GC of GOP with next buffer position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stick with DCHECKs for this to ease merging. +unit test Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "media/filters/source_buffer_range.h" 5 #include "media/filters/source_buffer_range.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "media/base/timestamp_constants.h" 9 #include "media/base/timestamp_constants.h"
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 bool SourceBufferRange::TruncateAt( 224 bool SourceBufferRange::TruncateAt(
225 DecodeTimestamp timestamp, BufferQueue* removed_buffers, 225 DecodeTimestamp timestamp, BufferQueue* removed_buffers,
226 bool is_exclusive) { 226 bool is_exclusive) {
227 // Find the place in |buffers_| where we will begin deleting data. 227 // Find the place in |buffers_| where we will begin deleting data.
228 BufferQueue::iterator starting_point = 228 BufferQueue::iterator starting_point =
229 GetBufferItrAt(timestamp, is_exclusive); 229 GetBufferItrAt(timestamp, is_exclusive);
230 return TruncateAt(starting_point, removed_buffers); 230 return TruncateAt(starting_point, removed_buffers);
231 } 231 }
232 232
233 size_t SourceBufferRange::DeleteGOPFromFront(BufferQueue* deleted_buffers) { 233 size_t SourceBufferRange::DeleteGOPFromFront(BufferQueue* deleted_buffers) {
234 DCHECK(!buffers_.empty());
234 DCHECK(!FirstGOPContainsNextBufferPosition()); 235 DCHECK(!FirstGOPContainsNextBufferPosition());
235 DCHECK(deleted_buffers); 236 DCHECK(deleted_buffers);
236 237
237 int buffers_deleted = 0; 238 int buffers_deleted = 0;
238 size_t total_bytes_deleted = 0; 239 size_t total_bytes_deleted = 0;
239 240
240 KeyframeMap::iterator front = keyframe_map_.begin(); 241 KeyframeMap::iterator front = keyframe_map_.begin();
241 DCHECK(front != keyframe_map_.end()); 242 DCHECK(front != keyframe_map_.end());
242 243
243 // Delete the keyframe at the start of |keyframe_map_|. 244 // Delete the keyframe at the start of |keyframe_map_|.
(...skipping 28 matching lines...) Expand all
272 273
273 // Invalidate media segment start time if we've deleted the first buffer of 274 // Invalidate media segment start time if we've deleted the first buffer of
274 // the range. 275 // the range.
275 if (buffers_deleted > 0) 276 if (buffers_deleted > 0)
276 media_segment_start_time_ = kNoDecodeTimestamp(); 277 media_segment_start_time_ = kNoDecodeTimestamp();
277 278
278 return total_bytes_deleted; 279 return total_bytes_deleted;
279 } 280 }
280 281
281 size_t SourceBufferRange::DeleteGOPFromBack(BufferQueue* deleted_buffers) { 282 size_t SourceBufferRange::DeleteGOPFromBack(BufferQueue* deleted_buffers) {
283 DCHECK(!buffers_.empty());
282 DCHECK(!LastGOPContainsNextBufferPosition()); 284 DCHECK(!LastGOPContainsNextBufferPosition());
283 DCHECK(deleted_buffers); 285 DCHECK(deleted_buffers);
284 286
285 // Remove the last GOP's keyframe from the |keyframe_map_|. 287 // Remove the last GOP's keyframe from the |keyframe_map_|.
286 KeyframeMap::iterator back = keyframe_map_.end(); 288 KeyframeMap::iterator back = keyframe_map_.end();
287 DCHECK_GT(keyframe_map_.size(), 0u); 289 DCHECK_GT(keyframe_map_.size(), 0u);
288 --back; 290 --back;
289 291
290 // The index of the first buffer in the last GOP is equal to the new size of 292 // The index of the first buffer in the last GOP is equal to the new size of
291 // |buffers_| after that GOP is deleted. 293 // |buffers_| after that GOP is deleted.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 628 }
627 629
628 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime()) 630 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime())
629 continue; 631 continue;
630 buffers->push_back(buffer); 632 buffers->push_back(buffer);
631 } 633 }
632 return previous_size < buffers->size(); 634 return previous_size < buffers->size();
633 } 635 }
634 636
635 } // namespace media 637 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698