blob: 5eb016fba73e0bef7a84290908200957061be067 [file] [log] [blame]
// Copyright (c) 2012 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 "media/base/media_switches.h"
#include "base/command_line.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/system_media_controls/linux/buildflags/buildflags.h"
#include "media/media_buildflags.h"
#include "base/cpu.h"
namespace switches {
// Allow users to specify a custom buffer size for debugging purpose.
const char kAudioBufferSize[] = "audio-buffer-size";
// Set a timeout (in milliseconds) for the audio service to quit if there are no
// client connections to it. If the value is negative the service never quits.
const char kAudioServiceQuitTimeoutMs[] = "audio-service-quit-timeout-ms";
// Command line flag name to set the autoplay policy.
const char kAutoplayPolicy[] = "autoplay-policy";
const char kDisableAudioOutput[] = "disable-audio-output";
// Causes the AudioManager to fail creating audio streams. Used when testing
// various failure cases.
const char kFailAudioStreamCreation[] = "fail-audio-stream-creation";
// Set number of threads to use for video decoding.
const char kVideoThreads[] = "video-threads";
// Do not immediately suspend media in background tabs.
const char kDisableBackgroundMediaSuspend[] =
// Force to report VP9 as an unsupported MIME type.
const char kReportVp9AsAnUnsupportedMimeType[] =
// The Alsa device to use when opening an audio input stream.
const char kAlsaInputDevice[] = "alsa-input-device";
// The Alsa device to use when opening an audio stream.
const char kAlsaOutputDevice[] = "alsa-output-device";
// Use exclusive mode audio streaming for Windows Vista and higher.
// Leads to lower latencies for audio streams which uses the
// AudioParameters::AUDIO_PCM_LOW_LATENCY audio path.
// See
// for details.
const char kEnableExclusiveAudio[] = "enable-exclusive-audio";
// Use Windows WaveOut/In audio API even if Core Audio is supported.
const char kForceWaveAudio[] = "force-wave-audio";
// Instead of always using the hardware channel layout, check if a driver
// supports the source channel layout. Avoids outputting empty channels and
// permits drivers to enable stereo to multichannel expansion. Kept behind a
// flag since some drivers lie about supported layouts and hang when used. See
// for more details.
const char kTrySupportedChannelLayouts[] = "try-supported-channel-layouts";
// Number of buffers to use for WaveOut.
const char kWaveOutBuffers[] = "waveout-buffers";
// Emulates audio capture timestamps instead of using timestamps from the actual
// audio device.
// See for more details.
const char kUseFakeAudioCaptureTimestamps[] =
// Enables protected buffers for encrypted video streams.
const char kEnableProtectedVideoBuffers[] = "enable-protected-video-buffers";
// Forces protected memory for all output video buffers generated by
// FuchsiaVideoDecoder, including unencrypted streams. Ignored unless
// --enable-protected-video-buffers is also specified.
const char kForceProtectedVideoOutputBuffers[] =
const char kDisableAudioInput[] = "disable-audio-input";
// Present video content as overlays.
const char kUseOverlaysForVideo[] = "use-overlays-for-video";
// Forces AudioManagerFuchsia to assume that the AudioCapturer implements echo
// cancellation.
// TODO( Remove this once AudioManagerFuchsia is updated to
// get this information from AudioCapturerFactory.
const char kAudioCapturerWithEchoCancellation[] =
#if defined(USE_CRAS)
// Use CRAS, the ChromeOS audio server.
const char kUseCras[] = "use-cras";
#endif // defined(USE_CRAS)
// For automated testing of protected content, this switch allows specific
// domains (e.g. to always allow the permission to share the
// protected media identifier. In this context, domain does not include the
// port number. User's content settings will not be affected by enabling this
// switch.
// Reference:
// Example:
const char kUnsafelyAllowProtectedMediaIdentifierForDomain[] =
// Use fake device for Media Stream to replace actual camera and microphone.
// For the list of allowed parameters, see
// FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString().
const char kUseFakeDeviceForMediaStream[] = "use-fake-device-for-media-stream";
// Use an .y4m file to play as the webcam. See the comments in
// media/capture/video/file_video_capture_device.h for more details.
const char kUseFileForFakeVideoCapture[] = "use-file-for-fake-video-capture";
// Play a .wav file as the microphone. Note that for WebRTC calls we'll treat
// the bits as if they came from the microphone, which means you should disable
// audio processing (lest your audio file will play back distorted). The input
// file is converted to suit Chrome's audio buses if necessary, so most sane
// .wav files should work. You can pass either <path> to play the file looping
// or <path>%noloop to stop after playing the file to completion.
const char kUseFileForFakeAudioCapture[] = "use-file-for-fake-audio-capture";
// Use a fake device for accelerated decoding of MJPEG. This allows, for
// example, testing of the communication to the GPU service without requiring
// actual accelerator hardware to be present.
const char kUseFakeMjpegDecodeAccelerator[] =
// Disable hardware acceleration of mjpeg decode for captured frame, where
// available.
const char kDisableAcceleratedMjpegDecode[] =
// When running tests on a system without the required hardware or libraries,
// this flag will cause the tests to fail. Otherwise, they silently succeed.
const char kRequireAudioHardwareForTesting[] =
// Mutes audio sent to the audio device so it is not audible during
// automated testing.
const char kMuteAudio[] = "mute-audio";
// Allows clients to override the threshold for when the media renderer will
// declare the underflow state for the video stream when audio is present.
// TODO(dalecurtis): Remove once experiments for finish.
const char kVideoUnderflowThresholdMs[] = "video-underflow-threshold-ms";
// Disables the new rendering algorithm for webrtc, which is designed to improve
// the rendering smoothness.
const char kDisableRTCSmoothnessAlgorithm[] =
// Force media player using SurfaceView instead of SurfaceTexture on Android.
const char kForceVideoOverlays[] = "force-video-overlays";
// Allows explicitly specifying MSE audio/video buffer sizes as megabytes.
// Default values are 150M for video and 12M for audio.
const char kMSEAudioBufferSizeLimitMb[] = "mse-audio-buffer-size-limit-mb";
const char kMSEVideoBufferSizeLimitMb[] = "mse-video-buffer-size-limit-mb";
// Specifies the path to the Clear Key CDM for testing, which is necessary to
// support External Clear Key key system when library CDM is enabled. Note that
// External Clear Key key system support is also controlled by feature
// kExternalClearKeyForTesting.
const char kClearKeyCdmPathForTesting[] = "clear-key-cdm-path-for-testing";
// Overrides the default enabled library CDM interface version(s) with the one
// specified with this switch, which will be the only version enabled. For
// example, on a build where CDM 8, CDM 9 and CDM 10 are all supported
// (implemented), but only CDM 8 and CDM 9 are enabled by default:
// --override-enabled-cdm-interface-version=8 : Only CDM 8 is enabled
// --override-enabled-cdm-interface-version=9 : Only CDM 9 is enabled
// --override-enabled-cdm-interface-version=10 : Only CDM 10 is enabled
// --override-enabled-cdm-interface-version=11 : No CDM interface is enabled
// This can be used for local testing and debugging. It can also be used to
// enable an experimental CDM interface (which is always disabled by default)
// for testing while it's still in development.
const char kOverrideEnabledCdmInterfaceVersion[] =
// Overrides hardware secure codecs support for testing. If specified, real
// platform hardware secure codecs check will be skipped. Valid codecs are:
// - video: "vp8", "vp9", "avc1", "hevc", "dolbyvision"
// - audio: "mp4a", "vorbis"
// Codecs are separated by comma. For example:
// --override-hardware-secure-codecs-for-testing=vp8,vp9,vorbis
// --override-hardware-secure-codecs-for-testing=avc1,mp4a
// CENC encryption scheme is assumed to be supported for the specified codecs.
// If no valid codecs specified, no hardware secure codecs are supported. This
// can be used to disable hardware secure codecs support:
// --override-hardware-secure-codecs-for-testing
const char kOverrideHardwareSecureCodecsForTesting[] =
// Sets the default value for the kLiveCaptionEnabled preference to true.
const char kEnableLiveCaptionPrefForTesting[] =
// These are flags passed from ash-chrome to lacros-chrome that correspond to
// buildflags for the platform we are running on. lacros-chrome only builds for
// x86/arm differences, so we unconditionally build in the below features into
// the relevant parts of lacros-chrome and then filter the functionality based
// on these command line flags.
MEDIA_EXPORT extern const char kLacrosEnablePlatformHevc[] =
MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedMedia[] =
MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedAv1[] =
namespace autoplay {
// Autoplay policy that requires a document user activation.
const char kDocumentUserActivationRequiredPolicy[] =
// Autoplay policy that does not require any user gesture.
const char kNoUserGestureRequiredPolicy[] = "no-user-gesture-required";
// Autoplay policy to require a user gesture in order to play.
const char kUserGestureRequiredPolicy[] = "user-gesture-required";
} // namespace autoplay
// Some (Qualcomm only at the moment) V4L2 video decoders require setting the
// framerate so that the hardware decoder can scale the clocks efficiently.
// This provides a mechanism during testing to lock the decoder framerate
// to a specific value.
const char kHardwareVideoDecodeFrameRate[] = "hardware-video-decode-framerate";
// Set the maximum number of decoder threads for hardware video decoders on
// ChromeOS. This is intended to be used for development only.
// TODO(b/195769334): Propagate this to Chrome utility process for
// Out-of-Process video decoding.
const char kMaxChromeOSDecoderThreads[] = "max-chromeos-decoder-threads";
} // namespace switches
namespace media {
// Prefer FFmpeg to LibVPX for Vp8 decoding with opaque alpha mode.
const base::Feature kFFmpegDecodeOpaqueVP8{"FFmpegDecodeOpaqueVP8",
// Only used for disabling overlay fullscreen (aka SurfaceView) in Clank.
const base::Feature kOverlayFullscreenVideo{"overlay-fullscreen-video",
// Enables user control over muting tab audio from the tab strip.
const base::Feature kEnableTabMuting{"EnableTabMuting",
// Enable Picture-in-Picture.
const base::Feature kPictureInPicture{"PictureInPicture",
// Enables HEVC hardware accelerated decoding.
const base::Feature kPlatformHEVCDecoderSupport{
"PlatformHEVCDecoderSupport", base::FEATURE_DISABLED_BY_DEFAULT};
// Only decode preload=metadata elements upon visibility.
// TODO( Remove this after M76 ships to stable
const base::Feature kPreloadMetadataLazyLoad{"PreloadMetadataLazyLoad",
// Let videos be resumed via remote controls (for example, the notification)
// when in background.
const base::Feature kResumeBackgroundVideo {
// When enabled, MediaCapabilities will check with GPU Video Accelerator
// Factories to determine isPowerEfficient = true/false.
const base::Feature kMediaCapabilitiesQueryGpuFactories{
"MediaCapabilitiesQueryGpuFactories", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable Media Capabilities with finch-parameters.
const base::Feature kMediaCapabilitiesWithParameters{
"MediaCapabilitiesWithParameters", base::FEATURE_ENABLED_BY_DEFAULT};
// Used to set a few tunable parameters for the WebRTC Media Capabilities
// implementation.
const base::Feature kWebrtcMediaCapabilitiesParameters{
"WebrtcMediaCapabilitiesParameters", base::FEATURE_ENABLED_BY_DEFAULT};
// Display the Cast overlay button on the media controls.
const base::Feature kMediaCastOverlayButton{"MediaCastOverlayButton",
// Use AndroidOverlay only if required for secure video playback. This requires
// that |kOverlayFullscreenVideo| is true, else it is ignored.
const base::Feature kUseAndroidOverlayForSecureOnly{
"UseAndroidOverlayForSecureOnly", base::FEATURE_DISABLED_BY_DEFAULT};
// Allows usage of OS-level (platform) audio encoders.
const base::Feature kPlatformAudioEncoder {
// If enabled, RTCVideoDecoderAdapter will wrap a DecoderStream as a video
// decoder, rather than using MojoVideoDecoder. This causes the RTC external
// decoder to have all the decoder selection / fallback/forward logic of the
// non-RTC pipeline.
// TODO(liberato): This also causes the external decoder to use software
// decoding sometimes, which changes the interpretation of "ExternalDecoder".
const base::Feature kUseDecoderStreamForWebRTC{
"UseDecoderStreamForWebRTC", base::FEATURE_DISABLED_BY_DEFAULT};
// If enabled, when RTCVideoDecoderAdapter is used then SW decoders will be
// exposed directly to WebRTC.
const base::Feature kExposeSwDecodersToWebRTC{
// Let video without audio be paused when it is playing in the background.
const base::Feature kBackgroundVideoPauseOptimization{
"BackgroundVideoPauseOptimization", base::FEATURE_ENABLED_BY_DEFAULT};
// CDM host verification is enabled by default. Can be disabled for testing.
// Has no effect if ENABLE_CDM_HOST_VERIFICATION buildflag is false.
const base::Feature kCdmHostVerification{"CdmHostVerification",
// Use per-CDM-type, per-user and per-site CDM processes (for library CDM). If
// disabled, the CDM processes are only per-CDM-type, meaning different sites
// using the same CDM type would share one CDM process.
const base::Feature kCdmProcessSiteIsolation{"CdmProcessSiteIsolation",
// If echo cancellation for a mic signal is requested, mix and cancel all audio
// playback going to a specific output device in the audio service.
const base::Feature kChromeWideEchoCancellation{
"ChromeWideEchoCancellation", base::FEATURE_DISABLED_BY_DEFAULT};
// If non-zero, audio processing is done on a dedicated processing thread which
// receives audio from the audio capture thread via a fifo of a specified size.
// Zero fifo size means the usage of such processing thread is disabled and
// processing is done on the audio capture thread itself.
const base::FeatureParam<int> kChromeWideEchoCancellationProcessingFifoSize{
&kChromeWideEchoCancellation, "processing_fifo_size", 0};
// When audio processing is done in the audio process, at the renderer side IPC
// is set up to receive audio at the processing sample rate. This is a
// kill-switch to fallback to receiving audio at the default sample rate of the
// audio capture device.
const base::FeatureParam<bool> kChromeWideEchoCancellationMinimizeResampling{
&kChromeWideEchoCancellation, "minimize_resampling", true};
// Dynamically sets audio::SyncReader's timeout based off of a percentage of
// buffer duration, in an attempt to minimize glitches.
// The default negative value indicates that no experiment is running, and
// we shouldn't use a mixing specific timeout value.
// If the similar kDynamicAudioTimeout feature is enabled and this value is set,
// this parameter will override kDynamicAudioTimeout values when we are mixing.
const base::FeatureParam<double>
&kChromeWideEchoCancellation, "mixing_buffer_duration_percent", -1.0};
// Make MSE garbage collection algorithm more aggressive when we are under
// moderate or critical memory pressure. This will relieve memory pressure by
// releasing stale data from MSE buffers.
const base::Feature kMemoryPressureBasedSourceBufferGC{
"MemoryPressureBasedSourceBufferGC", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable binding multiple shared images to a single GpuMemoryBuffer for video
// frames created by video capture.
const base::Feature kMultiPlaneVideoCaptureSharedImages {
// Controls whether the Open Screen libcast SenderSession is used for
// initializing and managing streaming sessions, or the legacy implementation.
const base::Feature kOpenscreenCastStreamingSession{
"OpenscreenCastStreamingSession", base::FEATURE_DISABLED_BY_DEFAULT};
// Approach original pre-REC MSE object URL autorevoking behavior, though await
// actual attempt to use the object URL for attachment to perform revocation.
// This will hopefully reduce runtime memory bloat for pages that do not
// explicitly detach their HTMLME+MSE object collections nor explicitly revoke
// the object URLs used to attach HTMLME+MSE. When disabled, revocation only
// occurs when application explicitly revokes the object URL, or upon the
// execution context teardown for the MediaSource object. When enabled,
// revocation occurs upon successful start of attachment of HTMLME to the object
// URL. Note, rather than immediately scheduling a task to revoke upon the URL's
// creation, as at least one other browser does and the original File API
// pattern used to follow, this delay until attachment start enables new
// scenarios that could use the object URL for attaching HTMLME+MSE cross-thread
// (MSE-in-workers), where there could be significant delay between the worker
// thread creation of the object URL and the main thread usage of the object URL
// for starting attachment to HTMLME.
const base::Feature kRevokeMediaSourceObjectURLOnAttach{
"RevokeMediaSourceObjectURLOnAttach", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kD3D11VideoDecoderUseSharedHandle{
"D3D11VideoDecoderUseSharedHandle", base::FEATURE_DISABLED_BY_DEFAULT};
// Falls back to other decoders after audio/video decode error happens. The
// implementation may choose different strategies on when to fallback. See
// DecoderStream for details. When disabled, playback will fail immediately
// after a decode error happens. This can be useful in debugging and testing
// because the behavior is simpler and more predictable.
const base::Feature kFallbackAfterDecodeError{"FallbackAfterDecodeError",
// Use Gav1VideoDecoder to decode AV1 streams.
const base::Feature kGav1VideoDecoder{"Gav1VideoDecoder",
// Show toolbar button that opens dialog for controlling media sessions.
const base::Feature kGlobalMediaControls {
// Auto-dismiss global media controls.
const base::Feature kGlobalMediaControlsAutoDismiss{
"GlobalMediaControlsAutoDismiss", base::FEATURE_ENABLED_BY_DEFAULT};
// Allow Global Media Controls in system tray of CrOS.
const base::Feature kGlobalMediaControlsForChromeOS{
"GlobalMediaControlsForChromeOS", base::FEATURE_ENABLED_BY_DEFAULT};
constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>::Option
kCrosGlobalMediaControlsParamOptions[] = {
{kCrosGlobalMediaControlsPinOptions::kPin, "default-pinned"},
{kCrosGlobalMediaControlsPinOptions::kNotPin, "default-unpinned"},
{kCrosGlobalMediaControlsPinOptions::kHeuristic, "heuristic"}};
constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>
// Show picture-in-picture button in Global Media Controls.
const base::Feature kGlobalMediaControlsPictureInPicture {
// Enable selection of audio output device in Global Media Controls.
const base::Feature kGlobalMediaControlsSeamlessTransfer{
"GlobalMediaControlsSeamlessTransfer", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable an updated version of the Global Media Controls UI.
const base::Feature kGlobalMediaControlsModernUI{
"GlobalMediaControlsModernUI", base::FEATURE_DISABLED_BY_DEFAULT};
// CanPlayThrough issued according to standard.
const base::Feature kSpecCompliantCanPlayThrough{
"SpecCompliantCanPlayThrough", base::FEATURE_ENABLED_BY_DEFAULT};
// Disables the real audio output stream after silent audio has been delivered
// for too long. Should save quite a bit of power in the muted video case.
const base::Feature kSuspendMutedAudio{"SuspendMutedAudio",
// Enables using the media history store to store media engagement metrics.
const base::Feature kUseMediaHistoryStore{"UseMediaHistoryStore",
// Use R16 texture for 9-16 bit channel instead of half-float conversion by CPU.
const base::Feature kUseR16Texture{"use-r16-texture",
// Enables the Unified Autoplay policy by overriding the platform's default
// autoplay policy.
const base::Feature kUnifiedAutoplay{"UnifiedAutoplay",
// Enable vaapi video decoding on linux. This is already enabled by default on
// chromeos, but needs an experiment on linux.
const base::Feature kVaapiVideoDecodeLinux{"VaapiVideoDecoder",
const base::Feature kVaapiVideoEncodeLinux{"VaapiVideoEncoder",
// Ignore the non-intel driver blacklist for VaapiVideoDecoder implementations.
// Intended for manual usage only in order to gague the status of newer driver
// implementations.
const base::Feature kVaapiIgnoreDriverChecks{"VaapiIgnoreDriverChecks",
// Enable VA-API hardware decode acceleration for AV1.
const base::Feature kVaapiAV1Decoder{"VaapiAV1Decoder",
// Enable VA-API hardware low power encoder for all codecs on intel Gen9x gpu.
const base::Feature kVaapiLowPowerEncoderGen9x{
"VaapiLowPowerEncoderGen9x", base::FEATURE_DISABLED_BY_DEFAULT};
// Reject creation of encode/decode VAContexts when the requested resolution is
// outside the enumerated minimum and maximum. TODO(b/171041334): Remove and
// enable by default once the ARC++ hw codecs issue is fixed.
const base::Feature kVaapiEnforceVideoMinMaxResolution{
"VaapiEnforceVideoMinMaxResolution", base::FEATURE_DISABLED_BY_DEFAULT};
// Ensure the advertised minimum supported resolution is larger than or equal to
// a given one (likely QVGA + 1) for certain codecs/modes and platforms, for
// performance reasons. This does not affect JPEG decoding.
const base::Feature kVaapiVideoMinResolutionForPerformance{
"VaapiVideoMinResolutionForPerformance", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable VA-API hardware encode acceleration for VP8.
const base::Feature kVaapiVP8Encoder{"VaapiVP8Encoder",
// Enable VA-API hardware encode acceleration for VP9.
const base::Feature kVaapiVP9Encoder{"VaapiVP9Encoder",
// Enable global VA-API lock. Disable this to use lock-free VA-API function
// calls for thread safe backends.
const base::Feature kGlobalVaapiLock{"GlobalVaapiLock",
// TODO(b/214589754): revisit the need for the BUILDFLAG(IS_CHROMEOS) guard (as
// opposed to BUILDFLAG(IS_CHROMEOS_ASH)) when the final design for HW
// encoding is implemented for lacros-chrome.
// Enable H264 temporal layer encoding with HW encoder on ChromeOS.
const base::Feature kVaapiH264TemporalLayerHWEncoding{
"VaapiH264TemporalLayerEncoding", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable VP8 temporal layer encoding with HW encoder on ChromeOS.
const base::Feature kVaapiVp8TemporalLayerHWEncoding{
"VaapiVp8TemporalLayerEncoding", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable VP9 k-SVC encoding with HW encoder for webrtc use case on ChromeOS.
const base::Feature kVaapiVp9kSVCHWEncoding{"VaapiVp9kSVCHWEncoding",
// Inform video blitter of video color space.
const base::Feature kVideoBlitColorAccuracy{"video-blit-color-accuracy",
// Enable VP9 k-SVC decoding with HW decoder for webrtc use case.
const base::Feature kVp9kSVCHWDecoding {
// TODO( Remove defined(ARCH_CPU_X86_FAMILY) once this is
// enabled by default on ChromeOS ARM devices.
// Takes a reference on a video frame, keeping it alive during the duration of a
// video.requestVideoFrameCallback call. Doesn't change anything to the API for
// now, as this is only used to measure the potential impact of keeping frames
// alive for longer. See
const base::Feature kKeepRvfcFrameAlive{"keep-rvfc-frame-alive",
// Enables support for External Clear Key (ECK) key system for testing on
// supported platforms. On platforms that do not support ECK, this feature has
// no effect.
const base::Feature kExternalClearKeyForTesting{
"ExternalClearKeyForTesting", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables the Live Caption feature on supported devices.
const base::Feature kLiveCaption{"LiveCaption",
// Controls whether a "Share this tab instead" button should be shown for
// getDisplayMedia captures. Note: This flag does not control if the "Share this
// tab instead" button is shown for chrome.desktopCapture captures.
const base::Feature kShareThisTabInsteadButtonGetDisplayMedia{
// If kShareThisTabInsteadButtonGetDisplayMedia is ENABLED, this flag controls
// whether a "Share this tab instead" button should be enabled for
// getDisplayMedia captures with audio.
// If kShareThisTabInsteadButtonGetDisplayMedia is DISABLED, this flag has no
// effect.
// Note: This flag does not control if the "Share this tab instead" button is
// shown for chrome.desktopCapture captures.
const base::Feature kShareThisTabInsteadButtonGetDisplayMediaAudio{
// Enable the Speaker Change Detection feature, which inserts a line break when
// the Speech On-Device API (SODA) detects a speaker change.
const base::Feature kSpeakerChangeDetection{"SpeakerChangeDetection",
// Live Caption can be used in multiple languages, as opposed to just English.
const base::Feature kLiveCaptionMultiLanguage{
"LiveCaptionMultiLanguage", base::FEATURE_DISABLED_BY_DEFAULT};
// Live Caption runs system-wide on ChromeOS, as opposed to just in the browser.
const base::Feature kLiveCaptionSystemWideOnChromeOS{
"LiveCaptionSystemWideOnChromeOS", base::FEATURE_DISABLED_BY_DEFAULT};
// Prevents UrlProvisionFetcher from making a provisioning request. If
// specified, any provisioning request made will not be sent to the provisioning
// server, and the response will indicate a failure to communicate with the
// provisioning server.
const base::Feature kFailUrlProvisionFetcherForTesting{
"FailUrlProvisionFetcherForTesting", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables hardware secure decryption if supported by hardware and CDM.
// TODO(xhwang): Currently this is only used for development of new features.
// Apply this to Android and ChromeOS as well where hardware secure decryption
// is already available.
const base::Feature kHardwareSecureDecryption{
"HardwareSecureDecryption", base::FEATURE_DISABLED_BY_DEFAULT};
// Same as `kHardwareSecureDecryption` above, but only enable experimental
// sub key systems. Which sub key system is experimental is key system specific.
const base::Feature kHardwareSecureDecryptionExperiment{
"HardwareSecureDecryptionExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
// Allows automatically disabling hardware secure Content Decryption Module
// (CDM) after failures or crashes to fallback to software secure CDMs. If this
// feature is disabled, the fallback will never happen and users could be stuck
// in playback failures.
const base::Feature kHardwareSecureDecryptionFallback{
"HardwareSecureDecryptionFallback", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kWakeLockOptimisationHiddenMuted{
"kWakeLockOptimisationHiddenMuted", base::FEATURE_ENABLED_BY_DEFAULT};
// If active, enable HiDPI mode that increases the display scale factor
// while capturing a low-resolution tab.
const base::Feature kWebContentsCaptureHiDpi{"WebContentsCaptureHiDPI",
// Enables handling of hardware media keys for controlling media.
const base::Feature kHardwareMediaKeyHandling {
// Enables a platform-specific resolution cutoff for prioritizing platform
// decoders over software decoders or vice-versa.
const base::Feature kResolutionBasedDecoderPriority{
"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.
const base::Feature kLowDelayVideoRenderingOnLiveStream{
// Whether the autoplay policy should ignore Web Audio. When ignored, the
// autoplay policy will be hardcoded to be the legacy one on based on the
// platform
const base::Feature kAutoplayIgnoreWebAudio{"AutoplayIgnoreWebAudio",
// Whether we should show a setting to disable autoplay policy.
const base::Feature kAutoplayDisableSettings{"AutoplayDisableSettings",
// Should we allow video playback to use an overlay if it's not needed for
// security? Normally, we'd always want to allow this, except as part of the
// power testing A/B experiment. .
const base::Feature kAllowNonSecureOverlays{"AllowNonSecureOverlays",
// Enable a gesture to make the media controls expaned into the display cutout.
// TODO(beccahughes): Remove this.
const base::Feature kMediaControlsExpandGesture{
"MediaControlsExpandGesture", base::FEATURE_ENABLED_BY_DEFAULT};
// An experimental feature to enable persistent-license type support in MediaDrm
// when using Encrypted Media Extensions (EME) API.
// TODO(xhwang): Remove this after feature launch. See
const base::Feature kMediaDrmPersistentLicense{
"MediaDrmPersistentLicense", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables MediaDrmOriginIdManager to provide preprovisioned origin IDs for
// MediaDrmBridge. If disabled, MediaDrmBridge will get unprovisioned origin IDs
// which will trigger provisioning process after MediaDrmBridge is created.
const base::Feature kMediaDrmPreprovisioning{"MediaDrmPreprovisioning",
// Determines if MediaDrmOriginIdManager should attempt to pre-provision origin
// IDs at startup (whenever a profile is loaded). Also used by tests that
// disable it so that the tests can setup before pre-provisioning is done.
// Note: Has no effect if kMediaDrmPreprovisioning feature is disabled.
const base::Feature kMediaDrmPreprovisioningAtStartup{
"MediaDrmPreprovisioningAtStartup", base::FEATURE_ENABLED_BY_DEFAULT};
// Enable picture in picture web api for android.
const base::Feature kPictureInPictureAPI{"PictureInPictureAPI",
// Enables CanPlayType() (and other queries) for HLS MIME types. Note that
// disabling this also causes navigation to .m3u8 files to trigger downloading
// instead of playback.
const base::Feature kCanPlayHls{"CanPlayHls", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables the use of MediaPlayerRenderer for HLS playback. When disabled,
// HLS manifests will fail to load (triggering source fallback or load error).
const base::Feature kHlsPlayer{"HlsPlayer", base::FEATURE_ENABLED_BY_DEFAULT};
// When enabled, Playing media sessions will request audio focus from the
// Android system.
const base::Feature kRequestSystemAudioFocus{"RequestSystemAudioFocus",
// Use the (hacky) AudioManager.getOutputLatency() call to get the estimated
// hardware latency for a stream for OpenSLES playback. This is normally not
// needed, except for some Android TV devices.
const base::Feature kUseAudioLatencyFromHAL{"UseAudioLatencyFromHAL",
// Enable pooling of SharedImageVideo objects for use by MCVD, to save a hop to
// the GPU main thread during VideoFrame construction.
const base::Feature kUsePooledSharedImageVideoProvider{
"UsePooledSharedImageVideoProvider", base::FEATURE_ENABLED_BY_DEFAULT};
// Historically we hardcoded sRGB for color space. This flags controls if we
// pass real color space to VideoFrame/SharedImages.
const base::Feature kUseRealColorSpaceForAndroidVideo{
"UseRealColorSpaceForAndroidVideo", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable Variable Bitrate encoding with hardware accelerated encoders on
// ChromeOS.
const base::Feature kChromeOSHWVBREncoding{"ChromeOSHWVBREncoding",
// Enable the hardware-accelerated direct video decoder instead of the one
// needing the VdaVideoDecoder adapter. This flag is used mainly as a
// chrome:flag for developers debugging issues as well as to be able to
// experiment with direct VideoDecoder path on Linux Desktop.
// TODO(b/159825227): remove when the direct video decoder is fully launched.
const base::Feature kUseChromeOSDirectVideoDecoder{
"UseChromeOSDirectVideoDecoder", base::FEATURE_ENABLED_BY_DEFAULT};
// Limit the number of concurrent hardware decoder instances on ChromeOS.
const base::Feature kLimitConcurrentDecoderInstances{
"LimitConcurrentDecoderInstances", base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(ARCH_CPU_ARM_FAMILY)
// Some architectures have separate image processor hardware that
// can be used by Chromium's ImageProcessor to color convert/crop/etc.
// video buffers. Sometimes it is more efficient/performant/correct
// to use libYUV instead of the hardware to do this processing.
const base::Feature kPreferLibYuvImageProcessor{
"PreferLibYUVImageProcessor", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(ARCH_CPU_ARM_FAMILY)
// ChromeOS has one of two VideoDecoder implementations active based on
// SoC/board specific configurations that are sent via command line flags. This
// switch allows using the non default implementation for testing.
// TODO(b/159825227): remove when the "old" video decoder is fully launched.
const base::Feature kUseAlternateVideoDecoderImplementation{
// Enable binding multiple shared images to a single GpuMemoryBuffer for
// accelerated video decode using VideoToolbox.
const base::Feature kMultiPlaneVideoToolboxSharedImages{
"MultiPlaneVideoToolboxSharedImages", base::FEATURE_ENABLED_BY_DEFAULT};
// Does NV12->NV12 video copy on the main thread right before the texture's
// used by GL.
const base::Feature kDelayCopyNV12Textures{"DelayCopyNV12Textures",
// Enables DirectShow GetPhotoState implementation
// Created to act as a kill switch by disabling it, in the case of the
// resurgence of
const base::Feature kDirectShowGetPhotoState{"DirectShowGetPhotoState",
// Includes Infrared cameras in the list returned for EnumerateDevices() on
// Windows.
const base::Feature kIncludeIRCamerasInDeviceEnumeration{
"IncludeIRCamerasInDeviceEnumeration", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables AV1 encode acceleration for Windows.
const base::Feature MEDIA_EXPORT kMediaFoundationAV1Encoding{
"MediaFoundationAV1Encoding", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables H.264 CBP encode acceleration for Windows.
// For feature check of kMediaFoundationH264CbpEncoding at runtime,
// please use IsMediaFoundationH264CbpEncodingEnabled() instead.
const base::Feature MEDIA_EXPORT kMediaFoundationH264CbpEncoding{
"MediaFoundationH264CbpEncoding", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables VP9 encode acceleration for Windows.
const base::Feature MEDIA_EXPORT kMediaFoundationVP9Encoding{
"MediaFoundationVP9Encoding", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables MediaFoundation based video capture
const base::Feature kMediaFoundationVideoCapture{
"MediaFoundationVideoCapture", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables MediaFoundation based video capture with D3D11
// For feature check of kMediaFoundationD3D11VideoCapture at runtime,
// please use IsMediaFoundationD3D11VideoCaptureEnabled() instead.
const base::Feature kMediaFoundationD3D11VideoCapture{
"MediaFoundationD3D11VideoCapture", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables VP8 decode acceleration for Windows.
const base::Feature MEDIA_EXPORT kMediaFoundationVP8Decoding{
"MediaFoundationVP8Decoding", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables the use of MediaFoundationRenderer for clear content on supported
// systems.
const base::Feature kMediaFoundationClearPlayback{
"MediaFoundationClearPlayback", base::FEATURE_DISABLED_BY_DEFAULT};
// Use the AUDCLNT_STREAMOPTIONS_RAW option on WASAPI input audio streams in
// combination with the IAudioClient2::SetClientProperties() API.
// The audio stream is a 'raw' stream that bypasses all signal processing except
// for endpoint specific, always-on processing in the Audio Processing Object
// (APO), driver, and hardware.
const base::Feature MEDIA_EXPORT kWasapiRawAudioCapture{
// Enable VP9 kSVC decoding with HW decoder for webrtc use case on Windows.
const base::Feature kD3D11Vp9kSVCHWDecoding{"D3D11Vp9kSVCHWDecoding",
// The Media Foundation Rendering Strategy determines which presentation mode
// Media Foundation Renderer should use for presenting clear content. This
// strategy has no impact for protected content, which must always use Direct
// Composition.
// The strategy may be one of the following options:
// 1.) Direct Composition: Media Foundation Renderer will use a Windowsless
// Swapchain to present directly to a Direct Composition surface.
// 2.) Frame Server: Media Foundation Renderer will produce Video Frames that
// may be passed through the Chromium video frame rendering pipeline.
// 3.) Dynamic: Media Foundation Renderer may freely switch between Direct
// Composition & Frame Server mode based on the current operating
// conditions.
// Command line invocation:
// --enable-features=MediaFoundationClearRendering:strategy/direct-composition
// --enable-features=MediaFoundationClearRendering:strategy/frame-server
// --enable-features=MediaFoundationClearRendering:strategy/dynamic
const base::Feature kMediaFoundationClearRendering = {
"MediaFoundationClearRendering", base::FEATURE_ENABLED_BY_DEFAULT};
constexpr base::FeatureParam<MediaFoundationClearRenderingStrategy>::Option
kMediaFoundationClearRenderingStrategyOptions[] = {
{MediaFoundationClearRenderingStrategy::kFrameServer, "frame-server"},
{MediaFoundationClearRenderingStrategy::kDynamic, "dynamic"}};
// TODO(, wicarr): Media Foundation for Clear should operate in
// dynamic mode by default. However due to a bug with dual adapters when using
// Frame Serve mode we currently start in Direct Composition mode.
const base::FeatureParam<MediaFoundationClearRenderingStrategy>
&kMediaFoundationClearRendering, "strategy",
const base::Feature MEDIA_EXPORT kDeprecateLowUsageCodecs{
"DeprecateLowUsageCodecs", base::FEATURE_ENABLED_BY_DEFAULT};
// Spawn utility processes to perform hardware decode acceleration instead of
// using the GPU process.
const base::Feature MEDIA_EXPORT kUseOutOfProcessVideoDecoding{
"UseOutOfProcessVideoDecoding", base::FEATURE_DISABLED_BY_DEFAULT};
std::string GetEffectiveAutoplayPolicy(const base::CommandLine& command_line) {
// Return the autoplay policy set in the command line, if any.
if (command_line.HasSwitch(switches::kAutoplayPolicy))
return command_line.GetSwitchValueASCII(switches::kAutoplayPolicy);
if (base::FeatureList::IsEnabled(media::kUnifiedAutoplay))
return switches::autoplay::kDocumentUserActivationRequiredPolicy;
// The default value is platform dependent.
return switches::autoplay::kUserGestureRequiredPolicy;
return switches::autoplay::kNoUserGestureRequiredPolicy;
// Enables Media Engagement Index recording. This data will be used to determine
// when to bypass autoplay policies. This is recorded on all platforms.
const base::Feature kRecordMediaEngagementScores{
"RecordMediaEngagementScores", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables Media Engagement Index recording for Web Audio playbacks.
const base::Feature kRecordWebAudioEngagement{"RecordWebAudioEngagement",
// The following Media Engagement flags are not enabled on mobile platforms:
// - MediaEngagementBypassAutoplayPolicies: enables the Media Engagement Index
// data to be esude to override autoplay policies. An origin with a high MEI
// will be allowed to autoplay.
// - PreloadMediaEngagementData: enables a list of origins to be considered as
// having a high MEI until there is enough local data to determine the user's
// preferred behaviour.
const base::Feature kMediaEngagementBypassAutoplayPolicies{
"MediaEngagementBypassAutoplayPolicies", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kPreloadMediaEngagementData{
"PreloadMediaEngagementData", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kMediaEngagementBypassAutoplayPolicies{
"MediaEngagementBypassAutoplayPolicies", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kPreloadMediaEngagementData{
"PreloadMediaEngagementData", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kMediaEngagementHTTPSOnly{
// Enables experimental local learning for media. Used in the context of media
// capabilities only. Adds reporting only; does not change media behavior.
const base::Feature kMediaLearningExperiment{"MediaLearningExperiment",
// Enables the general purpose media machine learning framework. Adds reporting
// only; does not change media behavior.
const base::Feature kMediaLearningFramework{"MediaLearningFramework",
// Enables the smoothness prediction experiment. Requires
// kMediaLearningFramework to be enabled also, else it does nothing.
const base::Feature kMediaLearningSmoothnessExperiment{
"MediaLearningSmoothnessExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
// Enable the prototype global optimization of tuneables via finch. See
// media/base/tuneable.h for how to create tuneable parameters.
const base::Feature kMediaOptimizer{"JointMediaOptimizer",
// Enable aggregate power measurement for media playback.
const base::Feature kMediaPowerExperiment{"MediaPowerExperiment",
// Enable WebRTC actions for the Media Session API.
const base::Feature kMediaSessionWebRTC{"MediaSessionWebRTC",
// Enables flash to be ducked by audio focus. This is enabled on Chrome OS which
// has audio focus enabled.
const base::Feature kAudioFocusDuckFlash {
// Only affects Android. Suspends a media session when audio focus is lost; when
// this setting is disabled, an Android media session will not be suspended when
// Audio focus is lost. This is used by Cast which sometimes needs to drive
// multiple media sessions.
const base::Feature kAudioFocusLossSuspendMediaSession{
"AudioFocusMediaSession", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables the internal Media Session logic without enabling the Media Session
// service.
const base::Feature kInternalMediaSession {
// Keypress detection which serves as input to noise suppression methods
// in WebRTC clients. This functionality is enabled by default but it can be
// disabled experemantally by using --disable-features=KeyPressMonitoring.
const base::Feature kKeyPressMonitoring{"KeyPressMonitoring",
const base::Feature kUseFakeDeviceForMediaStream{
"use-fake-device-for-media-stream", base::FEATURE_DISABLED_BY_DEFAULT};
// Makes VideoCadenceEstimator use Bresenham-like algorithm for frame cadence
// estimations.
const base::Feature kBresenhamCadence{"BresenhamCadence",
bool IsChromeWideEchoCancellationEnabled() {
return base::FeatureList::IsEnabled(kChromeWideEchoCancellation);
return false;
bool IsHardwareSecureDecryptionEnabled() {
return base::FeatureList::IsEnabled(kHardwareSecureDecryption) ||
bool IsVideoCaptureAcceleratedJpegDecodingEnabled() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAcceleratedMjpegDecode)) {
return false;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUseFakeMjpegDecodeAccelerator)) {
return true;
return true;
return false;
bool IsMediaFoundationH264CbpEncodingEnabled() {
return base::FeatureList::IsEnabled(kMediaFoundationH264CbpEncoding);
bool IsMediaFoundationD3D11VideoCaptureEnabled() {
return base::FeatureList::IsEnabled(kMediaFoundationD3D11VideoCapture);
} // namespace media