Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: content/test/data/media/webrtc_test_audio.js

Issue 220403006: Revert of Tighten up webrtc audio tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/data/media/peerconnection-call.html ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/media/webrtc_test_audio.js
diff --git a/content/test/data/media/webrtc_test_audio.js b/content/test/data/media/webrtc_test_audio.js
index 52c7d3897daf7e508c6545315e0263069ce72417..40668c6d38180c9e3b96f1de13d26f8a5ae6a41c 100644
--- a/content/test/data/media/webrtc_test_audio.js
+++ b/content/test/data/media/webrtc_test_audio.js
@@ -3,9 +3,6 @@
// found in the LICENSE file.
// Audio test utilities.
-
-// GetStats reports audio output energy in the [0, 32768] range.
-var MAX_AUDIO_OUTPUT_ENERGY = 32768;
// Gathers |numSamples| samples at |frequency| number of times per second and
// calls back |callback| with an array with numbers in the [0, 32768] range.
@@ -25,29 +22,28 @@
}, 1000 / frequency);
}
-// Tries to identify the beep-every-half-second signal generated by the fake
-// audio device in media/video/capture/fake_video_capture_device.cc. Fails the
-// test if we can't see a signal. The samples should have been gathered over at
-// least two seconds since we expect to see at least three "peaks" in there
-// (we should see either 3 or 4 depending on how things line up).
+// Tries to identify the beep-every-second signal generated by the fake audio
+// media/audio/fake_audio_input_stream.cc. Fails the test if we can't see a
+// signal.
function verifyAudioIsPlaying(samples) {
- var numPeaks = 0;
- var threshold = MAX_AUDIO_OUTPUT_ENERGY * 0.7;
- var currentlyOverThreshold = false;
+ var average = 0;
+ for (var i = 0; i < samples.length; ++i)
+ average += samples[i] / samples.length;
- // Detect when we have been been over the threshold and is going back again
- // (i.e. count peaks). We should see about one peak per second.
- for (var i = 0; i < samples.length; ++i) {
- if (currentlyOverThreshold && samples[i] < threshold)
- numPeaks++;
- currentlyOverThreshold = samples[i] >= threshold;
- }
+ var largest = 0;
+ for (var i = 0; i < samples.length; ++i)
+ largest = Math.max(largest, samples[i]);
- console.log('Number of peaks identified: ' + numPeaks);
+ console.log('Average audio level: ' + average + ', largest: ' + largest);
- if (numPeaks < 2)
- failTest('Expected to see at least two peaks in audio signal, got ' +
- numPeaks + '. Dumping samples for analysis: "' + samples + '"');
+ // TODO(phoglund): Make a more sophisticated curve-fitting algorithm. We want
+ // to see a number of peaks with relative silence between them. The following
+ // seems to work fine on a nexus 7.
+ if (average < 3000 || average > 8000)
+ failTest('Unexpected avg audio level: got ' + average + ', expected it ' +
+ 'to be 4000 < avg < 8000.');
+ if (largest < 25000)
+ failTest('Too low max audio level: got ' + largest + ', expected > 30000.');
}
// If silent (like when muted), we should get very near zero audio level.
« no previous file with comments | « content/test/data/media/peerconnection-call.html ('k') | media/video/capture/fake_video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698