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
|
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<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>
</head>
<body>
<video id="video1" autoplay controls playsinline></video>
<script src ="routines.js"></script>
<script>
async function waitForMessage(worker, data)
{
while (true) {
const received = await new Promise(resolve => worker.onmessage = (event) => resolve(event.data));
if (data === received)
return;
}
}
promise_test(async (test) => {
worker = new Worker('script-change-transform-worker.js');
const data = await new Promise(resolve => worker.onmessage = (event) => resolve(event.data));
assert_equals(data, "registered");
await setMediaPermission("granted", ["camera"]);
const localStream = await navigator.mediaDevices.getUserMedia({video: true});
let sender, receiver;
const senderTransform1 = new RTCRtpScriptTransform(worker, {name:'sender1'});
const senderTransform2 = new RTCRtpScriptTransform(worker, {name:'sender2'});
const receiverTransform = new RTCRtpScriptTransform(worker, {name:'receiver'});
const stream = await new Promise((resolve, reject) => {
createConnections(test, (firstConnection) => {
sender = firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
firstConnection.getTransceivers()[0].setCodecPreferences([{mimeType: "video/VP8", clockRate: 90000}]);
sender.transform = senderTransform1;
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
receiver = trackEvent.receiver;
receiver.transform = receiverTransform;
resolve(trackEvent.streams[0]);
};
});
test.step_timeout(() => reject("Test timed out"), 5000);
});
video1.srcObject = stream;
await video1.play();
const updatePromise = new Promise(resolve => worker.onmessage = (event) => resolve(event.data));
sender.transform = senderTransform2;
assert_equals(await updatePromise, "got value 2");
}, "change sender transform");
</script>
</body>
</html>
|