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