diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html new file mode 100644 index 0000000000..9530748a06 --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_scaleResolution.html @@ -0,0 +1,92 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> + createHTML({ + bug: "1244913", + title: "Scale resolution down on a PeerConnection", + visible: true + }); + + var mustRejectWith = (msg, reason, f) => + f().then(() => ok(false, msg), + e => is(e.name, reason, msg)); + + async function testScale(codec) { + var pc1 = new RTCPeerConnection(); + var pc2 = new RTCPeerConnection(); + + var add = (pc, can, failed) => can && pc.addIceCandidate(can).catch(failed); + pc1.onicecandidate = e => add(pc2, e.candidate, generateErrorCallback()); + pc2.onicecandidate = e => add(pc1, e.candidate, generateErrorCallback()); + + info("testing scaling with " + codec); + + let stream = await navigator.mediaDevices.getUserMedia({ video: true }); + + var v1 = createMediaElement('video', 'v1'); + var v2 = createMediaElement('video', 'v2'); + + var ontrackfired = new Promise(resolve => pc2.ontrack = e => resolve(e)); + var v2loadedmetadata = new Promise(resolve => v2.onloadedmetadata = resolve); + + is(v2.currentTime, 0, "v2.currentTime is zero at outset"); + + v1.srcObject = stream; + var sender = pc1.addTrack(stream.getVideoTracks()[0], stream); + + await mustRejectWith( + "Invalid scaleResolutionDownBy must reject", "RangeError", + () => sender.setParameters( + { encodings:[{ scaleResolutionDownBy: 0.5 } ] }) + ); + + await sender.setParameters({ encodings: [{ maxBitrate: 60000, + scaleResolutionDownBy: 2 }] }); + + let offer = await pc1.createOffer(); + if (codec == "VP8") { + offer.sdp = sdputils.removeAllButPayloadType(offer.sdp, 126); + } + await pc1.setLocalDescription(offer); + await pc2.setRemoteDescription(pc1.localDescription); + + let answer = await pc2.createAnswer(); + await pc2.setLocalDescription(answer); + await pc1.setRemoteDescription(pc2.localDescription); + let trackevent = await ontrackfired; + + v2.srcObject = trackevent.streams[0]; + + await v2loadedmetadata; + + await waitUntil(() => v2.currentTime > 0); + ok(v2.currentTime > 0, "v2.currentTime is moving (" + v2.currentTime + ")"); + + ok(v1.videoWidth > 0, "source width is positive"); + ok(v1.videoHeight > 0, "source height is positive"); + is(v2.videoWidth, v1.videoWidth / 2, "sink is half the width of source"); + is(v2.videoHeight, v1.videoHeight / 2, "sink is half the height of source"); + stream.getTracks().forEach(track => track.stop()); + v1.srcObject = v2.srcObject = null; + pc1.close() + pc2.close() + } + + runNetworkTest(async () => { + await pushPrefs(['media.peerconnection.video.lock_scaling', true]); + await testScale("VP8"); + if (!navigator.appVersion.includes("Android")) { + // No support for H.264 on Android in automation, see Bug 1355786 + await testScale("H264"); + } + networkTestFinished(); + }); +</script> +</pre> +</body> +</html> |