test_peerConnection_stats_oneway.html (2035B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 <script type="application/javascript" src="stats.js"></script> 6 </head> 7 <body> 8 <pre id="test"> 9 <script type="application/javascript"> 10 createHTML({ 11 bug: "1225722", 12 title: "WebRTC Stats composition and sanity for a one-way peer connection" 13 }); 14 15 runNetworkTest(async function (options) { 16 // We don't know how to get QP value when using Android system codecs. 17 if (navigator.userAgent.includes("Android")) { 18 await pushPrefs(["media.navigator.mediadatadecoder_vpx_enabled", false], 19 ["media.webrtc.hw.h264.enabled", false]); 20 } 21 22 // For accurate comparisons of `remoteTimestamp` (not using reduced precision) 23 // to `timestamp` (using reduced precision). 24 await pushPrefs(["privacy.resistFingerprinting.reduceTimerPrecision.jitter", 25 false]); 26 27 const test = new PeerConnectionTest(options); 28 29 test.chain.insertAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", 30 [PC_LOCAL_TEST_LOCAL_STATS]); 31 32 test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW", 33 [PC_REMOTE_TEST_REMOTE_STATS]); 34 35 const testOneWayStats = (stats, codecType) => { 36 const codecs = []; 37 stats.forEach(stat => { 38 if (stat.type == "codec") { 39 codecs.push(stat); 40 is(stat.codecType, codecType, "One-way codec has specific codecType"); 41 } 42 }); 43 is(codecs.length, 2, "One audio and one video codec"); 44 if (codecs.length == 2) { 45 isnot(codecs[0].mimeType.slice(0, 5), codecs[1].mimeType.slice(0, 5), 46 "Different media type for audio vs video mime types"); 47 } 48 }; 49 50 test.chain.append([ 51 async function PC_LOCAL_TEST_CODECTYPE_ENCODE(test) { 52 testOneWayStats(await test.pcLocal._pc.getStats(), "encode"); 53 }, 54 async function PC_REMOTE_TEST_CODECTYPE_DECODE(test) { 55 testOneWayStats(await test.pcRemote._pc.getStats(), "decode"); 56 }, 57 ]); 58 59 test.setMediaConstraints([{audio: true}, {video: true}], []); 60 await test.run(); 61 }); 62 </script> 63 </pre> 64 </body> 65 </html>