| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 return; | 491 return; |
| 492 | 492 |
| 493 base::TimeTicks render_time; | 493 base::TimeTicks render_time; |
| 494 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, | 494 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, |
| 495 &render_time)) { | 495 &render_time)) { |
| 496 TRACE_EVENT1("webrtc", "WebMediaPlayerMS::OnFrameAvailable", | 496 TRACE_EVENT1("webrtc", "WebMediaPlayerMS::OnFrameAvailable", |
| 497 "Ideal Render Instant", render_time.ToInternalValue()); | 497 "Ideal Render Instant", render_time.ToInternalValue()); |
| 498 } else { | 498 } else { |
| 499 TRACE_EVENT0("webrtc", "WebMediaPlayerMS::OnFrameAvailable"); | 499 TRACE_EVENT0("webrtc", "WebMediaPlayerMS::OnFrameAvailable"); |
| 500 } | 500 } |
| 501 |
| 501 const bool is_opaque = media::IsOpaque(frame->format()); | 502 const bool is_opaque = media::IsOpaque(frame->format()); |
| 503 media::VideoRotation video_rotation = media::VIDEO_ROTATION_0; |
| 504 ignore_result(frame->metadata()->GetRotation( |
| 505 media::VideoFrameMetadata::ROTATION, &video_rotation)); |
| 502 | 506 |
| 503 if (!received_first_frame_) { | 507 if (!received_first_frame_) { |
| 504 received_first_frame_ = true; | 508 received_first_frame_ = true; |
| 505 last_frame_opaque_ = is_opaque; | 509 last_frame_opaque_ = is_opaque; |
| 506 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 510 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 507 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 511 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
| 508 | 512 |
| 509 if (video_frame_provider_.get()) { | 513 if (video_frame_provider_.get()) |
| 510 ignore_result(frame->metadata()->GetRotation( | 514 OnRotationChanged(video_rotation, is_opaque); |
| 511 media::VideoFrameMetadata::ROTATION, &video_rotation_)); | 515 } else { |
| 512 | 516 // Only configure opacity on changes, since marking it as transparent is |
| 513 video_weblayer_.reset(new cc_blink::WebLayerImpl( | 517 // expensive, see https://crbug.com/647886. |
| 514 cc::VideoLayer::Create(compositor_.get(), video_rotation_))); | 518 if (last_frame_opaque_ != is_opaque) { |
| 519 last_frame_opaque_ = is_opaque; |
| 515 video_weblayer_->layer()->SetContentsOpaque(is_opaque); | 520 video_weblayer_->layer()->SetContentsOpaque(is_opaque); |
| 516 video_weblayer_->SetContentsOpaqueIsFixed(true); | |
| 517 get_client()->setWebLayer(video_weblayer_.get()); | |
| 518 } | 521 } |
| 519 } | 522 // Reset |video_weblayer_| with the updated rotation. |
| 520 | 523 if (video_rotation_ != video_rotation) |
| 521 // Only configure opacity on changes, since marking it as transparent is | 524 OnRotationChanged(video_rotation, is_opaque); |
| 522 // expensive, see https://crbug.com/647886. | |
| 523 if (video_weblayer_ && last_frame_opaque_ != is_opaque) { | |
| 524 last_frame_opaque_ = is_opaque; | |
| 525 video_weblayer_->layer()->SetContentsOpaque(is_opaque); | |
| 526 } | 525 } |
| 527 | 526 |
| 528 compositor_->EnqueueFrame(frame); | 527 compositor_->EnqueueFrame(frame); |
| 529 } | 528 } |
| 530 | 529 |
| 530 void WebMediaPlayerMS::OnRotationChanged(media::VideoRotation video_rotation, |
| 531 bool is_opaque) { |
| 532 DVLOG(1) << __func__; |
| 533 DCHECK(thread_checker_.CalledOnValidThread()); |
| 534 video_rotation_ = video_rotation; |
| 535 |
| 536 video_weblayer_.reset(new cc_blink::WebLayerImpl( |
| 537 cc::VideoLayer::Create(compositor_.get(), video_rotation))); |
| 538 video_weblayer_->layer()->SetContentsOpaque(is_opaque); |
| 539 video_weblayer_->SetContentsOpaqueIsFixed(true); |
| 540 get_client()->setWebLayer(video_weblayer_.get()); |
| 541 } |
| 542 |
| 531 void WebMediaPlayerMS::RepaintInternal() { | 543 void WebMediaPlayerMS::RepaintInternal() { |
| 532 DVLOG(1) << __func__; | 544 DVLOG(1) << __func__; |
| 533 DCHECK(thread_checker_.CalledOnValidThread()); | 545 DCHECK(thread_checker_.CalledOnValidThread()); |
| 534 get_client()->repaint(); | 546 get_client()->repaint(); |
| 535 } | 547 } |
| 536 | 548 |
| 537 void WebMediaPlayerMS::OnSourceError() { | 549 void WebMediaPlayerMS::OnSourceError() { |
| 538 DCHECK(thread_checker_.CalledOnValidThread()); | 550 DCHECK(thread_checker_.CalledOnValidThread()); |
| 539 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 551 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
| 540 RepaintInternal(); | 552 RepaintInternal(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 561 void WebMediaPlayerMS::ResetCanvasCache() { | 573 void WebMediaPlayerMS::ResetCanvasCache() { |
| 562 DCHECK(thread_checker_.CalledOnValidThread()); | 574 DCHECK(thread_checker_.CalledOnValidThread()); |
| 563 video_renderer_.ResetCache(); | 575 video_renderer_.ResetCache(); |
| 564 } | 576 } |
| 565 | 577 |
| 566 void WebMediaPlayerMS::TriggerResize() { | 578 void WebMediaPlayerMS::TriggerResize() { |
| 567 get_client()->sizeChanged(); | 579 get_client()->sizeChanged(); |
| 568 } | 580 } |
| 569 | 581 |
| 570 } // namespace content | 582 } // namespace content |
| OLD | NEW |