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

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

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

Powered by Google App Engine
This is Rietveld 408576698