| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 paused_(true), | 331 paused_(true), |
| 332 seeking_(false), | 332 seeking_(false), |
| 333 playback_rate_(0.0f), | 333 playback_rate_(0.0f), |
| 334 client_(client), | 334 client_(client), |
| 335 proxy_(NULL), | 335 proxy_(NULL), |
| 336 media_stream_client_(media_stream_client), | 336 media_stream_client_(media_stream_client), |
| 337 media_log_(media_log) { | 337 media_log_(media_log) { |
| 338 // Saves the current message loop. | 338 // Saves the current message loop. |
| 339 DCHECK(!main_loop_); | 339 DCHECK(!main_loop_); |
| 340 main_loop_ = MessageLoop::current(); | 340 main_loop_ = MessageLoop::current(); |
| 341 media_log_->AddEventOfType(media::MediaLogEvent::CREATING); | 341 media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::CREATING)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 bool WebMediaPlayerImpl::Initialize( | 344 bool WebMediaPlayerImpl::Initialize( |
| 345 WebKit::WebFrame* frame, | 345 WebKit::WebFrame* frame, |
| 346 bool use_simple_data_source, | 346 bool use_simple_data_source, |
| 347 scoped_refptr<WebVideoRenderer> web_video_renderer) { | 347 scoped_refptr<WebVideoRenderer> web_video_renderer) { |
| 348 MessageLoop* pipeline_message_loop = | 348 MessageLoop* pipeline_message_loop = |
| 349 message_loop_factory_->GetMessageLoop("PipelineThread"); | 349 message_loop_factory_->GetMessageLoop("PipelineThread"); |
| 350 if (!pipeline_message_loop) { | 350 if (!pipeline_message_loop) { |
| 351 NOTREACHED() << "Could not start PipelineThread"; | 351 NOTREACHED() << "Could not start PipelineThread"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 367 NewCallback(proxy_.get(), | 367 NewCallback(proxy_.get(), |
| 368 &WebMediaPlayerImpl::Proxy::PipelineEndedCallback), | 368 &WebMediaPlayerImpl::Proxy::PipelineEndedCallback), |
| 369 NewCallback(proxy_.get(), | 369 NewCallback(proxy_.get(), |
| 370 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback), | 370 &WebMediaPlayerImpl::Proxy::PipelineErrorCallback), |
| 371 NewCallback(proxy_.get(), | 371 NewCallback(proxy_.get(), |
| 372 &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); | 372 &WebMediaPlayerImpl::Proxy::NetworkEventCallback)); |
| 373 | 373 |
| 374 // A simple data source that keeps all data in memory. | 374 // A simple data source that keeps all data in memory. |
| 375 scoped_ptr<media::DataSourceFactory> simple_data_source_factory( | 375 scoped_ptr<media::DataSourceFactory> simple_data_source_factory( |
| 376 SimpleDataSource::CreateFactory(MessageLoop::current(), frame, | 376 SimpleDataSource::CreateFactory(MessageLoop::current(), frame, |
| 377 media_log_, |
| 377 proxy_->GetBuildObserver())); | 378 proxy_->GetBuildObserver())); |
| 378 | 379 |
| 379 // A sophisticated data source that does memory caching. | 380 // A sophisticated data source that does memory caching. |
| 380 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( | 381 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( |
| 381 BufferedDataSource::CreateFactory(MessageLoop::current(), frame, | 382 BufferedDataSource::CreateFactory(MessageLoop::current(), frame, |
| 383 media_log_, |
| 382 proxy_->GetBuildObserver())); | 384 proxy_->GetBuildObserver())); |
| 383 | 385 |
| 384 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( | 386 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( |
| 385 new media::CompositeDataSourceFactory()); | 387 new media::CompositeDataSourceFactory()); |
| 386 | 388 |
| 387 if (use_simple_data_source) { | 389 if (use_simple_data_source) { |
| 388 data_source_factory->AddFactory(simple_data_source_factory.release()); | 390 data_source_factory->AddFactory(simple_data_source_factory.release()); |
| 389 data_source_factory->AddFactory(buffered_data_source_factory.release()); | 391 data_source_factory->AddFactory(buffered_data_source_factory.release()); |
| 390 } else { | 392 } else { |
| 391 data_source_factory->AddFactory(buffered_data_source_factory.release()); | 393 data_source_factory->AddFactory(buffered_data_source_factory.release()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 418 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( | 420 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 419 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 421 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 420 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 422 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 421 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); | 423 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); |
| 422 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 424 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
| 423 | 425 |
| 424 return true; | 426 return true; |
| 425 } | 427 } |
| 426 | 428 |
| 427 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 429 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| 428 media_log_->AddEventOfType(media::MediaLogEvent::DESTROYING); | 430 media_log_->AddEvent( |
| 431 media_log_->CreateEvent(media::MediaLogEvent::DESTROYING)); |
| 429 Destroy(); | 432 Destroy(); |
| 430 | 433 |
| 431 // Finally tell the |main_loop_| we don't want to be notified of destruction | 434 // Finally tell the |main_loop_| we don't want to be notified of destruction |
| 432 // event. | 435 // event. |
| 433 if (main_loop_) { | 436 if (main_loop_) { |
| 434 main_loop_->RemoveDestructionObserver(this); | 437 main_loop_->RemoveDestructionObserver(this); |
| 435 } | 438 } |
| 436 } | 439 } |
| 437 | 440 |
| 438 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { | 441 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 457 | 460 |
| 458 // Initialize the pipeline. | 461 // Initialize the pipeline. |
| 459 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 462 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 460 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 463 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
| 461 pipeline_->Start( | 464 pipeline_->Start( |
| 462 filter_collection_.release(), | 465 filter_collection_.release(), |
| 463 url.spec(), | 466 url.spec(), |
| 464 NewCallback(proxy_.get(), | 467 NewCallback(proxy_.get(), |
| 465 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); | 468 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); |
| 466 | 469 |
| 467 media_log_->Load(url.spec()); | 470 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 468 } | 471 } |
| 469 | 472 |
| 470 void WebMediaPlayerImpl::cancelLoad() { | 473 void WebMediaPlayerImpl::cancelLoad() { |
| 471 DCHECK(MessageLoop::current() == main_loop_); | 474 DCHECK(MessageLoop::current() == main_loop_); |
| 472 } | 475 } |
| 473 | 476 |
| 474 void WebMediaPlayerImpl::play() { | 477 void WebMediaPlayerImpl::play() { |
| 475 DCHECK(MessageLoop::current() == main_loop_); | 478 DCHECK(MessageLoop::current() == main_loop_); |
| 476 | 479 |
| 477 paused_ = false; | 480 paused_ = false; |
| 478 pipeline_->SetPlaybackRate(playback_rate_); | 481 pipeline_->SetPlaybackRate(playback_rate_); |
| 479 | 482 |
| 480 media_log_->AddEventOfType(media::MediaLogEvent::PLAY); | 483 media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PLAY)); |
| 481 } | 484 } |
| 482 | 485 |
| 483 void WebMediaPlayerImpl::pause() { | 486 void WebMediaPlayerImpl::pause() { |
| 484 DCHECK(MessageLoop::current() == main_loop_); | 487 DCHECK(MessageLoop::current() == main_loop_); |
| 485 | 488 |
| 486 paused_ = true; | 489 paused_ = true; |
| 487 pipeline_->SetPlaybackRate(0.0f); | 490 pipeline_->SetPlaybackRate(0.0f); |
| 488 paused_time_ = pipeline_->GetCurrentTime(); | 491 paused_time_ = pipeline_->GetCurrentTime(); |
| 489 | 492 |
| 490 media_log_->AddEventOfType(media::MediaLogEvent::PAUSE); | 493 media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PAUSE)); |
| 491 } | 494 } |
| 492 | 495 |
| 493 bool WebMediaPlayerImpl::supportsFullscreen() const { | 496 bool WebMediaPlayerImpl::supportsFullscreen() const { |
| 494 DCHECK(MessageLoop::current() == main_loop_); | 497 DCHECK(MessageLoop::current() == main_loop_); |
| 495 return true; | 498 return true; |
| 496 } | 499 } |
| 497 | 500 |
| 498 bool WebMediaPlayerImpl::supportsSave() const { | 501 bool WebMediaPlayerImpl::supportsSave() const { |
| 499 DCHECK(MessageLoop::current() == main_loop_); | 502 DCHECK(MessageLoop::current() == main_loop_); |
| 500 return true; | 503 return true; |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 } | 1046 } |
| 1044 } | 1047 } |
| 1045 | 1048 |
| 1046 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1049 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 1047 DCHECK(MessageLoop::current() == main_loop_); | 1050 DCHECK(MessageLoop::current() == main_loop_); |
| 1048 DCHECK(client_); | 1051 DCHECK(client_); |
| 1049 return client_; | 1052 return client_; |
| 1050 } | 1053 } |
| 1051 | 1054 |
| 1052 } // namespace webkit_glue | 1055 } // namespace webkit_glue |
| OLD | NEW |