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

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

Issue 220103002: Fix unit test failures with estimated durations and splice frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix all the things. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_stream.h" 5 #include "media/filters/source_buffer_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 483
484 PrepareRangesForNextAppend(buffers, &deleted_buffers); 484 PrepareRangesForNextAppend(buffers, &deleted_buffers);
485 485
486 // If there's a range for |buffers|, insert |buffers| accordingly. Otherwise, 486 // If there's a range for |buffers|, insert |buffers| accordingly. Otherwise,
487 // create a new range with |buffers|. 487 // create a new range with |buffers|.
488 if (range_for_next_append_ != ranges_.end()) { 488 if (range_for_next_append_ != ranges_.end()) {
489 (*range_for_next_append_)->AppendBuffersToEnd(buffers); 489 (*range_for_next_append_)->AppendBuffersToEnd(buffers);
490 last_appended_buffer_timestamp_ = buffers.back()->GetDecodeTimestamp(); 490 last_appended_buffer_timestamp_ = buffers.back()->GetDecodeTimestamp();
491 last_appended_buffer_is_keyframe_ = buffers.back()->IsKeyframe(); 491 last_appended_buffer_is_keyframe_ = buffers.back()->IsKeyframe();
492 } else { 492 } else {
493 base::TimeDelta new_range_start_time = media_segment_start_time_; 493 base::TimeDelta new_range_start_time =
wolenetz 2014/04/02 00:47:07 If we allow range starts to be < media_segment_sta
acolwell GONE FROM CHROMIUM 2014/04/02 17:19:33 I believe adding a DCHECK(media_segment_start_time
DaleCurtis 2014/04/02 21:53:43 DCHECK() discussion moved to: https://codereview.c
494 std::min(media_segment_start_time_, buffers.front()->timestamp());
494 const BufferQueue* buffers_for_new_range = &buffers; 495 const BufferQueue* buffers_for_new_range = &buffers;
495 BufferQueue trimmed_buffers; 496 BufferQueue trimmed_buffers;
496 497
497 // If the new range is not being created because of a new media 498 // If the new range is not being created because of a new media
498 // segment, then we must make sure that we start with a keyframe. 499 // segment, then we must make sure that we start with a keyframe.
499 // This can happen if the GOP in the previous append gets destroyed 500 // This can happen if the GOP in the previous append gets destroyed
500 // by a Remove() call. 501 // by a Remove() call.
501 if (!new_media_segment_ && !buffers.front()->IsKeyframe()) { 502 if (!new_media_segment_ && !buffers.front()->IsKeyframe()) {
502 BufferQueue::const_iterator itr = buffers.begin(); 503 BufferQueue::const_iterator itr = buffers.begin();
503 504
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 interbuffer_distance_cb_(interbuffer_distance_cb), 1663 interbuffer_distance_cb_(interbuffer_distance_cb),
1663 size_in_bytes_(0) { 1664 size_in_bytes_(0) {
1664 DCHECK(!new_buffers.empty()); 1665 DCHECK(!new_buffers.empty());
1665 DCHECK(new_buffers.front()->IsKeyframe()); 1666 DCHECK(new_buffers.front()->IsKeyframe());
1666 DCHECK(!interbuffer_distance_cb.is_null()); 1667 DCHECK(!interbuffer_distance_cb.is_null());
1667 AppendBuffersToEnd(new_buffers); 1668 AppendBuffersToEnd(new_buffers);
1668 } 1669 }
1669 1670
1670 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) { 1671 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) {
1671 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers)); 1672 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers));
1673 DCHECK(media_segment_start_time_ == kNoTimestamp() ||
1674 media_segment_start_time_ <=
1675 new_buffers.front()->GetDecodeTimestamp());
1672 for (BufferQueue::const_iterator itr = new_buffers.begin(); 1676 for (BufferQueue::const_iterator itr = new_buffers.begin();
1673 itr != new_buffers.end(); ++itr) { 1677 itr != new_buffers.end();
1678 ++itr) {
1674 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp()); 1679 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp());
1675 buffers_.push_back(*itr); 1680 buffers_.push_back(*itr);
1676 size_in_bytes_ += (*itr)->data_size(); 1681 size_in_bytes_ += (*itr)->data_size();
1677 1682
1678 if ((*itr)->IsKeyframe()) { 1683 if ((*itr)->IsKeyframe()) {
1679 keyframe_map_.insert( 1684 keyframe_map_.insert(
1680 std::make_pair((*itr)->GetDecodeTimestamp(), 1685 std::make_pair((*itr)->GetDecodeTimestamp(),
1681 buffers_.size() - 1 + keyframe_map_index_base_)); 1686 buffers_.size() - 1 + keyframe_map_index_base_));
1682 } 1687 }
1683 } 1688 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 if (buffer->end_of_stream() || buffer->timestamp() >= end) 2177 if (buffer->end_of_stream() || buffer->timestamp() >= end)
2173 break; 2178 break;
2174 if (buffer->timestamp() + buffer->duration() <= start) 2179 if (buffer->timestamp() + buffer->duration() <= start)
2175 continue; 2180 continue;
2176 buffers->push_back(buffer); 2181 buffers->push_back(buffer);
2177 } 2182 }
2178 return previous_size < buffers->size(); 2183 return previous_size < buffers->size();
2179 } 2184 }
2180 2185
2181 } // namespace media 2186 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698