test_peerConnection_twoAudioVideoStreamsCombined.html (2301B)
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 11 createHTML({ 12 bug: "1091242", 13 title: "Multistream: Two audio/video streams" 14 }); 15 16 runNetworkTest(async (options) => { 17 const test = new PeerConnectionTest(options); 18 test.setMediaConstraints( 19 [{audio: true, video: {width: 50}}, {audio: true, video: {width: 50}}], 20 [{audio: true, video: {width: 50}}, {audio: true, video: {width: 50}}] 21 ); 22 23 // Test stats, including coalescing of codec stats. 24 test.chain.insertAfter("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", 25 [PC_LOCAL_TEST_LOCAL_STATS]); 26 27 test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW", 28 [PC_REMOTE_TEST_REMOTE_STATS]); 29 30 const testCoalescedCodecStats = stats => { 31 is([...stats.values()].filter(({type}) => type.endsWith("rtp")).length, 32 16, 33 "Expected: 4 outbound, 4 remote-inbound, 4 inbound, 4 remote-inbound"); 34 const codecs = [...stats.values()] 35 .filter(({type}) => type == "codec") 36 .sort((a, b) => a.mimeType > b.mimeType); 37 is(codecs.length, 2, "Should have registered two codecs (coalesced)"); 38 is(new Set(codecs.map(({transportId}) => transportId)).size, 1, 39 "Should have registered only one transport with BUNDLE"); 40 const codecTypes = new Set(codecs.map(({codecType}) => codecType)); 41 is(codecTypes.size, 1, 42 "Should have identical encode and decode configurations (and stats)"); 43 is(codecTypes[0], undefined, 44 "Should have identical encode and decode configurations (and stats)"); 45 is(codecs[0].mimeType.slice(0, 5), "audio", 46 "Should have registered an audio codec"); 47 is(codecs[1].mimeType.slice(0, 5), "video", 48 "Should have registered a video codec"); 49 }; 50 51 test.chain.append([ 52 async function PC_LOCAL_TEST_COALESCED_CODEC_STATS() { 53 testCoalescedCodecStats(await test.pcLocal._pc.getStats()); 54 }, 55 async function PC_REMOTE_TEST_COALESCED_CODEC_STATS() { 56 testCoalescedCodecStats(await test.pcRemote._pc.getStats()); 57 }, 58 ]); 59 60 return test.run(); 61 }); 62 </script> 63 </pre> 64 </body> 65 </html>