Commit 69c5c015 authored by Will Cassella's avatar Will Cassella Committed by Commit Bot

Add 'DisableNonPlatform(Video|Audio)Decoder' flags

This CL adds two additional feature flags for controlling decoder
selection: `DisableNonPlatformVideoDecoders` and
`DisableNonPlatformAudioDecoders`. These change the predicate
DecoderSelector uses to skip any non-platform decoders, regardless of
config resolution. This is primarily useful for testing platform
decoders without worrying about fallback.

Bug: 1119939
Change-Id: I25191207f65b0da0fc0220133ebf6f383c9dc5d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388272
Commit-Queue: Will Cassella <cassew@google.com>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806393}
parent a6d49bcb
...@@ -506,6 +506,16 @@ const base::Feature kHardwareMediaKeyHandling { ...@@ -506,6 +506,16 @@ const base::Feature kHardwareMediaKeyHandling {
const base::Feature kResolutionBasedDecoderPriority{ const base::Feature kResolutionBasedDecoderPriority{
"ResolutionBasedDecoderPriority", base::FEATURE_DISABLED_BY_DEFAULT}; "ResolutionBasedDecoderPriority", base::FEATURE_DISABLED_BY_DEFAULT};
// Forces use of hardware (platform) video decoders in
// `media::DecoderSelector`.
const base::Feature kForceHardwareVideoDecoders{
"ForceHardwareVideoDecoders", base::FEATURE_DISABLED_BY_DEFAULT};
// Forces use of hardware (platform) audio decoders in
// `media::DecoderSelector`.
const base::Feature kForceHardwareAudioDecoders{
"ForceHardwareAudioDecoders", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables low-delay video rendering in media pipeline on "live" stream. // Enables low-delay video rendering in media pipeline on "live" stream.
const base::Feature kLowDelayVideoRenderingOnLiveStream{ const base::Feature kLowDelayVideoRenderingOnLiveStream{
"low-delay-video-rendering-on-live-stream", "low-delay-video-rendering-on-live-stream",
......
...@@ -184,6 +184,8 @@ MEDIA_EXPORT extern const base::Feature kWakeLockOptimisationHiddenMuted; ...@@ -184,6 +184,8 @@ MEDIA_EXPORT extern const base::Feature kWakeLockOptimisationHiddenMuted;
MEDIA_EXPORT extern const base::Feature kWidevineAv1; MEDIA_EXPORT extern const base::Feature kWidevineAv1;
MEDIA_EXPORT extern const base::Feature kWidevineAv1ForceSupportForTesting; MEDIA_EXPORT extern const base::Feature kWidevineAv1ForceSupportForTesting;
MEDIA_EXPORT extern const base::Feature kResolutionBasedDecoderPriority; MEDIA_EXPORT extern const base::Feature kResolutionBasedDecoderPriority;
MEDIA_EXPORT extern const base::Feature kForceHardwareVideoDecoders;
MEDIA_EXPORT extern const base::Feature kForceHardwareAudioDecoders;
#if defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS) #if defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS)
MEDIA_EXPORT extern const base::Feature kVp9kSVCHWDecoding; MEDIA_EXPORT extern const base::Feature kVp9kSVCHWDecoding;
......
...@@ -60,8 +60,18 @@ DecoderPriority ResolutionBasedDecoderPriority(const VideoDecoderConfig& config, ...@@ -60,8 +60,18 @@ DecoderPriority ResolutionBasedDecoderPriority(const VideoDecoderConfig& config,
: DecoderPriority::kDeprioritized; : DecoderPriority::kDeprioritized;
} }
template <typename ConfigT, typename DecoderT>
DecoderPriority SkipNonPlatformDecoders(const ConfigT& /*config*/,
const DecoderT& decoder) {
return decoder.IsPlatformDecoder() ? DecoderPriority::kNormal
: DecoderPriority::kSkipped;
}
void SetDefaultDecoderPriorityCB(VideoDecoderSelector::DecoderPriorityCB* out) { void SetDefaultDecoderPriorityCB(VideoDecoderSelector::DecoderPriorityCB* out) {
if (base::FeatureList::IsEnabled(kResolutionBasedDecoderPriority)) { if (base::FeatureList::IsEnabled(kForceHardwareVideoDecoders)) {
*out = base::BindRepeating(
SkipNonPlatformDecoders<VideoDecoderConfig, VideoDecoder>);
} else if (base::FeatureList::IsEnabled(kResolutionBasedDecoderPriority)) {
*out = base::BindRepeating(ResolutionBasedDecoderPriority); *out = base::BindRepeating(ResolutionBasedDecoderPriority);
} else { } else {
*out = base::BindRepeating( *out = base::BindRepeating(
...@@ -70,9 +80,14 @@ void SetDefaultDecoderPriorityCB(VideoDecoderSelector::DecoderPriorityCB* out) { ...@@ -70,9 +80,14 @@ void SetDefaultDecoderPriorityCB(VideoDecoderSelector::DecoderPriorityCB* out) {
} }
void SetDefaultDecoderPriorityCB(AudioDecoderSelector::DecoderPriorityCB* out) { void SetDefaultDecoderPriorityCB(AudioDecoderSelector::DecoderPriorityCB* out) {
// Platform audio decoders are not currently prioritized or deprioritized if (base::FeatureList::IsEnabled(kForceHardwareAudioDecoders)) {
*out = base::BindRepeating( *out = base::BindRepeating(
NormalDecoderPriority<AudioDecoderConfig, AudioDecoder>); SkipNonPlatformDecoders<AudioDecoderConfig, AudioDecoder>);
} else {
// Platform audio decoders are not currently prioritized or deprioritized
*out = base::BindRepeating(
NormalDecoderPriority<AudioDecoderConfig, AudioDecoder>);
}
} }
} // namespace } // namespace
......
...@@ -107,6 +107,10 @@ class AudioDecoderSelectorTestParam { ...@@ -107,6 +107,10 @@ class AudioDecoderSelectorTestParam {
return std::make_unique<StreamTraits>(media_log, CHANNEL_LAYOUT_STEREO); return std::make_unique<StreamTraits>(media_log, CHANNEL_LAYOUT_STEREO);
} }
static const base::Feature& ForceHardwareDecodersFeature() {
return kForceHardwareAudioDecoders;
}
static media::DecoderPriority MockDecoderPriorityCB( static media::DecoderPriority MockDecoderPriorityCB(
const media::AudioDecoderConfig& config, const media::AudioDecoderConfig& config,
const media::AudioDecoder& decoder) { const media::AudioDecoder& decoder) {
...@@ -182,6 +186,10 @@ class VideoDecoderSelectorTestParam { ...@@ -182,6 +186,10 @@ class VideoDecoderSelectorTestParam {
using DecryptingDecoder = DecryptingVideoDecoder; using DecryptingDecoder = DecryptingVideoDecoder;
#endif // !defined(OS_ANDROID) #endif // !defined(OS_ANDROID)
static const base::Feature& ForceHardwareDecodersFeature() {
return kForceHardwareVideoDecoders;
}
static std::unique_ptr<StreamTraits> CreateStreamTraits(MediaLog* media_log) { static std::unique_ptr<StreamTraits> CreateStreamTraits(MediaLog* media_log) {
return std::make_unique<StreamTraits>(media_log); return std::make_unique<StreamTraits>(media_log);
} }
...@@ -608,6 +616,26 @@ TYPED_TEST(DecoderSelectorTest, ClearStream_SkipAllDecoders) { ...@@ -608,6 +616,26 @@ TYPED_TEST(DecoderSelectorTest, ClearStream_SkipAllDecoders) {
this->SelectDecoder(); this->SelectDecoder();
} }
TYPED_TEST(DecoderSelectorTest, ClearStream_ForceHardwareDecoders) {
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(TypeParam::ForceHardwareDecodersFeature());
this->AddMockPlatformDecoder(kDecoder1, kClearOnly);
this->AddMockDecoder(kDecoder2, kClearOnly);
this->AddMockPlatformDecoder(kDecoder3, kAlwaysSucceed);
this->AddMockDecoder(kDecoder4, kAlwaysSucceed);
this->UseClearDecoderConfig();
this->CreateDecoderSelector();
EXPECT_CALL(*this, OnDecoderSelected(kDecoder1, IsNull()));
this->SelectDecoder();
EXPECT_CALL(*this, OnDecoderSelected(kDecoder3, IsNull()));
this->SelectDecoder();
EXPECT_CALL(*this, OnDecoderSelected(kNoDecoder, IsNull()));
this->SelectDecoder();
}
// Tests the production predicate for `DecoderSelector<DemuxerStream::VIDEO>` // Tests the production predicate for `DecoderSelector<DemuxerStream::VIDEO>`
TEST_F(VideoDecoderSelectorTest, ClearStream_PrioritizeSoftwareDecoders) { TEST_F(VideoDecoderSelectorTest, ClearStream_PrioritizeSoftwareDecoders) {
base::test::ScopedFeatureList features; base::test::ScopedFeatureList features;
...@@ -782,6 +810,24 @@ TYPED_TEST(DecoderSelectorTest, EncryptedStream_SkipAllDecoders) { ...@@ -782,6 +810,24 @@ TYPED_TEST(DecoderSelectorTest, EncryptedStream_SkipAllDecoders) {
this->SelectDecoder(); this->SelectDecoder();
} }
TYPED_TEST(DecoderSelectorTest, EncryptedStream_ForceHardwareDecoders) {
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(TypeParam::ForceHardwareDecodersFeature());
this->AddMockPlatformDecoder(kDecoder1, kClearOnly);
this->AddMockDecoder(kDecoder2, kClearOnly);
this->AddMockPlatformDecoder(kDecoder3, kAlwaysSucceed);
this->AddMockDecoder(kDecoder4, kAlwaysSucceed);
this->UseEncryptedDecoderConfig();
this->CreateDecoderSelector();
EXPECT_CALL(*this, OnDecoderSelected(kDecoder3, IsNull()));
this->SelectDecoder();
EXPECT_CALL(*this, OnDecoderSelected(kNoDecoder, IsNull()));
this->SelectDecoder();
}
TYPED_TEST(DecoderSelectorTest, EncryptedStream_NoDecryptor_OneClearDecoder) { TYPED_TEST(DecoderSelectorTest, EncryptedStream_NoDecryptor_OneClearDecoder) {
this->AddMockDecoder(kDecoder1, kClearOnly); this->AddMockDecoder(kDecoder1, kClearOnly);
this->CreateCdmContext(kNoDecryptor); this->CreateCdmContext(kNoDecryptor);
......
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