Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 preload_(BufferedDataSource::AUTO), | 144 preload_(BufferedDataSource::AUTO), |
| 145 main_task_runner_(base::MessageLoopProxy::current()), | 145 main_task_runner_(base::MessageLoopProxy::current()), |
| 146 media_task_runner_(params.media_task_runner()), | 146 media_task_runner_(params.media_task_runner()), |
| 147 media_log_(params.media_log()), | 147 media_log_(params.media_log()), |
| 148 pipeline_(media_task_runner_, media_log_.get()), | 148 pipeline_(media_task_runner_, media_log_.get()), |
| 149 load_type_(LoadTypeURL), | 149 load_type_(LoadTypeURL), |
| 150 opaque_(false), | 150 opaque_(false), |
| 151 paused_(true), | 151 paused_(true), |
| 152 seeking_(false), | 152 seeking_(false), |
| 153 playback_rate_(0.0f), | 153 playback_rate_(0.0f), |
| 154 ended_(false), | |
| 154 pending_seek_(false), | 155 pending_seek_(false), |
| 155 pending_seek_seconds_(0.0f), | 156 pending_seek_seconds_(0.0f), |
| 156 should_notify_time_changed_(false), | 157 should_notify_time_changed_(false), |
| 157 client_(client), | 158 client_(client), |
| 158 delegate_(delegate), | 159 delegate_(delegate), |
| 159 defer_load_cb_(params.defer_load_cb()), | 160 defer_load_cb_(params.defer_load_cb()), |
| 160 gpu_factories_(params.gpu_factories()), | 161 gpu_factories_(params.gpu_factories()), |
| 161 supports_save_(true), | 162 supports_save_(true), |
| 162 chunk_demuxer_(NULL), | 163 chunk_demuxer_(NULL), |
| 163 compositor_task_runner_(params.compositor_task_runner()), | 164 compositor_task_runner_(params.compositor_task_runner()), |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 | 304 |
| 304 bool WebMediaPlayerImpl::supportsSave() const { | 305 bool WebMediaPlayerImpl::supportsSave() const { |
| 305 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 306 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 306 return supports_save_; | 307 return supports_save_; |
| 307 } | 308 } |
| 308 | 309 |
| 309 void WebMediaPlayerImpl::seek(double seconds) { | 310 void WebMediaPlayerImpl::seek(double seconds) { |
| 310 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; | 311 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; |
| 311 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 312 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 312 | 313 |
| 314 ended_ = false; | |
| 315 | |
| 313 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata) | 316 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata) |
| 314 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 317 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 315 | 318 |
| 316 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); | 319 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); |
| 317 | 320 |
| 318 if (seeking_) { | 321 if (seeking_) { |
| 319 pending_seek_ = true; | 322 pending_seek_ = true; |
| 320 pending_seek_seconds_ = seconds; | 323 pending_seek_seconds_ = seconds; |
| 321 if (chunk_demuxer_) | 324 if (chunk_demuxer_) |
| 322 chunk_demuxer_->CancelPendingSeek(seek_time); | 325 chunk_demuxer_->CancelPendingSeek(seek_time); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 439 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 437 | 440 |
| 438 if (pipeline_metadata_.timeline_offset.is_null()) | 441 if (pipeline_metadata_.timeline_offset.is_null()) |
| 439 return std::numeric_limits<double>::quiet_NaN(); | 442 return std::numeric_limits<double>::quiet_NaN(); |
| 440 | 443 |
| 441 return pipeline_metadata_.timeline_offset.ToJsTime(); | 444 return pipeline_metadata_.timeline_offset.ToJsTime(); |
| 442 } | 445 } |
| 443 | 446 |
| 444 double WebMediaPlayerImpl::currentTime() const { | 447 double WebMediaPlayerImpl::currentTime() const { |
| 445 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 448 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 449 | |
| 450 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) | |
|
acolwell GONE FROM CHROMIUM
2014/09/02 22:33:21
nit: I'd really prefer to see this logic in Blink
scherkus (not reviewing)
2014/09/02 23:43:57
Yeah I thought about some more while driving. Agre
| |
| 451 return 0.0; | |
| 452 | |
| 453 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, | |
| 454 // see http://crbug.com/409280 | |
| 455 if (ended_) | |
| 456 return duration(); | |
| 457 | |
| 446 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF(); | 458 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF(); |
| 447 } | 459 } |
| 448 | 460 |
| 449 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const { | 461 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const { |
| 450 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 462 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 451 return network_state_; | 463 return network_state_; |
| 452 } | 464 } |
| 453 | 465 |
| 454 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const { | 466 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const { |
| 455 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 467 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 // Update our paused time. | 703 // Update our paused time. |
| 692 if (paused_) | 704 if (paused_) |
| 693 paused_time_ = pipeline_.GetMediaTime(); | 705 paused_time_ = pipeline_.GetMediaTime(); |
| 694 | 706 |
| 695 should_notify_time_changed_ = time_changed; | 707 should_notify_time_changed_ = time_changed; |
| 696 } | 708 } |
| 697 | 709 |
| 698 void WebMediaPlayerImpl::OnPipelineEnded() { | 710 void WebMediaPlayerImpl::OnPipelineEnded() { |
| 699 DVLOG(1) << __FUNCTION__; | 711 DVLOG(1) << __FUNCTION__; |
| 700 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 712 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 713 | |
| 714 // Ignore state changes until we've completed all outstanding seeks. | |
| 715 if (seeking_ || pending_seek_) | |
| 716 return; | |
| 717 | |
| 718 ended_ = true; | |
| 701 client_->timeChanged(); | 719 client_->timeChanged(); |
| 702 } | 720 } |
| 703 | 721 |
| 704 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { | 722 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { |
| 705 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 723 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 706 DCHECK_NE(error, media::PIPELINE_OK); | 724 DCHECK_NE(error, media::PIPELINE_OK); |
| 707 | 725 |
| 708 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { | 726 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { |
| 709 // Any error that occurs before reaching ReadyStateHaveMetadata should | 727 // Any error that occurs before reaching ReadyStateHaveMetadata should |
| 710 // be considered a format error. | 728 // be considered a format error. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 compositor_task_runner_->PostTask(FROM_HERE, | 1029 compositor_task_runner_->PostTask(FROM_HERE, |
| 1012 base::Bind(&GetCurrentFrameAndSignal, | 1030 base::Bind(&GetCurrentFrameAndSignal, |
| 1013 base::Unretained(compositor_), | 1031 base::Unretained(compositor_), |
| 1014 &video_frame, | 1032 &video_frame, |
| 1015 &event)); | 1033 &event)); |
| 1016 event.Wait(); | 1034 event.Wait(); |
| 1017 return video_frame; | 1035 return video_frame; |
| 1018 } | 1036 } |
| 1019 | 1037 |
| 1020 } // namespace content | 1038 } // namespace content |
| OLD | NEW |