tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

peerconnection_audio_forced_sample_rate.js (1311B)


      1 // This function takes a sample-rate, and tests that audio flows correctly when
      2 // the sampling-rate at which the MTG runs is not one of the sampling-rates that
      3 // the MediaPipeline can work with.
      4 // It is in a separate file because we have an MTG per document, and we want to
      5 // test multiple sample-rates, so we include it in multiple HTML mochitest
      6 // files.
      7 async function test_peerconnection_audio_forced_sample_rate(forcedSampleRate) {
      8  await scriptsReady;
      9  await pushPrefs(["media.cubeb.force_sample_rate", forcedSampleRate]);
     10  await runNetworkTest(function (options) {
     11    const test = new PeerConnectionTest(options);
     12    const ac = new AudioContext();
     13    test.setMediaConstraints([{ audio: true }], []);
     14    test.chain.replace("PC_LOCAL_GUM", [
     15      function PC_LOCAL_WEBAUDIO_SOURCE(test) {
     16        const oscillator = ac.createOscillator();
     17        oscillator.type = "sine";
     18        oscillator.frequency.value = 700;
     19        oscillator.start();
     20        const dest = ac.createMediaStreamDestination();
     21        oscillator.connect(dest);
     22        test.pcLocal.attachLocalStream(dest.stream);
     23      },
     24    ]);
     25    test.chain.append([
     26      function CHECK_REMOTE_AUDIO_FLOW(test) {
     27        return test.pcRemote.checkReceivingToneFrom(ac, test.pcLocal);
     28      },
     29    ]);
     30    return test.run();
     31  });
     32 }