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

Side by Side Diff: content/renderer/media/webmediaplayer_impl.cc

Issue 24267018: Suppress redundant seeks to within same usec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.h ('k') | 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 "content/renderer/media/webmediaplayer_impl.h" 5 #include "content/renderer/media/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 WebKit::WebMediaPlayerClient* client, 131 WebKit::WebMediaPlayerClient* client,
132 base::WeakPtr<WebMediaPlayerDelegate> delegate, 132 base::WeakPtr<WebMediaPlayerDelegate> delegate,
133 const WebMediaPlayerParams& params) 133 const WebMediaPlayerParams& params)
134 : frame_(frame), 134 : frame_(frame),
135 network_state_(WebMediaPlayer::NetworkStateEmpty), 135 network_state_(WebMediaPlayer::NetworkStateEmpty),
136 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 136 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
137 main_loop_(base::MessageLoopProxy::current()), 137 main_loop_(base::MessageLoopProxy::current()),
138 media_loop_(params.message_loop_proxy()), 138 media_loop_(params.message_loop_proxy()),
139 paused_(true), 139 paused_(true),
140 seeking_(false), 140 seeking_(false),
141 playback_rate_(0.0f), 141 playback_rate_(0.0),
142 pending_seek_(false), 142 pending_seek_(false),
143 pending_seek_seconds_(0.0f),
144 client_(client), 143 client_(client),
145 delegate_(delegate), 144 delegate_(delegate),
146 defer_load_cb_(params.defer_load_cb()), 145 defer_load_cb_(params.defer_load_cb()),
147 media_log_(params.media_log()), 146 media_log_(params.media_log()),
148 accelerated_compositing_reported_(false), 147 accelerated_compositing_reported_(false),
149 incremented_externally_allocated_memory_(false), 148 incremented_externally_allocated_memory_(false),
150 gpu_factories_(params.gpu_factories()), 149 gpu_factories_(params.gpu_factories()),
151 is_local_source_(false), 150 is_local_source_(false),
152 supports_save_(true), 151 supports_save_(true),
153 starting_(false), 152 starting_(false),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 329 }
331 330
332 bool WebMediaPlayerImpl::supportsSave() const { 331 bool WebMediaPlayerImpl::supportsSave() const {
333 DCHECK(main_loop_->BelongsToCurrentThread()); 332 DCHECK(main_loop_->BelongsToCurrentThread());
334 return supports_save_; 333 return supports_save_;
335 } 334 }
336 335
337 void WebMediaPlayerImpl::seek(double seconds) { 336 void WebMediaPlayerImpl::seek(double seconds) {
338 DCHECK(main_loop_->BelongsToCurrentThread()); 337 DCHECK(main_loop_->BelongsToCurrentThread());
339 338
340 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); 339 base::TimeDelta new_seek_time = ConvertSecondsToTimestamp(seconds);
340
341 // Suppress redundant seek to same microsecond as current seek. Clear any
342 // pending seek in this case, too. For example, seek(1), seek(2), seek(1)
343 // without any intervening seek completion should result in only a current
344 // seek to (1) without any left-over pending seek.
345 if (seeking_ && new_seek_time == seek_time_) {
wolenetz 2013/10/01 19:51:49 This is incorrect; I'll need to fix this in subseq
346 pending_seek_ = false;
347 return;
348 }
341 349
342 if (starting_ || seeking_) { 350 if (starting_ || seeking_) {
343 pending_seek_ = true; 351 pending_seek_ = true;
344 pending_seek_seconds_ = seconds; 352 pending_seek_time_ = new_seek_time;
345 if (chunk_demuxer_) 353 if (chunk_demuxer_)
346 chunk_demuxer_->CancelPendingSeek(seek_time); 354 chunk_demuxer_->CancelPendingSeek(pending_seek_time_);
347 return; 355 return;
348 } 356 }
349 357
358 seek_time_ = new_seek_time;
350 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds)); 359 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds));
351 360
352 // Update our paused time. 361 // Update our paused time.
353 if (paused_) 362 if (paused_)
354 paused_time_ = seek_time; 363 paused_time_ = seek_time_;
355 364
356 seeking_ = true; 365 seeking_ = true;
357 366
358 if (chunk_demuxer_) 367 if (chunk_demuxer_)
359 chunk_demuxer_->StartWaitingForSeek(seek_time); 368 chunk_demuxer_->StartWaitingForSeek(seek_time_);
360 369
361 // Kick off the asynchronous seek! 370 // Kick off the asynchronous seek!
362 pipeline_->Seek( 371 pipeline_->Seek(
363 seek_time, 372 seek_time_,
364 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek)); 373 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek));
365 } 374 }
366 375
367 void WebMediaPlayerImpl::setRate(double rate) { 376 void WebMediaPlayerImpl::setRate(double rate) {
368 DCHECK(main_loop_->BelongsToCurrentThread()); 377 DCHECK(main_loop_->BelongsToCurrentThread());
369 378
370 // TODO(kylep): Remove when support for negatives is added. Also, modify the 379 // TODO(kylep): Remove when support for negatives is added. Also, modify the
371 // following checks so rewind uses reasonable values also. 380 // following checks so rewind uses reasonable values also.
372 if (rate < 0.0) 381 if (rate < 0.0)
373 return; 382 return;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 840
832 GetClient()->repaint(); 841 GetClient()->repaint();
833 } 842 }
834 843
835 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) { 844 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) {
836 DCHECK(main_loop_->BelongsToCurrentThread()); 845 DCHECK(main_loop_->BelongsToCurrentThread());
837 starting_ = false; 846 starting_ = false;
838 seeking_ = false; 847 seeking_ = false;
839 if (pending_seek_) { 848 if (pending_seek_) {
840 pending_seek_ = false; 849 pending_seek_ = false;
841 seek(pending_seek_seconds_); 850 seek(pending_seek_time_.InSecondsF());
842 return; 851 return;
843 } 852 }
844 853
845 if (status != media::PIPELINE_OK) { 854 if (status != media::PIPELINE_OK) {
846 OnPipelineError(status); 855 OnPipelineError(status);
847 return; 856 return;
848 } 857 }
849 858
850 // Update our paused time. 859 // Update our paused time.
851 if (paused_) 860 if (paused_)
(...skipping 23 matching lines...) Expand all
875 884
876 if (error == media::PIPELINE_ERROR_DECRYPT) 885 if (error == media::PIPELINE_ERROR_DECRYPT)
877 EmeUMAHistogramCounts(current_key_system_, "DecryptError", 1); 886 EmeUMAHistogramCounts(current_key_system_, "DecryptError", 1);
878 887
879 // Repaint to trigger UI update. 888 // Repaint to trigger UI update.
880 Repaint(); 889 Repaint();
881 } 890 }
882 891
883 void WebMediaPlayerImpl::OnPipelineBufferingState( 892 void WebMediaPlayerImpl::OnPipelineBufferingState(
884 media::Pipeline::BufferingState buffering_state) { 893 media::Pipeline::BufferingState buffering_state) {
894 DCHECK(main_loop_->BelongsToCurrentThread());
885 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; 895 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")";
886 896
887 switch (buffering_state) { 897 switch (buffering_state) {
888 case media::Pipeline::kHaveMetadata: 898 case media::Pipeline::kHaveMetadata:
889 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 899 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
890 900
891 if (hasVideo() && GetClient()->needsWebLayerForVideo()) { 901 if (hasVideo() && GetClient()->needsWebLayerForVideo()) {
892 DCHECK(!video_weblayer_); 902 DCHECK(!video_weblayer_);
893 video_weblayer_.reset( 903 video_weblayer_.reset(
894 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); 904 new webkit::WebLayerImpl(cc::VideoLayer::Create(this)));
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 1247
1238 if (pending_repaint_) 1248 if (pending_repaint_)
1239 return; 1249 return;
1240 1250
1241 pending_repaint_ = true; 1251 pending_repaint_ = true;
1242 main_loop_->PostTask(FROM_HERE, base::Bind( 1252 main_loop_->PostTask(FROM_HERE, base::Bind(
1243 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); 1253 &WebMediaPlayerImpl::Repaint, AsWeakPtr()));
1244 } 1254 }
1245 1255
1246 } // namespace content 1256 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698