Bug 1337777 - Add test for SDP answer without a=ssrc. r=drno, a=lizzard
☠☠ backed out by e5eb0121a580 ☠ ☠
authorRandell Jesup <rjesup@jesup.org>
Wed, 08 Mar 2017 02:37:52 -0500
changeset 379009 7b7a3daa9f812554d4efed205bb8afceedcbaae0
parent 379008 eb7181c6f54fe13d3e58979b820396b2feca9394
child 379010 dc8c26683d20ca523a1fa2e23dcbef9c09cbe43d
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersssrc, drno, lizzard
bugs1337777
milestone53.0
Bug 1337777 - Add test for SDP answer without a=ssrc. r=drno, a=lizzard MozReview-Commit-ID: 9YKjoeDSPFx
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/pc.js
dom/media/tests/mochitest/sdpUtils.js
dom/media/tests/mochitest/templates.js
dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_2d_noSSRC.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -136,16 +136,18 @@ skip-if = (android_version == '18') # an
 [test_peerConnection_bug1042791.html]
 skip-if = os == 'android' # bug 1043403
 [test_peerConnection_bug1064223.html]
 [test_peerConnection_capturedVideo.html]
 tags=capturestream
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_captureStream_canvas_2d.html]
 skip-if = android_version == '18' # android(Bug 1319019, timeouts on 4.3 emulator)
+[test_peerConnection_captureStream_canvas_2d_noSSRC.html]
+skip-if = android_version == '18' # android(Bug 1319019, timeouts on 4.3 emulator)
 [test_peerConnection_multiple_captureStream_canvas_2d.html]
 skip-if = (android_version == '18' && debug) # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_captureStream_canvas_webgl.html]
 # [test_peerConnection_certificates.html] # bug 1180968
 [test_peerConnection_close.html]
 [test_peerConnection_closeDuringIce.html]
 [test_peerConnection_constructedStream.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -58,16 +58,17 @@ function PeerConnectionTest(options) {
   options.commands = options.commands || makeDefaultCommands();
   options.is_local = "is_local" in options ? options.is_local : true;
   options.is_remote = "is_remote" in options ? options.is_remote : true;
 
   options.h264 = "h264" in options ? options.h264 : false;
   options.bundle = "bundle" in options ? options.bundle : true;
   options.rtcpmux = "rtcpmux" in options ? options.rtcpmux : true;
   options.opus = "opus" in options ? options.opus : true;
+  options.ssrc = "ssrc" in options ? options.ssrc : true;
 
   if (iceServersArray.length) {
     if (!options.turn_disabled_local) {
       options.config_local = options.config_local || {}
       options.config_local.iceServers = iceServersArray;
     }
     if (!options.turn_disabled_remote) {
       options.config_remote = options.config_remote || {}
@@ -446,16 +447,24 @@ PeerConnectionTest.prototype.updateChain
       'PC_LOCAL_CREATE_OFFER',
       [PC_LOCAL_REMOVE_BUNDLE_FROM_OFFER]);
   }
   if (!this.testOptions.rtcpmux) {
     this.chain.insertAfterEach(
       'PC_LOCAL_CREATE_OFFER',
       [PC_LOCAL_REMOVE_RTCPMUX_FROM_OFFER]);
   }
+  if (!this.testOptions.ssrc) {
+    this.chain.insertAfterEach(
+      'PC_LOCAL_CREATE_OFFER',
+      [PC_LOCAL_REMOVE_SSRC_FROM_OFFER]);
+    this.chain.insertAfterEach(
+      'PC_REMOTE_CREATE_ANSWER',
+      [PC_REMOTE_REMOVE_SSRC_FROM_ANSWER]);
+  }
   if (!this.testOptions.is_local) {
     this.chain.filterOut(/^PC_LOCAL/);
   }
   if (!this.testOptions.is_remote) {
     this.chain.filterOut(/^PC_REMOTE/);
   }
 };
 
--- a/dom/media/tests/mochitest/sdpUtils.js
+++ b/dom/media/tests/mochitest/sdpUtils.js
@@ -10,16 +10,21 @@ checkSdpAfterEndOfTrickle: function(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");
   } else {
     ok(sdp.sdp.includes("a=rtcp:"), label + ": SDP contains rtcp port");
   }
+  if (testOptions.ssrc) {
+    ok(sdp.sdp.includes("a=ssrc"), label + ": SDP contains a=ssrc");
+  } else {
+    ok(!sdp.sdp.includes("a=ssrc"), label + ": SDP does not contain a=ssrc");
+  }
 },
 
 // takes sdp in string form (or possibly a fragment, say an m-section), and
 // verifies that the default 0.0.0.0 addr is not present.
 checkSdpCLineNotDefault: function(sdpStr, label) {
   info("CLINE-NO-DEFAULT-ADDR-SDP: " + JSON.stringify(sdpStr));
   ok(!sdpStr.includes("c=IN IP4 0.0.0.0"), label + ": SDP contains non-zero IP c line");
 },
@@ -34,16 +39,20 @@ removeCodec: function(sdp, codec) {
     updated_sdp = updated_sdp.replace(new RegExp("a=rtcp-fb:" + codec + " ccm fir\\r\\n",""),"");
   return updated_sdp;
 },
 
 removeRtcpMux: function(sdp) {
   return sdp.replace(/a=rtcp-mux\r\n/g,"");
 },
 
