test_peerConnection_rtcp_rsize.html (2795B)
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 <script type="application/javascript" src="sdpUtils.js"></script> 7 </head> 8 <body> 9 <pre id="test"> 10 <script type="application/javascript"> 11 createHTML({ 12 bug: "1279153", 13 title: "rtcp-rsize", 14 visible: true 15 }); 16 17 // 0) Use webrtc-sdp 18 // 1) ADD RTCP-RISZE to all video m-sections 19 // 2) Check for RTCP-RSIZE in ANSWER 20 // 3) Wait for media to flow 21 // 4) Wait for RTCP stats 22 23 runNetworkTest(async function (options) { 24 const test = new PeerConnectionTest(options); 25 26 let mSectionsAltered = 0; 27 28 test.chain.insertAfter("PC_LOCAL_CREATE_OFFER", [ 29 function PC_LOCAL_ADD_RTCP_RSIZE(test) { 30 const lines = test.originalOffer.sdp.split("\r\n"); 31 info(`SDP before rtcp-rsize: ${lines.join('\n')}`); 32 // Insert an rtcp-rsize for each m section 33 const rsizeAdded = lines.flatMap(line => { 34 if (line.startsWith("m=video")) { 35 mSectionsAltered = mSectionsAltered + 1; 36 return [line, "a=rtcp-rsize"]; 37 } 38 return [line]; 39 }); 40 test.originalOffer.sdp = rsizeAdded.join("\r\n"); 41 info(`SDP with rtcp-rsize: ${rsizeAdded.join("\n")}`); 42 is(mSectionsAltered, 1, "We only altered 1 msection") 43 }]); 44 45 // Check that the rtcp-rsize makes into the answer 46 test.chain.insertAfter("PC_LOCAL_SET_REMOTE_DESCRIPTION", [ 47 function PC_LOCAL_CHECK_RTCP_RSIZE(test) { 48 const msections = sdputils.getMSections(test.pcLocal._pc.currentRemoteDescription.sdp); 49 var alteredMSectionsFound = 0; 50 for (msection of msections) { 51 if (msection.startsWith("m=video")) { 52 ok(msection.includes("\r\na=rtcp-rsize\r\n"), "video m-section includes RTCP-RSIZE"); 53 alteredMSectionsFound = alteredMSectionsFound + 1; 54 } else { 55 ok(!msection.includes("\r\na=rtcp-rsize\r\n"), "audio m-section does not include RTCP-RSIZE"); 56 } 57 } 58 is(alteredMSectionsFound, mSectionsAltered, "correct number of msections found"); 59 } 60 ]); 61 62 // Make sure that we are still getting RTCP stats 63 test.chain.insertAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW", 64 async function PC_LOCAL_AND_REMOTE_CHECK_FOR_RTCP_STATS(test) { 65 await Promise.all([ 66 waitForSyncedRtcp(test.pcLocal._pc), 67 waitForSyncedRtcp(test.pcRemote._pc), 68 ]); 69 // The work is done by waitForSyncedRtcp which will throw if 70 // RTCP stats are not received. 71 info("RTCP stats received!"); 72 }, 73 ); 74 test.setMediaConstraints([{audio: true}, {video: true}], []); 75 await test.run(); 76 }); 77 78 </script> 79 </pre> 80 </body> 81 </html>