summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 10:02:51 +0000
committerphoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 10:02:51 +0000
commitde31638a9e61f7f5db0f5a6eba9036a7998e70ae (patch)
treeb89f04c9d49ce6f1c30983d1f9089054c071bebd /content
parent5146c67157052a064bcdd22e014496fa377b9d9b (diff)
downloadchromium_src-de31638a9e61f7f5db0f5a6eba9036a7998e70ae.zip
chromium_src-de31638a9e61f7f5db0f5a6eba9036a7998e70ae.tar.gz
chromium_src-de31638a9e61f7f5db0f5a6eba9036a7998e70ae.tar.bz2
Revert 260913 "Revert of Tighten up webrtc audio tests. (https:/..."
> Revert of Tighten up webrtc audio tests. (https://codereview.chromium.org/216523003/) > > Reason for revert: > This might have resulted in some flaky tests. This failure happened two builds after the patch landed. > > http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%282%29/builds/10598 > > See bug for more details. > > BUG=358759 > > Original issue's description: > > Tighten up webrtc audio tests. > > > > See http://goo.gl/LDae10. I'm trying to improve this algorithm. We used to > > check that some value was high enough and that the average was in the right > > ballpark. The new algorithm will count falling edges in the peaks instead, > > as a means to detect the peaks in the audio signal. The algorithm reliably > > yields one peak per second of sampled audio, which is correct because the > > audio signal beeps at 1 Hz. To get some margin, I'm sampling four seconds > > and checking that I get at least two peaks, which should be a rock solid > > assumption even on slow machines. > > > > BUG=357287,357626 > > R=perkj@chromium.org > > NOTRY=True > > (passed all trybots, just got stuck on a broken win trybot) > > > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=260878 > > TBR=perkj@chromium.org,phoglund@chromium.org > NOTREECHECKS=true > NOTRY=true > BUG=357287,357626 > > Review URL: https://codereview.chromium.org/220403006 TBR=rlarocque@chromium.org Review URL: https://codereview.chromium.org/217423019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/test/data/media/peerconnection-call.html12
-rw-r--r--content/test/data/media/webrtc_test_audio.js40
2 files changed, 28 insertions, 24 deletions
diff --git a/content/test/data/media/peerconnection-call.html b/content/test/data/media/peerconnection-call.html
index 2327647..57658fa 100644
--- a/content/test/data/media/peerconnection-call.html
+++ b/content/test/data/media/peerconnection-call.html
@@ -63,7 +63,7 @@
waitForVideo('remote-view-2');
}
- // Test that we can setup call with an audio and video track and check that
+ // Test that we can setup call with an audio and video track and check that
// the video resolution is as expected.
function callAndExpectResolution(constraints,
expected_width,
@@ -308,8 +308,8 @@
// Wait until we have gathered samples and can conclude if audio is playing.
addExpectedEvent();
var onCallEstablished = function() {
- gatherAudioLevelSamples(gSecondConnection, 300, 100,
- function(samples) {
+ // Gather 50 samples per second for 2 seconds.
+ gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
verifyAudioIsPlaying(samples);
eventOccured();
});
@@ -329,7 +329,7 @@
enableRemoteAudio(gSecondConnection, false);
setTimeout(function() {
- gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) {
+ gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
verifyIsSilent(samples);
reportTestSuccess();
});
@@ -348,11 +348,11 @@
}, 500);
setTimeout(function() {
- gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) {
+ gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
verifyAudioIsPlaying(samples);
reportTestSuccess();
});
- }, 1000);
+ }, 1500);
});
}
diff --git a/content/test/data/media/webrtc_test_audio.js b/content/test/data/media/webrtc_test_audio.js
index 40668c6..52c7d38 100644
--- a/content/test/data/media/webrtc_test_audio.js
+++ b/content/test/data/media/webrtc_test_audio.js
@@ -4,6 +4,9 @@
// 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.
function gatherAudioLevelSamples(peerConnection, numSamples, frequency,
@@ -22,28 +25,29 @@ function gatherAudioLevelSamples(peerConnection, numSamples, frequency,
}, 1000 / frequency);
}
-// 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.
+// 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).
function verifyAudioIsPlaying(samples) {
- var average = 0;
- for (var i = 0; i < samples.length; ++i)
- average += samples[i] / samples.length;
+ var numPeaks = 0;
+ var threshold = MAX_AUDIO_OUTPUT_ENERGY * 0.7;
+ var currentlyOverThreshold = false;
- var largest = 0;
- for (var i = 0; i < samples.length; ++i)
- largest = Math.max(largest, samples[i]);
+ // 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;
+ }
- console.log('Average audio level: ' + average + ', largest: ' + largest);
+ console.log('Number of peaks identified: ' + numPeaks);
- // 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 (numPeaks < 2)
+ failTest('Expected to see at least two peaks in audio signal, got ' +
+ numPeaks + '. Dumping samples for analysis: "' + samples + '"');
}
// If silent (like when muted), we should get very near zero audio level.