diff options
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html b/dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html new file mode 100644 index 0000000000..503f85ad20 --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html @@ -0,0 +1,67 @@ +<!DOCTYPE HTML> +<html> +<head> + <script type="application/javascript" src="pc.js"></script> + <script type="application/javascript" src="parser_rtp.js"></script> + <script type="application/javascript" src="sdpUtils.js"></script> +</head> +<body> +<pre id="test"> +<script type="application/javascript"> + createHTML({ + bug: "1416932", + title: "Basic video-only peer connection and verify rtp header extensions" + }); + + var test; + runNetworkTest(function (options) { + test = new PeerConnectionTest(options); + test.setMediaConstraints([{video: true}], [{video: true}]); + + let getRtpPacket = (pc) => { + // we only examine received packets + let sending = false; + pc.mozEnablePacketDump(0, "rtp", sending); + return new Promise((res, rej) => + pc.mozSetPacketCallback((...args) => { + res([...args]); + pc.mozSetPacketCallback(() => {}); + pc.mozDisablePacketDump(0, "rtp", sending); + }) + ); + } + + const pc = SpecialPowers.wrap(test.pcRemote._pc); + const haveFirstPacket = getRtpPacket(pc); + + test.chain.insertBefore('PC_REMOTE_WAIT_FOR_MEDIA_FLOW', [ + async function PC_REMOTE_CHECK_RTP_HEADER_EXTS_AGAINST_SDP() { + + const sdpExtmapIds = sdputils.findExtmapIds(test.originalAnswer.sdp); + + const [level, type, sending, data] = await haveFirstPacket; + const packet = ParseRtpPacket(data); + const extIds = packet.header.extensions.map(e => `${e.id}`); + // make sure we got the same number of rtp header extensions in + // the received packet as were negotiated in the sdp. Then + // check to make sure each of the received extension ids were in + // the sdp. + is(sdpExtmapIds.length, extIds.length, + `number of sdp ids match received ids ` + + `${JSON.stringify(sdpExtmapIds)} == ${JSON.stringify(extIds)}\n` + + `sdp = ${test.originalAnswer.sdp}\n` + + `packet = ${JSON.stringify(packet, null, 2)}`); + // note, we are comparing a number (from the parsed rtp packet) + // and a string (from the answer sdp) + ok(extIds.every(id => sdpExtmapIds.includes(id)) && + sdpExtmapIds.every(id => extIds.includes(id)), + `extension id arrays equivalent`); + } + ]); + + test.run(); + }); +</script> +</pre> +</body> +</html> |