From 0737e57898d2ea09c84a6bcc4d946ac384dcd1b2 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 4 Apr 2024 15:02:31 +0000 Subject: [PATCH] Bug 1860492 - Add a pref to disable Theora playback, disable it on Nightly. r=media-playback-reviewers,alwu Differential Revision: https://phabricator.services.mozilla.com/D204052 --- dom/media/ogg/OggDecoder.cpp | 10 +++++++--- .../platforms/agnostic/AgnosticDecoderModule.cpp | 12 ++++++++---- modules/libpref/init/StaticPrefList.yaml | 6 ++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dom/media/ogg/OggDecoder.cpp b/dom/media/ogg/OggDecoder.cpp index 5f6d61f694c2..1bacafcf3e76 100644 --- a/dom/media/ogg/OggDecoder.cpp +++ b/dom/media/ogg/OggDecoder.cpp @@ -24,7 +24,10 @@ bool OggDecoder::IsSupportedType(const MediaContainerType& aContainerType) { return false; } - const bool isOggVideo = (aContainerType.Type() != MEDIAMIMETYPE(AUDIO_OGG)); + const bool isOggVideo = (aContainerType.Type() == MEDIAMIMETYPE(VIDEO_OGG)); + if (isOggVideo && !StaticPrefs::media_theora_enabled()) { + return false; + } const MediaCodecs& codecs = aContainerType.ExtendedType().Codecs(); if (codecs.IsEmpty()) { @@ -40,8 +43,9 @@ bool OggDecoder::IsSupportedType(const MediaContainerType& aContainerType) { } // Note: Only accept Theora in a video container type, not in an audio // container type. - if (isOggVideo && codec.EqualsLiteral("theora")) { - continue; + if (aContainerType.Type() != MEDIAMIMETYPE(AUDIO_OGG) && + codec.EqualsLiteral("theora")) { + return StaticPrefs::media_theora_enabled(); } // Some unsupported codec. return false; diff --git a/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp b/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp index 7bdc30b43248..753dee02381f 100644 --- a/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp +++ b/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp @@ -36,8 +36,9 @@ static bool IsAvailableInDefault(DecoderType type) { case DecoderType::AV1: return StaticPrefs::media_av1_enabled(); #endif - case DecoderType::Opus: case DecoderType::Theora: + return StaticPrefs::media_theora_enabled(); + case DecoderType::Opus: case DecoderType::Vorbis: case DecoderType::VPX: case DecoderType::Wave: @@ -56,7 +57,8 @@ static bool IsAvailableInRdd(DecoderType type) { case DecoderType::Opus: return StaticPrefs::media_rdd_opus_enabled(); case DecoderType::Theora: - return StaticPrefs::media_rdd_theora_enabled(); + return StaticPrefs::media_rdd_theora_enabled() && + StaticPrefs::media_theora_enabled(); case DecoderType::Vorbis: #if defined(__MINGW32__) // If this is a MinGW build we need to force AgnosticDecoderModule to @@ -129,7 +131,8 @@ media::DecodeSupportSet AgnosticDecoderModule::Supports( (AOMDecoder::IsAV1(mimeType) && IsAvailable(DecoderType::AV1)) || #endif (VPXDecoder::IsVPX(mimeType) && IsAvailable(DecoderType::VPX)) || - (TheoraDecoder::IsTheora(mimeType) && IsAvailable(DecoderType::Theora)); + (TheoraDecoder::IsTheora(mimeType) && IsAvailable(DecoderType::Theora) && + StaticPrefs::media_theora_enabled()); MOZ_LOG(sPDMLog, LogLevel::Debug, ("Agnostic decoder %s requested type '%s'", supports ? "supports" : "rejects", mimeType.BeginReading())); @@ -164,7 +167,8 @@ already_AddRefed AgnosticDecoderModule::CreateVideoDecoder( } } #endif - else if (TheoraDecoder::IsTheora(aParams.mConfig.mMimeType)) { + else if (TheoraDecoder::IsTheora(aParams.mConfig.mMimeType) && + StaticPrefs::media_theora_enabled()) { m = new TheoraDecoder(aParams); } diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 9ba3d123fae9..9d6cfd7f919e 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -11183,6 +11183,12 @@ mirror: always #endif +# Bug 1860492 - Deprecate and remove theora +- name: media.theora.enabled + type: RelaxedAtomicBool + value: @IS_NOT_NIGHTLY_BUILD@ + mirror: always + #--------------------------------------------------------------------------- # Prefs starting with "memory." #---------------------------------------------------------------------------