Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
<script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1709481",
title: "replaceTrack (null -> microphone) test",
visible: true
});
runNetworkTest(async () => {
// Make sure we use the fake audio device, and not loopback
await pushPrefs(
['media.audio_loopback_dev', ''],
['media.navigator.streams.fake', true]);
const pc1 = new RTCPeerConnection(), pc2 = new RTCPeerConnection();
pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);
let remoteStream;
pc2.ontrack = ({track}) => remoteStream = new MediaStream([track]);
const tc1 = pc1.addTransceiver("audio");
const stream = await navigator.mediaDevices.getUserMedia({audio: true});
const [track] = stream.getAudioTracks();
await pc1.setLocalDescription();
await pc2.setRemoteDescription(pc1.localDescription);
await pc2.setLocalDescription();
await pc1.setRemoteDescription(pc2.localDescription);
await wait(100);
await tc1.sender.replaceTrack(track);
const h = new AudioStreamFlowingHelper();
await h.checkAudioFlowing(remoteStream);
pc1.close();
pc2.close();
await SpecialPowers.popPrefEnv();
});
</script>
</pre>
</body>
</html>