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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "media/base/composite_data_source_factory.h" | 12 #include "media/base/composite_data_source_factory.h" |
| 13 #include "media/base/filter_collection.h" | 13 #include "media/base/filter_collection.h" |
| 14 #include "media/base/limits.h" | 14 #include "media/base/limits.h" |
| 15 #include "media/base/media_log.h" | |
| 15 #include "media/base/media_switches.h" | 16 #include "media/base/media_switches.h" |
| 16 #include "media/base/pipeline_impl.h" | 17 #include "media/base/pipeline_impl.h" |
| 17 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
| 18 #include "media/filters/adaptive_demuxer.h" | 19 #include "media/filters/adaptive_demuxer.h" |
| 19 #include "media/filters/chunk_demuxer_factory.h" | 20 #include "media/filters/chunk_demuxer_factory.h" |
| 20 #include "media/filters/ffmpeg_audio_decoder.h" | 21 #include "media/filters/ffmpeg_audio_decoder.h" |
| 21 #include "media/filters/ffmpeg_demuxer_factory.h" | 22 #include "media/filters/ffmpeg_demuxer_factory.h" |
| 22 #include "media/filters/ffmpeg_video_decoder.h" | 23 #include "media/filters/ffmpeg_video_decoder.h" |
| 23 #include "media/filters/null_audio_renderer.h" | 24 #include "media/filters/null_audio_renderer.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 chunk_demuxer_ = NULL; | 313 chunk_demuxer_ = NULL; |
| 313 } | 314 } |
| 314 | 315 |
| 315 ///////////////////////////////////////////////////////////////////////////// | 316 ///////////////////////////////////////////////////////////////////////////// |
| 316 // WebMediaPlayerImpl implementation | 317 // WebMediaPlayerImpl implementation |
| 317 | 318 |
| 318 WebMediaPlayerImpl::WebMediaPlayerImpl( | 319 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 319 WebKit::WebMediaPlayerClient* client, | 320 WebKit::WebMediaPlayerClient* client, |
| 320 media::FilterCollection* collection, | 321 media::FilterCollection* collection, |
| 321 media::MessageLoopFactory* message_loop_factory, | 322 media::MessageLoopFactory* message_loop_factory, |
| 322 MediaStreamClient* media_stream_client) | 323 MediaStreamClient* media_stream_client, |
| 324 media::MediaLog* media_log) | |
| 323 : network_state_(WebKit::WebMediaPlayer::Empty), | 325 : network_state_(WebKit::WebMediaPlayer::Empty), |
| 324 ready_state_(WebKit::WebMediaPlayer::HaveNothing), | 326 ready_state_(WebKit::WebMediaPlayer::HaveNothing), |
| 325 main_loop_(NULL), | 327 main_loop_(NULL), |
| 326 filter_collection_(collection), | 328 filter_collection_(collection), |
| 327 pipeline_(NULL), | 329 pipeline_(NULL), |
| 328 message_loop_factory_(message_loop_factory), | 330 message_loop_factory_(message_loop_factory), |
| 329 paused_(true), | 331 paused_(true), |
| 330 seeking_(false), | 332 seeking_(false), |
| 331 playback_rate_(0.0f), | 333 playback_rate_(0.0f), |
| 332 client_(client), | 334 client_(client), |
| 333 proxy_(NULL), | 335 proxy_(NULL), |
| 334 media_stream_client_(media_stream_client) { | 336 media_stream_client_(media_stream_client), |
| 337 media_log_(media_log) { | |
| 335 // Saves the current message loop. | 338 // Saves the current message loop. |
| 336 DCHECK(!main_loop_); | 339 DCHECK(!main_loop_); |
| 337 main_loop_ = MessageLoop::current(); | 340 main_loop_ = MessageLoop::current(); |
| 341 media_log_->AddEventOfType(media::MediaLogEvent::CREATE); | |
| 338 } | 342 } |
| 339 | 343 |
| 340 bool WebMediaPlayerImpl::Initialize( | 344 bool WebMediaPlayerImpl::Initialize( |
| 341 WebKit::WebFrame* frame, | 345 WebKit::WebFrame* frame, |
| 342 bool use_simple_data_source, | 346 bool use_simple_data_source, |
| 343 scoped_refptr<WebVideoRenderer> web_video_renderer) { | 347 scoped_refptr<WebVideoRenderer> web_video_renderer) { |
| 344 MessageLoop* pipeline_message_loop = | 348 MessageLoop* pipeline_message_loop = |
| 345 message_loop_factory_->GetMessageLoop("PipelineThread"); | 349 message_loop_factory_->GetMessageLoop("PipelineThread"); |
| 346 if (!pipeline_message_loop) { | 350 if (!pipeline_message_loop) { |
| 347 NOTREACHED() << "Could not start PipelineThread"; | 351 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( | 418 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 415 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 419 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 416 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 420 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 417 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); | 421 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); |
| 418 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 422 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
| 419 | 423 |
| 420 return true; | 424 return true; |
| 421 } | 425 } |
| 422 | 426 |
| 423 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 427 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
| 428 media_log_->AddEventOfType(media::MediaLogEvent::DESTROY); | |
|
acolwell GONE FROM CHROMIUM
2011/08/03 16:31:37
Is this intended to indicate when destruction has
Scott Franklin
2011/08/03 20:55:04
Starting destruction (I'll change it to DESTROYING
| |
| 424 Destroy(); | 429 Destroy(); |
| 425 | 430 |
| 426 // Finally tell the |main_loop_| we don't want to be notified of destruction | 431 // Finally tell the |main_loop_| we don't want to be notified of destruction |
| 427 // event. | 432 // event. |
| 428 if (main_loop_) { | 433 if (main_loop_) { |
| 429 main_loop_->RemoveDestructionObserver(this); | 434 main_loop_->RemoveDestructionObserver(this); |
| 430 } | 435 } |
| 431 } | 436 } |
| 432 | 437 |
| 433 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { | 438 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 451 setPreload(GetClient()->preload()); | 456 setPreload(GetClient()->preload()); |
| 452 | 457 |
| 453 // Initialize the pipeline. | 458 // Initialize the pipeline. |
| 454 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 459 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 455 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 460 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
| 456 pipeline_->Start( | 461 pipeline_->Start( |
| 457 filter_collection_.release(), | 462 filter_collection_.release(), |
| 458 url.spec(), | 463 url.spec(), |
| 459 NewCallback(proxy_.get(), | 464 NewCallback(proxy_.get(), |
| 460 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); | 465 &WebMediaPlayerImpl::Proxy::PipelineInitializationCallback)); |
| 466 | |
| 467 media_log_->Load(url.spec()); | |
| 461 } | 468 } |
| 462 | 469 |
| 463 void WebMediaPlayerImpl::cancelLoad() { | 470 void WebMediaPlayerImpl::cancelLoad() { |
| 464 DCHECK(MessageLoop::current() == main_loop_); | 471 DCHECK(MessageLoop::current() == main_loop_); |
| 465 } | 472 } |
| 466 | 473 |
| 467 void WebMediaPlayerImpl::play() { | 474 void WebMediaPlayerImpl::play() { |
| 468 DCHECK(MessageLoop::current() == main_loop_); | 475 DCHECK(MessageLoop::current() == main_loop_); |
| 469 | 476 |
| 470 paused_ = false; | 477 paused_ = false; |
| 471 pipeline_->SetPlaybackRate(playback_rate_); | 478 pipeline_->SetPlaybackRate(playback_rate_); |
| 479 | |
| 480 media_log_->AddEventOfType(media::MediaLogEvent::PLAY); | |
| 472 } | 481 } |
| 473 | 482 |
| 474 void WebMediaPlayerImpl::pause() { | 483 void WebMediaPlayerImpl::pause() { |
| 475 DCHECK(MessageLoop::current() == main_loop_); | 484 DCHECK(MessageLoop::current() == main_loop_); |
| 476 | 485 |
| 477 paused_ = true; | 486 paused_ = true; |
| 478 pipeline_->SetPlaybackRate(0.0f); | 487 pipeline_->SetPlaybackRate(0.0f); |
| 479 paused_time_ = pipeline_->GetCurrentTime(); | 488 paused_time_ = pipeline_->GetCurrentTime(); |
| 489 | |
| 490 media_log_->AddEventOfType(media::MediaLogEvent::PAUSE); | |
| 480 } | 491 } |
| 481 | 492 |
| 482 bool WebMediaPlayerImpl::supportsFullscreen() const { | 493 bool WebMediaPlayerImpl::supportsFullscreen() const { |
| 483 DCHECK(MessageLoop::current() == main_loop_); | 494 DCHECK(MessageLoop::current() == main_loop_); |
| 484 return true; | 495 return true; |
| 485 } | 496 } |
| 486 | 497 |
| 487 bool WebMediaPlayerImpl::supportsSave() const { | 498 bool WebMediaPlayerImpl::supportsSave() const { |
| 488 DCHECK(MessageLoop::current() == main_loop_); | 499 DCHECK(MessageLoop::current() == main_loop_); |
| 489 return true; | 500 return true; |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 } | 1038 } |
| 1028 } | 1039 } |
| 1029 | 1040 |
| 1030 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1041 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 1031 DCHECK(MessageLoop::current() == main_loop_); | 1042 DCHECK(MessageLoop::current() == main_loop_); |
| 1032 DCHECK(client_); | 1043 DCHECK(client_); |
| 1033 return client_; | 1044 return client_; |
| 1034 } | 1045 } |
| 1035 | 1046 |
| 1036 } // namespace webkit_glue | 1047 } // namespace webkit_glue |
| OLD | NEW |