From 6ef854d2676b3c57d5e528483a8ca30f3bee5344 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 4 Dec 2015 13:33:21 +1300 Subject: [PATCH] Bug 1230338 - Record video frames dropped by the compositor, or while flushing during skip-to-keyframe. r=jya --- dom/media/MediaFormatReader.cpp | 8 ++++++++ dom/media/VideoFrameContainer.h | 2 ++ dom/media/mediasink/VideoSink.cpp | 5 +++++ dom/media/mediasink/VideoSink.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 6271c2d28674..82b8a334335e 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -510,6 +510,14 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe, if (ShouldSkip(aSkipToNextKeyframe, timeThreshold)) { // Cancel any pending demux request. mVideo.mDemuxRequest.DisconnectIfExists(); + + // I think it's still possible for an output to have been sent from the decoder + // and is currently sitting in our event queue waiting to be processed. The following + // flush won't clear it, and when we return to the event loop it'll be added to our + // output queue and be used. + // This code will count that as dropped, which was the intent, but not quite true. + mDecoder->NotifyDecodedFrames(0, 0, SizeOfVideoQueueInFrames()); + Flush(TrackInfo::kVideoTrack); RefPtr p = mVideo.mPromise.Ensure(__func__); SkipVideoDemuxToNextKeyFrame(timeThreshold); diff --git a/dom/media/VideoFrameContainer.h b/dom/media/VideoFrameContainer.h index 40bacec38e0f..7c07299b0315 100644 --- a/dom/media/VideoFrameContainer.h +++ b/dom/media/VideoFrameContainer.h @@ -78,6 +78,8 @@ public: B2G_ACL_EXPORT ImageContainer* GetImageContainer(); void ForgetElement() { mElement = nullptr; } + uint32_t GetDroppedImageCount() { return mImageContainer->GetDroppedImageCount(); } + protected: void SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicSize, const nsTArray& aImages); diff --git a/dom/media/mediasink/VideoSink.cpp b/dom/media/mediasink/VideoSink.cpp index 5f39decb875e..112686ee5cf9 100644 --- a/dom/media/mediasink/VideoSink.cpp +++ b/dom/media/mediasink/VideoSink.cpp @@ -35,6 +35,7 @@ VideoSink::VideoSink(AbstractThread* aThread, , mRealTime(aRealTime) , mFrameStats(aFrameStats) , mVideoFrameEndTime(-1) + , mOldDroppedCount(0) , mHasVideo(false) , mUpdateScheduler(aThread) , mVideoQueueSendToCompositorSize(aVQueueSentToCompositerSize) @@ -327,6 +328,10 @@ VideoSink::RenderVideoFrames(int32_t aMaxFrames, frame->mTime, frame->mFrameID, VideoQueue().GetSize()); } mContainer->SetCurrentFrames(frames[0]->As()->mDisplay, images); + + uint32_t dropped = mContainer->GetDroppedImageCount(); + mFrameStats.NotifyDecodedFrames(0, 0, dropped - mOldDroppedCount); + mOldDroppedCount = dropped; } void diff --git a/dom/media/mediasink/VideoSink.h b/dom/media/mediasink/VideoSink.h index 0052c8da8627..c7c405d0c9b4 100644 --- a/dom/media/mediasink/VideoSink.h +++ b/dom/media/mediasink/VideoSink.h @@ -129,6 +129,8 @@ private: // in microseconds. int64_t mVideoFrameEndTime; + uint32_t mOldDroppedCount; + // Event listeners for VideoQueue MediaEventListener mPushListener;