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