diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html')
-rw-r--r-- | dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html | 82 |
1 files changed, 82 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..7874e52a10 --- /dev/null +++ b/dom/media/webrtc/tests/mochitests/test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html @@ -0,0 +1,82 @@ +<!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 getRtpPacketWithExtension = (pc, extension) => { + // we only examine received packets + let sending = false; + pc.mozEnablePacketDump(0, "rtp", sending); + return new Promise((res, rej) => + pc.mozSetPacketCallback((...args) => { + const packet = ParseRtpPacket(args[3]); + info(`midId = ${extension} packet = ${JSON.stringify(packet, null, 2)}`); + if (packet.header.extensions.find(e => e.id == extension) !== undefined) { + res(packet); + pc.mozSetPacketCallback(() => {}); + pc.mozDisablePacketDump(0, "rtp", sending); + } + }) + ); + } + + let havePacketWithMid; + let sdpExtmaps; + + // MID can stop being sent when acked causing failures if packets are checked later. + // Starting packet sniffer before PC_LOCAL_SET_REMOTE_DESCRIPTION to be ready + // to inspect packets ahead of any packets arriving. + test.chain.insertBefore('PC_LOCAL_SET_REMOTE_DESCRIPTION', [ + function PC_REMOTE_FIND_RTP_PACKETS_WITH_MIDID() { + + sdpExtmaps = sdputils.findExtmapIdsUrnsDirections(test.originalAnswer.sdp); + const [midId] = sdpExtmaps.find(([, urn]) => urn == "urn:ietf:params:rtp-hdrext:sdes:mid"); + const pc = SpecialPowers.wrap(test.pcRemote._pc); + havePacketWithMid = getRtpPacketWithExtension(pc, midId); + } + ]); + + test.chain.insertBefore('PC_REMOTE_WAIT_FOR_MEDIA_FLOW', [ + async function PC_REMOTE_CHECK_RTP_HEADER_EXTS_AGAINST_SDP() { + + const sdpExtmapIds = sdpExtmaps.map(e => e[0]); + const packet = await havePacketWithMid; + 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`); + } + ]); + + return test.run(); + }); +</script> +</pre> +</body> +</html> |