Bug 895754 - Update VideoPlaybackQuality to current MSE spec (remove playbackJitter, add totalFrameDelay). r=doublec

This commit is contained in:
Matthew Gregan 2013-07-24 11:46:43 +12:00
parent f6f620d05f
commit b12e013aba
7 changed files with 28 additions and 28 deletions

View File

@ -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<VideoPlaybackQuality> playbackQuality =
new VideoPlaybackQuality(this, creationTime, totalFrames, droppedFrames,
corruptedFrames, playbackJitter);
corruptedFrames, totalFrameDelay);
return playbackQuality.forget();
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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

View File

@ -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();
});

View File

@ -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;
};