Skip to content

Commit

Permalink
media: Add kForceDisableNewAcceleratedVideoDecoder argument.
Browse files Browse the repository at this point in the history
Currently, we used base::Feature "ChromeosVideoDecoder" to control VD
enabling. For those unsupported boards, we add the cmdline argument
"--disable-feature=ChromeosVideoDecoder" to disable the feature.
However, this argument doesn't affect at guest mode. So when we enable
the feature by default, those boards cannot play video at guest mode.

In this CL, we add a new cmdline flag "kForceDisableNewAcceleratedVideoDecoder".
We pass this flag to GPU process, and this flag forces to disable the
ChromeosVideoDecoder feature.

Bug: b:149797442
Test: Add/Remove "--force-disable-new-accelerated-video-decoder" at /etc/chrome_dev.conf
      then run `tast run $(DUT) video.Play.h264_guest`.
      Check VDA or VD is created as expected
Test: ./gpu_unittests --gtest_filter="GpuPreferencesTest.*"

Change-Id: I1257947fee388e0edbe52e258fbf3f6e5afca795
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063511
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: Alexander Alekseev <alemate@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748476}
  • Loading branch information
Chih-Yu Huang authored and Commit Bot committed Mar 10, 2020
1 parent 302931e commit 1415b63
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 2 deletions.
3 changes: 3 additions & 0 deletions chrome/browser/chromeos/login/chrome_restart_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ void DeriveCommandLine(const GURL& start_url,
::switches::kEnableZeroCopy,
::switches::kEnableHardwareOverlays,
::switches::kEdgeTouchFiltering,
#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
::switches::kForceDisableNewAcceleratedVideoDecoder,
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
::switches::kHostWindowBounds,
::switches::kMainFrameResizesAreOrientationChanges,
::switches::kForceDeviceScaleFactor,
Expand Down
7 changes: 7 additions & 0 deletions content/public/browser/gpu_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "gpu/command_buffer/service/service_utils.h"
#include "gpu/config/gpu_finch_features.h"
#include "gpu/config/gpu_switches.h"
#include "media/base/media_switches.h"
#include "media/media_buildflags.h"
#include "ui/gfx/switches.h"

Expand Down Expand Up @@ -110,6 +111,12 @@ const gpu::GpuPreferences GetGpuPreferencesFromCommandLine() {
gpu_preferences.enable_native_gpu_memory_buffers =
command_line->HasSwitch(switches::kEnableNativeGpuMemoryBuffers);

#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
gpu_preferences.force_disable_new_accelerated_video_decoder =
command_line->HasSwitch(
switches::kForceDisableNewAcceleratedVideoDecoder);
#endif

// Some of these preferences are set or adjusted in
// GpuDataManagerImplPrivate::AppendGpuCommandLine.
return gpu_preferences;
Expand Down
6 changes: 6 additions & 0 deletions gpu/config/gpu_preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ struct GPU_EXPORT GpuPreferences {
// Enable native CPU-mappable GPU memory buffer support on Linux.
bool enable_native_gpu_memory_buffers = false;

// ===================================
// Settings from //media/base/media_switches.h

// Force to disable new VideoDecoder.
bool force_disable_new_accelerated_video_decoder = false;

// Please update gpu_preferences_unittest.cc when making additions or
// changes to this struct.
};
Expand Down
3 changes: 3 additions & 0 deletions gpu/config/gpu_preferences_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ void CheckGpuPreferencesEqual(GpuPreferences left, GpuPreferences right) {
#endif
EXPECT_EQ(left.enable_native_gpu_memory_buffers,
right.enable_native_gpu_memory_buffers);
EXPECT_EQ(left.force_disable_new_accelerated_video_decoder,
right.force_disable_new_accelerated_video_decoder);
}

} // namespace
Expand Down Expand Up @@ -176,6 +178,7 @@ TEST(GpuPreferencesTest, EncodeDecode) {
base::MessagePumpType::UI)
#endif
GPU_PREFERENCES_FIELD(enable_native_gpu_memory_buffers, true);
GPU_PREFERENCES_FIELD(force_disable_new_accelerated_video_decoder, true);

input_prefs.texture_target_exception_list.emplace_back(
gfx::BufferUsage::SCANOUT, gfx::BufferFormat::RGBA_8888);
Expand Down
2 changes: 2 additions & 0 deletions gpu/ipc/common/gpu_preferences.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,6 @@ struct GpuPreferences {
mojo_base.mojom.MessagePumpType message_pump_type;

bool enable_native_gpu_memory_buffers;

bool force_disable_new_accelerated_video_decoder;
};
7 changes: 7 additions & 0 deletions gpu/ipc/common/gpu_preferences_mojom_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
out->enable_native_gpu_memory_buffers =
prefs.enable_native_gpu_memory_buffers();

out->force_disable_new_accelerated_video_decoder =
prefs.force_disable_new_accelerated_video_decoder();

return true;
}

