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