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