diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index ef8e362dc..e8d699f53 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -2648,6 +2648,7 @@ HTMLMediaElement::ReportEMETelemetry() void HTMLMediaElement::ReportMSETelemetry() { +#if(0) // Report telemetry for videos when a page is unloaded. We // want to know data on what state the video is at when // the user has exited. @@ -2700,6 +2701,7 @@ HTMLMediaElement::ReportMSETelemetry() Telemetry::Accumulate(Telemetry::VIDEO_MSE_JOIN_LATENCY_MS, SECONDS_TO_MS(latency)); LOG(LogLevel::Debug, ("%p VIDEO_MSE_JOIN_LATENCY = %f (%d ms) count=%d\n", this, latency, SECONDS_TO_MS(latency), mJoinLatency.Count())); +#endif } void HTMLMediaElement::UnbindFromTree(bool aDeep, @@ -4236,12 +4238,14 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE UpdateSrcMediaStreamPlaying(); UpdateAudioChannelPlayingState(); if (aPauseElement) { +#if(0) if (mMediaSource) { ReportMSETelemetry(); #ifdef MOZ_EME ReportEMETelemetry(); #endif } +#endif #ifdef MOZ_EME // For EME content, force destruction of the CDM client (and CDM diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp index 599c5cf08..8e8262317 100644 --- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp @@ -12,6 +12,7 @@ #include "FFmpegLog.h" #include "FFmpegDataDecoder.h" #include "prsystem.h" +#include "prenv.h" #include "FFmpegRuntimeLinker.h" #include "libavutil/pixfmt.h" @@ -248,9 +249,8 @@ FFmpegDataDecoder::FindAVCodec(AVCodecID aCodec) StaticMutexAutoLock mon(sMonitor); if (!sFFmpegInitDone) { avcodec_register_all(); -#ifdef DEBUG - av_log_set_level(AV_LOG_DEBUG); -#endif + if (PR_GetEnv("AV_LOG_DEBUG")) + av_log_set_level(AV_LOG_DEBUG); sFFmpegInitDone = true; } return avcodec_find_decoder(aCodec); diff --git a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp index 0c614067c..c27ed3899 100644 --- a/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp @@ -16,6 +16,8 @@ #include "FFmpegLog.h" #include "mozilla/PodOperations.h" +#include "prtime.h" + typedef mozilla::layers::Image Image; typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage; @@ -30,6 +32,10 @@ FFmpegH264Decoder::PtsCorrectionContext::PtsCorrectionContext() { } +// PRIntervalTime is insufficient since the timeout length may be +// many seconds. +static PRTime sLockOutDueToOOM = 0L; + int64_t FFmpegH264Decoder::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts) { @@ -93,6 +99,12 @@ FFmpegH264Decoder::DecodeResult FFmpegH264Decoder::DoDecodeFrame(MediaRawData* aSample) { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); + if (PR_Now() < sLockOutDueToOOM) { + // Halt further allocations. + NS_WARNING("** FFMPEG LOCKED OUT DUE TO OUT OF MEMORY **"); + mCallback->Error(); + return DecodeResult::DECODE_ERROR; + } uint8_t* inputData = const_cast(aSample->Data()); size_t inputSize = aSample->Size(); @@ -140,6 +152,12 @@ FFmpegH264Decoder::DoDecodeFrame(MediaRawData* aSample, uint8_t* aData, int aSize) { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); + if (PR_Now() < sLockOutDueToOOM) { + // Halt further allocations. + NS_WARNING("** FFMPEG LOCKED OUT DUE TO OUT OF MEMORY **"); + mCallback->Error(); + return DecodeResult::DECODE_ERROR; + } AVPacket packet; av_init_packet(&packet); @@ -234,7 +252,9 @@ FFmpegH264Decoder::DoDecodeFrame(MediaRawData* aSample, -1, mImage); if (!v) { - NS_WARNING("image allocation error."); + int32_t lockout = 3; /* XXX: make a pref */ + fprintf(stderr, "Warning: TenFourFox ran out of memory trying to decode H.264 video.\nAny H.264 video on any page playing in the next %i seconds will be blocked.\n", lockout); + sLockOutDueToOOM = PR_Now() + ( PR_USEC_PER_SEC * lockout ); mCallback->Error(); return DecodeResult::DECODE_ERROR; } diff --git a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp index 486920f8c..e84cb5bee 100644 --- a/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp @@ -104,11 +104,9 @@ FFmpegRuntimeLinker::Link() #endif free(libFullPath); } - // Try also finding the library in ~/Library/ffmpeg. - if (!sLinkedLib && - PR_GetEnv("HOME") && - asprintf(&libFullPath, "%s/Library/ffmpeg/%s", PR_GetEnv("HOME"), lib) - > 0 && libFullPath) { + // Try also finding the library in ~/Library/TenFourFox-FFmpeg. + if (!sLinkedLib && PR_GetEnv("HOME") && + asprintf(&libFullPath, "%s/Library/TenFourFox-FFmpeg/%s", PR_GetEnv("HOME"), lib) > 0 && libFullPath) { #if DEBUG fprintf(stderr, "TenFourFox looking for FFmpeg: %s\n", libFullPath); #endif