forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fuchsia] Add support for disabling software-only video codecs.
If the HARDWARE_VIDEO_DECODER_ONLY Context flag is set, then only the video codecs which are decodable in hardware are reported as playable. * Adds "enable_software_video_decoder" GN flag for Cast Runner. * Defines new command line switch --disable-software-video-decoders for propagating the flag across ContextProvider/Browser and Browser/Renderer process boundaries. * Bypasses software codec factory registration if the switch is set. * Uses hardcoded temporary logic for defining which codecs are hardware accelerated; will be replaced with a check against the Fuchsia media codec service later. * Adds new browser tests to verify the effect of --disable-software-video-decoders. Bug: 1000858 Change-Id: I780bd38eacf7537bfb1ceb52db2bad5a4ed8a879 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786079 Commit-Queue: Kevin Marshall <kmarshall@chromium.org> Reviewed-by: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Xiaohan Wang <xhwang@chromium.org> Auto-Submit: Kevin Marshall <kmarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#695253}
- Loading branch information
Kevin Marshall
authored and
Commit Bot
committed
Sep 10, 2019
1 parent
d3864a1
commit 4732c7a
Showing
16 changed files
with
238 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "fuchsia/engine/test/web_engine_browser_test.h" | ||
|
||
#include "base/files/file_path.h" | ||
#include "base/test/bind_test_util.h" | ||
#include "base/test/test_timeouts.h" | ||
#include "fuchsia/base/frame_test_util.h" | ||
#include "fuchsia/base/test_navigation_listener.h" | ||
#include "fuchsia/engine/common.h" | ||
#include "fuchsia/engine/switches.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace { | ||
const char kTestServerRoot[] = FILE_PATH_LITERAL("fuchsia/engine/test/data"); | ||
|
||
class MediaTest : public cr_fuchsia::WebEngineBrowserTest { | ||
public: | ||
MediaTest() | ||
: run_timeout_(TestTimeouts::action_timeout(), | ||
base::MakeExpectedNotRunClosure(FROM_HERE)) { | ||
set_test_server_root(base::FilePath(kTestServerRoot)); | ||
} | ||
~MediaTest() override = default; | ||
|
||
void SetUpOnMainThread() override { | ||
CHECK(embedded_test_server()->Start()); | ||
cr_fuchsia::WebEngineBrowserTest::SetUpOnMainThread(); | ||
} | ||
|
||
protected: | ||
// Creates a Frame with |navigation_listener_| attached. | ||
fuchsia::web::FramePtr CreateFrame() { | ||
return WebEngineBrowserTest::CreateFrame(&navigation_listener_); | ||
} | ||
|
||
cr_fuchsia::TestNavigationListener navigation_listener_; | ||
|
||
private: | ||
const base::RunLoop::ScopedRunTimeoutForTest run_timeout_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(MediaTest); | ||
}; | ||
|
||
// VP8 can presently only be decoded in software. | ||
// Verify that the --disable-software-video-decoders flag results in VP8 | ||
// media being reported as unplayable. | ||
class SoftwareDecoderDisabledTest : public MediaTest { | ||
public: | ||
SoftwareDecoderDisabledTest() = default; | ||
~SoftwareDecoderDisabledTest() override = default; | ||
|
||
void SetUp() override { | ||
base::CommandLine::ForCurrentProcess()->AppendSwitch( | ||
switches::kDisableSoftwareVideoDecoders); | ||
cr_fuchsia::WebEngineBrowserTest::SetUp(); | ||
} | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(SoftwareDecoderDisabledTest); | ||
}; | ||
|
||
IN_PROC_BROWSER_TEST_F(SoftwareDecoderDisabledTest, VP8IsTypeSupported) { | ||
const GURL kUrl(embedded_test_server()->GetURL("/can_play_vp8.html")); | ||
|
||
fuchsia::web::FramePtr frame = CreateFrame(); | ||
|
||
fuchsia::web::NavigationControllerPtr controller; | ||
frame->GetNavigationController(controller.NewRequest()); | ||
|
||
EXPECT_TRUE(cr_fuchsia::LoadUrlAndExpectResponse( | ||
controller.get(), fuchsia::web::LoadUrlParams(), kUrl.spec())); | ||
navigation_listener_.RunUntilUrlAndTitleEquals(kUrl, "can play vp8: false"); | ||
} | ||
|
||
using SoftwareDecoderEnabledTest = MediaTest; | ||
|
||
// Verify that VP8 is reported as playable if --disable-software-video-decoders | ||
// is unset. | ||
IN_PROC_BROWSER_TEST_F(SoftwareDecoderEnabledTest, VP8IsTypeSupported) { | ||
const GURL kUrl(embedded_test_server()->GetURL("/can_play_vp8.html")); | ||
|
||
fuchsia::web::FramePtr frame = CreateFrame(); | ||
|
||
fuchsia::web::NavigationControllerPtr controller; | ||
frame->GetNavigationController(controller.NewRequest()); | ||
|
||
EXPECT_TRUE(cr_fuchsia::LoadUrlAndExpectResponse( | ||
controller.get(), fuchsia::web::LoadUrlParams(), kUrl.spec())); | ||
navigation_listener_.RunUntilUrlAndTitleEquals(kUrl, "can play vp8: true"); | ||
} | ||
|
||
// Verify that a VP8 video is loaded if --disable-software-video-decoders is | ||
// unset. | ||
IN_PROC_BROWSER_TEST_F(SoftwareDecoderEnabledTest, PlayVP8) { | ||
const GURL kUrl(embedded_test_server()->GetURL("/play_vp8.html")); | ||
|
||
fuchsia::web::FramePtr frame = CreateFrame(); | ||
|
||
fuchsia::web::NavigationControllerPtr controller; | ||
frame->GetNavigationController(controller.NewRequest()); | ||
|
||
EXPECT_TRUE(cr_fuchsia::LoadUrlAndExpectResponse( | ||
controller.get(), fuchsia::web::LoadUrlParams(), kUrl.spec())); | ||
navigation_listener_.RunUntilUrlAndTitleEquals(kUrl, "loaded"); | ||
} | ||
|
||
// Verifies that VP8 videos won't play if --disable-software-video-decoders is | ||
// set. | ||
IN_PROC_BROWSER_TEST_F(SoftwareDecoderDisabledTest, PlayVP8Disabled) { | ||
const GURL kUrl(embedded_test_server()->GetURL("/play_vp8.html")); | ||
|
||
fuchsia::web::FramePtr frame = CreateFrame(); | ||
|
||
fuchsia::web::NavigationControllerPtr controller; | ||
frame->GetNavigationController(controller.NewRequest()); | ||
|
||
EXPECT_TRUE(cr_fuchsia::LoadUrlAndExpectResponse( | ||
controller.get(), fuchsia::web::LoadUrlParams(), kUrl.spec())); | ||
navigation_listener_.RunUntilUrlAndTitleEquals(kUrl, "error"); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
<head></head> | ||
<body> | ||
<script> | ||
document.title = 'can play vp8: ' + | ||
MediaSource.isTypeSupported('video/webm;codecs="vp8"'); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<script> | ||
var bear = document.createElement('video'); | ||
bear.onerror = function() { document.title = 'error'; } | ||
bear.onloadeddata = function() { document.title = 'loaded'; } | ||
bear.src = 'bear-vp8a.webm'; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.