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

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

Issue 2581533002: MSE: Fix logic bugs with high precision duration (Closed)
Patch Set: Feedback Created 3 years, 11 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/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 DCHECK_NE(state_, SHUTDOWN); 1202 DCHECK_NE(state_, SHUTDOWN);
1203 host_->AddTextStream(text_stream, config); 1203 host_->AddTextStream(text_stream, config);
1204 } 1204 }
1205 1205
1206 bool ChunkDemuxer::IsValidId(const std::string& source_id) const { 1206 bool ChunkDemuxer::IsValidId(const std::string& source_id) const {
1207 lock_.AssertAcquired(); 1207 lock_.AssertAcquired();
1208 return source_state_map_.count(source_id) > 0u; 1208 return source_state_map_.count(source_id) > 0u;
1209 } 1209 }
1210 1210
1211 void ChunkDemuxer::UpdateDuration(TimeDelta new_duration) { 1211 void ChunkDemuxer::UpdateDuration(TimeDelta new_duration) {
1212 DCHECK(duration_ != new_duration); 1212 DCHECK(duration_ != new_duration ||
1213 user_specified_duration_ != new_duration.InSecondsF());
1213 user_specified_duration_ = -1; 1214 user_specified_duration_ = -1;
1214 duration_ = new_duration; 1215 duration_ = new_duration;
1215 host_->SetDuration(new_duration); 1216 host_->SetDuration(new_duration);
1216 } 1217 }
1217 1218
1218 void ChunkDemuxer::IncreaseDurationIfNecessary(TimeDelta new_duration) { 1219 void ChunkDemuxer::IncreaseDurationIfNecessary(TimeDelta new_duration) {
1219 DCHECK(new_duration != kNoTimestamp); 1220 DCHECK(new_duration != kNoTimestamp);
1220 DCHECK(new_duration != kInfiniteDuration); 1221 DCHECK(new_duration != kInfiniteDuration);
1221 1222
1222 // Per April 1, 2014 MSE spec editor's draft: 1223 // Per April 1, 2014 MSE spec editor's draft:
(...skipping 19 matching lines...) Expand all
1242 1243
1243 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1244 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1244 ++itr) { 1245 ++itr) {
1245 max_duration = std::max(max_duration, 1246 max_duration = std::max(max_duration,
1246 itr->second->GetMaxBufferedDuration()); 1247 itr->second->GetMaxBufferedDuration());
1247 } 1248 }
1248 1249
1249 if (max_duration.is_zero()) 1250 if (max_duration.is_zero())
1250 return; 1251 return;
1251 1252
1252 if (max_duration < duration_) 1253 // Note: be careful to also check |user_specified_duration_|, which may have
1254 // higher precision than |duration_|.
1255 if (max_duration < duration_ ||
1256 max_duration.InSecondsF() < user_specified_duration_) {
1253 UpdateDuration(max_duration); 1257 UpdateDuration(max_duration);
1258 }
1254 } 1259 }
1255 1260
1256 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { 1261 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const {
1257 base::AutoLock auto_lock(lock_); 1262 base::AutoLock auto_lock(lock_);
1258 return GetBufferedRanges_Locked(); 1263 return GetBufferedRanges_Locked();
1259 } 1264 }
1260 1265
1261 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges_Locked() const { 1266 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges_Locked() const {
1262 lock_.AssertAcquired(); 1267 lock_.AssertAcquired();
1263 1268
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 } 1307 }
1303 1308
1304 void ChunkDemuxer::ShutdownAllStreams() { 1309 void ChunkDemuxer::ShutdownAllStreams() {
1305 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1310 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1306 ++itr) { 1311 ++itr) {
1307 itr->second->Shutdown(); 1312 itr->second->Shutdown();
1308 } 1313 }
1309 } 1314 }
1310 1315
1311 } // namespace media 1316 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698