From dbcfe9d22f1a4398f318a8b605cc592032669734 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Fri, 5 Jul 2013 12:24:55 +1200 Subject: [PATCH] Bug 889201 - Add tests for VideoPlaybackQuality. r=roc --- content/html/content/src/HTMLVideoElement.cpp | 31 +++++----- content/media/test/Makefile.in | 2 + .../media/test/test_VideoPlaybackQuality.html | 62 +++++++++++++++++++ .../test_VideoPlaybackQuality_disabled.html | 33 ++++++++++ dom/webidl/VideoPlaybackQuality.webidl | 1 + 5 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 content/media/test/test_VideoPlaybackQuality.html create mode 100644 content/media/test/test_VideoPlaybackQuality_disabled.html diff --git a/content/html/content/src/HTMLVideoElement.cpp b/content/html/content/src/HTMLVideoElement.cpp index 4fece4b3d38..04be2723087 100644 --- a/content/html/content/src/HTMLVideoElement.cpp +++ b/content/html/content/src/HTMLVideoElement.cpp @@ -262,24 +262,27 @@ already_AddRefed HTMLVideoElement::GetVideoPlaybackQuality() { DOMHighResTimeStamp creationTime = 0; - nsPIDOMWindow* window = OwnerDoc()->GetInnerWindow(); - if (window) { - nsPerformance* perf = window->GetPerformance(); - if (perf) { - creationTime = perf->GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now()); - } - } - uint64_t totalFrames = 0; uint64_t droppedFrames = 0; uint64_t corruptedFrames = 0; double playbackJitter = 0.0; - if (mDecoder && sVideoStatsEnabled) { - MediaDecoder::FrameStatistics& stats = mDecoder->GetFrameStatistics(); - totalFrames = stats.GetParsedFrames(); - droppedFrames = totalFrames - stats.GetPresentedFrames(); - corruptedFrames = totalFrames - stats.GetDecodedFrames(); - playbackJitter = stats.GetPlaybackJitter(); + + if (sVideoStatsEnabled) { + nsPIDOMWindow* window = OwnerDoc()->GetInnerWindow(); + if (window) { + nsPerformance* perf = window->GetPerformance(); + if (perf) { + creationTime = perf->GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now()); + } + } + + if (mDecoder) { + MediaDecoder::FrameStatistics& stats = mDecoder->GetFrameStatistics(); + totalFrames = stats.GetParsedFrames(); + droppedFrames = totalFrames - stats.GetPresentedFrames(); + corruptedFrames = totalFrames - stats.GetDecodedFrames(); + playbackJitter = stats.GetPlaybackJitter(); + } } nsRefPtr playbackQuality = diff --git a/content/media/test/Makefile.in b/content/media/test/Makefile.in index 63767c568c5..d1d936c05e0 100644 --- a/content/media/test/Makefile.in +++ b/content/media/test/Makefile.in @@ -141,6 +141,8 @@ MOCHITEST_FILES = \ test_texttrackcue.html \ test_timeupdate_small_files.html \ test_unseekable.html \ + test_VideoPlaybackQuality.html \ + test_VideoPlaybackQuality_disabled.html \ test_webvtt_disabled.html \ $(NULL) diff --git a/content/media/test/test_VideoPlaybackQuality.html b/content/media/test/test_VideoPlaybackQuality.html new file mode 100644 index 00000000000..968b10aec7d --- /dev/null +++ b/content/media/test/test_VideoPlaybackQuality.html @@ -0,0 +1,62 @@ + + + + Test basic functionality of VideoPlaybackQuality + + + + +
+
+
+ + diff --git a/content/media/test/test_VideoPlaybackQuality_disabled.html b/content/media/test/test_VideoPlaybackQuality_disabled.html new file mode 100644 index 00000000000..36f8a5c6e5d --- /dev/null +++ b/content/media/test/test_VideoPlaybackQuality_disabled.html @@ -0,0 +1,33 @@ + + + + Test basic functionality of VideoPlaybackQuality + + + + +
+
+
+ + diff --git a/dom/webidl/VideoPlaybackQuality.webidl b/dom/webidl/VideoPlaybackQuality.webidl index 5fb6b3e8205..62caa146663 100644 --- a/dom/webidl/VideoPlaybackQuality.webidl +++ b/dom/webidl/VideoPlaybackQuality.webidl @@ -12,6 +12,7 @@ [Pref="media.mediasource.enabled"] interface VideoPlaybackQuality { + readonly attribute DOMHighResTimeStamp creationTime; readonly attribute unsigned long totalVideoFrames; readonly attribute unsigned long droppedVideoFrames; readonly attribute unsigned long corruptedVideoFrames;