LibWebRTCRtpReceiverBackend::getSynchronizationSources should use Vector::append
[WebKit-https.git] / LayoutTests / webrtc / multi-video.html
1 <!doctype html>
2 <html>
3     <head>
4         <meta charset="utf-8">
5         <title>Testing basic video exchange from offerer to receiver</title>
6         <script src="../resources/testharness.js"></script>
7         <script src="../resources/testharnessreport.js"></script>
8     </head>
9     <body>
10         <video id="video1" autoplay=""></video>
11         <video id="video2" autoplay=""></video>
12         <video id="video3" autoplay=""></video>
13         <video id="video4" autoplay=""></video>
14         <video id="video5" autoplay=""></video>
15         <video id="video6" autoplay=""></video>
16         <canvas id="canvas" width="640" height="480"></canvas>
17         <script src ="routines.js"></script>
18         <script>
19 function testImage(video)
20 {
21     var id= video.id;
22     canvas.width = video.videoWidth;
23     canvas.height = video.videoHeight;
24     canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
25
26     imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
27     data = imageData.data;
28
29     var index = 20;
30     assert_true(data[index] < 100, "test 1 for " + id);
31     assert_true(data[index + 1] < 100, "test 2 for " + id);
32     assert_true(data[index + 2] < 100, "test 3 for " + id);
33
34     index = 80;
35     assert_true(data[index] > 200, "test 4 for " + id);
36     assert_true(data[index + 1] > 200, "test 5 for " + id);
37     assert_true(data[index + 2] > 200, "test 6 for " + id);
38
39     index += 80;
40     assert_true(data[index] > 200, "test 7 for " + id);
41     assert_true(data[index + 1] > 200, "test 8 for " + id);
42     assert_true(data[index + 2] < 100, "test 9 for " + id);
43 }
44
45 promise_test((test) => {
46     if (window.testRunner)
47         testRunner.setUserMediaPermission(true);
48
49     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
50         return new Promise((resolve, reject) => {
51             createConnections((firstConnection) => {
52                 var track = stream.getVideoTracks()[0];
53                 var track1 = track.clone();
54                 var track2 = track.clone();
55                 var track3 = track.clone();
56                 var track4 = track.clone();
57                 var track5 = track.clone();
58                 var track6 = track.clone();
59                 var newStream = new MediaStream([track1, track2, track3, track4, track5, track6]);
60                 firstConnection.addTrack(track1, newStream);
61                 firstConnection.addTrack(track2, newStream);
62                 firstConnection.addTrack(track3, newStream);
63                 firstConnection.addTrack(track4, newStream);
64                 firstConnection.addTrack(track5, newStream);
65                 firstConnection.addTrack(track6, newStream);
66             }, (secondConnection) => {
67                 secondConnection.ontrack = (trackEvent) => {
68                     resolve(trackEvent.streams[0]);
69                 };
70             });
71             setTimeout(() => reject("Test timed out"), 5000);
72         });
73     }).then((stream) => {
74         video1.srcObject = new MediaStream(stream.getVideoTracks([0]));
75         video2.srcObject = new MediaStream(stream.getVideoTracks([1]));
76         video3.srcObject = new MediaStream(stream.getVideoTracks([2]));
77         video4.srcObject = new MediaStream(stream.getVideoTracks([3]));
78         video5.srcObject = new MediaStream(stream.getVideoTracks([4]));
79         video6.srcObject = new MediaStream(stream.getVideoTracks([5]));
80         return Promise.all([video1.play(), video2.play(), video3.play(), video4.play(), video5.play(), video6.play()]);
81     }).then(() => {
82         return waitFor(100);
83     }).then(() => {
84         testImage(video1);
85         testImage(video2);
86         testImage(video3);
87         testImage(video4);
88         testImage(video5);
89         testImage(video6);
90     });
91 }, "Basic video exchange");
92         </script>
93     </body>
94 </html>