diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webrtc-svc/svc-helper.js | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc-svc/svc-helper.js')
-rw-r--r-- | testing/web-platform/tests/webrtc-svc/svc-helper.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc-svc/svc-helper.js b/testing/web-platform/tests/webrtc-svc/svc-helper.js new file mode 100644 index 0000000000..e73ccfa750 --- /dev/null +++ b/testing/web-platform/tests/webrtc-svc/svc-helper.js @@ -0,0 +1,50 @@ +function supportsCodec(mimeType) { + return RTCRtpSender.getCapabilities('video').codecs.filter(c => c.mimeType == mimeType).length() > 0; +} + +async function supportsScalabilityMode(mimeType, scalabilityMode) { + let result = await navigator.mediaCapabilities.encodingInfo({ + type: 'webrtc', + video: { + contentType: mimeType, + width: 60, + height: 60, + bitrate: 10000, + framerate: 30, + scalabilityMode: scalabilityMode + } + }); + return result.supported; +} + +function createScalabilityTest(mimeType, scalabilityModes) { + for (const scalabilityMode of scalabilityModes) { + promise_test(async t => { + assert_implements_optional( + supportsScalabilityMode(mimeType, scalabilityMode), + `${mimeType} supported` + ); + const v = document.createElement('video'); + v.autoplay = true; + const pc1 = new RTCPeerConnection(); + const pc2 = new RTCPeerConnection(); + t.add_cleanup(() => pc1.close()); + t.add_cleanup(() => pc2.close()); + const stream1 = await getNoiseStream({ video: { signal: 100, width: 60, height: 60 } }); + const [track1] = stream1.getTracks(); + t.add_cleanup(() => track1.stop()); + const transceiver = pc1.addTransceiver(track1, { + sendEncodings: [{ scalabilityMode: scalabilityMode }], + }); + transceiver.setCodecPreferences(RTCRtpSender.getCapabilities('video').codecs.filter(c => c.mimeType == mimeType)); + const haveTrackEvent = new Promise(r => pc2.ontrack = r); + exchangeIceCandidates(pc1, pc2); + await exchangeOfferAnswer(pc1, pc2); + v.srcObject = new MediaStream([(await haveTrackEvent).track]); + await new Promise(r => v.onloadedmetadata = r); + await detectSignal(t, v, 100); + const sendParams = pc1.getSenders()[0].getParameters(); + assert_equals(sendParams.encodings[0].scalabilityMode, scalabilityMode); + }, `${mimeType} - ${scalabilityMode} should produce valid video content`); + } +} |