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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1305273007: Don't short-circuit MSE seeks in WebMediaPlayer impls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 ReadyState old_state = ready_state_; 297 ReadyState old_state = ready_state_;
298 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata) 298 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata)
299 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 299 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
300 300
301 base::TimeDelta new_seek_time = base::TimeDelta::FromSecondsD(seconds); 301 base::TimeDelta new_seek_time = base::TimeDelta::FromSecondsD(seconds);
302 302
303 if (seeking_) { 303 if (seeking_) {
304 if (new_seek_time == seek_time_) { 304 if (new_seek_time == seek_time_) {
305 if (chunk_demuxer_) { 305 if (chunk_demuxer_) {
306 if (!pending_seek_) { 306 if (!pending_seek_) {
wolenetz 2015/08/31 21:15:31 This is another instance of short-circuiting redun
wolenetz 2015/08/31 22:19:11 Patch set 2 removes this kind of short-circuiting
307 // If using media source demuxer, only suppress redundant seeks if 307 // If using media source demuxer, only suppress redundant seeks if
308 // there is no pending seek. This enforces that any pending seek that 308 // there is no pending seek. This enforces that any pending seek that
309 // results in a demuxer seek is preceded by matching 309 // results in a demuxer seek is preceded by matching
310 // CancelPendingSeek() and StartWaitingForSeek() calls. 310 // CancelPendingSeek() and StartWaitingForSeek() calls.
311 return; 311 return;
312 } 312 }
313 } else { 313 } else {
314 // Suppress all redundant seeks if unrestricted by media source demuxer 314 // Suppress all redundant seeks if unrestricted by media source demuxer
315 // API. 315 // API.
316 pending_seek_ = false; 316 pending_seek_ = false;
317 pending_seek_time_ = base::TimeDelta(); 317 pending_seek_time_ = base::TimeDelta();
318 return; 318 return;
319 } 319 }
320 } 320 }
321 321
322 pending_seek_ = true; 322 pending_seek_ = true;
323 pending_seek_time_ = new_seek_time; 323 pending_seek_time_ = new_seek_time;
324 if (chunk_demuxer_) 324 if (chunk_demuxer_)
325 chunk_demuxer_->CancelPendingSeek(pending_seek_time_); 325 chunk_demuxer_->CancelPendingSeek(pending_seek_time_);
326 return; 326 return;
327 } 327 }
328 328
329 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds)); 329 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds));
330 330
331 // Update our paused time. 331 // Update our paused time.
332 // In paused state ignore the seek operations to current time if the loading 332 // For non-MSE playbacks, in paused state ignore the seek operations to
333 // is completed and generate OnPipelineBufferingStateChanged event to 333 // current time if the loading is completed and generate
334 // eventually fire seeking and seeked events 334 // OnPipelineBufferingStateChanged event to eventually fire seeking and seeked
335 // events. We don't short-circuit MSE seeks in this logic because the
336 // underlying buffers around the seek time might have changed (or even been
337 // removed) since previous seek/preroll/pause action, and the pipeline might
338 // need to flush so the new buffers are decoded and rendered instead of the
339 // old ones.
335 if (paused_) { 340 if (paused_) {
336 if (paused_time_ != new_seek_time) { 341 if (paused_time_ != new_seek_time || chunk_demuxer_) {
337 paused_time_ = new_seek_time; 342 paused_time_ = new_seek_time;
338 } else if (old_state == ReadyStateHaveEnoughData) { 343 } else if (old_state == ReadyStateHaveEnoughData) {
339 main_task_runner_->PostTask( 344 main_task_runner_->PostTask(
340 FROM_HERE, 345 FROM_HERE,
341 base::Bind(&WebMediaPlayerImpl::OnPipelineBufferingStateChanged, 346 base::Bind(&WebMediaPlayerImpl::OnPipelineBufferingStateChanged,
342 AsWeakPtr(), BUFFERING_HAVE_ENOUGH)); 347 AsWeakPtr(), BUFFERING_HAVE_ENOUGH));
343 return; 348 return;
344 } 349 }
345 } 350 }
346 351
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1058
1054 // pause() may be called after playback has ended and the HTMLMediaElement 1059 // pause() may be called after playback has ended and the HTMLMediaElement
1055 // requires that currentTime() == duration() after ending. We want to ensure 1060 // requires that currentTime() == duration() after ending. We want to ensure
1056 // |paused_time_| matches currentTime() in this case or a future seek() may 1061 // |paused_time_| matches currentTime() in this case or a future seek() may
1057 // incorrectly discard what it thinks is a seek to the existing time. 1062 // incorrectly discard what it thinks is a seek to the existing time.
1058 paused_time_ = 1063 paused_time_ =
1059 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); 1064 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime();
1060 } 1065 }
1061 1066
1062 } // namespace media 1067 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698