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(); | |
| 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", | |
|
DaleCurtis
2015/07/31 17:48:27
No need for BEGIN, END since your trace is within
qiangchen
2015/07/31 20:06:07
The point is that after implementing the algorithm
| |
| 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, | |
| 503 &render_time)) { | |
| 504 render_time = base::TimeTicks(); | |
| 505 } | |
| 506 TRACE_EVENT1("webrtc", "WebMediaPlayerMS::OnFrameAvailable", | |
| 507 "Ideal Render Instant", render_time.ToInternalValue()); | |
| 508 | |
| 486 ++total_frame_count_; | 509 ++total_frame_count_; |
| 487 if (!received_first_frame_) { | 510 if (!received_first_frame_) { |
| 488 received_first_frame_ = true; | 511 received_first_frame_ = true; |
| 489 { | 512 { |
| 490 base::AutoLock auto_lock(current_frame_lock_); | 513 base::AutoLock auto_lock(current_frame_lock_); |
| 491 DCHECK(!current_frame_used_); | 514 DCHECK(!current_frame_used_); |
| 492 current_frame_ = frame; | 515 current_frame_ = frame; |
| 493 } | 516 } |
| 494 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 517 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 495 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 518 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 515 base::AutoLock auto_lock(current_frame_lock_); | 538 base::AutoLock auto_lock(current_frame_lock_); |
| 516 if (!current_frame_used_ && current_frame_.get()) | 539 if (!current_frame_used_ && current_frame_.get()) |
| 517 ++dropped_frame_count_; | 540 ++dropped_frame_count_; |
| 518 current_frame_ = frame; | 541 current_frame_ = frame; |
| 519 current_time_ = frame->timestamp(); | 542 current_time_ = frame->timestamp(); |
| 520 current_frame_used_ = false; | 543 current_frame_used_ = false; |
| 521 } | 544 } |
| 522 | 545 |
| 523 if (size_changed) | 546 if (size_changed) |
| 524 GetClient()->sizeChanged(); | 547 GetClient()->sizeChanged(); |
| 525 | |
| 526 GetClient()->repaint(); | |
| 527 } | 548 } |
| 528 | 549 |
| 529 void WebMediaPlayerMS::RepaintInternal() { | 550 void WebMediaPlayerMS::RepaintInternal() { |
| 530 DVLOG(1) << "WebMediaPlayerMS::RepaintInternal"; | 551 DVLOG(1) << "WebMediaPlayerMS::RepaintInternal"; |
| 531 DCHECK(thread_checker_.CalledOnValidThread()); | 552 DCHECK(thread_checker_.CalledOnValidThread()); |
| 532 GetClient()->repaint(); | 553 GetClient()->repaint(); |
| 533 } | 554 } |
| 534 | 555 |
| 535 void WebMediaPlayerMS::OnSourceError() { | 556 void WebMediaPlayerMS::OnSourceError() { |
| 536 DVLOG(1) << "WebMediaPlayerMS::OnSourceError"; | 557 DVLOG(1) << "WebMediaPlayerMS::OnSourceError"; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 553 GetClient()->readyStateChanged(); | 574 GetClient()->readyStateChanged(); |
| 554 } | 575 } |
| 555 | 576 |
| 556 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 577 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
| 557 DCHECK(thread_checker_.CalledOnValidThread()); | 578 DCHECK(thread_checker_.CalledOnValidThread()); |
| 558 DCHECK(client_); | 579 DCHECK(client_); |
| 559 return client_; | 580 return client_; |
| 560 } | 581 } |
| 561 | 582 |
| 562 } // namespace content | 583 } // namespace content |
| OLD | NEW |