av1-profile-asymmetry.https.html (2101B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="../third_party/sdp/sdp.js"></script> 6 <script> 7 'use strict'; 8 9 promise_test(async t => { 10 const av1SendCodec = RTCRtpSender.getCapabilities('video').codecs.find( 11 codec => codec.mimeType == 'video/AV1'); 12 assert_not_equals(av1SendCodec, undefined); 13 14 const pc1 = new RTCPeerConnection(); 15 t.add_cleanup(() => pc1.close()); 16 const pc2 = new RTCPeerConnection(); 17 t.add_cleanup(() => pc2.close()); 18 19 const transceiver = pc1.addTransceiver('video'); 20 transceiver.setCodecPreferences([av1SendCodec]); 21 22 await pc1.setLocalDescription(); 23 await pc2.setRemoteDescription(pc1.localDescription); 24 await pc2.setLocalDescription(); 25 await pc1.setRemoteDescription(pc2.localDescription); 26 27 // Modify the profile ID of `av1SendCodec` to ensure a strict codec comparison 28 // matcher would no longer consider them the same. 29 const sdpFmtpMap = SDPUtils.parseFmtp(av1SendCodec.sdpFmtpLine); 30 const profileId = Number(sdpFmtpMap['profile']); 31 av1SendCodec.sdpFmtpLine = 32 av1SendCodec.sdpFmtpLine.replace(`profile=${profileId}`, 33 `profile=${profileId + 1}`); 34 35 const sender = transceiver.sender; 36 let params = sender.getParameters(); 37 params.encodings[0].codec = av1SendCodec; 38 // Set parameters should not reject because the codec dictionary match 39 // algorithm[1] is able to ignore asymmetrical parameters such as AV1's 40 // `profile` parameter, see [2]. 41 // 42 // [1] https://w3c.github.io/webrtc-pc/#dfn-codec-dictionary-match 43 // [2] https://aomediacodec.github.io/av1-rtp-spec/#723-usage-with-the-sdp-offeranswer-model 44 await sender.setParameters(params); 45 // getParameters() returns `av1SendCodec` now. 46 params = sender.getParameters(); 47 assert_equals(params.encodings[0].codec.mimeType, 'video/AV1'); 48 assert_equals(params.encodings[0].codec.sdpFmtpLine, 49 av1SendCodec.sdpFmtpLine); 50 }, `setParameters() ignores the asymmetrical AV1 parameter 'profile'`); 51 </script>