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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Remote tracks should not get ended except for stop/close</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script src='../mediacapture-streams/permission-helper.js'></script>
<script src="RTCPeerConnection-helper.js"></script>
</head>
<body>
<video id="video" controls autoplay playsinline></video>
<script>
let pc1, pc2;
let localTrack, remoteTrack;
promise_test(async (test) => {
await setMediaPermission("granted", ["microphone"]);
const localStream = await navigator.mediaDevices.getUserMedia({audio: true});
localTrack = localStream.getAudioTracks()[0];
pc1 = new RTCPeerConnection();
pc1.addTrack(localTrack, localStream);
pc2 = new RTCPeerConnection();
let trackPromise = new Promise(resolve => {
pc2.ontrack = e => resolve(e.track);
});
exchangeIceCandidates(pc1, pc2);
await exchangeOfferAnswer(pc1, pc2);
remoteTrack = await trackPromise;
video.srcObject = new MediaStream([remoteTrack]);
await video.play();
}, "Setup audio call");
promise_test(async (test) => {
pc1.getTransceivers()[0].direction = "inactive";
let offer = await pc1.createOffer();
await pc1.setLocalDescription(offer);
// Let's remove ssrc lines
let sdpLines = offer.sdp.split("\r\n");
offer.sdp = sdpLines.filter(line => line && !line.startsWith("a=ssrc")).join("\r\n") + "\r\n";
await pc2.setRemoteDescription(offer);
let answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
await pc1.setRemoteDescription(answer);
assert_equals(remoteTrack.readyState, "live");
}, "Inactivate the audio transceiver");
promise_test(async (test) => {
pc1.getTransceivers()[0].direction = "sendonly";
await exchangeOfferAnswer(pc1, pc2);
assert_equals(remoteTrack.readyState, "live");
}, "Reactivate the audio transceiver");
promise_test(async (test) => {
pc1.close();
pc2.close();
localTrack.stop();
}, "Clean-up");
</script>
</body>
</html>
|