Bug 1406529: added mochitest for extmap verification r=ng

MozReview-Commit-ID: QVn5MI0XdH

--HG--
rename : dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html => dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmap.html
rename : dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html => dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmapSendonly.html
extra : rebase_source : 866f93d306db933d988ea8ca476a625c9b3952d5
This commit is contained in:
Nils Ohlmeier [:drno] 2018-03-05 22:07:05 -08:00
Родитель c43eaec585
Коммит e2747ff63c
4 изменённых файлов: 241 добавлений и 10 удалений

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

@ -132,6 +132,10 @@ skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emula
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoCombined.html]
skip-if = toolkit == 'android' # Bug 1189784
[test_peerConnection_basicAudioVideoVerifyExtmap.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoVerifyExtmapSendonly.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoNoBundle.html]
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoNoBundleNoRtcpMux.html]

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

@ -26,19 +26,62 @@ findCodecId: function(sdp, format, offset = 0) {
// 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]);
}
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;
},
findExtmapIdsUrnsDirections: function(sdp) {
var sdpExtmap = [];
extmapRegEx = /^a=extmap:([0-9+])([A-Za-z/]*) ([A-Za-z0-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.
var idUrn = [];
idUrn.push(searchResults[1]);
idUrn.push(searchResults[3]);
idUrn.push(searchResults[2].slice(1));
sdpExtmap.push(idUrn);
}
return sdpExtmap;
},
verify_unique_extmap_ids: function(sdp) {
const sdpExtmapIds = sdputils.findExtmapIdsUrnsDirections(sdp);
return sdpExtmapIds.reduce(function(result, item, index) {
const [id, urn, dir] = item;
ok((!(id in result)) ||
((result[id][0] === urn) && (result[id][1] === dir)),
"ID " + id + " is unique ID for " + urn + " and direction " + dir);
result[id] = [urn, dir];
return result;
}, {});
},
getMSections: function(sdp) {
return sdp.split(new RegExp('^m=', 'gm')).slice(1);
},
getAudioMSections: function(sdp) {
return this.getMSections(sdp).filter(section => section.startsWith('audio'))
},
getVideoMSections: function(sdp) {
return this.getMSections(sdp).filter(section => section.startsWith('video'))
},
checkSdpAfterEndOfTrickle: function(sdp, testOptions, label) {
info("EOC-SDP: " + JSON.stringify(sdp));

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

@ -0,0 +1,92 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1406529",
title: "Verify SDP extmap attribute for sendrecv connection"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}, {video: true}],
[{audio: true}, {video: true}]);
test.chain.insertAfter('PC_LOCAL_SET_LOCAL_DESCRIPTION', [
async function PC_LOCAL_CHECK_SDP_OFFER_EXTMAP() {
sdputils.verify_unique_extmap_ids(test.originalOffer.sdp);
const audio = sdputils.findExtmapIdsUrnsDirections(
sdputils.getAudioMSections(test.originalOffer.sdp));
const expected_audio = [
/* Please modify this list when you add or remove RTP header
extensions. */
["1", "urn:ietf:params:rtp-hdrext:ssrc-audio-level", ""],
["2", "urn:ietf:params:rtp-hdrext:csrc-audio-level", "recvonly"],
["3", "urn:ietf:params:rtp-hdrext:sdes:mid", ""],
];
// *Ugh* ...
ok(JSON.stringify(audio) ===
JSON.stringify(expected_audio),
"List of offer audio URNs meets expected values");
const video = sdputils.findExtmapIdsUrnsDirections(
sdputils.getVideoMSections(test.originalOffer.sdp));
const expected_video = [
/* Please modify this list when you add or remove RTP header
extensions. */
["3", "urn:ietf:params:rtp-hdrext:sdes:mid", ""],
["4", "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", ""],
["5", "urn:ietf:params:rtp-hdrext:toffset", ""],
];
// *Ugh* ...
ok(JSON.stringify(video) ===
JSON.stringify(expected_video),
"List of offer video URNs meets expected values");
}
]);
test.chain.removeAfter('PC_REMOTE_SET_LOCAL_DESCRIPTION');
test.chain.append([
async function PC_REMOTE_CHECK_SDP_ANSWER_EXTMAP() {
sdputils.verify_unique_extmap_ids(test.originalAnswer.sdp);
const audio = sdputils.findExtmapIdsUrnsDirections(
sdputils.getAudioMSections(test.originalAnswer.sdp));
const expected_audio = [
/* Please modify this list when you add or remove RTP header
extensions. */
["1", "urn:ietf:params:rtp-hdrext:ssrc-audio-level",""],
["3", "urn:ietf:params:rtp-hdrext:sdes:mid",""],
];
// *Ugh* ...
ok(JSON.stringify(audio) ===
JSON.stringify(expected_audio),
"List of answer audio URNs meets expected values");
const video = sdputils.findExtmapIdsUrnsDirections(
sdputils.getVideoMSections(test.originalAnswer.sdp));
const expected_video = [
/* Please modify this list when you add or remove RTP header
extensions. */
["3", "urn:ietf:params:rtp-hdrext:sdes:mid",""],
["4", "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",""],
["5", "urn:ietf:params:rtp-hdrext:toffset",""],
];
ok(JSON.stringify(video) ===
JSON.stringify(expected_video),
"List of answer video URNs meets expected values");
}
]);
test.run();
});
</script>
</pre>
</body>
</html>

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

