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

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

Issue 1119163005: Return EOS when selected_range_ is NULL in SourceBufferStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review nitpicks Created 5 years, 7 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 (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 #include <sstream> 9 #include <sstream>
10 10
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 } 921 }
922 922
923 if (itr == ranges_.end()) 923 if (itr == ranges_.end())
924 return; 924 return;
925 925
926 SeekAndSetSelectedRange(*itr, seek_dts); 926 SeekAndSetSelectedRange(*itr, seek_dts);
927 seek_pending_ = false; 927 seek_pending_ = false;
928 } 928 }
929 929
930 bool SourceBufferStream::IsSeekPending() const { 930 bool SourceBufferStream::IsSeekPending() const {
931 return !(end_of_stream_ && IsEndSelected()) && seek_pending_; 931 return seek_pending_ && !IsEndOfStreamReached();
932 } 932 }
933 933
934 void SourceBufferStream::OnSetDuration(base::TimeDelta duration) { 934 void SourceBufferStream::OnSetDuration(base::TimeDelta duration) {
935 DecodeTimestamp duration_dts = 935 DecodeTimestamp duration_dts =
936 DecodeTimestamp::FromPresentationTime(duration); 936 DecodeTimestamp::FromPresentationTime(duration);
937 DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName() 937 DVLOG(1) << __FUNCTION__ << " " << GetStreamTypeName()
938 << " (" << duration.InSecondsF() << ")"; 938 << " (" << duration.InSecondsF() << ")";
939 939
940 RangeList::iterator itr = ranges_.end(); 940 RangeList::iterator itr = ranges_.end();
941 for (itr = ranges_.begin(); itr != ranges_.end(); ++itr) { 941 for (itr = ranges_.begin(); itr != ranges_.end(); ++itr) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 // If the track buffer becomes empty, then try to set the selected range 1093 // If the track buffer becomes empty, then try to set the selected range
1094 // based on the timestamp of this buffer being returned. 1094 // based on the timestamp of this buffer being returned.
1095 if (track_buffer_.empty()) 1095 if (track_buffer_.empty())
1096 SetSelectedRangeIfNeeded(last_output_buffer_timestamp_); 1096 SetSelectedRangeIfNeeded(last_output_buffer_timestamp_);
1097 1097
1098 return kSuccess; 1098 return kSuccess;
1099 } 1099 }
1100 1100
1101 if (!selected_range_ || !selected_range_->HasNextBuffer()) { 1101 if (!selected_range_ || !selected_range_->HasNextBuffer()) {
1102 if (end_of_stream_ && IsEndSelected()) 1102 if (IsEndOfStreamReached()) {
1103 DCHECK(track_buffer_.empty());
wolenetz 2015/05/13 18:23:02 nit: Sorry, I meant to have this DCHECK be stronge
1103 return kEndOfStream; 1104 return kEndOfStream;
1105 }
1104 DVLOG(3) << __FUNCTION__ << " " << GetStreamTypeName() 1106 DVLOG(3) << __FUNCTION__ << " " << GetStreamTypeName()
1105 << ": returning kNeedBuffer " 1107 << ": returning kNeedBuffer "
1106 << (selected_range_ ? "(selected range has no next buffer)" 1108 << (selected_range_ ? "(selected range has no next buffer)"
1107 : "(no selected range)"); 1109 : "(no selected range)");
1108 return kNeedBuffer; 1110 return kNeedBuffer;
1109 } 1111 }
1110 1112
1111 if (selected_range_->GetNextConfigId() != current_config_index_) { 1113 if (selected_range_->GetNextConfigId() != current_config_index_) {
1112 config_change_pending_ = true; 1114 config_change_pending_ = true;
1113 DVLOG(1) << "Config change (selected range config ID does not match)."; 1115 DVLOG(1) << "Config change (selected range config ID does not match).";
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 void SourceBufferStream::MarkEndOfStream() { 1200 void SourceBufferStream::MarkEndOfStream() {
1199 DCHECK(!end_of_stream_); 1201 DCHECK(!end_of_stream_);
1200 end_of_stream_ = true; 1202 end_of_stream_ = true;
1201 } 1203 }
1202 1204
1203 void SourceBufferStream::UnmarkEndOfStream() { 1205 void SourceBufferStream::UnmarkEndOfStream() {
1204 DCHECK(end_of_stream_); 1206 DCHECK(end_of_stream_);
1205 end_of_stream_ = false; 1207 end_of_stream_ = false;
1206 } 1208 }
1207 1209
1208 bool SourceBufferStream::IsEndSelected() const { 1210 bool SourceBufferStream::IsEndOfStreamReached() const {
1211 if (!end_of_stream_ || !track_buffer_.empty())
1212 return false;
1213
1209 if (ranges_.empty()) 1214 if (ranges_.empty())
1210 return true; 1215 return true;
1211 1216
1212 if (seek_pending_) { 1217 if (seek_pending_) {
1213 base::TimeDelta last_range_end_time = 1218 base::TimeDelta last_range_end_time =
1214 ranges_.back()->GetBufferedEndTimestamp().ToPresentationTime(); 1219 ranges_.back()->GetBufferedEndTimestamp().ToPresentationTime();
1215 return seek_buffer_timestamp_ >= last_range_end_time; 1220 return seek_buffer_timestamp_ >= last_range_end_time;
1216 } 1221 }
1217 1222
1223 if (!selected_range_)
1224 return true;
1225
1218 return selected_range_ == ranges_.back(); 1226 return selected_range_ == ranges_.back();
1219 } 1227 }
1220 1228
1221 const AudioDecoderConfig& SourceBufferStream::GetCurrentAudioDecoderConfig() { 1229 const AudioDecoderConfig& SourceBufferStream::GetCurrentAudioDecoderConfig() {
1222 if (config_change_pending_) 1230 if (config_change_pending_)
1223 CompleteConfigChange(); 1231 CompleteConfigChange();
1224 return audio_configs_[current_config_index_]; 1232 return audio_configs_[current_config_index_];
1225 } 1233 }
1226 1234
1227 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { 1235 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 return false; 1583 return false;
1576 1584
1577 DCHECK_NE(have_splice_buffers, have_preroll_buffer); 1585 DCHECK_NE(have_splice_buffers, have_preroll_buffer);
1578 splice_buffers_index_ = 0; 1586 splice_buffers_index_ = 0;
1579 pending_buffer_.swap(*out_buffer); 1587 pending_buffer_.swap(*out_buffer);
1580 pending_buffers_complete_ = false; 1588 pending_buffers_complete_ = false;
1581 return true; 1589 return true;
1582 } 1590 }
1583 1591
1584 } // namespace media 1592 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698