blob: 356517e79ff1e5a1feb964932b6fe03a66582785 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!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">
<video id="video" width="160" height="120" autoplay></video>
<script type="application/javascript">
createHTML({
bug: "1709481",
title: "replaceTrack (null -> camera) test",
visible: true
});
runNetworkTest(async () => {
// Make sure we use the fake video device, and not loopback
await pushPrefs(
['media.video_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);
pc2.ontrack = ({track}) => video.srcObject = new MediaStream([track]);
pc1.addTransceiver("audio");
const tc1 = pc1.addTransceiver("video");
const stream = await navigator.mediaDevices.getUserMedia({video: true});
const [track] = stream.getVideoTracks();
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 VideoStreamHelper();
await h.checkVideoPlaying(video);
pc1.close();
pc2.close();
await SpecialPowers.popPrefEnv();
});
</script>
</pre>
</body>
</html>
|