blob: 39687a5a26dd936064800b222c2ced3d6b34ab93 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing H.264 baseline with various resolutions</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<video id="video" autoplay=""></video>
<script src ="routines.js"></script>
<script>
const resolutions = [
[320, 240],
[640, 480],
[1024, 768],
[1280, 960],
[1600, 1200],
[320, 180],
[640, 360],
[1280, 720],
[1920, 1080]
];
async function waitForVideoSize(width, height)
{
let counter = 0;
while (++counter < 50 && video.videoWidth != width && video.videoHeight != height)
await waitFor(200);
if (counter === 20)
return Promise.reject("Video size not expected : " + video.videoWidth + " " + video.videoHeight);
}
let pc1, pc2;
let localVideoTrack;
promise_test(async (test) => {
const localStream = await navigator.mediaDevices.getUserMedia({ video: true });
localVideoTrack = localStream.getVideoTracks()[0];
const stream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
pc1 = firstConnection;
firstConnection.addTrack(localVideoTrack, localStream);
}, (secondConnection) => {
pc2 = secondConnection;
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
}, { observeOffer : (offer) => {
offer.sdp = setH264BaselineCodec(offer.sdp);
return offer;
}
});
setTimeout(() => reject("Test timed out"), 5000);
});
video.srcObject = stream;
await video.play();
}, "Baseline video exchange");
resolutions.forEach(resolution => {
promise_test(async (test) => {
await localVideoTrack.applyConstraints({ width : resolution[0], height : resolution[1] });
return waitForVideoSize(resolution[0], resolution[1]);
}, "Video resolution test: " + resolution[0] + " " + resolution[1]);
});
resolutions.forEach(resolution => {
promise_test(async (test) => {
const parameters = pc1.getSenders()[0].getParameters();
parameters.encodings[0].maxBitrate = 100000;
pc1.getSenders()[0].setParameters(parameters);
await localVideoTrack.applyConstraints({ width : resolution[0], height : resolution[1] });
return waitForVideoSize(resolution[0], resolution[1]);
}, "Video resolution test with maxBitrate: " + resolution[0] + " " + resolution[1]);
});
</script>
</body>
</html>