blob: 6d7e984b8f3156eb348e9013edcb9a92d26b42aa [file] [log] [blame]
<!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","audioLevel":0,"detached":false,"echoReturnLoss":0,"echoReturnLossEnhancement":0,"ended":false,"frameHeight":0,"frameWidth":0,"framesCorrupted":0,"framesDecoded":0,"framesDropped":0,"framesPerSecond":0,"framesReceived":0,"framesSent":0,"fullFramesLost":0,"partialFramesLost":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>