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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 main_task_runner_(base::MessageLoopProxy::current()), | 148 main_task_runner_(base::MessageLoopProxy::current()), |
149 media_task_runner_( | 149 media_task_runner_( |
150 RenderThreadImpl::current()->GetMediaThreadTaskRunner()), | 150 RenderThreadImpl::current()->GetMediaThreadTaskRunner()), |
151 media_log_(new RenderMediaLog()), | 151 media_log_(new RenderMediaLog()), |
152 pipeline_(media_task_runner_, media_log_.get()), | 152 pipeline_(media_task_runner_, media_log_.get()), |
153 load_type_(LoadTypeURL), | 153 load_type_(LoadTypeURL), |
154 opaque_(false), | 154 opaque_(false), |
155 paused_(true), | 155 paused_(true), |
156 seeking_(false), | 156 seeking_(false), |
157 playback_rate_(0.0f), | 157 playback_rate_(0.0f), |
158 ended_(false), | |
158 pending_seek_(false), | 159 pending_seek_(false), |
159 pending_seek_seconds_(0.0f), | 160 pending_seek_seconds_(0.0f), |
160 should_notify_time_changed_(false), | 161 should_notify_time_changed_(false), |
161 client_(client), | 162 client_(client), |
162 delegate_(delegate), | 163 delegate_(delegate), |
163 defer_load_cb_(params.defer_load_cb()), | 164 defer_load_cb_(params.defer_load_cb()), |
164 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), | 165 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), |
165 supports_save_(true), | 166 supports_save_(true), |
166 chunk_demuxer_(NULL), | 167 chunk_demuxer_(NULL), |
167 // Threaded compositing isn't enabled universally yet. | 168 // Threaded compositing isn't enabled universally yet. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 | 306 |
306 bool WebMediaPlayerImpl::supportsSave() const { | 307 bool WebMediaPlayerImpl::supportsSave() const { |
307 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 308 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
308 return supports_save_; | 309 return supports_save_; |
309 } | 310 } |
310 | 311 |
311 void WebMediaPlayerImpl::seek(double seconds) { | 312 void WebMediaPlayerImpl::seek(double seconds) { |
312 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; | 313 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; |
313 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 314 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
314 | 315 |
316 ended_ = false; | |
317 | |
315 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata) | 318 if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata) |
316 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 319 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
317 | 320 |
318 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); | 321 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); |
319 | 322 |
320 if (seeking_) { | 323 if (seeking_) { |
321 pending_seek_ = true; | 324 pending_seek_ = true; |
322 pending_seek_seconds_ = seconds; | 325 pending_seek_seconds_ = seconds; |
323 if (chunk_demuxer_) | 326 if (chunk_demuxer_) |
324 chunk_demuxer_->CancelPendingSeek(seek_time); | 327 chunk_demuxer_->CancelPendingSeek(seek_time); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 441 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
439 | 442 |
440 if (pipeline_metadata_.timeline_offset.is_null()) | 443 if (pipeline_metadata_.timeline_offset.is_null()) |
441 return std::numeric_limits<double>::quiet_NaN(); | 444 return std::numeric_limits<double>::quiet_NaN(); |
442 | 445 |
443 return pipeline_metadata_.timeline_offset.ToJsTime(); | 446 return pipeline_metadata_.timeline_offset.ToJsTime(); |
444 } | 447 } |
445 | 448 |
446 double WebMediaPlayerImpl::currentTime() const { | 449 double WebMediaPlayerImpl::currentTime() const { |
447 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 450 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
451 | |
acolwell GONE FROM CHROMIUM
2014/08/30 01:00:28
nit: Add a DCHECK here to make sure you are never
scherkus (not reviewing)
2014/09/02 20:58:25
Sadly Blink does call this when we HAVE_NOTHING du
| |
452 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, | |
453 // see http://crbug.com/409280 | |
454 if (ended_) | |
455 return duration(); | |
456 | |
448 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF(); | 457 return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF(); |
449 } | 458 } |
450 | 459 |
451 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const { | 460 WebMediaPlayer::NetworkState WebMediaPlayerImpl::networkState() const { |
452 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 461 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
453 return network_state_; | 462 return network_state_; |
454 } | 463 } |
455 | 464 |
456 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const { | 465 WebMediaPlayer::ReadyState WebMediaPlayerImpl::readyState() const { |
457 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 466 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 // Update our paused time. | 702 // Update our paused time. |
694 if (paused_) | 703 if (paused_) |
695 paused_time_ = pipeline_.GetMediaTime(); | 704 paused_time_ = pipeline_.GetMediaTime(); |
696 | 705 |
697 should_notify_time_changed_ = time_changed; | 706 should_notify_time_changed_ = time_changed; |
698 } | 707 } |
699 | 708 |
700 void WebMediaPlayerImpl::OnPipelineEnded() { | 709 void WebMediaPlayerImpl::OnPipelineEnded() { |
701 DVLOG(1) << __FUNCTION__; | 710 DVLOG(1) << __FUNCTION__; |
702 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 711 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
712 ended_ = true; | |
acolwell GONE FROM CHROMIUM
2014/08/30 01:00:28
I don't think you can blindly update it here. At a
scherkus (not reviewing)
2014/09/02 20:58:25
Good catch -- done. We have a similar check in OnB
| |
703 client_->timeChanged(); | 713 client_->timeChanged(); |
704 } | 714 } |
705 | 715 |
706 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { | 716 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { |
707 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 717 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
708 DCHECK_NE(error, media::PIPELINE_OK); | 718 DCHECK_NE(error, media::PIPELINE_OK); |
709 | 719 |
710 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { | 720 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) { |
711 // Any error that occurs before reaching ReadyStateHaveMetadata should | 721 // Any error that occurs before reaching ReadyStateHaveMetadata should |
712 // be considered a format error. | 722 // be considered a format error. |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 compositor_task_runner_->PostTask(FROM_HERE, | 1023 compositor_task_runner_->PostTask(FROM_HERE, |
1014 base::Bind(&GetCurrentFrameAndSignal, | 1024 base::Bind(&GetCurrentFrameAndSignal, |
1015 base::Unretained(compositor_), | 1025 base::Unretained(compositor_), |
1016 &video_frame, | 1026 &video_frame, |
1017 &event)); | 1027 &event)); |
1018 event.Wait(); | 1028 event.Wait(); |
1019 return video_frame; | 1029 return video_frame; |
1020 } | 1030 } |
1021 | 1031 |
1022 } // namespace content | 1032 } // namespace content |
OLD | NEW |