Expand Down Expand Up @@ -358,6 +361,10 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
const gpu::GpuPreferences& prefs) {
return prefs.enable_native_gpu_memory_buffers;
}
static bool force_disable_new_accelerated_video_decoder(
const gpu::GpuPreferences& prefs) {
return prefs.force_disable_new_accelerated_video_decoder;
}
};

} // namespace mojo
Expand Down
6 changes: 6 additions & 0 deletions media/base/media_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ const char kOverrideEnabledCdmInterfaceVersion[] =
const char kOverrideHardwareSecureCodecsForTesting[] =
"override-hardware-secure-codecs-for-testing";

#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
// Force to disable kChromeosVideoDecoder feature, used for unsupported boards.
const char kForceDisableNewAcceleratedVideoDecoder[] =
"force-disable-new-accelerated-video-decoder";
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)

namespace autoplay {

// Autoplay policy that requires a document user activation.
Expand Down
4 changes: 4 additions & 0 deletions media/base/media_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ MEDIA_EXPORT extern const char kForceProtectedVideoOutputBuffers[];
MEDIA_EXPORT extern const char kEnableFuchsiaAudioConsumer[];
#endif

#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
MEDIA_EXPORT extern const char kForceDisableNewAcceleratedVideoDecoder[];
#endif

#if defined(USE_CRAS)
MEDIA_EXPORT extern const char kUseCras[];
#endif
Expand Down
13 changes: 11 additions & 2 deletions media/mojo/services/gpu_mojo_media_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ D3D11VideoDecoder::GetD3D11DeviceCB GetD3D11DeviceCallback() {
}
#endif

#if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
// Return true if we switch to use new HW-accelerated video decoder.
bool IsNewAcceleratedVideoDecoderUsed(
const gpu::GpuPreferences& gpu_preferences) {
return !gpu_preferences.force_disable_new_accelerated_video_decoder &&
base::FeatureList::IsEnabled(kChromeosVideoDecoder);
}
#endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)

} // namespace

GpuMojoMediaClient::GpuMojoMediaClient(
Expand Down Expand Up @@ -156,7 +165,7 @@ GpuMojoMediaClient::GetSupportedVideoDecoderConfigs() {
*d3d11_supported_configs_;

#elif BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
if (base::FeatureList::IsEnabled(kChromeosVideoDecoder)) {
if (IsNewAcceleratedVideoDecoderUsed(gpu_preferences_)) {
if (!cros_supported_configs_) {
cros_supported_configs_ =
ChromeosVideoDecoderFactory::GetSupportedConfigs();
Expand Down Expand Up @@ -235,7 +244,7 @@ std::unique_ptr<VideoDecoder> GpuMojoMediaClient::CreateVideoDecoder(
std::move(ycbcr_helper)));

#elif BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
if (base::FeatureList::IsEnabled(kChromeosVideoDecoder)) {
if (IsNewAcceleratedVideoDecoderUsed(gpu_preferences_)) {
auto frame_pool = std::make_unique<PlatformVideoFramePool>(
gpu_memory_buffer_factory_);
auto frame_converter = MailboxVideoFrameConverter::Create(
Expand Down

0 comments on commit 1415b63

Please sign in to comment.