Commit 094d246a authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Entering Picture-In-Picture re-enables disabled video track if needed.

This CL makes sure video track disabled by video background track
optimization is re-enabled when entering Picture-in-Picture.

Bug: 949265
Change-Id: Id0cca141f262537672f49f8cdc8bc6db5c10e3dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1556837Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721018}
parent ddf9671c
......@@ -3351,7 +3351,7 @@ bool WebMediaPlayerImpl::IsBackgroundOptimizationCandidate() const {
}
void WebMediaPlayerImpl::UpdateBackgroundVideoOptimizationState() {
if (IsHidden()) {
if (IsHidden() && !IsInPictureInPicture()) {
if (ShouldPausePlaybackWhenHidden()) {
PauseVideoIfNeeded();
} else if (update_background_status_cb_.IsCancelled()) {
......
......@@ -591,6 +591,10 @@ class WebMediaPlayerImplTest : public testing::Test {
testing::Mock::VerifyAndClearExpectations(compositor_);
}
void UpdateBackgroundVideoOptimizationState() {
wmpi_->UpdateBackgroundVideoOptimizationState();
}
void Play() { wmpi_->Play(); }
void Pause() { wmpi_->Pause(); }
......@@ -2185,6 +2189,22 @@ TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) {
// provides much of a benefit at the moment, this is being ignored.
EXPECT_TRUE(IsDisableVideoTrackPending());
}
// If the video wasn't in Picture-in-Picture and didn't pause, trigger
// Picture-in-Picture. It should disable optimizations.
if (!IsPictureInPictureOn() && IsDisableVideoTrackPending()) {
EXPECT_CALL(client_, DisplayType())
.WillRepeatedly(
Return(blink::WebMediaPlayer::DisplayType::kPictureInPicture));
EXPECT_CALL(client_, OnPictureInPictureStateChange()).Times(1);
wmpi_->OnSurfaceIdUpdated(surface_id_);
UpdateBackgroundVideoOptimizationState();
EXPECT_FALSE(IsVideoTrackDisabled());
EXPECT_FALSE(IsDisableVideoTrackPending());
}
}
INSTANTIATE_TEST_SUITE_P(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment