| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // as format error. Should post a task to call to |webmediaplayer_|. | 694 // as format error. Should post a task to call to |webmediaplayer_|. |
| 688 SetNetworkState(WebKit::WebMediaPlayer::FormatError); | 695 SetNetworkState(WebKit::WebMediaPlayer::FormatError); |
| 689 } | 696 } |
| 690 | 697 |
| 691 // Repaint to trigger UI update. | 698 // Repaint to trigger UI update. |
| 692 Repaint(); | 699 Repaint(); |
| 693 } | 700 } |
| 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_); |
| 704 seeking_ = false; |
| 705 if (pending_seek_) { |
| 706 pending_seek_ = false; |
| 707 seek(pending_seek_seconds_); |
| 708 return; |
| 709 } |
| 710 |
| 697 if (status == media::PIPELINE_OK) { | 711 if (status == media::PIPELINE_OK) { |
| 698 // Update our paused time. | 712 // Update our paused time. |
| 699 if (paused_) { | 713 if (paused_) { |
| 700 paused_time_ = pipeline_->GetCurrentTime(); | 714 paused_time_ = pipeline_->GetCurrentTime(); |
| 701 } | 715 } |
| 702 | 716 |
| 703 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); | 717 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); |
| 704 seeking_ = false; | |
| 705 GetClient()->timeChanged(); | 718 GetClient()->timeChanged(); |
| 706 } | 719 } |
| 707 } | 720 } |
| 708 | 721 |
| 709 void WebMediaPlayerImpl::OnPipelineEnded(PipelineStatus status) { | 722 void WebMediaPlayerImpl::OnPipelineEnded(PipelineStatus status) { |
| 710 DCHECK(MessageLoop::current() == main_loop_); | 723 DCHECK(MessageLoop::current() == main_loop_); |
| 711 if (status == media::PIPELINE_OK) { | 724 if (status == media::PIPELINE_OK) { |
| 712 GetClient()->timeChanged(); | 725 GetClient()->timeChanged(); |
| 713 } | 726 } |
| 714 } | 727 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 } | 828 } |
| 816 } | 829 } |
| 817 | 830 |
| 818 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 831 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 819 DCHECK(MessageLoop::current() == main_loop_); | 832 DCHECK(MessageLoop::current() == main_loop_); |
| 820 DCHECK(client_); | 833 DCHECK(client_); |
| 821 return client_; | 834 return client_; |
| 822 } | 835 } |
| 823 | 836 |
| 824 } // namespace webkit_glue | 837 } // namespace webkit_glue |
| OLD | NEW |