| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 chunk_demuxer_ = NULL; | 312 chunk_demuxer_ = NULL; |
| 313 } | 313 } |
| 314 | 314 |
| 315 ///////////////////////////////////////////////////////////////////////////// | 315 ///////////////////////////////////////////////////////////////////////////// |
| 316 // WebMediaPlayerImpl implementation | 316 // WebMediaPlayerImpl implementation |
| 317 | 317 |
| 318 WebMediaPlayerImpl::WebMediaPlayerImpl( | 318 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 319 WebKit::WebMediaPlayerClient* client, | 319 WebKit::WebMediaPlayerClient* client, |
| 320 media::FilterCollection* collection, | 320 media::FilterCollection* collection, |
| 321 media::MessageLoopFactory* message_loop_factory, | 321 media::MessageLoopFactory* message_loop_factory, |
| 322 MediaStreamClient* media_stream_client) | 322 MediaStreamClient* media_stream_client, |
| 323 media::MediaLog* media_log) |
| 323 : network_state_(WebKit::WebMediaPlayer::Empty), | 324 : network_state_(WebKit::WebMediaPlayer::Empty), |
| 324 ready_state_(WebKit::WebMediaPlayer::HaveNothing), | 325 ready_state_(WebKit::WebMediaPlayer::HaveNothing), |
| 325 main_loop_(NULL), | 326 main_loop_(NULL), |
| 326 filter_collection_(collection), | 327 filter_collection_(collection), |
| 327 pipeline_(NULL), | 328 pipeline_(NULL), |
| 328 message_loop_factory_(message_loop_factory), | 329 message_loop_factory_(message_loop_factory), |
| 329 paused_(true), | 330 paused_(true), |
| 330 seeking_(false), | 331 seeking_(false), |
| 331 playback_rate_(0.0f), | 332 playback_rate_(0.0f), |
| 332 client_(client), | 333 client_(client), |
| 333 proxy_(NULL), | 334 proxy_(NULL), |
| 334 media_stream_client_(media_stream_client) { | 335 media_stream_client_(media_stream_client), |
| 336 media_log_(media_log) { |
| 335 // Saves the current message loop. | 337 // Saves the current message loop. |
| 336 DCHECK(!main_loop_); | 338 DCHECK(!main_loop_); |
| 337 main_loop_ = MessageLoop::current(); | 339 main_loop_ = MessageLoop::current(); |
| 340 media_log_->AddEventOfType(media::MediaLog::CREATED); |
| 338 } | 341 } |
| 339 | 342 |
| 340 bool WebMediaPlayerImpl::Initialize( | 343 bool WebMediaPlayerImpl::Initialize( |
| 341 WebKit::WebFrame* frame, | 344 WebKit::WebFrame* frame, |
| 342 bool use_simple_data_source, | 345 bool use_simple_data_source, |
| 343 scoped_refptr<WebVideoRenderer> web_video_renderer) { | 346 scoped_refptr<WebVideoRenderer> web_video_renderer) { |
| 344 MessageLoop* pipeline_message_loop = | 347 MessageLoop* pipeline_message_loop = |
| 345 message_loop_factory_->GetMessageLoop("PipelineThread"); | 348 message_loop_factory_->GetMessageLoop("PipelineThread"); |
| 346 if (!pipeline_message_loop) { | 349 if (!pipeline_message_loop) { |
| 347 NOTREACHED() << "Could not start PipelineThread"; | 350 NOTREACHED() << "Could not start PipelineThread"; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( | 417 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 415 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 418 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 416 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 419 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 417 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); | 420 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); |
| 418 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 421 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
| 419 | 422 |
| 420 return true; | 423 return true; |
| 421 } | 424 } |
| 422 | 425 |
| 423 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 426 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| 427 media_log_->AddEventOfType(media::MediaLog::DESTROYED); |
| 424 Destroy(); | 428 Destroy(); |
| 425 | 429 |
| 426 // Finally tell the |main_loop_| we don't want to be notified of destruction | 430 // Finally tell the |main_loop_| we don't want to be notified of destruction |
| 427 // event. | 431 // event. |
| 428 if (main_loop_) { | 432 if (main_loop_) { |
| 429 main_loop_->RemoveDestructionObserver(this); | 433 main_loop_->RemoveDestructionObserver(this); |
| 430 } | 434 } |
| 431 } | 435 } |
| 432 | 436 |
| 433 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { | 437 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 451 setPreload(GetClient()->preload()); | 455 setPreload(GetClient()->preload()); |
| 452 | 456 |
| 453 // Initialize the pipeline. | 457 // Initialize the pipeline. |
| 454 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 458 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 455 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 459 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
| 456 pipeline_->Start( | 460 pipeline_->Start( |
| 457 filter_collection_.release(), | 461 filter_collection_.release(), |
| 458 url.spec(), | 462 url.spec(), |
| 459 NewCallback(proxy_.get(), | 463 NewCallback(proxy_.get(), |
| 460 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); | 464 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); |
| 465 |
| 466 media_log_->Load(url.spec()); |
| 461 } | 467 } |
| 462 | 468 |
| 463 void WebMediaPlayerImpl::cancelLoad() { | 469 void WebMediaPlayerImpl::cancelLoad() { |
| 464 DCHECK(MessageLoop::current() == main_loop_); | 470 DCHECK(MessageLoop::current() == main_loop_); |
| 465 } | 471 } |
| 466 | 472 |
| 467 void WebMediaPlayerImpl::play() { | 473 void WebMediaPlayerImpl::play() { |
| 468 DCHECK(MessageLoop::current() == main_loop_); | 474 DCHECK(MessageLoop::current() == main_loop_); |
| 469 | 475 |
| 470 paused_ = false; | 476 paused_ = false; |
| 471 pipeline_->SetPlaybackRate(playback_rate_); | 477 pipeline_->SetPlaybackRate(playback_rate_); |
| 478 |
| 479 media_log_->AddEventOfType(media::MediaLog::PLAY); |
| 472 } | 480 } |
| 473 | 481 |
| 474 void WebMediaPlayerImpl::pause() { | 482 void WebMediaPlayerImpl::pause() { |
| 475 DCHECK(MessageLoop::current() == main_loop_); | 483 DCHECK(MessageLoop::current() == main_loop_); |
| 476 | 484 |
| 477 paused_ = true; | 485 paused_ = true; |
| 478 pipeline_->SetPlaybackRate(0.0f); | 486 pipeline_->SetPlaybackRate(0.0f); |
| 479 paused_time_ = pipeline_->GetCurrentTime(); | 487 paused_time_ = pipeline_->GetCurrentTime(); |
| 488 |
| 489 media_log_->AddEventOfType(media::MediaLog::PAUSE); |
| 480 } | 490 } |
| 481 | 491 |
| 482 bool WebMediaPlayerImpl::supportsFullscreen() const { | 492 bool WebMediaPlayerImpl::supportsFullscreen() const { |
| 483 DCHECK(MessageLoop::current() == main_loop_); | 493 DCHECK(MessageLoop::current() == main_loop_); |
| 484 return true; | 494 return true; |
| 485 } | 495 } |
| 486 | 496 |
| 487 bool WebMediaPlayerImpl::supportsSave() const { | 497 bool WebMediaPlayerImpl::supportsSave() const { |
| 488 DCHECK(MessageLoop::current() == main_loop_); | 498 DCHECK(MessageLoop::current() == main_loop_); |
| 489 return true; | 499 return true; |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 } | 1037 } |
| 1028 } | 1038 } |
| 1029 | 1039 |
| 1030 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1040 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 1031 DCHECK(MessageLoop::current() == main_loop_); | 1041 DCHECK(MessageLoop::current() == main_loop_); |
| 1032 DCHECK(client_); | 1042 DCHECK(client_); |
| 1033 return client_; | 1043 return client_; |
| 1034 } | 1044 } |
| 1035 | 1045 |
| 1036 } // namespace webkit_glue | 1046 } // namespace webkit_glue |
| OLD | NEW |