| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Testing basic video exchange from offerer to receiver</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <script src ="routines.js"></script> |
| <script> |
| function getTrackStats(connection) |
| { |
| return connection.getStats().then((report) => { |
| var stats; |
| report.forEach((statItem) => { |
| if (statItem.type === "track") { |
| stats = statItem; |
| } |
| }); |
| return stats; |
| }); |
| } |
| |
| var firstConnection, secondConnection; |
| promise_test((test) => { |
| if (window.testRunner) |
| testRunner.setUserMediaPermission(true); |
| |
| var localStream, remoteStream; |
| return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => { |
| localStream = stream; |
| return new Promise((resolve, reject) => { |
| createConnections((connection) => { |
| firstConnection = connection; |
| firstConnection.addTrack(stream.getVideoTracks()[0], stream); |
| }, (connection) => { |
| secondConnection = connection; |
| secondConnection.ontrack = (trackEvent) => { |
| remoteStream = trackEvent.streams[0]; |
| resolve(); |
| }; |
| }); |
| setTimeout(() => reject("Test timed out"), 5000); |
| }); |
| }).then(() => { |
| return getTrackStats(secondConnection); |
| }).then((stats) => { |
| assert_true(!!stats, "tracks stats should not be null or undefined"); |
| stats.id = "id"; |
| stats.timestamp = 1; |
| stats.trackIdentifier = "trackid"; |
| 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"}'); |
| return waitFor(1000); |
| }).then(() => { |
| return getTrackStats(secondConnection); |
| }).then((stats) => { |
| assert_equals(stats.frameHeight, 480); |
| assert_equals(stats.frameWidth, 640); |
| assert_true(stats.framesDecoded > 0); |
| assert_true(stats.framesReceived > 0); |
| }); |
| }, "Basic video media stream track stats"); |
| </script> |
| </body> |
| </html> |