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 draft
authorPaul Adenot <paul@paul.cx>
Mon, 05 Mar 2018 14:53:09 +0100
changeset 770000 31111b84bd7cbb07de54ac08ddd1ca9594316583
parent 769999 ac3bc24df5a1b0c3af0770048c4fcba7df03a6a5
child 770001 922364e4d9bccbc464a30000313dc2b304e1fe9f
push id103277
push userpaul@paul.cx
push dateTue, 20 Mar 2018 14:33:33 +0000
reviewerspehrsons
bugs1437366
milestone61.0a1
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 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
@@ -99,16 +100,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') || (os == 'linux' && debug) # android(Bug 1189784, timeouts on 4.3 emulator), Bug 1432025
 [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>