Bug 1437366 - Test that sending and receiving audio when using a graph with a sample-rate that is not supported by the MediaPipeline code works. r=pehrsons, a=jcristau
authorPaul Adenot <paul@paul.cx>
Mon, 05 Mar 2018 14:53:09 +0100
changeset 463340 d755d3934e22335d200033570e3a1ec9b012cae5
parent 463339 522585f451f4b90c0cac50cc2305a9105efe8a29
child 463341 323d9687b9cd49ac8a471ee042253d7db6b86965
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons, jcristau
bugs1437366
milestone60.0
Bug 1437366 - Test that sending and receiving audio when using a graph with a sample-rate that is not supported by the MediaPipeline code works. r=pehrsons, a=jcristau MozReview-Commit-ID: 4c5zgkYCX2T
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/peerconnection_audio_forced_sample_rate.js
dom/media/tests/mochitest/test_peerConnection_basicAudio_forced_higher_rate.html
dom/media/tests/mochitest/test_peerConnection_basicAudio_forced_lower_rate.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -10,16 +10,17 @@ support-files =
   pc.js
   templates.js
   NetworkPreparationChromeScript.js
   blacksilence.js
   turnConfig.js
   sdpUtils.js
   addTurnsSelfsignedCert.js
   parser_rtp.js
+  peerconnection_audio_forced_sample_rate.js
   !/dom/canvas/test/captureStream_common.js
   !/dom/canvas/test/webgl-mochitest/webgl-util.js
   !/dom/media/test/manifest.js
   !/dom/media/test/320x240.ogv
   !/dom/media/test/r11025_s16_c1.wav
   !/dom/media/test/bug461281.ogg
   !/dom/media/test/seek.webm
   !/dom/media/test/gizmo.mp4
@@ -101,16 +102,18 @@ skip-if = toolkit == 'android' # no scre
 [test_peerConnection_addtrack_removetrack_events.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_audioCodecs.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_transceivers.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_basicAudio.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
+[test_peerConnection_basicAudio_forced_lower_rate.html]
+[test_peerConnection_basicAudio_forced_higher_rate.html]
 [test_peerConnection_audioSynchronizationSources.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_audioSynchronizationSourcesUnidirectional.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_audioContributingSources.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_checkPacketDumpHook.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/peerconnection_audio_forced_sample_rate.js
@@ -0,0 +1,38 @@
+// This function takes a sample-rate, and tests that audio flows correctly when
+// the sampling-rate at which the MSG runs is not one of the sampling-rates that
+// the MediaPipeline can work with.
+// It is in a separate file because we have an MSG per document, and we want to
+// test multiple sample-rates, so we include it in multiple HTML mochitest
+// files.
+function test_peerconnection_audio_forced_sample_rate(forcedSampleRate) {
+  scriptsReady.then(function () {
+    pushPrefs(
+      ["media.cubeb.force_sample_rate", forcedSampleRate]
+    ).then(function () {
+      runNetworkTest(function (options) {
+        let test = new PeerConnectionTest(options);
+        let ac = new AudioContext();
+        test.setMediaConstraints([{
+          audio: true
+        }], []);
+        test.chain.replace("PC_LOCAL_GUM", [
+          function PC_LOCAL_WEBAUDIO_SOURCE(test) {
+            let oscillator = ac.createOscillator();
+            oscillator.type = 'sine';
+            oscillator.frequency.value = 700;
+            oscillator.start();
+            let dest = ac.createMediaStreamDestination();
+            oscillator.connect(dest);
+            test.pcLocal.attachLocalStream(dest.stream);
+          }
+        ]);
+        test.chain.append([
+          function CHECK_REMOTE_AUDIO_FLOW(test) {
+            return test.pcRemote.checkReceivingToneFrom(ac, test.pcLocal);
+          }
+        ]);
+        test.run();
+      });
+    });
+  })
+}
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_basicAudio_forced_higher_rate.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+  <script type="application/javascript" src="peerconnection_audio_forced_sample_rate.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    bug: "1437366",
+    title: "Basic audio-only peer connection, with the MSG running at a rate not supported by the MediaPipeline (96000Hz)"
+  });
+
+  test_peerconnection_audio_forced_sample_rate(96000);
+
+</script>
+</pre>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_basicAudio_forced_lower_rate.html
@@ -0,0 +1,20 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+  <script type="application/javascript" src="peerconnection_audio_forced_sample_rate.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  createHTML({
+    bug: "1437366",
+    title: "Basic audio-only peer connection, with the MSG running at a rate not supported by the MediaPipeline (24000Hz)"
+  });
+
+test_peerconnection_audio_forced_sample_rate(24000);
+
+</script>
+</pre>
+</body>
+</html>