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

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: Merge all EOS checks to single function and add unit tests 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 !IsEndOfStreamReached() && seek_pending_;
wolenetz 2015/05/12 20:36:24 nit: please swap the order of the evaluation here
landell 2015/05/13 09:55:56 Done.
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 track_buffer_.pop_front(); 1090 track_buffer_.pop_front();
1091 last_output_buffer_timestamp_ = (*out_buffer)->GetDecodeTimestamp(); 1091 last_output_buffer_timestamp_ = (*out_buffer)->GetDecodeTimestamp();
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
wolenetz 2015/05/12 20:36:23 nit: probably good for protection against later re
landell 2015/05/13 09:55:56 Done.
1101 if (!selected_range_ || !selected_range_->HasNextBuffer()) { 1101 if (!selected_range_ || !selected_range_->HasNextBuffer()) {
1102 if (end_of_stream_ && IsEndSelected()) 1102 if (IsEndOfStreamReached())
1103 return kEndOfStream; 1103 return kEndOfStream;
1104 DVLOG(3) << __FUNCTION__ << " " << GetStreamTypeName() 1104 DVLOG(3) << __FUNCTION__ << " " << GetStreamTypeName()
1105 << ": returning kNeedBuffer " 1105 << ": returning kNeedBuffer "
1106 << (selected_range_ ? "(selected range has no next buffer)" 1106 << (selected_range_ ? "(selected range has no next buffer)"
1107 : "(no selected range)"); 1107 : "(no selected range)");
1108 return kNeedBuffer; 1108 return kNeedBuffer;
1109 } 1109 }
1110 1110
1111 if (selected_range_->GetNextConfigId() != current_config_index_) { 1111 if (selected_range_->GetNextConfigId() != current_config_index_) {
1112 config_change_pending_ = true; 1112 config_change_pending_ = true;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 void SourceBufferStream::MarkEndOfStream() { 1198 void SourceBufferStream::MarkEndOfStream() {
1199 DCHECK(!end_of_stream_); 1199 DCHECK(!end_of_stream_);
1200 end_of_stream_ = true; 1200 end_of_stream_ = true;
1201 } 1201 }
1202 1202
1203 void SourceBufferStream::UnmarkEndOfStream() { 1203 void SourceBufferStream::UnmarkEndOfStream() {
1204 DCHECK(end_of_stream_); 1204 DCHECK(end_of_stream_);
1205 end_of_stream_ = false; 1205 end_of_stream_ = false;
1206 } 1206 }
1207 1207
1208 bool SourceBufferStream::IsEndSelected() const { 1208 bool SourceBufferStream::IsEndOfStreamReached() const {
1209 if (!end_of_stream_)
1210 return false;
1211
1209 if (ranges_.empty()) 1212 if (ranges_.empty())
wolenetz 2015/05/12 20:36:23 nit: I think it might be possible in an edge case
landell 2015/05/13 09:55:56 Done.
1210 return true; 1213 return true;
1211 1214
1212 if (seek_pending_) { 1215 if (seek_pending_) {
1213 base::TimeDelta last_range_end_time = 1216 base::TimeDelta last_range_end_time =
1214 ranges_.back()->GetBufferedEndTimestamp().ToPresentationTime(); 1217 ranges_.back()->GetBufferedEndTimestamp().ToPresentationTime();
1215 return seek_buffer_timestamp_ >= last_range_end_time; 1218 return seek_buffer_timestamp_ >= last_range_end_time;
1216 } 1219 }
1217 1220
1221 if (!selected_range_ && track_buffer_.empty())
wolenetz 2015/05/12 20:36:24 nit: see my comment, above.
landell 2015/05/13 09:55:56 Done.
1222 return true;
1223
1218 return selected_range_ == ranges_.back(); 1224 return selected_range_ == ranges_.back();
1219 } 1225 }
1220 1226
1221 const AudioDecoderConfig& SourceBufferStream::GetCurrentAudioDecoderConfig() { 1227 const AudioDecoderConfig& SourceBufferStream::GetCurrentAudioDecoderConfig() {
1222 if (config_change_pending_) 1228 if (config_change_pending_)
1223 CompleteConfigChange(); 1229 CompleteConfigChange();
1224 return audio_configs_[current_config_index_]; 1230 return audio_configs_[current_config_index_];
1225 } 1231 }
1226 1232
1227 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() { 1233 const VideoDecoderConfig& SourceBufferStream::GetCurrentVideoDecoderConfig() {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 return false; 1581 return false;
1576 1582
1577 DCHECK_NE(have_splice_buffers, have_preroll_buffer); 1583 DCHECK_NE(have_splice_buffers, have_preroll_buffer);
1578 splice_buffers_index_ = 0; 1584 splice_buffers_index_ = 0;
1579 pending_buffer_.swap(*out_buffer); 1585 pending_buffer_.swap(*out_buffer);
1580 pending_buffers_complete_ = false; 1586 pending_buffers_complete_ = false;
1581 return true; 1587 return true;
1582 } 1588 }
1583 1589
1584 } // namespace media 1590 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698