763d03
diff -up firefox-115.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-115.0/dom/media/mp4/MP4Demuxer.cpp
763d03
--- firefox-115.0/dom/media/mp4/MP4Demuxer.cpp.1670333	2023-06-06 23:14:43.000000000 +0200
763d03
+++ firefox-115.0/dom/media/mp4/MP4Demuxer.cpp	2023-06-08 08:15:48.214109403 +0200
763d03
@@ -32,6 +32,8 @@ mozilla::LogModule* GetDemuxerLog() { re
26f3ef
   DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
26f3ef
             __func__, ##__VA_ARGS__)
26f3ef
 
26f3ef
+extern bool gUseKeyframeFromContainer;
26f3ef
+
26f3ef
 namespace mozilla {
26f3ef
 
763d03
 using TimeUnit = media::TimeUnit;
763d03
@@ -404,6 +406,12 @@ already_AddRefed<MediaRawData> MP4TrackD
26f3ef
           [[fallthrough]];
26f3ef
         case H264::FrameType::OTHER: {
26f3ef
           bool keyframe = type == H264::FrameType::I_FRAME;
26f3ef
+          if (gUseKeyframeFromContainer) {
26f3ef
+            if (sample->mKeyframe && sample->mKeyframe != keyframe) {
26f3ef
+              sample->mKeyframe = keyframe;
26f3ef
+            }
26f3ef
+            break;
26f3ef
+          }
26f3ef
           if (sample->mKeyframe != keyframe) {
26f3ef
             NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
26f3ef
                                        "@ pts:%" PRId64 " dur:%" PRId64
763d03
diff -up firefox-115.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-115.0/dom/media/platforms/PDMFactory.cpp
763d03
--- firefox-115.0/dom/media/platforms/PDMFactory.cpp.1670333	2023-06-06 23:14:44.000000000 +0200
763d03
+++ firefox-115.0/dom/media/platforms/PDMFactory.cpp	2023-06-08 08:09:33.145289602 +0200
763d03
@@ -67,6 +67,8 @@
26f3ef
 
26f3ef
 #include <functional>
26f3ef
 
26f3ef
+bool gUseKeyframeFromContainer = false;
26f3ef
+
763d03
 using DecodeSupport = mozilla::media::DecodeSupport;
763d03
 using DecodeSupportSet = mozilla::media::DecodeSupportSet;
763d03
 using MediaCodec = mozilla::media::MediaCodec;
763d03
@@ -562,7 +564,7 @@ void PDMFactory::CreateRddPDMs() {
26f3ef
 #ifdef MOZ_FFMPEG
26f3ef
   if (StaticPrefs::media_ffmpeg_enabled() &&
26f3ef
       StaticPrefs::media_rdd_ffmpeg_enabled() &&
26f3ef
-      !CreateAndStartupPDM<FFmpegRuntimeLinker>()) {
26f3ef
+      !(mFFmpegUsed = CreateAndStartupPDM<FFmpegRuntimeLinker>())) {
26f3ef
     mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
26f3ef
         FFmpegRuntimeLinker::LinkStatusCode());
26f3ef
   }
763d03
@@ -738,9 +740,10 @@ void PDMFactory::CreateDefaultPDMs() {
26f3ef
 
26f3ef
   CreateAndStartupPDM<AgnosticDecoderModule>();
26f3ef
 
26f3ef
-  if (StaticPrefs::media_gmp_decoder_enabled() &&
26f3ef
+  if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
763d03
       !StartupPDM(GMPDecoderModule::Create(),
763d03
                   StaticPrefs::media_gmp_decoder_preferred())) {
26f3ef
+    gUseKeyframeFromContainer = true;
26f3ef
     mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
26f3ef
   }
26f3ef
 }
763d03
diff -up firefox-115.0/dom/media/platforms/PDMFactory.h.1670333 firefox-115.0/dom/media/platforms/PDMFactory.h
763d03
--- firefox-115.0/dom/media/platforms/PDMFactory.h.1670333	2023-06-06 23:14:42.000000000 +0200
763d03
+++ firefox-115.0/dom/media/platforms/PDMFactory.h	2023-06-08 08:09:33.145289602 +0200
763d03
@@ -103,6 +103,7 @@ class PDMFactory final {
26f3ef
   RefPtr<PlatformDecoderModule> mNullPDM;
26f3ef
 
26f3ef
   DecoderDoctorDiagnostics::FlagsSet mFailureFlags;
26f3ef
+  bool mFFmpegUsed = false;
26f3ef
 
26f3ef
   friend class RemoteVideoDecoderParent;
26f3ef
   static void EnsureInit();