media_switches.cc 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "media/base/media_switches.h"
  5. #include "base/command_line.h"
  6. #include "build/build_config.h"
  7. #include "build/chromeos_buildflags.h"
  8. #include "components/system_media_controls/linux/buildflags/buildflags.h"
  9. #include "media/media_buildflags.h"
  10. #if BUILDFLAG(IS_LINUX)
  11. #include "base/cpu.h"
  12. #endif
  13. namespace switches {
  14. // Allow users to specify a custom buffer size for debugging purpose.
  15. const char kAudioBufferSize[] = "audio-buffer-size";
  16. // Set a timeout (in milliseconds) for the audio service to quit if there are no
  17. // client connections to it. If the value is negative the service never quits.
  18. const char kAudioServiceQuitTimeoutMs[] = "audio-service-quit-timeout-ms";
  19. // Command line flag name to set the autoplay policy.
  20. const char kAutoplayPolicy[] = "autoplay-policy";
  21. const char kDisableAudioOutput[] = "disable-audio-output";
  22. // Causes the AudioManager to fail creating audio streams. Used when testing
  23. // various failure cases.
  24. const char kFailAudioStreamCreation[] = "fail-audio-stream-creation";
  25. // Set number of threads to use for video decoding.
  26. const char kVideoThreads[] = "video-threads";
  27. // Do not immediately suspend media in background tabs.
  28. const char kDisableBackgroundMediaSuspend[] =
  29. "disable-background-media-suspend";
  30. // Force to report VP9 as an unsupported MIME type.
  31. const char kReportVp9AsAnUnsupportedMimeType[] =
  32. "report-vp9-as-an-unsupported-mime-type";
  33. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_FREEBSD) || \
  34. BUILDFLAG(IS_SOLARIS)
  35. // The Alsa device to use when opening an audio input stream.
  36. const char kAlsaInputDevice[] = "alsa-input-device";
  37. // The Alsa device to use when opening an audio stream.
  38. const char kAlsaOutputDevice[] = "alsa-output-device";
  39. #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
  40. // BUILDFLAG(IS_FREEBSD) || BUILDFLAG(IS_SOLARIS)
  41. #if BUILDFLAG(IS_WIN)
  42. // Use exclusive mode audio streaming for Windows Vista and higher.
  43. // Leads to lower latencies for audio streams which uses the
  44. // AudioParameters::AUDIO_PCM_LOW_LATENCY audio path.
  45. // See http://msdn.microsoft.com/en-us/library/windows/desktop/dd370844.aspx
  46. // for details.
  47. const char kEnableExclusiveAudio[] = "enable-exclusive-audio";
  48. // Use Windows WaveOut/In audio API even if Core Audio is supported.
  49. const char kForceWaveAudio[] = "force-wave-audio";
  50. // Instead of always using the hardware channel layout, check if a driver
  51. // supports the source channel layout. Avoids outputting empty channels and
  52. // permits drivers to enable stereo to multichannel expansion. Kept behind a
  53. // flag since some drivers lie about supported layouts and hang when used. See
  54. // http://crbug.com/259165 for more details.
  55. const char kTrySupportedChannelLayouts[] = "try-supported-channel-layouts";
  56. // Number of buffers to use for WaveOut.
  57. const char kWaveOutBuffers[] = "waveout-buffers";
  58. // Emulates audio capture timestamps instead of using timestamps from the actual
  59. // audio device.
  60. // See crbug.com/1315231 for more details.
  61. const char kUseFakeAudioCaptureTimestamps[] =
  62. "use-fake-audio-capture-timestamps";
  63. #endif // BUILDFLAG(IS_WIN)
  64. #if BUILDFLAG(IS_FUCHSIA)
  65. // Enables protected buffers for encrypted video streams.
  66. const char kEnableProtectedVideoBuffers[] = "enable-protected-video-buffers";
  67. // Forces protected memory for all output video buffers generated by
  68. // FuchsiaVideoDecoder, including unencrypted streams. Ignored unless
  69. // --enable-protected-video-buffers is also specified.
  70. const char kForceProtectedVideoOutputBuffers[] =
  71. "force-protected-video-output-buffers";
  72. const char kDisableAudioInput[] = "disable-audio-input";
  73. // Present video content as overlays.
  74. const char kUseOverlaysForVideo[] = "use-overlays-for-video";
  75. // Forces AudioManagerFuchsia to assume that the AudioCapturer implements echo
  76. // cancellation.
  77. // TODO(crbug.com/852834): Remove this once AudioManagerFuchsia is updated to
  78. // get this information from AudioCapturerFactory.
  79. const char kAudioCapturerWithEchoCancellation[] =
  80. "audio-capturer-with-echo-cancellation";
  81. #endif // BUILDFLAG(IS_FUCHSIA)
  82. #if defined(USE_CRAS)
  83. // Use CRAS, the ChromeOS audio server.
  84. const char kUseCras[] = "use-cras";
  85. #endif // defined(USE_CRAS)
  86. // For automated testing of protected content, this switch allows specific
  87. // domains (e.g. example.com) to always allow the permission to share the
  88. // protected media identifier. In this context, domain does not include the
  89. // port number. User's content settings will not be affected by enabling this
  90. // switch.
  91. // Reference: http://crbug.com/718608
  92. // Example:
  93. // --unsafely-allow-protected-media-identifier-for-domain=a.com,b.ca
  94. const char kUnsafelyAllowProtectedMediaIdentifierForDomain[] =
  95. "unsafely-allow-protected-media-identifier-for-domain";
  96. // Use fake device for Media Stream to replace actual camera and microphone.
  97. // For the list of allowed parameters, see
  98. // FakeVideoCaptureDeviceFactory::ParseFakeDevicesConfigFromOptionsString().
  99. const char kUseFakeDeviceForMediaStream[] = "use-fake-device-for-media-stream";
  100. // Use an .y4m file to play as the webcam. See the comments in
  101. // media/capture/video/file_video_capture_device.h for more details.
  102. const char kUseFileForFakeVideoCapture[] = "use-file-for-fake-video-capture";
  103. // Play a .wav file as the microphone. Note that for WebRTC calls we'll treat
  104. // the bits as if they came from the microphone, which means you should disable
  105. // audio processing (lest your audio file will play back distorted). The input
  106. // file is converted to suit Chrome's audio buses if necessary, so most sane
  107. // .wav files should work. You can pass either <path> to play the file looping
  108. // or <path>%noloop to stop after playing the file to completion.
  109. const char kUseFileForFakeAudioCapture[] = "use-file-for-fake-audio-capture";
  110. // Use a fake device for accelerated decoding of MJPEG. This allows, for
  111. // example, testing of the communication to the GPU service without requiring
  112. // actual accelerator hardware to be present.
  113. const char kUseFakeMjpegDecodeAccelerator[] =
  114. "use-fake-mjpeg-decode-accelerator";
  115. // Disable hardware acceleration of mjpeg decode for captured frame, where
  116. // available.
  117. const char kDisableAcceleratedMjpegDecode[] =
  118. "disable-accelerated-mjpeg-decode";
  119. // When running tests on a system without the required hardware or libraries,
  120. // this flag will cause the tests to fail. Otherwise, they silently succeed.
  121. const char kRequireAudioHardwareForTesting[] =
  122. "require-audio-hardware-for-testing";
  123. // Mutes audio sent to the audio device so it is not audible during
  124. // automated testing.
  125. const char kMuteAudio[] = "mute-audio";
  126. // Allows clients to override the threshold for when the media renderer will
  127. // declare the underflow state for the video stream when audio is present.
  128. // TODO(dalecurtis): Remove once experiments for http://crbug.com/470940 finish.
  129. const char kVideoUnderflowThresholdMs[] = "video-underflow-threshold-ms";
  130. // Disables the new rendering algorithm for webrtc, which is designed to improve
  131. // the rendering smoothness.
  132. const char kDisableRTCSmoothnessAlgorithm[] =
  133. "disable-rtc-smoothness-algorithm";
  134. // Force media player using SurfaceView instead of SurfaceTexture on Android.
  135. const char kForceVideoOverlays[] = "force-video-overlays";
  136. // Allows explicitly specifying MSE audio/video buffer sizes as megabytes.
  137. // Default values are 150M for video and 12M for audio.
  138. const char kMSEAudioBufferSizeLimitMb[] = "mse-audio-buffer-size-limit-mb";
  139. const char kMSEVideoBufferSizeLimitMb[] = "mse-video-buffer-size-limit-mb";
  140. // Specifies the path to the Clear Key CDM for testing, which is necessary to
  141. // support External Clear Key key system when library CDM is enabled. Note that
  142. // External Clear Key key system support is also controlled by feature
  143. // kExternalClearKeyForTesting.
  144. const char kClearKeyCdmPathForTesting[] = "clear-key-cdm-path-for-testing";
  145. // Overrides the default enabled library CDM interface version(s) with the one
  146. // specified with this switch, which will be the only version enabled. For
  147. // example, on a build where CDM 8, CDM 9 and CDM 10 are all supported
  148. // (implemented), but only CDM 8 and CDM 9 are enabled by default:
  149. // --override-enabled-cdm-interface-version=8 : Only CDM 8 is enabled
  150. // --override-enabled-cdm-interface-version=9 : Only CDM 9 is enabled
  151. // --override-enabled-cdm-interface-version=10 : Only CDM 10 is enabled
  152. // --override-enabled-cdm-interface-version=11 : No CDM interface is enabled
  153. // This can be used for local testing and debugging. It can also be used to
  154. // enable an experimental CDM interface (which is always disabled by default)
  155. // for testing while it's still in development.
  156. const char kOverrideEnabledCdmInterfaceVersion[] =
  157. "override-enabled-cdm-interface-version";
  158. // Overrides hardware secure codecs support for testing. If specified, real
  159. // platform hardware secure codecs check will be skipped. Valid codecs are:
  160. // - video: "vp8", "vp9", "avc1", "hevc", "dolbyvision"
  161. // - audio: "mp4a", "vorbis"
  162. // Codecs are separated by comma. For example:
  163. // --override-hardware-secure-codecs-for-testing=vp8,vp9,vorbis
  164. // --override-hardware-secure-codecs-for-testing=avc1,mp4a
  165. // CENC encryption scheme is assumed to be supported for the specified codecs.
  166. // If no valid codecs specified, no hardware secure codecs are supported. This
  167. // can be used to disable hardware secure codecs support:
  168. // --override-hardware-secure-codecs-for-testing
  169. const char kOverrideHardwareSecureCodecsForTesting[] =
  170. "override-hardware-secure-codecs-for-testing";
  171. // Sets the default value for the kLiveCaptionEnabled preference to true.
  172. const char kEnableLiveCaptionPrefForTesting[] =
  173. "enable-live-caption-pref-for-testing";
  174. #if BUILDFLAG(IS_CHROMEOS)
  175. // These are flags passed from ash-chrome to lacros-chrome that correspond to
  176. // buildflags for the platform we are running on. lacros-chrome only builds for
  177. // x86/arm differences, so we unconditionally build in the below features into
  178. // the relevant parts of lacros-chrome and then filter the functionality based
  179. // on these command line flags.
  180. MEDIA_EXPORT extern const char kLacrosEnablePlatformHevc[] =
  181. "lacros-enable-platform-hevc";
  182. MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedMedia[] =
  183. "lacros-use-chromeos-protected-media";
  184. MEDIA_EXPORT extern const char kLacrosUseChromeosProtectedAv1[] =
  185. "lacros-use-chromeos-protected-av1";
  186. #endif // BUILDFLAG(IS_CHROMEOS)
  187. namespace autoplay {
  188. // Autoplay policy that requires a document user activation.
  189. const char kDocumentUserActivationRequiredPolicy[] =
  190. "document-user-activation-required";
  191. // Autoplay policy that does not require any user gesture.
  192. const char kNoUserGestureRequiredPolicy[] = "no-user-gesture-required";
  193. // Autoplay policy to require a user gesture in order to play.
  194. const char kUserGestureRequiredPolicy[] = "user-gesture-required";
  195. } // namespace autoplay
  196. #if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
  197. // Some (Qualcomm only at the moment) V4L2 video decoders require setting the
  198. // framerate so that the hardware decoder can scale the clocks efficiently.
  199. // This provides a mechanism during testing to lock the decoder framerate
  200. // to a specific value.
  201. const char kHardwareVideoDecodeFrameRate[] = "hardware-video-decode-framerate";
  202. // Set the maximum number of decoder threads for hardware video decoders on
  203. // ChromeOS. This is intended to be used for development only.
  204. // TODO(b/195769334): Propagate this to Chrome utility process for
  205. // Out-of-Process video decoding.
  206. const char kMaxChromeOSDecoderThreads[] = "max-chromeos-decoder-threads";
  207. #endif
  208. } // namespace switches
  209. namespace media {
  210. // Prefer FFmpeg to LibVPX for Vp8 decoding with opaque alpha mode.
  211. const base::Feature kFFmpegDecodeOpaqueVP8{"FFmpegDecodeOpaqueVP8",
  212. base::FEATURE_ENABLED_BY_DEFAULT};
  213. // Only used for disabling overlay fullscreen (aka SurfaceView) in Clank.
  214. const base::Feature kOverlayFullscreenVideo{"overlay-fullscreen-video",
  215. base::FEATURE_ENABLED_BY_DEFAULT};
  216. // Enables user control over muting tab audio from the tab strip.
  217. const base::Feature kEnableTabMuting{"EnableTabMuting",
  218. base::FEATURE_DISABLED_BY_DEFAULT};
  219. // Enable Picture-in-Picture.
  220. const base::Feature kPictureInPicture{"PictureInPicture",
  221. base::FEATURE_ENABLED_BY_DEFAULT};
  222. #if BUILDFLAG(ENABLE_PLATFORM_HEVC)
  223. // Enables HEVC hardware accelerated decoding.
  224. const base::Feature kPlatformHEVCDecoderSupport{
  225. "PlatformHEVCDecoderSupport", base::FEATURE_DISABLED_BY_DEFAULT};
  226. #endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
  227. // Only decode preload=metadata elements upon visibility.
  228. // TODO(crbug.com/879406): Remove this after M76 ships to stable
  229. const base::Feature kPreloadMetadataLazyLoad{"PreloadMetadataLazyLoad",
  230. base::FEATURE_ENABLED_BY_DEFAULT};
  231. // Let videos be resumed via remote controls (for example, the notification)
  232. // when in background.
  233. const base::Feature kResumeBackgroundVideo {
  234. "resume-background-video",
  235. #if BUILDFLAG(IS_ANDROID)
  236. base::FEATURE_ENABLED_BY_DEFAULT
  237. #else
  238. base::FEATURE_DISABLED_BY_DEFAULT
  239. #endif
  240. };
  241. // When enabled, MediaCapabilities will check with GPU Video Accelerator
  242. // Factories to determine isPowerEfficient = true/false.
  243. const base::Feature kMediaCapabilitiesQueryGpuFactories{
  244. "MediaCapabilitiesQueryGpuFactories", base::FEATURE_ENABLED_BY_DEFAULT};
  245. // Enable Media Capabilities with finch-parameters.
  246. const base::Feature kMediaCapabilitiesWithParameters{
  247. "MediaCapabilitiesWithParameters", base::FEATURE_ENABLED_BY_DEFAULT};
  248. // Used to set a few tunable parameters for the WebRTC Media Capabilities
  249. // implementation.
  250. const base::Feature kWebrtcMediaCapabilitiesParameters{
  251. "WebrtcMediaCapabilitiesParameters", base::FEATURE_ENABLED_BY_DEFAULT};
  252. // Display the Cast overlay button on the media controls.
  253. const base::Feature kMediaCastOverlayButton{"MediaCastOverlayButton",
  254. base::FEATURE_ENABLED_BY_DEFAULT};
  255. // Use AndroidOverlay only if required for secure video playback. This requires
  256. // that |kOverlayFullscreenVideo| is true, else it is ignored.
  257. const base::Feature kUseAndroidOverlayForSecureOnly{
  258. "UseAndroidOverlayForSecureOnly", base::FEATURE_DISABLED_BY_DEFAULT};
  259. // Allows usage of OS-level (platform) audio encoders.
  260. const base::Feature kPlatformAudioEncoder {
  261. "PlatformAudioEncoder",
  262. #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
  263. base::FEATURE_ENABLED_BY_DEFAULT
  264. #else
  265. base::FEATURE_DISABLED_BY_DEFAULT
  266. #endif
  267. };
  268. // If enabled, RTCVideoDecoderAdapter will wrap a DecoderStream as a video
  269. // decoder, rather than using MojoVideoDecoder. This causes the RTC external
  270. // decoder to have all the decoder selection / fallback/forward logic of the
  271. // non-RTC pipeline.
  272. // TODO(liberato): This also causes the external decoder to use software
  273. // decoding sometimes, which changes the interpretation of "ExternalDecoder".
  274. const base::Feature kUseDecoderStreamForWebRTC{
  275. "UseDecoderStreamForWebRTC", base::FEATURE_DISABLED_BY_DEFAULT};
  276. // If enabled, when RTCVideoDecoderAdapter is used then SW decoders will be
  277. // exposed directly to WebRTC.
  278. const base::Feature kExposeSwDecodersToWebRTC{
  279. "ExposeSwDecodersToWebRTC", base::FEATURE_DISABLED_BY_DEFAULT};
  280. // Let video without audio be paused when it is playing in the background.
  281. const base::Feature kBackgroundVideoPauseOptimization{
  282. "BackgroundVideoPauseOptimization", base::FEATURE_ENABLED_BY_DEFAULT};
  283. // CDM host verification is enabled by default. Can be disabled for testing.
  284. // Has no effect if ENABLE_CDM_HOST_VERIFICATION buildflag is false.
  285. const base::Feature kCdmHostVerification{"CdmHostVerification",
  286. base::FEATURE_ENABLED_BY_DEFAULT};
  287. // Use per-CDM-type, per-user and per-site CDM processes (for library CDM). If
  288. // disabled, the CDM processes are only per-CDM-type, meaning different sites
  289. // using the same CDM type would share one CDM process.
  290. const base::Feature kCdmProcessSiteIsolation{"CdmProcessSiteIsolation",
  291. base::FEATURE_ENABLED_BY_DEFAULT};
  292. #if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
  293. // If echo cancellation for a mic signal is requested, mix and cancel all audio
  294. // playback going to a specific output device in the audio service.
  295. const base::Feature kChromeWideEchoCancellation{
  296. "ChromeWideEchoCancellation", base::FEATURE_DISABLED_BY_DEFAULT};
  297. // If non-zero, audio processing is done on a dedicated processing thread which
  298. // receives audio from the audio capture thread via a fifo of a specified size.
  299. // Zero fifo size means the usage of such processing thread is disabled and
  300. // processing is done on the audio capture thread itself.
  301. const base::FeatureParam<int> kChromeWideEchoCancellationProcessingFifoSize{
  302. &kChromeWideEchoCancellation, "processing_fifo_size", 0};
  303. // When audio processing is done in the audio process, at the renderer side IPC
  304. // is set up to receive audio at the processing sample rate. This is a
  305. // kill-switch to fallback to receiving audio at the default sample rate of the
  306. // audio capture device.
  307. const base::FeatureParam<bool> kChromeWideEchoCancellationMinimizeResampling{
  308. &kChromeWideEchoCancellation, "minimize_resampling", true};
  309. // Dynamically sets audio::SyncReader's timeout based off of a percentage of
  310. // buffer duration, in an attempt to minimize glitches.
  311. // The default negative value indicates that no experiment is running, and
  312. // we shouldn't use a mixing specific timeout value.
  313. // If the similar kDynamicAudioTimeout feature is enabled and this value is set,
  314. // this parameter will override kDynamicAudioTimeout values when we are mixing.
  315. const base::FeatureParam<double>
  316. kChromeWideEchoCancellationDynamicMixingTimeout{
  317. &kChromeWideEchoCancellation, "mixing_buffer_duration_percent", -1.0};
  318. // Allows all sample rates to be used for audio processing. If disabled, only
  319. // sample rates divisible by 100 are allowed; a request for a media stream with
  320. // enabled audio processing will fail otherwise. For context see
  321. // https://crbug.com/1332484.
  322. const base::FeatureParam<bool> kChromeWideEchoCancellationAllowAllSampleRates{
  323. &kChromeWideEchoCancellation, "allow_all_sample_rates", true};
  324. #endif
  325. // Make MSE garbage collection algorithm more aggressive when we are under
  326. // moderate or critical memory pressure. This will relieve memory pressure by
  327. // releasing stale data from MSE buffers.
  328. const base::Feature kMemoryPressureBasedSourceBufferGC{
  329. "MemoryPressureBasedSourceBufferGC", base::FEATURE_DISABLED_BY_DEFAULT};
  330. // Enable binding multiple shared images to a single GpuMemoryBuffer for video
  331. // frames created by video capture.
  332. const base::Feature kMultiPlaneVideoCaptureSharedImages {
  333. "MultiPlaneVideoCaptureSharedImages",
  334. #if BUILDFLAG(IS_MAC)
  335. base::FEATURE_ENABLED_BY_DEFAULT
  336. #else
  337. base::FEATURE_DISABLED_BY_DEFAULT
  338. #endif
  339. };
  340. // Controls whether the Open Screen libcast SenderSession is used for
  341. // initializing and managing streaming sessions, or the legacy implementation.
  342. const base::Feature kOpenscreenCastStreamingSession{
  343. "OpenscreenCastStreamingSession", base::FEATURE_DISABLED_BY_DEFAULT};
  344. // Approach original pre-REC MSE object URL autorevoking behavior, though await
  345. // actual attempt to use the object URL for attachment to perform revocation.
  346. // This will hopefully reduce runtime memory bloat for pages that do not
  347. // explicitly detach their HTMLME+MSE object collections nor explicitly revoke
  348. // the object URLs used to attach HTMLME+MSE. When disabled, revocation only
  349. // occurs when application explicitly revokes the object URL, or upon the
  350. // execution context teardown for the MediaSource object. When enabled,
  351. // revocation occurs upon successful start of attachment of HTMLME to the object
  352. // URL. Note, rather than immediately scheduling a task to revoke upon the URL's
  353. // creation, as at least one other browser does and the original File API
  354. // pattern used to follow, this delay until attachment start enables new
  355. // scenarios that could use the object URL for attaching HTMLME+MSE cross-thread
  356. // (MSE-in-workers), where there could be significant delay between the worker
  357. // thread creation of the object URL and the main thread usage of the object URL
  358. // for starting attachment to HTMLME.
  359. const base::Feature kRevokeMediaSourceObjectURLOnAttach{
  360. "RevokeMediaSourceObjectURLOnAttach", base::FEATURE_ENABLED_BY_DEFAULT};
  361. const base::Feature kD3D11VideoDecoderUseSharedHandle{
  362. "D3D11VideoDecoderUseSharedHandle", base::FEATURE_DISABLED_BY_DEFAULT};
  363. // Falls back to other decoders after audio/video decode error happens. The
  364. // implementation may choose different strategies on when to fallback. See
  365. // DecoderStream for details. When disabled, playback will fail immediately
  366. // after a decode error happens. This can be useful in debugging and testing
  367. // because the behavior is simpler and more predictable.
  368. const base::Feature kFallbackAfterDecodeError{"FallbackAfterDecodeError",
  369. base::FEATURE_ENABLED_BY_DEFAULT};
  370. // Use Gav1VideoDecoder to decode AV1 streams.
  371. const base::Feature kGav1VideoDecoder{"Gav1VideoDecoder",
  372. base::FEATURE_DISABLED_BY_DEFAULT};
  373. // Show toolbar button that opens dialog for controlling media sessions.
  374. const base::Feature kGlobalMediaControls {
  375. "GlobalMediaControls",
  376. #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
  377. base::FEATURE_ENABLED_BY_DEFAULT
  378. #else
  379. base::FEATURE_DISABLED_BY_DEFAULT
  380. #endif
  381. };
  382. // Auto-dismiss global media controls.
  383. const base::Feature kGlobalMediaControlsAutoDismiss{
  384. "GlobalMediaControlsAutoDismiss", base::FEATURE_ENABLED_BY_DEFAULT};
  385. #if BUILDFLAG(IS_CHROMEOS)
  386. // Show Cast sessions in Global Media Controls.
  387. const base::Feature kGlobalMediaControlsForCast{
  388. "GlobalMediaControlsForCast", base::FEATURE_DISABLED_BY_DEFAULT};
  389. #endif
  390. // Allow Global Media Controls in system tray of CrOS.
  391. const base::Feature kGlobalMediaControlsForChromeOS{
  392. "GlobalMediaControlsForChromeOS", base::FEATURE_ENABLED_BY_DEFAULT};
  393. constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>::Option
  394. kCrosGlobalMediaControlsParamOptions[] = {
  395. {kCrosGlobalMediaControlsPinOptions::kPin, "default-pinned"},
  396. {kCrosGlobalMediaControlsPinOptions::kNotPin, "default-unpinned"},
  397. {kCrosGlobalMediaControlsPinOptions::kHeuristic, "heuristic"}};
  398. constexpr base::FeatureParam<kCrosGlobalMediaControlsPinOptions>
  399. kCrosGlobalMediaControlsPinParam(
  400. &kGlobalMediaControlsForChromeOS,
  401. "CrosGlobalMediaControlsPinParam",
  402. kCrosGlobalMediaControlsPinOptions::kHeuristic,
  403. &kCrosGlobalMediaControlsParamOptions);
  404. // Show picture-in-picture button in Global Media Controls.
  405. const base::Feature kGlobalMediaControlsPictureInPicture {
  406. "GlobalMediaControlsPictureInPicture",
  407. #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
  408. BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_CHROMEOS_LACROS)
  409. base::FEATURE_ENABLED_BY_DEFAULT
  410. #else
  411. base::FEATURE_DISABLED_BY_DEFAULT
  412. #endif
  413. };
  414. // Enable selection of audio output device in Global Media Controls.
  415. const base::Feature kGlobalMediaControlsSeamlessTransfer{
  416. "GlobalMediaControlsSeamlessTransfer", base::FEATURE_DISABLED_BY_DEFAULT};
  417. // Enable an updated version of the Global Media Controls UI.
  418. const base::Feature kGlobalMediaControlsModernUI{
  419. "GlobalMediaControlsModernUI", base::FEATURE_DISABLED_BY_DEFAULT};
  420. // CanPlayThrough issued according to standard.
  421. const base::Feature kSpecCompliantCanPlayThrough{
  422. "SpecCompliantCanPlayThrough", base::FEATURE_ENABLED_BY_DEFAULT};
  423. // Disables the real audio output stream after silent audio has been delivered
  424. // for too long. Should save quite a bit of power in the muted video case.
  425. const base::Feature kSuspendMutedAudio{"SuspendMutedAudio",
  426. base::FEATURE_ENABLED_BY_DEFAULT};
  427. // Enables using the media history store to store media engagement metrics.
  428. const base::Feature kUseMediaHistoryStore{"UseMediaHistoryStore",
  429. base::FEATURE_DISABLED_BY_DEFAULT};
  430. // Use R16 texture for 9-16 bit channel instead of half-float conversion by CPU.
  431. const base::Feature kUseR16Texture{"use-r16-texture",
  432. base::FEATURE_DISABLED_BY_DEFAULT};
  433. // Enables the Unified Autoplay policy by overriding the platform's default
  434. // autoplay policy.
  435. const base::Feature kUnifiedAutoplay{"UnifiedAutoplay",
  436. base::FEATURE_ENABLED_BY_DEFAULT};
  437. #if BUILDFLAG(IS_LINUX)
  438. // Enable vaapi video decoding on linux. This is already enabled by default on
  439. // chromeos, but needs an experiment on linux.
  440. const base::Feature kVaapiVideoDecodeLinux{"VaapiVideoDecoder",
  441. base::FEATURE_ENABLED_BY_DEFAULT};
  442. const base::Feature kVaapiVideoEncodeLinux{"VaapiVideoEncoder",
  443. base::FEATURE_DISABLED_BY_DEFAULT};
  444. // Ignore the non-intel driver blacklist for VaapiVideoDecoder implementations.
  445. // Intended for manual usage only in order to gague the status of newer driver
  446. // implementations.
  447. const base::Feature kVaapiIgnoreDriverChecks{"VaapiIgnoreDriverChecks",
  448. base::FEATURE_DISABLED_BY_DEFAULT};
  449. #endif // BUILDFLAG(IS_LINUX)
  450. // Enable VA-API hardware decode acceleration for AV1.
  451. const base::Feature kVaapiAV1Decoder{"VaapiAV1Decoder",
  452. base::FEATURE_ENABLED_BY_DEFAULT};
  453. // Enable VA-API hardware low power encoder for all codecs on intel Gen9x gpu.
  454. const base::Feature kVaapiLowPowerEncoderGen9x{
  455. "VaapiLowPowerEncoderGen9x", base::FEATURE_DISABLED_BY_DEFAULT};
  456. // Reject creation of encode/decode VAContexts when the requested resolution is
  457. // outside the enumerated minimum and maximum. TODO(b/171041334): Remove and
  458. // enable by default once the ARC++ hw codecs issue is fixed.
  459. const base::Feature kVaapiEnforceVideoMinMaxResolution{
  460. "VaapiEnforceVideoMinMaxResolution", base::FEATURE_DISABLED_BY_DEFAULT};
  461. // Ensure the advertised minimum supported resolution is larger than or equal to
  462. // a given one (likely QVGA + 1) for certain codecs/modes and platforms, for
  463. // performance reasons. This does not affect JPEG decoding.
  464. const base::Feature kVaapiVideoMinResolutionForPerformance{
  465. "VaapiVideoMinResolutionForPerformance", base::FEATURE_ENABLED_BY_DEFAULT};
  466. // Enable VA-API hardware encode acceleration for VP8.
  467. const base::Feature kVaapiVP8Encoder{"VaapiVP8Encoder",
  468. base::FEATURE_ENABLED_BY_DEFAULT};
  469. // Enable VA-API hardware encode acceleration for VP9.
  470. const base::Feature kVaapiVP9Encoder{"VaapiVP9Encoder",
  471. base::FEATURE_ENABLED_BY_DEFAULT};
  472. // Enable global VA-API lock. Disable this to use lock-free VA-API function
  473. // calls for thread safe backends.
  474. const base::Feature kGlobalVaapiLock{"GlobalVaapiLock",
  475. base::FEATURE_ENABLED_BY_DEFAULT};
  476. #if defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_CHROMEOS)
  477. // TODO(b/214589754): revisit the need for the BUILDFLAG(IS_CHROMEOS) guard (as
  478. // opposed to BUILDFLAG(IS_CHROMEOS_ASH)) when the final design for HW
  479. // encoding is implemented for lacros-chrome.
  480. // Enable H264 temporal layer encoding with HW encoder on ChromeOS.
  481. const base::Feature kVaapiH264TemporalLayerHWEncoding{
  482. "VaapiH264TemporalLayerEncoding", base::FEATURE_ENABLED_BY_DEFAULT};
  483. // Enable VP8 temporal layer encoding with HW encoder on ChromeOS.
  484. const base::Feature kVaapiVp8TemporalLayerHWEncoding{
  485. "VaapiVp8TemporalLayerEncoding", base::FEATURE_ENABLED_BY_DEFAULT};
  486. // Enable VP9 k-SVC encoding with HW encoder for webrtc use case on ChromeOS.
  487. const base::Feature kVaapiVp9kSVCHWEncoding{"VaapiVp9kSVCHWEncoding",
  488. base::FEATURE_ENABLED_BY_DEFAULT};
  489. #endif // defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_CHROMEOS)
  490. // Inform video blitter of video color space.
  491. const base::Feature kVideoBlitColorAccuracy{"video-blit-color-accuracy",
  492. base::FEATURE_ENABLED_BY_DEFAULT};
  493. // Enable VP9 k-SVC decoding with HW decoder for webrtc use case.
  494. const base::Feature kVp9kSVCHWDecoding {
  495. "Vp9kSVCHWDecoding",
  496. #if BUILDFLAG(IS_CHROMEOS)
  497. base::FEATURE_ENABLED_BY_DEFAULT
  498. #else
  499. base::FEATURE_DISABLED_BY_DEFAULT
  500. #endif
  501. };
  502. // Takes a reference on a video frame, keeping it alive during the duration of a
  503. // video.requestVideoFrameCallback call. Doesn't change anything to the API for
  504. // now, as this is only used to measure the potential impact of keeping frames
  505. // alive for longer. See crbug.com/1259784.
  506. const base::Feature kKeepRvfcFrameAlive{"keep-rvfc-frame-alive",
  507. base::FEATURE_DISABLED_BY_DEFAULT};
  508. // Enables support for External Clear Key (ECK) key system for testing on
  509. // supported platforms. On platforms that do not support ECK, this feature has
  510. // no effect.
  511. const base::Feature kExternalClearKeyForTesting{
  512. "ExternalClearKeyForTesting", base::FEATURE_DISABLED_BY_DEFAULT};
  513. // Enables the Live Caption feature on supported devices.
  514. const base::Feature kLiveCaption{"LiveCaption",
  515. base::FEATURE_ENABLED_BY_DEFAULT};
  516. // Controls whether a "Share this tab instead" button should be shown for
  517. // getDisplayMedia captures. Note: This flag does not control if the "Share this
  518. // tab instead" button is shown for chrome.desktopCapture captures.
  519. const base::Feature kShareThisTabInsteadButtonGetDisplayMedia{
  520. "ShareThisTabInsteadButtonGetDisplayMedia",
  521. base::FEATURE_DISABLED_BY_DEFAULT};
  522. // If kShareThisTabInsteadButtonGetDisplayMedia is ENABLED, this flag controls
  523. // whether a "Share this tab instead" button should be enabled for
  524. // getDisplayMedia captures with audio.
  525. // If kShareThisTabInsteadButtonGetDisplayMedia is DISABLED, this flag has no
  526. // effect.
  527. // Note: This flag does not control if the "Share this tab instead" button is
  528. // shown for chrome.desktopCapture captures.
  529. const base::Feature kShareThisTabInsteadButtonGetDisplayMediaAudio{
  530. "ShareThisTabInsteadButtonGetDisplayMediaAudio",
  531. base::FEATURE_ENABLED_BY_DEFAULT};
  532. // Enable the Speaker Change Detection feature, which inserts a line break when
  533. // the Speech On-Device API (SODA) detects a speaker change.
  534. const base::Feature kSpeakerChangeDetection{"SpeakerChangeDetection",
  535. base::FEATURE_DISABLED_BY_DEFAULT};
  536. // Live Caption can be used in multiple languages, as opposed to just English.
  537. const base::Feature kLiveCaptionMultiLanguage{
  538. "LiveCaptionMultiLanguage", base::FEATURE_DISABLED_BY_DEFAULT};
  539. // Live Caption runs system-wide on ChromeOS, as opposed to just in the browser.
  540. const base::Feature kLiveCaptionSystemWideOnChromeOS{
  541. "LiveCaptionSystemWideOnChromeOS", base::FEATURE_DISABLED_BY_DEFAULT};
  542. // Prevents UrlProvisionFetcher from making a provisioning request. If
  543. // specified, any provisioning request made will not be sent to the provisioning
  544. // server, and the response will indicate a failure to communicate with the
  545. // provisioning server.
  546. const base::Feature kFailUrlProvisionFetcherForTesting{
  547. "FailUrlProvisionFetcherForTesting", base::FEATURE_DISABLED_BY_DEFAULT};
  548. // Enables hardware secure decryption if supported by hardware and CDM.
  549. // TODO(xhwang): Currently this is only used for development of new features.
  550. // Apply this to Android and ChromeOS as well where hardware secure decryption
  551. // is already available.
  552. const base::Feature kHardwareSecureDecryption{
  553. "HardwareSecureDecryption", base::FEATURE_DISABLED_BY_DEFAULT};
  554. // Same as `kHardwareSecureDecryption` above, but only enable experimental
  555. // sub key systems. Which sub key system is experimental is key system specific.
  556. const base::Feature kHardwareSecureDecryptionExperiment{
  557. "HardwareSecureDecryptionExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
  558. // Allows automatically disabling hardware secure Content Decryption Module
  559. // (CDM) after failures or crashes to fallback to software secure CDMs. If this
  560. // feature is disabled, the fallback will never happen and users could be stuck
  561. // in playback failures.
  562. const base::Feature kHardwareSecureDecryptionFallback{
  563. "HardwareSecureDecryptionFallback", base::FEATURE_ENABLED_BY_DEFAULT};
  564. const base::Feature kWakeLockOptimisationHiddenMuted{
  565. "kWakeLockOptimisationHiddenMuted", base::FEATURE_ENABLED_BY_DEFAULT};
  566. // If active, enable HiDPI mode that increases the display scale factor
  567. // while capturing a low-resolution tab.
  568. const base::Feature kWebContentsCaptureHiDpi{"WebContentsCaptureHiDPI",
  569. base::FEATURE_DISABLED_BY_DEFAULT};
  570. // Enables handling of hardware media keys for controlling media.
  571. const base::Feature kHardwareMediaKeyHandling {
  572. "HardwareMediaKeyHandling",
  573. #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \
  574. BUILDFLAG(USE_MPRIS)
  575. base::FEATURE_ENABLED_BY_DEFAULT
  576. #else
  577. base::FEATURE_DISABLED_BY_DEFAULT
  578. #endif
  579. };
  580. // Enables a platform-specific resolution cutoff for prioritizing platform
  581. // decoders over software decoders or vice-versa.
  582. const base::Feature kResolutionBasedDecoderPriority{
  583. "ResolutionBasedDecoderPriority", base::FEATURE_DISABLED_BY_DEFAULT};
  584. // Forces use of hardware (platform) video decoders in
  585. // `media::DecoderSelector`.
  586. const base::Feature kForceHardwareVideoDecoders{
  587. "ForceHardwareVideoDecoders", base::FEATURE_DISABLED_BY_DEFAULT};
  588. // Forces use of hardware (platform) audio decoders in
  589. // `media::DecoderSelector`.
  590. const base::Feature kForceHardwareAudioDecoders{
  591. "ForceHardwareAudioDecoders", base::FEATURE_DISABLED_BY_DEFAULT};
  592. // Enables low-delay video rendering in media pipeline on "live" stream.
  593. const base::Feature kLowDelayVideoRenderingOnLiveStream{
  594. "low-delay-video-rendering-on-live-stream",
  595. base::FEATURE_ENABLED_BY_DEFAULT};
  596. // Whether the autoplay policy should ignore Web Audio. When ignored, the
  597. // autoplay policy will be hardcoded to be the legacy one on based on the
  598. // platform
  599. const base::Feature kAutoplayIgnoreWebAudio{"AutoplayIgnoreWebAudio",
  600. base::FEATURE_DISABLED_BY_DEFAULT};
  601. // Whether we should show a setting to disable autoplay policy.
  602. const base::Feature kAutoplayDisableSettings{"AutoplayDisableSettings",
  603. base::FEATURE_DISABLED_BY_DEFAULT};
  604. #if BUILDFLAG(IS_ANDROID)
  605. // Should we allow video playback to use an overlay if it's not needed for
  606. // security? Normally, we'd always want to allow this, except as part of the
  607. // power testing A/B experiment. https://crbug.com/1081346 .
  608. const base::Feature kAllowNonSecureOverlays{"AllowNonSecureOverlays",
  609. base::FEATURE_ENABLED_BY_DEFAULT};
  610. // Enable a gesture to make the media controls expaned into the display cutout.
  611. // TODO(beccahughes): Remove this.
  612. const base::Feature kMediaControlsExpandGesture{
  613. "MediaControlsExpandGesture", base::FEATURE_ENABLED_BY_DEFAULT};
  614. // An experimental feature to enable persistent-license type support in MediaDrm
  615. // when using Encrypted Media Extensions (EME) API.
  616. // TODO(xhwang): Remove this after feature launch. See http://crbug.com/493521
  617. const base::Feature kMediaDrmPersistentLicense{
  618. "MediaDrmPersistentLicense", base::FEATURE_ENABLED_BY_DEFAULT};
  619. // Enables MediaDrmOriginIdManager to provide preprovisioned origin IDs for
  620. // MediaDrmBridge. If disabled, MediaDrmBridge will get unprovisioned origin IDs
  621. // which will trigger provisioning process after MediaDrmBridge is created.
  622. const base::Feature kMediaDrmPreprovisioning{"MediaDrmPreprovisioning",
  623. base::FEATURE_ENABLED_BY_DEFAULT};
  624. // Determines if MediaDrmOriginIdManager should attempt to pre-provision origin
  625. // IDs at startup (whenever a profile is loaded). Also used by tests that
  626. // disable it so that the tests can setup before pre-provisioning is done.
  627. // Note: Has no effect if kMediaDrmPreprovisioning feature is disabled.
  628. const base::Feature kMediaDrmPreprovisioningAtStartup{
  629. "MediaDrmPreprovisioningAtStartup", base::FEATURE_ENABLED_BY_DEFAULT};
  630. // Enable picture in picture web api for android.
  631. const base::Feature kPictureInPictureAPI{"PictureInPictureAPI",
  632. base::FEATURE_ENABLED_BY_DEFAULT};
  633. // Enables CanPlayType() (and other queries) for HLS MIME types. Note that
  634. // disabling this also causes navigation to .m3u8 files to trigger downloading
  635. // instead of playback.
  636. const base::Feature kCanPlayHls{"CanPlayHls", base::FEATURE_ENABLED_BY_DEFAULT};
  637. // Enables the use of MediaPlayerRenderer for HLS playback. When disabled,
  638. // HLS manifests will fail to load (triggering source fallback or load error).
  639. const base::Feature kHlsPlayer{"HlsPlayer", base::FEATURE_ENABLED_BY_DEFAULT};
  640. // When enabled, Playing media sessions will request audio focus from the
  641. // Android system.
  642. const base::Feature kRequestSystemAudioFocus{"RequestSystemAudioFocus",
  643. base::FEATURE_ENABLED_BY_DEFAULT};
  644. // Use the (hacky) AudioManager.getOutputLatency() call to get the estimated
  645. // hardware latency for a stream for OpenSLES playback. This is normally not
  646. // needed, except for some Android TV devices.
  647. const base::Feature kUseAudioLatencyFromHAL{"UseAudioLatencyFromHAL",
  648. base::FEATURE_DISABLED_BY_DEFAULT};
  649. // Enable pooling of SharedImageVideo objects for use by MCVD, to save a hop to
  650. // the GPU main thread during VideoFrame construction.
  651. const base::Feature kUsePooledSharedImageVideoProvider{
  652. "UsePooledSharedImageVideoProvider", base::FEATURE_ENABLED_BY_DEFAULT};
  653. // Historically we hardcoded sRGB for color space. This flags controls if we
  654. // pass real color space to VideoFrame/SharedImages.
  655. const base::Feature kUseRealColorSpaceForAndroidVideo{
  656. "UseRealColorSpaceForAndroidVideo", base::FEATURE_ENABLED_BY_DEFAULT};
  657. #endif // BUILDFLAG(IS_ANDROID)
  658. #if BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
  659. // Enable Variable Bitrate encoding with hardware accelerated encoders on
  660. // ChromeOS.
  661. const base::Feature kChromeOSHWVBREncoding{"ChromeOSHWVBREncoding",
  662. base::FEATURE_DISABLED_BY_DEFAULT};
  663. // Enable the hardware-accelerated direct video decoder instead of the one
  664. // needing the VdaVideoDecoder adapter. This flag is used mainly as a
  665. // chrome:flag for developers debugging issues as well as to be able to
  666. // experiment with direct VideoDecoder path on Linux Desktop.
  667. // TODO(b/159825227): remove when the direct video decoder is fully launched.
  668. const base::Feature kUseChromeOSDirectVideoDecoder{
  669. "UseChromeOSDirectVideoDecoder", base::FEATURE_ENABLED_BY_DEFAULT};
  670. // Limit the number of concurrent hardware decoder instances on ChromeOS.
  671. const base::Feature kLimitConcurrentDecoderInstances{
  672. "LimitConcurrentDecoderInstances", base::FEATURE_ENABLED_BY_DEFAULT};
  673. #if defined(ARCH_CPU_ARM_FAMILY)
  674. // Some architectures have separate image processor hardware that
  675. // can be used by Chromium's ImageProcessor to color convert/crop/etc.
  676. // video buffers. Sometimes it is more efficient/performant/correct
  677. // to use libYUV instead of the hardware to do this processing.
  678. const base::Feature kPreferLibYuvImageProcessor{
  679. "PreferLibYUVImageProcessor", base::FEATURE_DISABLED_BY_DEFAULT};
  680. #endif // defined(ARCH_CPU_ARM_FAMILY)
  681. #if BUILDFLAG(IS_CHROMEOS)
  682. // ChromeOS has one of two VideoDecoder implementations active based on
  683. // SoC/board specific configurations that are sent via command line flags. This
  684. // switch allows using the non default implementation for testing.
  685. // TODO(b/159825227): remove when the "old" video decoder is fully launched.
  686. const base::Feature kUseAlternateVideoDecoderImplementation{
  687. "UseAlternateVideoDecoderImplementation",
  688. base::FEATURE_DISABLED_BY_DEFAULT};
  689. #endif // BUILDFLAG(IS_CHROMEOS)
  690. #endif // BUILDFLAG(USE_CHROMEOS_MEDIA_ACCELERATION)
  691. #if BUILDFLAG(IS_MAC)
  692. // Enable binding multiple shared images to a single GpuMemoryBuffer for
  693. // accelerated video decode using VideoToolbox.
  694. const base::Feature kMultiPlaneVideoToolboxSharedImages{
  695. "MultiPlaneVideoToolboxSharedImages", base::FEATURE_ENABLED_BY_DEFAULT};
  696. #endif // BUILDFLAG(IS_MAC)
  697. #if BUILDFLAG(IS_WIN)
  698. // Does NV12->NV12 video copy on the main thread right before the texture's
  699. // used by GL.
  700. const base::Feature kDelayCopyNV12Textures{"DelayCopyNV12Textures",
  701. base::FEATURE_ENABLED_BY_DEFAULT};
  702. // Enables DirectShow GetPhotoState implementation
  703. // Created to act as a kill switch by disabling it, in the case of the
  704. // resurgence of https://crbug.com/722038
  705. const base::Feature kDirectShowGetPhotoState{"DirectShowGetPhotoState",
  706. base::FEATURE_ENABLED_BY_DEFAULT};
  707. // Includes Infrared cameras in the list returned for EnumerateDevices() on
  708. // Windows.
  709. const base::Feature kIncludeIRCamerasInDeviceEnumeration{
  710. "IncludeIRCamerasInDeviceEnumeration", base::FEATURE_DISABLED_BY_DEFAULT};
  711. // Enables AV1 encode acceleration for Windows.
  712. const base::Feature MEDIA_EXPORT kMediaFoundationAV1Encoding{
  713. "MediaFoundationAV1Encoding", base::FEATURE_DISABLED_BY_DEFAULT};
  714. // Enables H.264 CBP encode acceleration for Windows.
  715. // For feature check of kMediaFoundationH264CbpEncoding at runtime,
  716. // please use IsMediaFoundationH264CbpEncodingEnabled() instead.
  717. const base::Feature MEDIA_EXPORT kMediaFoundationH264CbpEncoding{
  718. "MediaFoundationH264CbpEncoding", base::FEATURE_DISABLED_BY_DEFAULT};
  719. // Enables VP9 encode acceleration for Windows.
  720. const base::Feature MEDIA_EXPORT kMediaFoundationVP9Encoding{
  721. "MediaFoundationVP9Encoding", base::FEATURE_DISABLED_BY_DEFAULT};
  722. // Enables MediaFoundation based video capture
  723. const base::Feature kMediaFoundationVideoCapture{
  724. "MediaFoundationVideoCapture", base::FEATURE_ENABLED_BY_DEFAULT};
  725. // Enables MediaFoundation based video capture with D3D11
  726. // For feature check of kMediaFoundationD3D11VideoCapture at runtime,
  727. // please use IsMediaFoundationD3D11VideoCaptureEnabled() instead.
  728. const base::Feature kMediaFoundationD3D11VideoCapture{
  729. "MediaFoundationD3D11VideoCapture", base::FEATURE_DISABLED_BY_DEFAULT};
  730. // Enables VP8 decode acceleration for Windows.
  731. const base::Feature MEDIA_EXPORT kMediaFoundationVP8Decoding{
  732. "MediaFoundationVP8Decoding", base::FEATURE_DISABLED_BY_DEFAULT};
  733. // Enables the use of MediaFoundationRenderer for clear content on supported
  734. // systems.
  735. const base::Feature kMediaFoundationClearPlayback{
  736. "MediaFoundationClearPlayback", base::FEATURE_DISABLED_BY_DEFAULT};
  737. // Use the AUDCLNT_STREAMOPTIONS_RAW option on WASAPI input audio streams in
  738. // combination with the IAudioClient2::SetClientProperties() API.
  739. // The audio stream is a 'raw' stream that bypasses all signal processing except
  740. // for endpoint specific, always-on processing in the Audio Processing Object
  741. // (APO), driver, and hardware.
  742. // https://docs.microsoft.com/en-us/windows/win32/api/audioclient/ne-audioclient-audclnt_streamoptions
  743. const base::Feature MEDIA_EXPORT kWasapiRawAudioCapture{
  744. "WASAPIRawAudioCapture", base::FEATURE_ENABLED_BY_DEFAULT};
  745. // Enable VP9 kSVC decoding with HW decoder for webrtc use case on Windows.
  746. const base::Feature kD3D11Vp9kSVCHWDecoding{"D3D11Vp9kSVCHWDecoding",
  747. base::FEATURE_DISABLED_BY_DEFAULT};
  748. // The Media Foundation Rendering Strategy determines which presentation mode
  749. // Media Foundation Renderer should use for presenting clear content. This
  750. // strategy has no impact for protected content, which must always use Direct
  751. // Composition.
  752. //
  753. // The strategy may be one of the following options:
  754. // 1.) Direct Composition: Media Foundation Renderer will use a Windowsless
  755. // Swapchain to present directly to a Direct Composition surface.
  756. // 2.) Frame Server: Media Foundation Renderer will produce Video Frames that
  757. // may be passed through the Chromium video frame rendering pipeline.
  758. // 3.) Dynamic: Media Foundation Renderer may freely switch between Direct
  759. // Composition & Frame Server mode based on the current operating
  760. // conditions.
  761. //
  762. // Command line invocation:
  763. // --enable-features=MediaFoundationClearRendering:strategy/direct-composition
  764. // --enable-features=MediaFoundationClearRendering:strategy/frame-server
  765. // --enable-features=MediaFoundationClearRendering:strategy/dynamic
  766. const base::Feature kMediaFoundationClearRendering = {
  767. "MediaFoundationClearRendering", base::FEATURE_ENABLED_BY_DEFAULT};
  768. constexpr base::FeatureParam<MediaFoundationClearRenderingStrategy>::Option
  769. kMediaFoundationClearRenderingStrategyOptions[] = {
  770. {MediaFoundationClearRenderingStrategy::kDirectComposition,
  771. "direct-composition"},
  772. {MediaFoundationClearRenderingStrategy::kFrameServer, "frame-server"},
  773. {MediaFoundationClearRenderingStrategy::kDynamic, "dynamic"}};
  774. const base::FeatureParam<MediaFoundationClearRenderingStrategy>
  775. kMediaFoundationClearRenderingStrategyParam{
  776. &kMediaFoundationClearRendering, "strategy",
  777. MediaFoundationClearRenderingStrategy::kDynamic,
  778. &kMediaFoundationClearRenderingStrategyOptions};
  779. #endif // BUILDFLAG(IS_WIN)
  780. #if BUILDFLAG(IS_CHROMEOS)
  781. const base::Feature MEDIA_EXPORT kDeprecateLowUsageCodecs{
  782. "DeprecateLowUsageCodecs", base::FEATURE_ENABLED_BY_DEFAULT};
  783. #endif // BUILDFLAG(IS_CHROMEOS)
  784. #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  785. // Spawn utility processes to perform hardware decode acceleration instead of
  786. // using the GPU process.
  787. const base::Feature MEDIA_EXPORT kUseOutOfProcessVideoDecoding{
  788. "UseOutOfProcessVideoDecoding", base::FEATURE_DISABLED_BY_DEFAULT};
  789. #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
  790. std::string GetEffectiveAutoplayPolicy(const base::CommandLine& command_line) {
  791. // Return the autoplay policy set in the command line, if any.
  792. if (command_line.HasSwitch(switches::kAutoplayPolicy))
  793. return command_line.GetSwitchValueASCII(switches::kAutoplayPolicy);
  794. if (base::FeatureList::IsEnabled(media::kUnifiedAutoplay))
  795. return switches::autoplay::kDocumentUserActivationRequiredPolicy;
  796. // The default value is platform dependent.
  797. #if BUILDFLAG(IS_ANDROID)
  798. return switches::autoplay::kUserGestureRequiredPolicy;
  799. #else
  800. return switches::autoplay::kNoUserGestureRequiredPolicy;
  801. #endif
  802. }
  803. // Enables Media Engagement Index recording. This data will be used to determine
  804. // when to bypass autoplay policies. This is recorded on all platforms.
  805. const base::Feature kRecordMediaEngagementScores{
  806. "RecordMediaEngagementScores", base::FEATURE_ENABLED_BY_DEFAULT};
  807. // Enables Media Engagement Index recording for Web Audio playbacks.
  808. const base::Feature kRecordWebAudioEngagement{"RecordWebAudioEngagement",
  809. base::FEATURE_ENABLED_BY_DEFAULT};
  810. // The following Media Engagement flags are not enabled on mobile platforms:
  811. // - MediaEngagementBypassAutoplayPolicies: enables the Media Engagement Index
  812. // data to be esude to override autoplay policies. An origin with a high MEI
  813. // will be allowed to autoplay.
  814. // - PreloadMediaEngagementData: enables a list of origins to be considered as
  815. // having a high MEI until there is enough local data to determine the user's
  816. // preferred behaviour.
  817. #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS)
  818. const base::Feature kMediaEngagementBypassAutoplayPolicies{
  819. "MediaEngagementBypassAutoplayPolicies", base::FEATURE_DISABLED_BY_DEFAULT};
  820. const base::Feature kPreloadMediaEngagementData{
  821. "PreloadMediaEngagementData", base::FEATURE_DISABLED_BY_DEFAULT};
  822. #else
  823. const base::Feature kMediaEngagementBypassAutoplayPolicies{
  824. "MediaEngagementBypassAutoplayPolicies", base::FEATURE_ENABLED_BY_DEFAULT};
  825. const base::Feature kPreloadMediaEngagementData{
  826. "PreloadMediaEngagementData", base::FEATURE_ENABLED_BY_DEFAULT};
  827. #endif
  828. const base::Feature kMediaEngagementHTTPSOnly{
  829. "MediaEngagementHTTPSOnly", base::FEATURE_DISABLED_BY_DEFAULT};
  830. // Enables experimental local learning for media. Used in the context of media
  831. // capabilities only. Adds reporting only; does not change media behavior.
  832. const base::Feature kMediaLearningExperiment{"MediaLearningExperiment",
  833. base::FEATURE_DISABLED_BY_DEFAULT};
  834. // Enables the general purpose media machine learning framework. Adds reporting
  835. // only; does not change media behavior.
  836. const base::Feature kMediaLearningFramework{"MediaLearningFramework",
  837. base::FEATURE_DISABLED_BY_DEFAULT};
  838. // Enables the smoothness prediction experiment. Requires
  839. // kMediaLearningFramework to be enabled also, else it does nothing.
  840. const base::Feature kMediaLearningSmoothnessExperiment{
  841. "MediaLearningSmoothnessExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
  842. // Enable the prototype global optimization of tuneables via finch. See
  843. // media/base/tuneable.h for how to create tuneable parameters.
  844. const base::Feature kMediaOptimizer{"JointMediaOptimizer",
  845. base::FEATURE_DISABLED_BY_DEFAULT};
  846. // Enable aggregate power measurement for media playback.
  847. const base::Feature kMediaPowerExperiment{"MediaPowerExperiment",
  848. base::FEATURE_DISABLED_BY_DEFAULT};
  849. // Enable WebRTC actions for the Media Session API.
  850. const base::Feature kMediaSessionWebRTC{"MediaSessionWebRTC",
  851. base::FEATURE_ENABLED_BY_DEFAULT};
  852. // Enables flash to be ducked by audio focus. This is enabled on Chrome OS which
  853. // has audio focus enabled.
  854. const base::Feature kAudioFocusDuckFlash {
  855. "AudioFocusDuckFlash",
  856. #if BUILDFLAG(IS_CHROMEOS_ASH)
  857. base::FEATURE_ENABLED_BY_DEFAULT
  858. #else
  859. base::FEATURE_DISABLED_BY_DEFAULT
  860. #endif
  861. };
  862. // Only affects Android. Suspends a media session when audio focus is lost; when
  863. // this setting is disabled, an Android media session will not be suspended when
  864. // Audio focus is lost. This is used by Cast which sometimes needs to drive
  865. // multiple media sessions.
  866. const base::Feature kAudioFocusLossSuspendMediaSession{
  867. "AudioFocusMediaSession", base::FEATURE_ENABLED_BY_DEFAULT};
  868. // Enables the internal Media Session logic without enabling the Media Session
  869. // service.
  870. const base::Feature kInternalMediaSession {
  871. "InternalMediaSession",
  872. #if BUILDFLAG(IS_ANDROID)
  873. base::FEATURE_ENABLED_BY_DEFAULT
  874. #else
  875. base::FEATURE_DISABLED_BY_DEFAULT
  876. #endif
  877. };
  878. // Keypress detection which serves as input to noise suppression methods
  879. // in WebRTC clients. This functionality is enabled by default but it can be
  880. // disabled experemantally by using --disable-features=KeyPressMonitoring.
  881. const base::Feature kKeyPressMonitoring{"KeyPressMonitoring",
  882. base::FEATURE_ENABLED_BY_DEFAULT};
  883. const base::Feature kUseFakeDeviceForMediaStream{
  884. "use-fake-device-for-media-stream", base::FEATURE_DISABLED_BY_DEFAULT};
  885. // Makes VideoCadenceEstimator use Bresenham-like algorithm for frame cadence
  886. // estimations.
  887. const base::Feature kBresenhamCadence{"BresenhamCadence",
  888. base::FEATURE_DISABLED_BY_DEFAULT};
  889. bool IsChromeWideEchoCancellationEnabled() {
  890. #if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
  891. return base::FeatureList::IsEnabled(kChromeWideEchoCancellation);
  892. #else
  893. return false;
  894. #endif
  895. }
  896. bool IsHardwareSecureDecryptionEnabled() {
  897. return base::FeatureList::IsEnabled(kHardwareSecureDecryption) ||
  898. base::FeatureList::IsEnabled(kHardwareSecureDecryptionExperiment);
  899. }
  900. bool IsVideoCaptureAcceleratedJpegDecodingEnabled() {
  901. if (base::CommandLine::ForCurrentProcess()->HasSwitch(
  902. switches::kDisableAcceleratedMjpegDecode)) {
  903. return false;
  904. }
  905. if (base::CommandLine::ForCurrentProcess()->HasSwitch(
  906. switches::kUseFakeMjpegDecodeAccelerator)) {
  907. return true;
  908. }
  909. #if BUILDFLAG(IS_CHROMEOS_ASH)
  910. return true;
  911. #else
  912. return false;
  913. #endif
  914. }
  915. #if BUILDFLAG(IS_WIN)
  916. bool IsMediaFoundationH264CbpEncodingEnabled() {
  917. return base::FeatureList::IsEnabled(kMediaFoundationH264CbpEncoding);
  918. }
  919. bool IsMediaFoundationD3D11VideoCaptureEnabled() {
  920. return base::FeatureList::IsEnabled(kMediaFoundationD3D11VideoCapture);
  921. }
  922. #endif
  923. } // namespace media