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