summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js')
-rw-r--r--dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js b/dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js
new file mode 100644
index 0000000000..d0c647be0d
--- /dev/null
+++ b/dom/media/webrtc/tests/mochitests/peerconnection_audio_forced_sample_rate.js
@@ -0,0 +1,32 @@
+// This function takes a sample-rate, and tests that audio flows correctly when
+// the sampling-rate at which the MTG runs is not one of the sampling-rates that
+// the MediaPipeline can work with.
+// It is in a separate file because we have an MTG per document, and we want to
+// test multiple sample-rates, so we include it in multiple HTML mochitest
+// files.
+async function test_peerconnection_audio_forced_sample_rate(forcedSampleRate) {
+ await scriptsReady;
+ await pushPrefs(["media.cubeb.force_sample_rate", forcedSampleRate]);
+ await runNetworkTest(function (options) {
+ const test = new PeerConnectionTest(options);
+ const ac = new AudioContext();
+ test.setMediaConstraints([{ audio: true }], []);
+ test.chain.replace("PC_LOCAL_GUM", [
+ function PC_LOCAL_WEBAUDIO_SOURCE(test) {
+ const oscillator = ac.createOscillator();
+ oscillator.type = "sine";
+ oscillator.frequency.value = 700;
+ oscillator.start();
+ const 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);
+ },
+ ]);
+ return test.run();
+ });
+}