diff --git a/content/html/content/src/HTMLVideoElement.cpp b/content/html/content/src/HTMLVideoElement.cpp index 6ebc4576c9a5..07d7fa47cfef 100644 --- a/content/html/content/src/HTMLVideoElement.cpp +++ b/content/html/content/src/HTMLVideoElement.cpp @@ -264,7 +264,7 @@ HTMLVideoElement::GetVideoPlaybackQuality() uint64_t totalFrames = 0; uint64_t droppedFrames = 0; uint64_t corruptedFrames = 0; - double playbackJitter = 0.0; + double totalFrameDelay = 0.0; if (sVideoStatsEnabled) { nsPIDOMWindow* window = OwnerDoc()->GetInnerWindow(); @@ -280,13 +280,13 @@ HTMLVideoElement::GetVideoPlaybackQuality() totalFrames = stats.GetParsedFrames(); droppedFrames = totalFrames - stats.GetPresentedFrames(); corruptedFrames = totalFrames - stats.GetDecodedFrames(); - playbackJitter = stats.GetPlaybackJitter(); + totalFrameDelay = stats.GetTotalFrameDelay(); } } nsRefPtr playbackQuality = new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames, - corruptedFrames, playbackJitter); + corruptedFrames, totalFrameDelay); return playbackQuality.forget(); } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 343e8ec47de5..fa8ea35f1f53 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -818,7 +818,7 @@ public: FrameStatistics() : mReentrantMonitor("MediaDecoder::FrameStats"), - mPlaybackJitter(0.0), + mTotalFrameDelay(0.0), mParsedFrames(0), mDecodedFrames(0), mPresentedFrames(0) {} @@ -845,9 +845,9 @@ public: return mPresentedFrames; } - double GetPlaybackJitter() { + double GetTotalFrameDelay() { ReentrantMonitorAutoEnter mon(mReentrantMonitor); - return mPlaybackJitter; + return mTotalFrameDelay; } // Increments the parsed and decoded frame counters by the passed in counts. @@ -867,11 +867,11 @@ public: ++mPresentedFrames; } - // Tracks the sum of display errors. + // Tracks the sum of display delay. // Can be called on any thread. - void NotifyPlaybackJitter(double aDisplayError) { + void NotifyFrameDelay(double aFrameDelay) { ReentrantMonitorAutoEnter mon(mReentrantMonitor); - mPlaybackJitter += aDisplayError; + mTotalFrameDelay += aFrameDelay; } private: @@ -879,20 +879,20 @@ public: // ReentrantMonitor to protect access of playback statistics. ReentrantMonitor mReentrantMonitor; - // Sum of display duration error. - // Access protected by mStatsReentrantMonitor. - double mPlaybackJitter; + // Sum of displayed frame delays. + // Access protected by mReentrantMonitor. + double mTotalFrameDelay; // Number of frames parsed and demuxed from media. - // Access protected by mStatsReentrantMonitor. + // Access protected by mReentrantMonitor. uint32_t mParsedFrames; // Number of parsed frames which were actually decoded. - // Access protected by mStatsReentrantMonitor. + // Access protected by mReentrantMonitor. uint32_t mDecodedFrames; // Number of decoded frames which were actually sent down the rendering - // pipeline to be painted ("presented"). Access protected by mStatsReentrantMonitor. + // pipeline to be painted ("presented"). Access protected by mReentrantMonitor. uint32_t mPresentedFrames; }; diff --git a/content/media/MediaDecoderStateMachine.cpp b/content/media/MediaDecoderStateMachine.cpp index 209a982db153..f35977a5743a 100644 --- a/content/media/MediaDecoderStateMachine.cpp +++ b/content/media/MediaDecoderStateMachine.cpp @@ -2540,10 +2540,10 @@ void MediaDecoderStateMachine::AdvanceFrame() } MediaDecoder::FrameStatistics& frameStats = mDecoder->GetFrameStatistics(); frameStats.NotifyPresentedFrame(); + double frameDelay = double(clock_time - currentFrame->mTime) / USECS_PER_S; + NS_ASSERTION(frameDelay >= 0.0, "Frame should never be displayed early."); + frameStats.NotifyFrameDelay(frameDelay); remainingTime = currentFrame->mEndTime - clock_time; - int64_t frameDuration = currentFrame->mEndTime - currentFrame->mTime; - double displayError = fabs(double(frameDuration - remainingTime) / USECS_PER_S); - frameStats.NotifyPlaybackJitter(displayError); currentFrame = nullptr; } diff --git a/content/media/VideoPlaybackQuality.cpp b/content/media/VideoPlaybackQuality.cpp index 247f45ae4cd4..f2d1a9df0074 100644 --- a/content/media/VideoPlaybackQuality.cpp +++ b/content/media/VideoPlaybackQuality.cpp @@ -21,13 +21,13 @@ VideoPlaybackQuality::VideoPlaybackQuality(HTMLMediaElement* aElement, uint64_t aTotalFrames, uint64_t aDroppedFrames, uint64_t aCorruptedFrames, - double aPlaybackJitter) + double aTotalFrameDelay) : mElement(aElement) , mCreationTime(aCreationTime) , mTotalFrames(aTotalFrames) , mDroppedFrames(aDroppedFrames) , mCorruptedFrames(aCorruptedFrames) - , mPlaybackJitter(aPlaybackJitter) + , mTotalFrameDelay(aTotalFrameDelay) { SetIsDOMBinding(); } diff --git a/content/media/VideoPlaybackQuality.h b/content/media/VideoPlaybackQuality.h index d29db7c599b2..3921a75475b7 100644 --- a/content/media/VideoPlaybackQuality.h +++ b/content/media/VideoPlaybackQuality.h @@ -23,7 +23,7 @@ public: VideoPlaybackQuality(HTMLMediaElement* aElement, DOMHighResTimeStamp aCreationTime, uint64_t aTotalFrames, uint64_t aDroppedFrames, - uint64_t aCorruptedFrames, double aPlaybackJitter); + uint64_t aCorruptedFrames, double aTotalFrameDelay); HTMLMediaElement* GetParentObject() const; @@ -49,9 +49,9 @@ public: return mCorruptedFrames; } - double PlaybackJitter() + double TotalFrameDelay() { - return mPlaybackJitter; + return mTotalFrameDelay; } private: @@ -60,7 +60,7 @@ private: uint64_t mTotalFrames; uint64_t mDroppedFrames; uint64_t mCorruptedFrames; - double mPlaybackJitter; + double mTotalFrameDelay; }; } // namespace dom diff --git a/content/media/test/test_VideoPlaybackQuality.html b/content/media/test/test_VideoPlaybackQuality.html index bdd804989b22..962e3760e44c 100644 --- a/content/media/test/test_VideoPlaybackQuality.html +++ b/content/media/test/test_VideoPlaybackQuality.html @@ -21,7 +21,7 @@ function test() { is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0"); is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0"); is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0"); - is(vpq.playbackJitter, 0, "playbackJitter should be 0"); + is(vpq.totalFrameDelay, 0, "totalFrameDelay should be 0"); var vpq2 = video.getVideoPlaybackQuality(); ok(vpq !== vpq2, "getVideoPlaybackQuality should return a new object"); @@ -38,7 +38,7 @@ function test() { ok(vpq.totalVideoFrames > 0, "totalVideoFrames should be > 0"); ok(vpq.droppedVideoFrames >= 0, "droppedVideoFrames should be >= 0"); ok(vpq.corruptedVideoFrames >= 0, "corruptedVideoFrames should be >= 0"); - ok(vpq.playbackJitter >= 0, "playbackJitter should be >= 0"); + ok(vpq.totalFrameDelay >= 0, "totalFrameDelay should be >= 0"); SpecialPowers.pushPrefEnv({"set": [["media.video_stats.enabled", false]]}, function () { vpq = video.getVideoPlaybackQuality(); @@ -46,7 +46,7 @@ function test() { is(vpq.totalVideoFrames, 0, "totalVideoFrames should be 0"); is(vpq.droppedVideoFrames, 0, "droppedVideoFrames should be 0"); is(vpq.corruptedVideoFrames, 0, "corruptedVideoFrames should be 0"); - is(vpq.playbackJitter, 0, "playbackJitter should be 0"); + is(vpq.totalFrameDelay, 0, "totalFrameDelay should be 0"); SimpleTest.finish(); }); diff --git a/dom/webidl/VideoPlaybackQuality.webidl b/dom/webidl/VideoPlaybackQuality.webidl index 62caa146663e..737bed305c81 100644 --- a/dom/webidl/VideoPlaybackQuality.webidl +++ b/dom/webidl/VideoPlaybackQuality.webidl @@ -16,6 +16,6 @@ interface VideoPlaybackQuality { readonly attribute unsigned long totalVideoFrames; readonly attribute unsigned long droppedVideoFrames; readonly attribute unsigned long corruptedVideoFrames; - readonly attribute double playbackJitter; + readonly attribute double totalFrameDelay; };