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_->AddEventOfType(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED); |
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"; |
352 return false; | 352 return false; |
353 } | 353 } |
354 | 354 |
355 pipeline_ = new media::PipelineImpl(pipeline_message_loop); | 355 pipeline_ = new media::PipelineImpl(pipeline_message_loop, media_log_); |
356 | 356 |
357 // Also we want to be notified of |main_loop_| destruction. | 357 // Also we want to be notified of |main_loop_| destruction. |
358 main_loop_->AddDestructionObserver(this); | 358 main_loop_->AddDestructionObserver(this); |
359 | 359 |
360 // Creates the proxy. | 360 // Creates the proxy. |
361 proxy_ = new Proxy(main_loop_, this); | 361 proxy_ = new Proxy(main_loop_, this); |
362 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); | 362 web_video_renderer->SetWebMediaPlayerImplProxy(proxy_); |
363 proxy_->SetVideoRenderer(web_video_renderer); | 363 proxy_->SetVideoRenderer(web_video_renderer); |
364 | 364 |
365 // Set our pipeline callbacks. | 365 // Set our pipeline callbacks. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( | 418 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
419 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 419 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
420 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 420 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
421 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); | 421 message_loop_factory_->GetMessageLoop("VideoDecoderThread"), NULL)); |
422 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 422 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
423 | 423 |
424 return true; | 424 return true; |
425 } | 425 } |
426 | 426 |
427 WebMediaPlayerImpl::~WebMediaPlayerImpl() { | 427 WebMediaPlayerImpl::~WebMediaPlayerImpl() { |
428 media_log_->AddEventOfType(media::MediaLogEvent::DESTROYING); | |
429 Destroy(); | 428 Destroy(); |
| 429 media_log_->AddEventOfType(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED); |
430 | 430 |
431 // 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 |
432 // event. | 432 // event. |
433 if (main_loop_) { | 433 if (main_loop_) { |
434 main_loop_->RemoveDestructionObserver(this); | 434 main_loop_->RemoveDestructionObserver(this); |
435 } | 435 } |
436 } | 436 } |
437 | 437 |
438 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { | 438 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { |
439 DCHECK(MessageLoop::current() == main_loop_); | 439 DCHECK(MessageLoop::current() == main_loop_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 // cause extra pre-rolling and will break servers without range request | 508 // cause extra pre-rolling and will break servers without range request |
509 // support. | 509 // support. |
510 // | 510 // |
511 // We still have to notify WebKit that time has changed otherwise | 511 // We still have to notify WebKit that time has changed otherwise |
512 // HTMLMediaElement gets into an inconsistent state. | 512 // HTMLMediaElement gets into an inconsistent state. |
513 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) { | 513 if (pipeline_->GetCurrentTime().ToInternalValue() == 0 && seconds == 0) { |
514 GetClient()->timeChanged(); | 514 GetClient()->timeChanged(); |
515 return; | 515 return; |
516 } | 516 } |
517 | 517 |
| 518 media_log_->Seek(seconds); |
| 519 |
518 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); | 520 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); |
519 | 521 |
520 // Update our paused time. | 522 // Update our paused time. |
521 if (paused_) { | 523 if (paused_) { |
522 paused_time_ = seek_time; | 524 paused_time_ = seek_time; |
523 } | 525 } |
524 | 526 |
525 seeking_ = true; | 527 seeking_ = true; |
526 | 528 |
527 proxy_->DemuxerFlush(); | 529 proxy_->DemuxerFlush(); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 } | 1045 } |
1044 } | 1046 } |
1045 | 1047 |
1046 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 1048 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
1047 DCHECK(MessageLoop::current() == main_loop_); | 1049 DCHECK(MessageLoop::current() == main_loop_); |
1048 DCHECK(client_); | 1050 DCHECK(client_); |
1049 return client_; | 1051 return client_; |
1050 } | 1052 } |
1051 | 1053 |
1052 } // namespace webkit_glue | 1054 } // namespace webkit_glue |
OLD | NEW |