Bug 1166832 - Add test to verify video (using capture stream) after renegotiation. r=bwc
authorMichael Froman <mfroman@mozilla.com>
Wed, 13 Jan 2016 20:59:52 -0600
changeset 280348 5a7e55e8c0b3a8874517f60808246de0733a6898
parent 280347 bd18104e0d2c9a6c91213d805c98d86887eeb0ac
child 280349 64d267bd052790e62828a6808fdf39573150018c
push id29912
push usercbook@mozilla.com
push dateMon, 18 Jan 2016 13:23:03 +0000
treeherdermozilla-central@a77b73c7723e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1166832
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1166832 - Add test to verify video (using capture stream) after renegotiation. r=bwc
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_peerConnection_verifyVideoAfterRenegotiation.html
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -204,20 +204,21 @@ skip-if = toolkit == 'gonk' || (android_
 skip-if = toolkit == 'gonk' || android_version == '18'
 [test_peerConnection_removeThenAddVideoTrackNoBundle.html]
 # B2G emulator is too slow to finish a renegotiation test in under 5 minutes, Bug 1180000 for Linux debug e10s, android(Bug 1189784, timeouts on 4.3 emulator)
 skip-if = toolkit == 'gonk' || android_version == '18'
 [test_peerConnection_addDataChannel.html]
 skip-if = toolkit == 'gonk' # B2G emulator seems to be so slow that DTLS cannot establish properly
 [test_peerConnection_addDataChannelNoBundle.html]
 skip-if = toolkit == 'gonk' || (android_version == '18' && debug) # b2g(emulator seems to be so slow that DTLS cannot establish properly), android(bug 1240256, intermittent ICE failures starting w/bug 1232082, possibly from timeout)
-
- # b2g(Bug 960442, video support for WebRTC is disabled on b2g), android(Bug 1189784, timeouts on 4.3 emulator)
-
+[test_peerConnection_verifyVideoAfterRenegotiation.html]
+# B2G emulator is too slow to finish a renegotiation test in under 5 minutes, Bug 1180000 for Linux debug e10s, android(Bug 1189784, timeouts on 4.3 emulator)
+skip-if = toolkit == 'gonk' || android_version == '18'
 [test_peerConnection_webAudio.html]
+# b2g(Bug 960442, video support for WebRTC is disabled on b2g), android(Bug 1189784, timeouts on 4.3 emulator)
 tags = webaudio webrtc
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
 [test_peerConnection_localRollback.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
 [test_peerConnection_localReofferRollback.html]
 skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
 [test_peerConnection_remoteRollback.html]
 skip-if = toolkit == 'gonk' || (android_version == '18' && debug) # b2g (Bug 1059867), android(Bug 1189784, timeouts on 4.3 emulator)
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_peerConnection_verifyVideoAfterRenegotiation.html
@@ -0,0 +1,100 @@
+<!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({
+    bug: "1166832",
+    title: "Renegotiation: verify video after renegotiation"
+  });
+
+runNetworkTest(() => {
+  var test = new PeerConnectionTest();
+
+  var h1 = new CaptureStreamTestHelper2D(50, 50);
+  var canvas1 = h1.createAndAppendElement('canvas', 'source_canvas1');
+  var stream1;
+  var vremote1;
+
+  var h2 = new CaptureStreamTestHelper2D(50, 50);
+  var canvas2;
+  var stream2;
+  var vremote2;
+
+  test.setMediaConstraints([{video: true}], []);
+  test.chain.replace("PC_LOCAL_GUM", [
+    function DRAW_INITIAL_LOCAL_GREEN(test) {
+      h1.drawColor(canvas1, h1.green);
+    },
+    function PC_LOCAL_CANVAS_CAPTURESTREAM(test) {
+      stream1 = canvas1.captureStream(0);
+      test.pcLocal.attachMedia(stream1, 'video', 'local');
+    }
+  ]);
+
+  test.chain.append([
+    function FIND_REMOTE_VIDEO() {
+      vremote1 = document.getElementById('pcRemote_remote1_video');
+      ok(!!vremote1, "Should have remote video element for pcRemote");
+    },
+    function WAIT_FOR_REMOTE_GREEN() {
+      return h1.waitForPixelColor(vremote1, h1.green, 128,
+                                 "pcRemote's remote should become green");
+    },
+    function 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.
+      stream1.requestFrame();
+      h1.drawColor(canvas1, h1.red);
+    },
+    function WAIT_FOR_REMOTE_RED() {
+      return h1.waitForPixelColor(vremote1, h1.red, 128,
+                                 "pcRemote's remote should become red");
+    }
+  ]);
+
+  addRenegotiation(test.chain,
+    [
+      function PC_LOCAL_ADD_SECOND_STREAM(test) {
+        canvas2 = h2.createAndAppendElement('canvas', 'source_canvas2');
+        h2.drawColor(canvas2, h2.blue);
+        stream2 = canvas2.captureStream(0);
+
+        // can't use test.pcLocal.getAllUserMedia([{video: true}]);
+        // because it doesn't let us substitute the capture stream
+        return test.pcLocal.attachMedia(stream2, 'video', 'local');
+      }
+    ]
+  );
+
+  test.chain.append([
+    function FIND_REMOTE2_VIDEO() {
+      vremote2 = document.getElementById('pcRemote_remote2_video');
+      ok(!!vremote2, "Should have remote2 video element for pcRemote");
+    },
+    function WAIT_FOR_REMOTE2_BLUE() {
+      return h2.waitForPixelColor(vremote2, h2.blue, 128,
+                                 "pcRemote's remote2 should become blue");
+    },
+    function DRAW_NEW_LOCAL_GREEN(test) {
+      stream1.requestFrame();
+      h1.drawColor(canvas1, h1.green);
+    },
+    function WAIT_FOR_REMOTE1_GREEN() {
+      return h1.waitForPixelColor(vremote1, h1.green, 128,
+                                 "pcRemote's remote1 should become green");
+    }
+  ]);
+
+  test.run();
+});
+
+</script>
+</pre>
+</body>
+</html>
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -1139,27 +1139,31 @@ WebrtcVideoConduit::SelectSendResolution
   }
 
 
   // Adapt to getUserMedia resolution changes
   // check if we need to reconfigure the sending resolution.
   bool changed = false;
   if (mSendingWidth != width || mSendingHeight != height)
   {
+    CSFLogDebug(logTag, "%s: resolution changing to %ux%u (from %ux%u)",
+                __FUNCTION__, width, height, mSendingWidth, mSendingHeight);
     // This will avoid us continually retrying this operation if it fails.
     // If the resolution changes, we'll try again.  In the meantime, we'll
     // keep using the old size in the encoder.
     mSendingWidth = width;
     mSendingHeight = height;
     changed = true;
   }
 
   // uses mSendingWidth/Height
   unsigned int framerate = SelectSendFrameRate(mSendingFramerate);
   if (mSendingFramerate != framerate) {
+    CSFLogDebug(logTag, "%s: framerate changing to %u (from %u)",
+                __FUNCTION__, framerate, mSendingFramerate);
     mSendingFramerate = framerate;
     changed = true;
   }
 
   if (changed) {
     // On a resolution change, bounce this to the correct thread to
     // re-configure (same as used for Init().  Do *not* block the calling
     // thread since that may be the MSG thread.
@@ -1216,16 +1220,20 @@ WebrtcVideoConduit::ReconfigureSendCodec
   int32_t err;
 
   mInReconfig = false;
   if ((err = mPtrViECodec->GetSendCodec(mChannel, vie_codec)) != 0)
   {
     CSFLogError(logTag, "%s: GetSendCodec failed, err %d", __FUNCTION__, err);
     return NS_ERROR_FAILURE;
   }
+
+  CSFLogDebug(logTag,
+              "%s: Requesting resolution change to %ux%u (from %ux%u)",
+              __FUNCTION__, width, height, vie_codec.width, vie_codec.height);
   // Likely spurious unless there was some error, but rarely checked
   if (vie_codec.width != width || vie_codec.height != height ||
       vie_codec.maxFramerate != mSendingFramerate)
   {
     vie_codec.width = width;
     vie_codec.height = height;
     vie_codec.maxFramerate = mSendingFramerate;
     SelectBandwidth(vie_codec, width, height, mLastFramerateTenths);
@@ -1394,16 +1402,18 @@ WebrtcVideoConduit::SendVideoFrame(webrt
   // Don't compate mSendingWidth/Height, since those may not be the same as the input.
   {
     MutexAutoLock lock(mCodecMutex);
     if (mInReconfig) {
       // Waiting for it to finish
       return kMediaConduitNoError;
     }
     if (frame.width() != mLastWidth || frame.height() != mLastHeight) {
+      CSFLogDebug(logTag, "%s: call SelectSendResolution with %ux%u",
+                  __FUNCTION__, frame.width(), frame.height());
       if (SelectSendResolution(frame.width(), frame.height(), &frame)) {
         // SelectSendResolution took ownership of the data in i420_frame.
         // Submit the frame after reconfig is done
         return kMediaConduitNoError;
       }
     }
   }
   mPtrExtCapture->IncomingFrame(frame);