Bug 1406529: added mochitest for extmap verification
MozReview-Commit-ID: QVn5MI0XdH
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -127,16 +127,20 @@ 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]
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]
skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoNoRtcpMux.html]
skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
[test_peerConnection_basicAudioVideoTransceivers.html]
skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
--- a/dom/media/tests/mochitest/sdpUtils.js
+++ b/dom/media/tests/mochitest/sdpUtils.js
@@ -21,29 +21,72 @@ findCodecId: function(sdp, format, offse
// match[1] is the first parenthesis group
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]);
- }
+ 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));
ok(sdp.sdp.includes("a=end-of-candidates"), label + ": SDP contains end-of-candidates");
sdputils.checkSdpCLineNotDefault(sdp.sdp, label);
if (testOptions.rtcpmux) {
ok(sdp.sdp.includes("a=rtcp-mux"), label + ": SDP contains rtcp-mux");
copy from dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html
copy to dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmap.html
--- a/dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html
+++ b/dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmap.html
@@ -2,23 +2,91 @@
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
- bug: "796890",
- title: "Basic audio/video (separate) peer connection"
+ 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>
copy from dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html
copy to dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmapSendonly.html
--- a/dom/media/tests/mochitest/test_peerConnection_basicAudioVideo.html
+++ b/dom/media/tests/mochitest/test_peerConnection_basicAudioVideoVerifyExtmapSendonly.html
@@ -2,23 +2,91 @@
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
- bug: "796890",
- title: "Basic audio/video (separate) peer connection"
+ 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}],
- [{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>