Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/webmediaplayer_ms.h" | 5 #include "content/renderer/media/webmediaplayer_ms.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 return true; | 444 return true; |
| 445 } | 445 } |
| 446 | 446 |
| 447 void WebMediaPlayerMS::SetVideoFrameProviderClient( | 447 void WebMediaPlayerMS::SetVideoFrameProviderClient( |
| 448 cc::VideoFrameProvider::Client* client) { | 448 cc::VideoFrameProvider::Client* client) { |
| 449 // This is called from both the main renderer thread and the compositor | 449 // This is called from both the main renderer thread and the compositor |
| 450 // thread (when the main thread is blocked). | 450 // thread (when the main thread is blocked). |
| 451 if (video_frame_provider_client_) | 451 if (video_frame_provider_client_) |
| 452 video_frame_provider_client_->StopUsingProvider(); | 452 video_frame_provider_client_->StopUsingProvider(); |
| 453 video_frame_provider_client_ = client; | 453 video_frame_provider_client_ = client; |
| 454 if (client) | |
| 455 client->StartRendering(); | |
|
DaleCurtis
2015/08/04 21:49:26
Where are you calling StopRendering? How are you h
qiangchen
2015/08/04 22:13:24
video_frame_provider_client_->StopUsingProvider()
DaleCurtis
2015/08/04 23:19:14
Well, delivering begin frame callbacks is expensiv
qiangchen
2015/08/04 23:45:45
I did not quite understand what is " delivering be
DaleCurtis
2015/08/04 23:49:02
You shouldn't keep rendering enabled when the tab
qiangchen
2015/08/05 16:23:57
Let me do another patch to explain this issue.
| |
| 454 } | 456 } |
| 455 | 457 |
| 456 bool WebMediaPlayerMS::UpdateCurrentFrame(base::TimeTicks deadline_min, | 458 bool WebMediaPlayerMS::UpdateCurrentFrame(base::TimeTicks deadline_min, |
| 457 base::TimeTicks deadline_max) { | 459 base::TimeTicks deadline_max) { |
| 460 TRACE_EVENT_BEGIN2("webrtc", "WebMediaPlayerMS::UpdateCurrentFrame", | |
| 461 "Actual Render Begin", deadline_min.ToInternalValue(), | |
| 462 "Actual Render End", deadline_max.ToInternalValue()); | |
| 463 | |
| 458 // TODO(dalecurtis): This should make use of the deadline interval to ensure | 464 // TODO(dalecurtis): This should make use of the deadline interval to ensure |
| 459 // the painted frame is correct for the given interval. | 465 // the painted frame is correct for the given interval. |
| 460 NOTREACHED(); | 466 |
| 461 return false; | 467 base::TimeTicks render_time; |
| 468 if (!current_frame_->metadata()->GetTimeTicks( | |
| 469 media::VideoFrameMetadata::REFERENCE_TIME, &render_time)) { | |
| 470 render_time = base::TimeTicks(); | |
| 471 } | |
| 472 TRACE_EVENT_END1("webrtc", "WebMediaPlayerMS::UpdateCurrentFrame", | |
| 473 "Ideal Render Instant", render_time.ToInternalValue()); | |
| 474 return !current_frame_used_; | |
| 462 } | 475 } |
| 463 | 476 |
| 464 bool WebMediaPlayerMS::HasCurrentFrame() { | 477 bool WebMediaPlayerMS::HasCurrentFrame() { |
| 465 base::AutoLock auto_lock(current_frame_lock_); | 478 base::AutoLock auto_lock(current_frame_lock_); |
| 466 return current_frame_; | 479 return current_frame_; |
| 467 } | 480 } |
| 468 | 481 |
| 469 scoped_refptr<media::VideoFrame> WebMediaPlayerMS::GetCurrentFrame() { | 482 scoped_refptr<media::VideoFrame> WebMediaPlayerMS::GetCurrentFrame() { |
| 470 DVLOG(3) << "WebMediaPlayerMS::GetCurrentFrame"; | 483 DVLOG(3) << "WebMediaPlayerMS::GetCurrentFrame"; |
| 471 base::AutoLock auto_lock(current_frame_lock_); | 484 base::AutoLock auto_lock(current_frame_lock_); |
| 472 if (!current_frame_.get()) | 485 if (!current_frame_.get()) |
| 473 return NULL; | 486 return NULL; |
| 474 current_frame_used_ = true; | 487 current_frame_used_ = true; |
| 475 return current_frame_; | 488 return current_frame_; |
| 476 } | 489 } |
| 477 | 490 |
| 478 void WebMediaPlayerMS::PutCurrentFrame() { | 491 void WebMediaPlayerMS::PutCurrentFrame() { |
| 479 DVLOG(3) << "WebMediaPlayerMS::PutCurrentFrame"; | 492 DVLOG(3) << "WebMediaPlayerMS::PutCurrentFrame"; |
| 480 } | 493 } |
| 481 | 494 |
| 482 void WebMediaPlayerMS::OnFrameAvailable( | 495 void WebMediaPlayerMS::OnFrameAvailable( |
| 483 const scoped_refptr<media::VideoFrame>& frame) { | 496 const scoped_refptr<media::VideoFrame>& frame) { |
| 484 DVLOG(3) << "WebMediaPlayerMS::OnFrameAvailable"; | 497 DVLOG(3) << "WebMediaPlayerMS::OnFrameAvailable"; |
| 485 DCHECK(thread_checker_.CalledOnValidThread()); | 498 DCHECK(thread_checker_.CalledOnValidThread()); |
| 499 | |
| 500 base::TimeTicks render_time; | |
| 501 if (!frame->metadata()->GetTimeTicks( | |
| 502 media::VideoFrameMetadata::REFERENCE_TIME, &render_time)) { | |
| 503 render_time = base::TimeTicks(); | |
| 504 } | |
| 505 TRACE_EVENT1("webrtc", "WebMediaPlayerMS::OnFrameAvailable", | |
| 506 "Ideal Render Instant", render_time.ToInternalValue()); | |
| 507 | |
| 486 ++total_frame_count_; | 508 ++total_frame_count_; |
| 487 if (!received_first_frame_) { | 509 if (!received_first_frame_) { |
| 488 received_first_frame_ = true; | 510 received_first_frame_ = true; |
| 489 { | 511 { |
| 490 base::AutoLock auto_lock(current_frame_lock_); | 512 base::AutoLock auto_lock(current_frame_lock_); |
| 491 DCHECK(!current_frame_used_); | 513 DCHECK(!current_frame_used_); |
| 492 current_frame_ = frame; | 514 current_frame_ = frame; |
| 493 } | 515 } |
| 494 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 516 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 495 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 517 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 515 base::AutoLock auto_lock(current_frame_lock_); | 537 base::AutoLock auto_lock(current_frame_lock_); |
| 516 if (!current_frame_used_ && current_frame_.get()) | 538 if (!current_frame_used_ && current_frame_.get()) |
| 517 ++dropped_frame_count_; | 539 ++dropped_frame_count_; |
| 518 current_frame_ = frame; | 540 current_frame_ = frame; |
| 519 current_time_ = frame->timestamp(); | 541 current_time_ = frame->timestamp(); |
| 520 current_frame_used_ = false; | 542 current_frame_used_ = false; |
| 521 } | 543 } |
| 522 | 544 |
| 523 if (size_changed) | 545 if (size_changed) |
| 524 GetClient()->sizeChanged(); | 546 GetClient()->sizeChanged(); |
| 525 | |
| 526 GetClient()->repaint(); | |
| 527 } | 547 } |
| 528 | 548 |
| 529 void WebMediaPlayerMS::RepaintInternal() { | 549 void WebMediaPlayerMS::RepaintInternal() { |
| 530 DVLOG(1) << "WebMediaPlayerMS::RepaintInternal"; | 550 DVLOG(1) << "WebMediaPlayerMS::RepaintInternal"; |
| 531 DCHECK(thread_checker_.CalledOnValidThread()); | 551 DCHECK(thread_checker_.CalledOnValidThread()); |
| 532 GetClient()->repaint(); | 552 GetClient()->repaint(); |
| 533 } | 553 } |
| 534 | 554 |
| 535 void WebMediaPlayerMS::OnSourceError() { | 555 void WebMediaPlayerMS::OnSourceError() { |
| 536 DVLOG(1) << "WebMediaPlayerMS::OnSourceError"; | 556 DVLOG(1) << "WebMediaPlayerMS::OnSourceError"; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 553 GetClient()->readyStateChanged(); | 573 GetClient()->readyStateChanged(); |
| 554 } | 574 } |
| 555 | 575 |
| 556 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 576 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
| 557 DCHECK(thread_checker_.CalledOnValidThread()); | 577 DCHECK(thread_checker_.CalledOnValidThread()); |
| 558 DCHECK(client_); | 578 DCHECK(client_); |
| 559 return client_; | 579 return client_; |
| 560 } | 580 } |
| 561 | 581 |
| 562 } // namespace content | 582 } // namespace content |
| OLD | NEW |