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

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: Comments. 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 =
494 std::min(media_segment_start_time_, buffers.front()->timestamp());
acolwell GONE FROM CHROMIUM 2014/04/03 01:09:34 I believe this should actually be GetDecodeTimesta
DaleCurtis 2014/04/08 21:29:08 Done.
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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 interbuffer_distance_cb_(interbuffer_distance_cb), 1666 interbuffer_distance_cb_(interbuffer_distance_cb),
1666 size_in_bytes_(0) { 1667 size_in_bytes_(0) {
1667 DCHECK(!new_buffers.empty()); 1668 DCHECK(!new_buffers.empty());
1668 DCHECK(new_buffers.front()->IsKeyframe()); 1669 DCHECK(new_buffers.front()->IsKeyframe());
1669 DCHECK(!interbuffer_distance_cb.is_null()); 1670 DCHECK(!interbuffer_distance_cb.is_null());
1670 AppendBuffersToEnd(new_buffers); 1671 AppendBuffersToEnd(new_buffers);
1671 } 1672 }
1672 1673
1673 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) { 1674 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) {
1674 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers)); 1675 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers));
1676 DCHECK(media_segment_start_time_ == kNoTimestamp() ||
1677 media_segment_start_time_ <=
1678 new_buffers.front()->GetDecodeTimestamp());
1675 for (BufferQueue::const_iterator itr = new_buffers.begin(); 1679 for (BufferQueue::const_iterator itr = new_buffers.begin();
1676 itr != new_buffers.end(); ++itr) { 1680 itr != new_buffers.end();
1681 ++itr) {
1677 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp()); 1682 DCHECK((*itr)->GetDecodeTimestamp() != kNoTimestamp());
1678 buffers_.push_back(*itr); 1683 buffers_.push_back(*itr);
1679 size_in_bytes_ += (*itr)->data_size(); 1684 size_in_bytes_ += (*itr)->data_size();
1680 1685
1681 if ((*itr)->IsKeyframe()) { 1686 if ((*itr)->IsKeyframe()) {
1682 keyframe_map_.insert( 1687 keyframe_map_.insert(
1683 std::make_pair((*itr)->GetDecodeTimestamp(), 1688 std::make_pair((*itr)->GetDecodeTimestamp(),
1684 buffers_.size() - 1 + keyframe_map_index_base_)); 1689 buffers_.size() - 1 + keyframe_map_index_base_));
1685 } 1690 }
1686 } 1691 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2175 if (buffer->end_of_stream() || buffer->timestamp() >= end) 2180 if (buffer->end_of_stream() || buffer->timestamp() >= end)
2176 break; 2181 break;
2177 if (buffer->timestamp() + buffer->duration() <= start) 2182 if (buffer->timestamp() + buffer->duration() <= start)
2178 continue; 2183 continue;
2179 buffers->push_back(buffer); 2184 buffers->push_back(buffer);
2180 } 2185 }
2181 return previous_size < buffers->size(); 2186 return previous_size < buffers->size();
2182 } 2187 }
2183 2188
2184 } // namespace media 2189 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698