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

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

Issue 712593003: Move key frame flag from StreamParserBuffer to DecoderBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 namespace media { 9 namespace media {
10 10
(...skipping 18 matching lines...) Expand all
29 GapPolicy gap_policy, const BufferQueue& new_buffers, 29 GapPolicy gap_policy, const BufferQueue& new_buffers,
30 DecodeTimestamp media_segment_start_time, 30 DecodeTimestamp media_segment_start_time,
31 const InterbufferDistanceCB& interbuffer_distance_cb) 31 const InterbufferDistanceCB& interbuffer_distance_cb)
32 : gap_policy_(gap_policy), 32 : gap_policy_(gap_policy),
33 keyframe_map_index_base_(0), 33 keyframe_map_index_base_(0),
34 next_buffer_index_(-1), 34 next_buffer_index_(-1),
35 media_segment_start_time_(media_segment_start_time), 35 media_segment_start_time_(media_segment_start_time),
36 interbuffer_distance_cb_(interbuffer_distance_cb), 36 interbuffer_distance_cb_(interbuffer_distance_cb),
37 size_in_bytes_(0) { 37 size_in_bytes_(0) {
38 CHECK(!new_buffers.empty()); 38 CHECK(!new_buffers.empty());
39 DCHECK(new_buffers.front()->IsKeyframe()); 39 DCHECK(new_buffers.front()->is_keyframe());
40 DCHECK(!interbuffer_distance_cb.is_null()); 40 DCHECK(!interbuffer_distance_cb.is_null());
41 AppendBuffersToEnd(new_buffers); 41 AppendBuffersToEnd(new_buffers);
42 } 42 }
43 43
44 SourceBufferRange::~SourceBufferRange() {} 44 SourceBufferRange::~SourceBufferRange() {}
45 45
46 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) { 46 void SourceBufferRange::AppendBuffersToEnd(const BufferQueue& new_buffers) {
47 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers)); 47 DCHECK(buffers_.empty() || CanAppendBuffersToEnd(new_buffers));
48 DCHECK(media_segment_start_time_ == kNoDecodeTimestamp() || 48 DCHECK(media_segment_start_time_ == kNoDecodeTimestamp() ||
49 media_segment_start_time_ <= 49 media_segment_start_time_ <=
50 new_buffers.front()->GetDecodeTimestamp()); 50 new_buffers.front()->GetDecodeTimestamp());
51 for (BufferQueue::const_iterator itr = new_buffers.begin(); 51 for (BufferQueue::const_iterator itr = new_buffers.begin();
52 itr != new_buffers.end(); 52 itr != new_buffers.end();
53 ++itr) { 53 ++itr) {
54 DCHECK((*itr)->GetDecodeTimestamp() != kNoDecodeTimestamp()); 54 DCHECK((*itr)->GetDecodeTimestamp() != kNoDecodeTimestamp());
55 buffers_.push_back(*itr); 55 buffers_.push_back(*itr);
56 size_in_bytes_ += (*itr)->data_size(); 56 size_in_bytes_ += (*itr)->data_size();
57 57
58 if ((*itr)->IsKeyframe()) { 58 if ((*itr)->is_keyframe()) {
59 keyframe_map_.insert( 59 keyframe_map_.insert(
60 std::make_pair((*itr)->GetDecodeTimestamp(), 60 std::make_pair((*itr)->GetDecodeTimestamp(),
61 buffers_.size() - 1 + keyframe_map_index_base_)); 61 buffers_.size() - 1 + keyframe_map_index_base_));
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 void SourceBufferRange::Seek(DecodeTimestamp timestamp) { 66 void SourceBufferRange::Seek(DecodeTimestamp timestamp) {
67 DCHECK(CanSeekTo(timestamp)); 67 DCHECK(CanSeekTo(timestamp));
68 DCHECK(!keyframe_map_.empty()); 68 DCHECK(!keyframe_map_.empty());
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 bool SourceBufferRange::CanAppendRangeToEnd( 443 bool SourceBufferRange::CanAppendRangeToEnd(
444 const SourceBufferRange& range) const { 444 const SourceBufferRange& range) const {
445 return CanAppendBuffersToEnd(range.buffers_); 445 return CanAppendBuffersToEnd(range.buffers_);
446 } 446 }
447 447
448 bool SourceBufferRange::CanAppendBuffersToEnd( 448 bool SourceBufferRange::CanAppendBuffersToEnd(
449 const BufferQueue& buffers) const { 449 const BufferQueue& buffers) const {
450 DCHECK(!buffers_.empty()); 450 DCHECK(!buffers_.empty());
451 return IsNextInSequence(buffers.front()->GetDecodeTimestamp(), 451 return IsNextInSequence(buffers.front()->GetDecodeTimestamp(),
452 buffers.front()->IsKeyframe()); 452 buffers.front()->is_keyframe());
453 } 453 }
454 454
455 bool SourceBufferRange::BelongsToRange(DecodeTimestamp timestamp) const { 455 bool SourceBufferRange::BelongsToRange(DecodeTimestamp timestamp) const {
456 DCHECK(!buffers_.empty()); 456 DCHECK(!buffers_.empty());
457 457
458 return (IsNextInSequence(timestamp, false) || 458 return (IsNextInSequence(timestamp, false) ||
459 (GetStartTimestamp() <= timestamp && timestamp <= GetEndTimestamp())); 459 (GetStartTimestamp() <= timestamp && timestamp <= GetEndTimestamp()));
460 } 460 }
461 461
462 bool SourceBufferRange::CanSeekTo(DecodeTimestamp timestamp) const { 462 bool SourceBufferRange::CanSeekTo(DecodeTimestamp timestamp) const {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 bool SourceBufferRange::IsNextInSequence( 534 bool SourceBufferRange::IsNextInSequence(
535 DecodeTimestamp timestamp, bool is_keyframe) const { 535 DecodeTimestamp timestamp, bool is_keyframe) const {
536 DecodeTimestamp end = buffers_.back()->GetDecodeTimestamp(); 536 DecodeTimestamp end = buffers_.back()->GetDecodeTimestamp();
537 if (end < timestamp && 537 if (end < timestamp &&
538 (gap_policy_ == ALLOW_GAPS || 538 (gap_policy_ == ALLOW_GAPS ||
539 timestamp <= end + GetFudgeRoom())) { 539 timestamp <= end + GetFudgeRoom())) {
540 return true; 540 return true;
541 } 541 }
542 542
543 return timestamp == end && AllowSameTimestamp( 543 return timestamp == end && AllowSameTimestamp(
544 buffers_.back()->IsKeyframe(), is_keyframe); 544 buffers_.back()->is_keyframe(), is_keyframe);
545 } 545 }
546 546
547 base::TimeDelta SourceBufferRange::GetFudgeRoom() const { 547 base::TimeDelta SourceBufferRange::GetFudgeRoom() const {
548 // Because we do not know exactly when is the next timestamp, any buffer 548 // Because we do not know exactly when is the next timestamp, any buffer
549 // that starts within 2x the approximate duration of a buffer is considered 549 // that starts within 2x the approximate duration of a buffer is considered
550 // within this range. 550 // within this range.
551 return 2 * GetApproximateDuration(); 551 return 2 * GetApproximateDuration();
552 } 552 }
553 553
554 base::TimeDelta SourceBufferRange::GetApproximateDuration() const { 554 base::TimeDelta SourceBufferRange::GetApproximateDuration() const {
(...skipping 27 matching lines...) Expand all
582 } 582 }
583 583
584 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime()) 584 if (buffer->timestamp() + buffer->duration() <= start.ToPresentationTime())
585 continue; 585 continue;
586 buffers->push_back(buffer); 586 buffers->push_back(buffer);
587 } 587 }
588 return previous_size < buffers->size(); 588 return previous_size < buffers->size();
589 } 589 }
590 590
591 } // namespace media 591 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698