+removeSSRCs: function(sdp) {
+  return sdp.replace(/a=ssrc.*\r\n/g,"");
+},
+
 removeBundle: function(sdp) {
   return sdp.replace(/a=group:BUNDLE .*\r\n/g, "");
 },
 
 reduceAudioMLineToPcmuPcma: function(sdp) {
   return sdp.replace(/m=audio .*\r\n/g, "m=audio 9 UDP/TLS/RTP/SAVPF 0 8\r\n");
 },
 
@@ -122,16 +131,17 @@ verifySdp: function(desc, expectedType, 
     ok(desc.sdp.includes("m=video"), "video m-line is present in SDP");
     if (testOptions.h264) {
       ok(desc.sdp.includes("a=rtpmap:126 H264/90000"), "H.264 codec is present in SDP");
     } else {
 	ok(desc.sdp.includes("a=rtpmap:120 VP8/90000") ||
 	   desc.sdp.includes("a=rtpmap:121 VP9/90000"), "VP8 or VP9 codec is present in SDP");
     }
     is(testOptions.rtcpmux, desc.sdp.includes("a=rtcp-mux"), "RTCP Mux is offered in SDP");
+    is(testOptions.ssrc, desc.sdp.includes("a=ssrc"), "a=ssrc signaled in SDP");
   }
 
   return requiresTrickleIce;
 },
 
 /**
  * Counts the amount of audio tracks in a given media constraint.
  *
--- a/dom/media/tests/mochitest/templates.js
+++ b/dom/media/tests/mochitest/templates.js
@@ -504,16 +504,26 @@ function PC_LOCAL_REMOVE_BUNDLE_FROM_OFF
   info("Updated no bundle offer: " + JSON.stringify(test.originalOffer));
 };
 
 function PC_LOCAL_REMOVE_RTCPMUX_FROM_OFFER(test) {
   test.originalOffer.sdp = sdputils.removeRtcpMux(test.originalOffer.sdp);
   info("Updated no RTCP-Mux offer: " + JSON.stringify(test.originalOffer));
 };
 
+function PC_LOCAL_REMOVE_SSRC_FROM_OFFER(test) {
+  test.originalOffer.sdp = sdputils.removeSSRCs(test.originalOffer.sdp);
+  info("Updated no SSRCs offer: " + JSON.stringify(test.originalOffer));
+};
+
+function PC_REMOTE_REMOVE_SSRC_FROM_ANSWER(test) {
+  test.originalAnswer.sdp = sdputils.removeSSRCs(test.originalAnswer.sdp);
+  info("Updated no SSRCs answer: " + JSON.stringify(test.originalAnswerr));
+};
+
 var addRenegotiation = (chain, commands, checks) => {
   chain.append(commands);
   chain.append(commandsPeerConnectionOfferAnswer);
   if (checks) {
     chain.append(checks);
   }
 };
 
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_captureStream_canvas_2d_noSSRC.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="pc.js"></script>
+  <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+createHTML({
+  title: "Canvas(2D)::CaptureStream as video-only input to peerconnection with no a=ssrc",
+  visible: true
+});
+
+var test;
+runNetworkTest((options) => {
+  options = options || { };
+  options.ssrc = false;
+  test = new PeerConnectionTest(options);
+  var mediaElement;
+  var h = new CaptureStreamTestHelper2D();
+  var canvas = document.createElement('canvas');
+  var stream;
+  canvas.id = 'source_canvas';
+  canvas.width = canvas.height = 10;
+  document.getElementById('content').appendChild(canvas);
+
+  test.setMediaConstraints([{video: true}], []);
+  test.chain.replace("PC_LOCAL_GUM", [
+    function PC_LOCAL_DRAW_INITIAL_LOCAL_GREEN(test) {
+      h.drawColor(canvas, h.green);
+    },
+    function PC_LOCAL_CANVAS_CAPTURESTREAM(test) {
+      stream = canvas.captureStream(0);
+      test.pcLocal.attachLocalStream(stream);
+    }
+  ]);
+  test.chain.append([
+    function PC_REMOTE_WAIT_FOR_REMOTE_GREEN() {
+      mediaElement = test.pcRemote.remoteMediaElements[0];
+      ok(!!mediaElement, "Should have remote video element for pcRemote");
+      return h.waitForPixelColor(mediaElement, h.green, 128,
+                                 "pcRemote's remote should become green");
+    },
+    function PC_LOCAL_DRAW_LOCAL_RED() {
+      // After requesting a frame it will be captured at the time of next render.
+      // Next render will happen at next stable state, at the earliest,
+      // i.e., this order of `requestFrame(); draw();` should work.
+      stream.requestFrame();
+      h.drawColor(canvas, h.red);
+      var i = 0;
+      return setInterval(function() {
+        try {
+          info("draw " + i ? "green" : "red");
+          h.drawColor(canvas, i ? h.green : h.red);
+          i = 1 - i;
+          stream.requestFrame();
+        } catch (e) {
+          // ignore; stream might have shut down, and we don't bother clearing
+          // the setInterval.
+        }
+      }, 500);
+    },
+    function PC_REMOTE_WAIT_FOR_REMOTE_RED() {
+      return h.waitForPixelColor(mediaElement, h.red, 128,
+                                 "pcRemote's remote should become red");
+    }
+  ]);
+  test.run();
+});
+</script>
+</pre>
+</body>
+</html>