cbe2c5
diff -up firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-99.0/dom/media/mp4/MP4Demuxer.cpp
cbe2c5
--- firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
cbe2c5
+++ firefox-99.0/dom/media/mp4/MP4Demuxer.cpp	2022-04-04 09:58:35.606351546 +0200
cbe2c5
@@ -31,6 +31,8 @@ mozilla::LogModule* GetDemuxerLog() { re
cbe2c5
   DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
cbe2c5
             __func__, ##__VA_ARGS__)
cbe2c5
 
cbe2c5
+extern bool gUseKeyframeFromContainer;
cbe2c5
+
cbe2c5
 namespace mozilla {
cbe2c5
 
cbe2c5
 DDLoggedTypeDeclNameAndBase(MP4TrackDemuxer, MediaTrackDemuxer);
cbe2c5
@@ -394,6 +396,12 @@ already_AddRefed<MediaRawData> MP4TrackD
cbe2c5
           [[fallthrough]];
cbe2c5
         case H264::FrameType::OTHER: {
cbe2c5
           bool keyframe = type == H264::FrameType::I_FRAME;
cbe2c5
+          if (gUseKeyframeFromContainer) {
cbe2c5
+            if (sample->mKeyframe && sample->mKeyframe != keyframe) {
cbe2c5
+              sample->mKeyframe = keyframe;
cbe2c5
+            }
cbe2c5
+            break;
cbe2c5
+          }
cbe2c5
           if (sample->mKeyframe != keyframe) {
cbe2c5
             NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
cbe2c5
                                        "@ pts:%" PRId64 " dur:%" PRId64
cbe2c5
diff -up firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-99.0/dom/media/platforms/PDMFactory.cpp
cbe2c5
--- firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
cbe2c5
+++ firefox-99.0/dom/media/platforms/PDMFactory.cpp	2022-04-04 10:09:57.383419125 +0200
cbe2c5
@@ -58,6 +58,8 @@
cbe2c5
 
cbe2c5
 #include <functional>
cbe2c5
 
cbe2c5
+bool gUseKeyframeFromContainer = false;
cbe2c5
+
cbe2c5
 namespace mozilla {
cbe2c5
 
cbe2c5
 #define PDM_INIT_LOG(msg, ...) \
cbe2c5
@@ -495,7 +497,7 @@ void PDMFactory::CreateRddPDMs() {
cbe2c5
 #ifdef MOZ_FFMPEG
cbe2c5
   if (StaticPrefs::media_ffmpeg_enabled() &&
cbe2c5
       StaticPrefs::media_rdd_ffmpeg_enabled() &&
cbe2c5
-      !CreateAndStartupPDM<FFmpegRuntimeLinker>()) {
cbe2c5
+      !(mFFmpegUsed = CreateAndStartupPDM<FFmpegRuntimeLinker>())) {
cbe2c5
     mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
cbe2c5
         FFmpegRuntimeLinker::LinkStatusCode());
cbe2c5
   }
cbe2c5
@@ -602,8 +604,9 @@ void PDMFactory::CreateDefaultPDMs() {
cbe2c5
 
cbe2c5
   CreateAndStartupPDM<AgnosticDecoderModule>();
cbe2c5
 
cbe2c5
-  if (StaticPrefs::media_gmp_decoder_enabled() &&
cbe2c5
+  if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
cbe2c5
       !CreateAndStartupPDM<GMPDecoderModule>()) {
cbe2c5
+    gUseKeyframeFromContainer = true;
cbe2c5
     mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
cbe2c5
   }
cbe2c5
 }
cbe2c5
diff -up firefox-99.0/dom/media/platforms/PDMFactory.h.1670333 firefox-99.0/dom/media/platforms/PDMFactory.h
cbe2c5
--- firefox-99.0/dom/media/platforms/PDMFactory.h.1670333	2022-03-31 01:24:44.000000000 +0200
cbe2c5
+++ firefox-99.0/dom/media/platforms/PDMFactory.h	2022-04-04 09:58:35.606351546 +0200
cbe2c5
@@ -121,6 +121,7 @@ class PDMFactory final {
cbe2c5
   RefPtr<PlatformDecoderModule> mNullPDM;
cbe2c5
 
cbe2c5
   DecoderDoctorDiagnostics::FlagsSet mFailureFlags;
cbe2c5
+  bool mFFmpegUsed = false;
cbe2c5
 
cbe2c5
   friend class RemoteVideoDecoderParent;
cbe2c5
   static void EnsureInit();