@ -0,0 +1,92 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "1406529",
title: "Verify SDP extmap attribute for sendonly connection"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}, {video: true}],
[]);
test.chain.insertAfter('PC_LOCAL_SET_LOCAL_DESCRIPTION', [
async function PC_LOCAL_CHECK_SDP_OFFER_EXTMAP() {
sdputils.verify_unique_extmap_ids(test.originalOffer.sdp);
const audio = sdputils.findExtmapIdsUrnsDirections(
sdputils.getAudioMSections(test.originalOffer.sdp));
const expected_audio = [
/* Please modify this list when you add or remove RTP header
extensions. */
["1", "urn:ietf:params:rtp-hdrext:ssrc-audio-level", ""],
["2", "urn:ietf:params:rtp-hdrext:csrc-audio-level", "recvonly"],
["3", "urn:ietf:params:rtp-hdrext:sdes:mid", ""],
];
// *Ugh* ...
ok(JSON.stringify(audio) ===
JSON.stringify(expected_audio),
"List of offer audio URNs meets expected values");
const video = sdputils.findExtmapIdsUrnsDirections(
sdputils.getVideoMSections(test.originalOffer.sdp));
const expected_video = [
/* Please modify this list when you add or remove RTP header
extensions. */
["3", "urn:ietf:params:rtp-hdrext:sdes:mid", ""],
["4", "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", ""],
["5", "urn:ietf:params:rtp-hdrext:toffset", ""],
];
// *Ugh* ...
ok(JSON.stringify(video) ===
JSON.stringify(expected_video),
"List of offer video URNs meets expected values");
}
]);
test.chain.removeAfter('PC_REMOTE_SET_LOCAL_DESCRIPTION');
test.chain.append([
async function PC_REMOTE_CHECK_SDP_ANSWER_EXTMAP() {
sdputils.verify_unique_extmap_ids(test.originalAnswer.sdp);
const audio = sdputils.findExtmapIdsUrnsDirections(
sdputils.getAudioMSections(test.originalAnswer.sdp));
const expected_audio = [
/* Please modify this list when you add or remove RTP header
extensions. */
["1", "urn:ietf:params:rtp-hdrext:ssrc-audio-level",""],
["3", "urn:ietf:params:rtp-hdrext:sdes:mid",""],
];
// *Ugh* ...
ok(JSON.stringify(audio) ===
JSON.stringify(expected_audio),
"List of answer audio URNs meets expected values");
const video = sdputils.findExtmapIdsUrnsDirections(
sdputils.getVideoMSections(test.originalAnswer.sdp));
const expected_video = [
/* Please modify this list when you add or remove RTP header
extensions. */
["3", "urn:ietf:params:rtp-hdrext:sdes:mid",""],
["4", "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",""],
["5", "urn:ietf:params:rtp-hdrext:toffset",""],
];
ok(JSON.stringify(video) ===
JSON.stringify(expected_video),
"List of answer video URNs meets expected values");
}
]);
test.run();
});
</script>
</pre>
</body>
</html>