Bug 1595994 - P5: Agnostic PDM reports supported mime types for current process. r=kamidphish

Depends on D54875

Differential Revision: https://phabricator.services.mozilla.com/D54877
This commit is contained in:
Dan Glastonbury 2020-10-20 23:24:48 +00:00
Родитель 7ef0bd86bd
Коммит 9ef1beee14
1 изменённых файлов: 79 добавлений и 45 удалений

Просмотреть файл

@ -20,10 +20,47 @@
namespace mozilla { namespace mozilla {
bool AgnosticDecoderModule::SupportsMimeType( enum class DecoderType {
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const { #ifdef MOZ_AV1
bool supports = AV1,
VPXDecoder::IsVPX(aMimeType) || TheoraDecoder::IsTheora(aMimeType); #endif
Opus,
Theora,
Vorbis,
VPX,
Wave,
};
static bool IsAvailableInDefault(DecoderType type) {
switch (type) {
#ifdef MOZ_AV1
case DecoderType::AV1:
// We remove support for decoding AV1 here if RDD is enabled so that
// decoding on the content process doesn't accidentally happen in case
// something goes wrong with launching the RDD process.
return StaticPrefs::media_av1_enabled() &&
!StaticPrefs::media_rdd_process_enabled();
#endif
case DecoderType::Opus:
case DecoderType::Theora:
case DecoderType::Vorbis:
case DecoderType::VPX:
case DecoderType::Wave:
return true;
default:
return false;
}
}
static bool IsAvailableInRdd(DecoderType type) {
switch (type) {
#ifdef MOZ_AV1
case DecoderType::AV1:
return StaticPrefs::media_av1_enabled();
#endif
case DecoderType::Opus:
return StaticPrefs::media_rdd_opus_enabled();
case DecoderType::Vorbis:
#if defined(__MINGW32__) #if defined(__MINGW32__)
// If this is a MinGW build we need to force AgnosticDecoderModule to // If this is a MinGW build we need to force AgnosticDecoderModule to
// handle the decision to support Vorbis decoding (instead of // handle the decision to support Vorbis decoding (instead of
@ -32,33 +69,39 @@ bool AgnosticDecoderModule::SupportsMimeType(
// would be dealt with using defines in StaticPrefList.yaml, but we // would be dealt with using defines in StaticPrefList.yaml, but we
// must handle it here because of Bug 1598426 (the __MINGW32__ define // must handle it here because of Bug 1598426 (the __MINGW32__ define
// isn't supported in StaticPrefList.yaml). // isn't supported in StaticPrefList.yaml).
supports |= VorbisDataDecoder::IsVorbis(aMimeType); return false;
#else #else
if (!StaticPrefs::media_rdd_vorbis_enabled() || return StaticPrefs::media_rdd_vorbis_enabled();
!StaticPrefs::media_rdd_process_enabled() ||
!BrowserTabsRemoteAutostart()) {
supports |= VorbisDataDecoder::IsVorbis(aMimeType);
}
#endif #endif
if (!StaticPrefs::media_rdd_wav_enabled() || case DecoderType::Wave:
!StaticPrefs::media_rdd_process_enabled() || return StaticPrefs::media_rdd_wav_enabled();
!BrowserTabsRemoteAutostart()) { default:
supports |= WaveDataDecoder::IsWave(aMimeType); return false;
} }
if (!StaticPrefs::media_rdd_opus_enabled() ||
!StaticPrefs::media_rdd_process_enabled() ||
!BrowserTabsRemoteAutostart()) {
supports |= OpusDataDecoder::IsOpus(aMimeType);
} }
// Checks if decoder is available in the current process
static bool IsAvailable(DecoderType type) {
return XRE_IsRDDProcess() ? IsAvailableInRdd(type)
: IsAvailableInDefault(type);
}
bool AgnosticDecoderModule::SupportsMimeType(
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
bool supports =
#ifdef MOZ_AV1 #ifdef MOZ_AV1
// We remove support for decoding AV1 here if RDD is enabled so that // We remove support for decoding AV1 here if RDD is enabled so that
// decoding on the content process doesn't accidentally happen in case // decoding on the content process doesn't accidentally happen in case
// something goes wrong with launching the RDD process. // something goes wrong with launching the RDD process.
if (StaticPrefs::media_av1_enabled() && (AOMDecoder::IsAV1(aMimeType) && IsAvailable(DecoderType::AV1)) ||
!StaticPrefs::media_rdd_process_enabled()) {
supports |= AOMDecoder::IsAV1(aMimeType);
}
#endif #endif
(VPXDecoder::IsVPX(aMimeType) && IsAvailable(DecoderType::VPX)) ||
(TheoraDecoder::IsTheora(aMimeType) &&
IsAvailable(DecoderType::Theora)) ||
(VorbisDataDecoder::IsVorbis(aMimeType) &&
IsAvailable(DecoderType::Vorbis)) ||
(WaveDataDecoder::IsWave(aMimeType) && IsAvailable(DecoderType::Wave)) ||
(OpusDataDecoder::IsOpus(aMimeType) && IsAvailable(DecoderType::Opus));
MOZ_LOG(sPDMLog, LogLevel::Debug, MOZ_LOG(sPDMLog, LogLevel::Debug,
("Agnostic decoder %s requested type", ("Agnostic decoder %s requested type",
supports ? "supports" : "rejects")); supports ? "supports" : "rejects"));
@ -74,9 +117,7 @@ already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateVideoDecoder(
} }
#ifdef MOZ_AV1 #ifdef MOZ_AV1
// see comment above about AV1 and the RDD process // see comment above about AV1 and the RDD process
else if (AOMDecoder::IsAV1(aParams.mConfig.mMimeType) && else if (AOMDecoder::IsAV1(aParams.mConfig.mMimeType)) {
!StaticPrefs::media_rdd_process_enabled() &&
StaticPrefs::media_av1_enabled()) {
if (StaticPrefs::media_av1_use_dav1d()) { if (StaticPrefs::media_av1_use_dav1d()) {
m = new DAV1DDecoder(aParams); m = new DAV1DDecoder(aParams);
} else { } else {
@ -99,14 +140,7 @@ already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateAudioDecoder(
if (VorbisDataDecoder::IsVorbis(config.mMimeType)) { if (VorbisDataDecoder::IsVorbis(config.mMimeType)) {
m = new VorbisDataDecoder(aParams); m = new VorbisDataDecoder(aParams);
} else if (OpusDataDecoder::IsOpus(config.mMimeType)) { } else if (OpusDataDecoder::IsOpus(config.mMimeType)) {
CreateDecoderParams params(aParams); m = new OpusDataDecoder(aParams);
// Check IsDefaultPlaybackDeviceMono here and set the option in
// mOptions so OpusDataDecoder doesn't have to do it later (in case
// it is running on RDD).
if (IsDefaultPlaybackDeviceMono()) {
params.mOptions += CreateDecoderParams::Option::DefaultPlaybackDeviceMono;
}
m = new OpusDataDecoder(params);
} else if (WaveDataDecoder::IsWave(config.mMimeType)) { } else if (WaveDataDecoder::IsWave(config.mMimeType)) {
m = new WaveDataDecoder(aParams); m = new WaveDataDecoder(aParams);
} }