LibWebRTCRtpReceiverBackend::getSynchronizationSources should use Vector::append
[WebKit-https.git] / LayoutTests / webrtc / video-mediastreamtrack-stats.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         <script src ="routines.js"></script>
11         <script>
12 function getTrackStats(connection)
13 {
14     return connection.getStats().then((report) => {
15         var stats;
16         report.forEach((statItem) => {
17             if (statItem.type === "track") {
18                 stats = statItem;
19             }
20         });
21         return stats;
22     });
23 }
24
25 var firstConnection, secondConnection;
26 promise_test((test) => {
27     if (window.testRunner)
28         testRunner.setUserMediaPermission(true);
29
30     var localStream, remoteStream;
31     return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
32         localStream = stream;
33         return new Promise((resolve, reject) => {
34             createConnections((connection) => {
35                 firstConnection = connection;
36                 firstConnection.addTrack(stream.getVideoTracks()[0], stream);
37             }, (connection) => {
38                 secondConnection = connection;
39                 secondConnection.ontrack = (trackEvent) => {
40                     remoteStream = trackEvent.streams[0];
41                     resolve();
42                 };
43             });
44             setTimeout(() => reject("Test timed out"), 5000);
45         });
46     }).then(() => {
47         return getTrackStats(secondConnection);
48     }).then((stats) => {
49         assert_true(!!stats, "tracks stats should not be null or undefined");
50         stats.id = "id";
51         stats.timestamp = 1;
52         stats.trackIdentifier = "trackid";
53         assert_equals(JSON.stringify(stats), '{"id":"id","timestamp":1,"type":"track","detached":false,"ended":false,"framesDecoded":0,"framesDropped":0,"framesReceived":0,"remoteSource":true,"trackIdentifier":"trackid"}');
54         return waitFor(1000);
55     }).then(() => {
56         return getTrackStats(secondConnection);
57     }).then((stats) => {
58         assert_equals(stats.frameHeight, 480);
59         assert_equals(stats.frameWidth, 640);
60         assert_true(stats.framesDecoded > 0);
61         assert_true(stats.framesReceived > 0);
62     });
63 }, "Basic video media stream track stats");
64         </script>
65     </body>
66 </html>