Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/webmediaplayer_impl.h" | 5 #include "webkit/glue/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 media::MediaLog* media_log) | 92 media::MediaLog* media_log) |
| 93 : network_state_(WebKit::WebMediaPlayer::Empty), | 93 : network_state_(WebKit::WebMediaPlayer::Empty), |
| 94 ready_state_(WebKit::WebMediaPlayer::HaveNothing), | 94 ready_state_(WebKit::WebMediaPlayer::HaveNothing), |
| 95 main_loop_(NULL), | 95 main_loop_(NULL), |
| 96 filter_collection_(collection), | 96 filter_collection_(collection), |
| 97 pipeline_(NULL), | 97 pipeline_(NULL), |
| 98 message_loop_factory_(message_loop_factory), | 98 message_loop_factory_(message_loop_factory), |
| 99 paused_(true), | 99 paused_(true), |
| 100 seeking_(false), | 100 seeking_(false), |
| 101 playback_rate_(0.0f), | 101 playback_rate_(0.0f), |
| 102 pending_seek_(false), | |
| 102 client_(client), | 103 client_(client), |
| 103 proxy_(NULL), | 104 proxy_(NULL), |
| 104 media_stream_client_(media_stream_client), | 105 media_stream_client_(media_stream_client), |
| 105 media_log_(media_log) { | 106 media_log_(media_log) { |
| 106 // Saves the current message loop. | 107 // Saves the current message loop. |
| 107 DCHECK(!main_loop_); | 108 DCHECK(!main_loop_); |
| 108 main_loop_ = MessageLoop::current(); | 109 main_loop_ = MessageLoop::current(); |
| 109 media_log_->AddEvent( | 110 media_log_->AddEvent( |
| 110 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 111 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 111 } | 112 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 // cause extra pre-rolling and will break servers without range request | 289 // cause extra pre-rolling and will break servers without range request |
| 289 // support. | 290 // support. |
| 290 // | 291 // |
| 291 // We still have to notify WebKit that time has changed otherwise | 292 // We still have to notify WebKit that time has changed otherwise |
| 292 // HTMLMediaElement gets into an inconsistent state. | 293 // HTMLMediaElement gets into an inconsistent state. |
| 293 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) { | 294 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) { |
| 294 GetClient()->timeChanged(); | 295 GetClient()->timeChanged(); |
| 295 return; | 296 return; |
| 296 } | 297 } |
| 297 | 298 |
| 299 if (seeking_) { | |
| 300 pending_seek_ = true; | |
| 301 pending_seek_seconds_ = seconds; | |
| 302 return; | |
| 303 } | |
| 304 | |
| 298 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds)); | 305 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds)); |
| 299 | 306 |
| 300 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); | 307 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); |
| 301 | 308 |
| 302 // Update our paused time. | 309 // Update our paused time. |
| 303 if (paused_) { | 310 if (paused_) { |
| 304 paused_time_ = seek_time; | 311 paused_time_ = seek_time; |
| 305 } | 312 } |
| 306 | 313 |
| 307 seeking_ = true; | 314 seeking_ = true; |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 | 701 |
| 695 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) { | 702 void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) { |
| 696 DCHECK(MessageLoop::current() == main_loop_); | 703 DCHECK(MessageLoop::current() == main_loop_); |
| 697 if (status == media::PIPELINE_OK) { | 704 if (status == media::PIPELINE_OK) { |
| 698 // Update our paused time. | 705 // Update our paused time. |
| 699 if (paused_) { | 706 if (paused_) { |
| 700 paused_time_ = pipeline_->GetCurrentTime(); | 707 paused_time_ = pipeline_->GetCurrentTime(); |
| 701 } | 708 } |
| 702 | 709 |
| 703 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | 710 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 704 seeking_ = false; | |
| 705 GetClient()->timeChanged(); | 711 GetClient()->timeChanged(); |
| 706 } | 712 } |
| 713 seeking_ = false; | |
|
Ami GONE FROM CHROMIUM
2011/09/13 20:12:58
Curious about the reason for this move.
SeRya
2011/09/13 22:14:21
Player should leave "seeking" state whether seek s
| |
| 714 | |
| 715 if (pending_seek_) { | |
| 716 pending_seek_ = false; | |
| 717 seek(pending_seek_seconds_); | |
| 718 } | |
| 707 } | 719 } |
| 708 | 720 |
| 709 void WebMediaPlayerImpl::OnPipelineEnded(PipelineStatus status) { | 721 void WebMediaPlayerImpl::OnPipelineEnded(PipelineStatus status) { |
| 710 DCHECK(MessageLoop::current() == main_loop_); | 722 DCHECK(MessageLoop::current() == main_loop_); |
| 711 if (status == media::PIPELINE_OK) { | 723 if (status == media::PIPELINE_OK) { |
| 712 GetClient()->timeChanged(); | 724 GetClient()->timeChanged(); |
| 713 } | 725 } |
| 714 } | 726 } |
| 715 | 727 |
| 716 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { | 728 void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 } | 827 } |
| 816 } | 828 } |
| 817 | 829 |
| 818 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 830 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 819 DCHECK(MessageLoop::current() == main_loop_); | 831 DCHECK(MessageLoop::current() == main_loop_); |
| 820 DCHECK(client_); | 832 DCHECK(client_); |
| 821 return client_; | 833 return client_; |
| 822 } | 834 } |
| 823 | 835 |
| 824 } // namespace webkit_glue | 836 } // namespace webkit_glue |
| OLD | NEW |