Bug 1416932 - adding tests to detect RTP header extension negotiated are in RTP packets. r=drno

MozReview-Commit-ID: 9TqeID5XJAd

--HG--
extra : rebase_source : e5f6720501ffc14256327e527c638e772c65c86c
This commit is contained in:
Michael Froman 2017-11-13 17:45:13 -06:00
Родитель b64c46808f
Коммит 72e9b053d9
4 изменённых файлов: 141 добавлений и 0 удалений

Просмотреть файл

@ -116,6 +116,8 @@ skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emula
skip-if = android_version == '18'
[test_peerConnection_basicAudioDynamicPtMissingRtpmap.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVerifyRtpHeaderExtensions.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideo.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoCombined.html]
@ -128,6 +130,8 @@ skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulato
skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicVideo.html]
skip-if = (android_version == '18' && debug) # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicVideoVerifyRtpHeaderExtensions.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicScreenshare.html]
# frequent timeouts/crashes on e10s (bug 1048455)
skip-if = toolkit == 'android' # no screenshare on android

Просмотреть файл

@ -22,6 +22,23 @@ findCodecId: function(sdp, format, offset = 0) {
return match[1];
},
// Finds all the extmap ids in the given sdp. Note that this does NOT
// consider m-sections, so a more generic version would need to
// look at each m-section separately.
findExtmapIds: function(sdp) {
var sdpExtmapIds = [];
extmapRegEx = /^a=extmap:([0-9+])/gm;
// must call exec on the regex to get each match in the string
while ((searchResults = extmapRegEx.exec(sdp))
!== null) {
// returned array has the matched text as the first item,
// and then one item for each capturing parenthesis that
// matched containing the text that was captured.
sdpExtmapIds.push(searchResults[1]);
}
return sdpExtmapIds;
},
checkSdpAfterEndOfTrickle: function(sdp, testOptions, label) {
info("EOC-SDP: " + JSON.stringify(sdp));

Просмотреть файл

@ -0,0 +1,61 @@
<!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 audio-only peer connection and verify rtp header extensions"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
// pc.js uses video elements by default, we want to test audio elements here
test.pcLocal.audioElementsOnly = 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);
})
);
}
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);
let pc = SpecialPowers.wrap(test.pcRemote._pc);
let [level, type, sending, data] = await getRtpPacket(pc);
let extensions = ParseRtpPacket(data).header.extensions;
// 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, extensions.length, "number of received ids match sdp ids");
// note, we are comparing a number (from the parsed rtp packet)
// and a string (from the answer sdp)
ok(extensions.every((ext) => sdpExtmapIds.includes(""+ext.id)), "extension id arrays equivalent");
}
]);
test.run();
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -0,0 +1,59 @@
<!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);
})
);
}
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);
let pc = SpecialPowers.wrap(test.pcRemote._pc);
let [level, type, sending, data] = await getRtpPacket(pc);
let extensions = ParseRtpPacket(data).header.extensions;
// 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, extensions.length, "number of received ids match sdp ids");
// note, we are comparing a number (from the parsed rtp packet)
// and a string (from the answer sdp)
ok(extensions.every((ext) => sdpExtmapIds.includes(""+ext.id)), "extension id arrays equivalent");
}
]);
test.run();
});
</script>
</pre>
</body>
</html>