2016-05-09 07:59:02 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MEDIA_PREFS_H
|
|
|
|
#define MEDIA_PREFS_H
|
|
|
|
|
2016-06-23 16:25:10 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2017-04-11 18:16:48 +03:00
|
|
|
#include "GeneratedJNIWrappers.h"
|
2016-06-23 16:25:10 +03:00
|
|
|
#endif
|
|
|
|
|
2016-07-14 10:50:23 +03:00
|
|
|
#include "mozilla/Atomics.h"
|
|
|
|
|
2016-05-09 07:59:02 +03:00
|
|
|
// First time MediaPrefs::GetSingleton() needs to be called on the main thread,
|
|
|
|
// before any of the methods accessing the values are used, but after
|
|
|
|
// the Preferences system has been initialized.
|
|
|
|
|
|
|
|
// The static methods to access the preference value are safe to call
|
|
|
|
// from any thread after that first call.
|
|
|
|
|
|
|
|
// To register a preference, you need to add a line in this file using
|
|
|
|
// the DECL_MEDIA_PREF macro.
|
|
|
|
//
|
|
|
|
// For example this line in the .h:
|
|
|
|
// DECL_MEDIA_PREF("media.resampling.enabled",AudioSinkResampling,bool,false);
|
|
|
|
// means that you can call
|
|
|
|
// const bool& var = MediaPrefs::AudioSinkResampling();
|
|
|
|
// from any thread, you will get the most up to date preference value of
|
|
|
|
// "media.resampling.enabled". If the value is not set, the default would be
|
|
|
|
// false.
|
|
|
|
|
|
|
|
#define DECL_MEDIA_PREF(Pref, Name, Type, Default) \
|
|
|
|
public: \
|
|
|
|
static const Type& Name() { MOZ_ASSERT(SingletonExists()); return GetSingleton().mPref##Name.mValue; } \
|
|
|
|
private: \
|
|
|
|
static const char* Get##Name##PrefName() { return Pref; } \
|
2016-07-14 10:50:23 +03:00
|
|
|
static StripAtomic<Type> Get##Name##PrefDefault() { return Default; } \
|
2016-05-09 07:59:02 +03:00
|
|
|
PrefTemplate<Type, Get##Name##PrefDefault, Get##Name##PrefName> mPref##Name
|
|
|
|
|
2016-05-10 04:02:28 +03:00
|
|
|
// Custom Definitions.
|
|
|
|
#define GMP_DEFAULT_ASYNC_SHUTDOWN_TIMEOUT 3000
|
2016-05-30 10:25:10 +03:00
|
|
|
#define SUSPEND_BACKGROUND_VIDEO_DELAY_MS 10000
|
2016-05-10 04:02:28 +03:00
|
|
|
#define TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE "media.webspeech.test.fake_recognition_service"
|
|
|
|
|
2016-05-09 07:59:02 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
template<class T> class StaticAutoPtr;
|
|
|
|
|
|
|
|
class MediaPrefs final
|
|
|
|
{
|
2016-07-14 10:50:23 +03:00
|
|
|
typedef Atomic<uint32_t, Relaxed> AtomicUint32;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct StripAtomicImpl {
|
|
|
|
typedef T Type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, MemoryOrdering Order>
|
|
|
|
struct StripAtomicImpl<Atomic<T, Order>> {
|
|
|
|
typedef T Type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
using StripAtomic = typename StripAtomicImpl<T>::Type;
|
2016-05-09 07:59:02 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Since we cannot use const char*, use a function that returns it.
|
2016-07-14 10:50:23 +03:00
|
|
|
template <class T, StripAtomic<T> Default(), const char* Pref()>
|
2016-05-09 07:59:02 +03:00
|
|
|
class PrefTemplate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PrefTemplate()
|
|
|
|
: mValue(Default())
|
|
|
|
{
|
|
|
|
Register(Pref());
|
|
|
|
}
|
|
|
|
T mValue;
|
|
|
|
private:
|
|
|
|
void Register(const char* aPreference)
|
|
|
|
{
|
|
|
|
AssertMainThread();
|
|
|
|
PrefAddVarCache(&mValue, aPreference, mValue);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is where DECL_MEDIA_PREF for each of the preferences should go.
|
2016-05-10 04:02:28 +03:00
|
|
|
|
2017-05-30 12:43:28 +03:00
|
|
|
// Cache sizes.
|
2017-07-06 07:12:58 +03:00
|
|
|
DECL_MEDIA_PREF("media.cache_size", MediaCacheSizeKb, uint32_t, 512000);
|
2017-06-09 14:15:04 +03:00
|
|
|
DECL_MEDIA_PREF("media.memory_cache_max_size", MediaMemoryCacheMaxSize, uint32_t, 8192);
|
2017-06-12 06:42:26 +03:00
|
|
|
DECL_MEDIA_PREF("media.memory_caches_combined_limit_kb", MediaMemoryCachesCombinedLimitKb, uint32_t, 524288);
|
|
|
|
DECL_MEDIA_PREF("media.memory_caches_combined_limit_pc_sysmem",
|
|
|
|
MediaMemoryCachesCombinedLimitPcSysmem, uint32_t, 5);
|
2017-05-30 12:43:28 +03:00
|
|
|
DECL_MEDIA_PREF("media.cache.resource-index", MediaResourceIndexCache, uint32_t, 8192);
|
|
|
|
|
2016-05-10 04:02:28 +03:00
|
|
|
// AudioSink
|
|
|
|
DECL_MEDIA_PREF("accessibility.monoaudio.enable", MonoAudio, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.resampling.enabled", AudioSinkResampling, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.resampling.rate", AudioSinkResampleRate, uint32_t, 48000);
|
2017-02-20 23:00:50 +03:00
|
|
|
#if defined(XP_WIN) || defined(XP_DARWIN) || defined(MOZ_PULSEAUDIO)
|
|
|
|
// libcubeb backend implement .get_preferred_channel_layout
|
2017-02-12 10:24:59 +03:00
|
|
|
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, false);
|
2017-02-20 23:00:50 +03:00
|
|
|
#else
|
|
|
|
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, true);
|
2017-01-26 12:35:31 +03:00
|
|
|
#endif
|
2016-08-19 12:34:42 +03:00
|
|
|
// VideoSink
|
|
|
|
DECL_MEDIA_PREF("media.ruin-av-sync.enabled", RuinAvSync, bool, false);
|
|
|
|
|
2016-10-18 05:42:02 +03:00
|
|
|
// Encrypted Media Extensions
|
|
|
|
DECL_MEDIA_PREF("media.clearkey.persistent-license.enabled", ClearKeyPersistentLicenseEnabled, bool, false);
|
|
|
|
|
2016-05-10 04:02:28 +03:00
|
|
|
// PlatformDecoderModule
|
|
|
|
DECL_MEDIA_PREF("media.apple.forcevda", AppleForceVDA, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.gmp.insecure.allow", GMPAllowInsecure, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.eme.enabled", EMEEnabled, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.use-blank-decoder", PDMUseBlankDecoder, bool, false);
|
2016-09-21 12:24:44 +03:00
|
|
|
DECL_MEDIA_PREF("media.gpu-process-decoder", PDMUseGPUDecoder, bool, false);
|
2016-05-10 04:02:28 +03:00
|
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
|
|
DECL_MEDIA_PREF("media.gonk.enabled", PDMGonkDecoderEnabled, bool, true);
|
|
|
|
#endif
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
DECL_MEDIA_PREF("media.android-media-codec.enabled", PDMAndroidMediaCodecEnabled, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.android-media-codec.preferred", PDMAndroidMediaCodecPreferred, bool, false);
|
2017-03-30 04:00:13 +03:00
|
|
|
DECL_MEDIA_PREF("media.navigator.hardware.vp8_encode.acceleration_remote_enabled", RemoteMediaCodecVP8EncoderEnabled, bool, false);
|
2016-05-10 04:02:28 +03:00
|
|
|
#endif
|
|
|
|
#ifdef MOZ_FFMPEG
|
|
|
|
DECL_MEDIA_PREF("media.ffmpeg.enabled", PDMFFmpegEnabled, bool, true);
|
2016-10-06 01:04:04 +03:00
|
|
|
DECL_MEDIA_PREF("media.libavcodec.allow-obsolete", LibavcodecAllowObsolete, bool, false);
|
2016-05-10 04:02:28 +03:00
|
|
|
#endif
|
2017-02-26 01:53:53 +03:00
|
|
|
#if defined(MOZ_FFMPEG) || defined(MOZ_FFVPX)
|
|
|
|
DECL_MEDIA_PREF("media.ffmpeg.low-latency.enabled", PDMFFmpegLowLatencyEnabled, bool, false);
|
|
|
|
#endif
|
2016-05-10 04:02:28 +03:00
|
|
|
#ifdef MOZ_FFVPX
|
|
|
|
DECL_MEDIA_PREF("media.ffvpx.enabled", PDMFFVPXEnabled, bool, true);
|
|
|
|
#endif
|
|
|
|
#ifdef XP_WIN
|
|
|
|
DECL_MEDIA_PREF("media.wmf.enabled", PDMWMFEnabled, bool, true);
|
2016-11-07 10:12:51 +03:00
|
|
|
DECL_MEDIA_PREF("media.wmf.skip-blacklist", PDMWMFSkipBlacklist, bool, false);
|
2016-05-23 18:33:37 +03:00
|
|
|
DECL_MEDIA_PREF("media.decoder-doctor.wmf-disabled-is-failure", DecoderDoctorWMFDisabledIsFailure, bool, false);
|
2016-10-28 09:03:56 +03:00
|
|
|
DECL_MEDIA_PREF("media.wmf.vp9.enabled", PDMWMFVP9DecoderEnabled, bool, true);
|
2016-05-10 04:02:28 +03:00
|
|
|
DECL_MEDIA_PREF("media.wmf.decoder.thread-count", PDMWMFThreadCount, int32_t, -1);
|
2017-01-16 01:26:54 +03:00
|
|
|
DECL_MEDIA_PREF("media.wmf.allow-unsupported-resolutions", PDMWMFAllowUnsupportedResolutions, bool, false);
|
2016-05-10 04:02:28 +03:00
|
|
|
#endif
|
|
|
|
DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0);
|
|
|
|
DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true);
|
2016-11-29 10:03:14 +03:00
|
|
|
DECL_MEDIA_PREF("media.decoder.recycle.enabled", MediaDecoderCheckRecycling, bool, false);
|
2017-06-12 11:36:42 +03:00
|
|
|
DECL_MEDIA_PREF("media.decoder.skip-to-next-key-frame.enabled", MFRSkipToNextKeyFrameEnabled, bool, true);
|
2016-05-10 04:02:28 +03:00
|
|
|
DECL_MEDIA_PREF("media.gmp.decoder.enabled", PDMGMPEnabled, bool, true);
|
|
|
|
DECL_MEDIA_PREF("media.gmp.decoder.aac", GMPAACPreferred, uint32_t, 0);
|
|
|
|
DECL_MEDIA_PREF("media.gmp.decoder.h264", GMPH264Preferred, uint32_t, 0);
|
2017-01-31 05:42:45 +03:00
|
|
|
DECL_MEDIA_PREF("media.eme.audio.blank", EMEBlankAudio, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.eme.video.blank", EMEBlankVideo, bool, false);
|
2017-02-22 04:40:30 +03:00
|
|
|
DECL_MEDIA_PREF("media.eme.chromium-api.enabled", EMEChromiumAPIEnabled, bool, false);
|
Bug 1351953 - Pre-allocate shmems for the CDM process to use for storing decrypted and audio samples. r=gerald
Makes transfer of samples between the content and CDM processes use shmems.
The Chromium CDM API requires us to implement a synchronous interface to supply
buffers to the CDM for it to write decrypted samples into. We want our buffers
to be backed by shmems, in order to reduce the overhead of transferring decoded
frames. However due to sandboxing restrictions, the CDM process cannot allocate
shmems itself. We don't want to be doing synchronous IPC to request shmems
from the content process, nor do we want to have to do intr IPC or make async
IPC conform to the sync allocation interface. So instead we have the content
process pre-allocate a set of shmems and give them to the CDM process in
advance of them being needed.
When the CDM needs to allocate a buffer for storing a decrypted sample, the CDM
host gives it one of these shmems' buffers. When this is sent back to the
content process, we copy the result out (uploading to a GPU surface for video
frames), and send the shmem back to the CDM process so it can reuse it.
We predict the size of buffer the CDM will allocate, and prepopulate the CDM's
list of shmems with shmems of at least that size, plus a bit of padding for
safety. We pad frames out to be the next multiple of 16, as we've seen some
decoders do that.
Normally the CDM won't allocate more than one buffer at once, but we've seen
cases where it allocates two buffers, returns one and holds onto the other. So
the minimum number of shmems we give to the CDM must be at least two, and the
default is three for safety.
MozReview-Commit-ID: 5FaWAst3aeh
--HG--
extra : rebase_source : a0cb126e72bfb2905bcdf02e864dc654e8340410
2017-03-28 08:59:11 +03:00
|
|
|
DECL_MEDIA_PREF("media.eme.chromium-api.video-shmems",
|
|
|
|
EMEChromiumAPIVideoShmemCount,
|
|
|
|
uint32_t,
|
|
|
|
3);
|
2016-05-10 04:02:28 +03:00
|
|
|
|
2016-05-30 10:25:10 +03:00
|
|
|
// MediaDecoderStateMachine
|
|
|
|
DECL_MEDIA_PREF("media.suspend-bkgnd-video.enabled", MDSMSuspendBackgroundVideoEnabled, bool, false);
|
2016-07-14 10:50:23 +03:00
|
|
|
DECL_MEDIA_PREF("media.suspend-bkgnd-video.delay-ms", MDSMSuspendBackgroundVideoDelay, AtomicUint32, SUSPEND_BACKGROUND_VIDEO_DELAY_MS);
|
2016-10-20 09:45:05 +03:00
|
|
|
DECL_MEDIA_PREF("media.dormant-on-pause-timeout-ms", DormantOnPauseTimeout, int32_t, 5000);
|
2016-05-30 10:25:10 +03:00
|
|
|
|
2016-05-10 04:02:28 +03:00
|
|
|
// WebSpeech
|
|
|
|
DECL_MEDIA_PREF("media.webspeech.synth.force_global_queue", WebSpeechForceGlobal, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.webspeech.test.enable", WebSpeechTestEnabled, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.webspeech.test.fake_fsm_events", WebSpeechFakeFSMEvents, bool, false);
|
|
|
|
DECL_MEDIA_PREF(TEST_PREFERENCE_FAKE_RECOGNITION_SERVICE, WebSpeechFakeRecognitionService, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.webspeech.recognition.enable", WebSpeechRecognitionEnabled, bool, false);
|
|
|
|
DECL_MEDIA_PREF("media.webspeech.recognition.force_enable", WebSpeechRecognitionForceEnabled, bool, false);
|
2016-05-09 07:59:02 +03:00
|
|
|
|
2016-05-10 04:27:05 +03:00
|
|
|
DECL_MEDIA_PREF("media.num-decode-threads", MediaThreadPoolDefaultCount, uint32_t, 4);
|
2016-06-23 16:25:10 +03:00
|
|
|
DECL_MEDIA_PREF("media.decoder.limit", MediaDecoderLimit, int32_t, MediaDecoderLimitDefault());
|
2016-05-10 04:27:05 +03:00
|
|
|
|
2017-05-24 10:25:09 +03:00
|
|
|
#if defined(RELEASE_OR_BETA)
|
|
|
|
DECL_MEDIA_PREF("media.audio-max-decode-error", MaxAudioDecodeError, uint32_t, 3);
|
|
|
|
DECL_MEDIA_PREF("media.video-max-decode-error", MaxVideoDecodeError, uint32_t, 2);
|
|
|
|
#else
|
|
|
|
// Take zero tolerance of decoding error in debug for any decoder regression.
|
|
|
|
DECL_MEDIA_PREF("media.audio-max-decode-error", MaxAudioDecodeError, uint32_t, 0);
|
|
|
|
DECL_MEDIA_PREF("media.video-max-decode-error", MaxVideoDecodeError, uint32_t, 0);
|
|
|
|
#endif
|
|
|
|
|
2016-08-04 10:14:28 +03:00
|
|
|
// Ogg
|
|
|
|
DECL_MEDIA_PREF("media.ogg.enabled", OggEnabled, bool, true);
|
2016-08-17 08:42:18 +03:00
|
|
|
// Flac
|
2016-08-04 10:14:28 +03:00
|
|
|
DECL_MEDIA_PREF("media.ogg.flac.enabled", FlacInOgg, bool, false);
|
2016-08-17 08:42:18 +03:00
|
|
|
DECL_MEDIA_PREF("media.flac.enabled", FlacEnabled, bool, true);
|
2016-08-04 10:14:28 +03:00
|
|
|
|
2017-05-05 10:57:22 +03:00
|
|
|
// Hls
|
|
|
|
DECL_MEDIA_PREF("media.hls.enabled", HLSEnabled, bool, false);
|
|
|
|
|
2017-06-14 06:29:10 +03:00
|
|
|
// Both rust/stagefright will be enabled when this is true regardless of 'media.rust.mp4parser'.
|
2016-09-19 05:31:45 +03:00
|
|
|
DECL_MEDIA_PREF("media.rust.test_mode", RustTestMode, bool, false);
|
|
|
|
|
2017-06-14 06:29:10 +03:00
|
|
|
// True, it enables rust parser and fallback to stagefright if rust parser fails.
|
|
|
|
// False, it uses stagefright only.
|
2017-03-26 18:19:49 +03:00
|
|
|
DECL_MEDIA_PREF("media.rust.mp4parser", EnableRustMP4Parser, bool, true);
|
2017-03-14 10:42:09 +03:00
|
|
|
|
2017-05-10 02:31:16 +03:00
|
|
|
DECL_MEDIA_PREF("media.mp4.enabled", MP4Enabled, bool, false);
|
|
|
|
|
2017-03-03 08:10:48 +03:00
|
|
|
// Error/warning handling, Decoder Doctor
|
|
|
|
DECL_MEDIA_PREF("media.playback.warnings-as-errors", MediaWarningsAsErrors, bool, false);
|
2017-02-27 05:36:59 +03:00
|
|
|
DECL_MEDIA_PREF("media.playback.warnings-as-errors.stagefright-vs-rust",
|
|
|
|
MediaWarningsAsErrorsStageFrightVsRust, bool, false);
|
2017-03-03 08:10:48 +03:00
|
|
|
|
2016-05-09 07:59:02 +03:00
|
|
|
public:
|
|
|
|
// Manage the singleton:
|
|
|
|
static MediaPrefs& GetSingleton();
|
|
|
|
static bool SingletonExists();
|
|
|
|
|
|
|
|
private:
|
|
|
|
template<class T> friend class StaticAutoPtr;
|
|
|
|
static StaticAutoPtr<MediaPrefs> sInstance;
|
|
|
|
|
2016-06-23 16:25:10 +03:00
|
|
|
// Default value functions
|
|
|
|
static int32_t MediaDecoderLimitDefault()
|
|
|
|
{
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2017-04-11 18:16:48 +03:00
|
|
|
if (jni::GetAPIVersion() < 18) {
|
2016-06-23 16:25:10 +03:00
|
|
|
// Older Android versions have broken support for multiple simultaneous
|
|
|
|
// decoders, see bug 1278574.
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// Otherwise, set no decoder limit.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-05-09 07:59:02 +03:00
|
|
|
// Creating these to avoid having to include Preferences.h in the .h
|
|
|
|
static void PrefAddVarCache(bool*, const char*, bool);
|
|
|
|
static void PrefAddVarCache(int32_t*, const char*, int32_t);
|
|
|
|
static void PrefAddVarCache(uint32_t*, const char*, uint32_t);
|
|
|
|
static void PrefAddVarCache(float*, const char*, float);
|
2016-07-14 10:50:23 +03:00
|
|
|
static void PrefAddVarCache(AtomicUint32*, const char*, uint32_t);
|
2016-05-09 07:59:02 +03:00
|
|
|
|
|
|
|
static void AssertMainThread();
|
|
|
|
|
|
|
|
MediaPrefs();
|
|
|
|
MediaPrefs(const MediaPrefs&) = delete;
|
|
|
|
MediaPrefs& operator=(const MediaPrefs&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef DECL_MEDIA_PREF /* Don't need it outside of this file */
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MEDIA_PREFS_H */
|