PeerConnectionTest.java: make the test work for the bots' v4l2loopback.

- Make the test agnostic to the actual resolution used, since v4l2_file_player
  is playing a non-640x480 file (go/httfw)
- Teach DeviceInfoLinux::FillCapabilityMap() about I420 since that's what
  v4l2_file_player is feeding.

Requires https://gist.github.com/fischman/2e9a9b2efd2ad363ef82 be applied to the
v4l2loopback driver code.

BUG=1796
R=wu@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1891004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4422 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
fischman@webrtc.org 2013-07-29 20:43:15 +00:00
parent 147d44a450
commit d6134c7cfd
2 changed files with 27 additions and 14 deletions

View File

@ -57,8 +57,9 @@ public class PeerConnectionTest extends TestCase {
private final String name; private final String name;
private int expectedIceCandidates = 0; private int expectedIceCandidates = 0;
private int expectedErrors = 0; private int expectedErrors = 0;
private LinkedList<Integer> expectedSetSizeDimensions = private int expectedSetSize = 0;
new LinkedList<Integer>(); // Alternating width/height. private int previouslySeenWidth = 0;
private int previouslySeenHeight = 0;
private int expectedFramesDelivered = 0; private int expectedFramesDelivered = 0;
private LinkedList<SignalingState> expectedSignalingChanges = private LinkedList<SignalingState> expectedSignalingChanges =
new LinkedList<SignalingState>(); new LinkedList<SignalingState>();
@ -116,21 +117,30 @@ public class PeerConnectionTest extends TestCase {
assertTrue(--expectedErrors >= 0); assertTrue(--expectedErrors >= 0);
} }
public synchronized void expectSetSize(int width, int height) { public synchronized void expectSetSize() {
if (RENDER_TO_GUI) { if (RENDER_TO_GUI) {
// When new frames are delivered to the GUI renderer we don't get // When new frames are delivered to the GUI renderer we don't get
// notified of frame size info. // notified of frame size info.
return; return;
} }
expectedSetSizeDimensions.add(width); ++expectedSetSize;
expectedSetSizeDimensions.add(height);
} }
@Override @Override
public synchronized void setSize(int width, int height) { public synchronized void setSize(int width, int height) {
assertFalse(RENDER_TO_GUI); assertFalse(RENDER_TO_GUI);
assertEquals(width, expectedSetSizeDimensions.removeFirst().intValue()); assertTrue(--expectedSetSize >= 0);
assertEquals(height, expectedSetSizeDimensions.removeFirst().intValue()); // Because different camera devices (fake & physical) produce different
// resolutions, we only sanity-check the set sizes,
assertTrue(width > 0);
assertTrue(height > 0);
if (previouslySeenWidth > 0) {
assertEquals(previouslySeenWidth, width);
assertEquals(previouslySeenHeight, height);
} else {
previouslySeenWidth = width;
previouslySeenHeight = height;
}
} }
public synchronized void expectFramesDelivered(int count) { public synchronized void expectFramesDelivered(int count) {
@ -292,9 +302,8 @@ public class PeerConnectionTest extends TestCase {
stillWaitingForExpectations.add( stillWaitingForExpectations.add(
"expectedRemoveStreamLabels: " + expectedRemoveStreamLabels.size()); "expectedRemoveStreamLabels: " + expectedRemoveStreamLabels.size());
} }
if (!expectedSetSizeDimensions.isEmpty()) { if (expectedSetSize != 0) {
stillWaitingForExpectations.add( stillWaitingForExpectations.add("expectedSetSize");
"expectedSetSizeDimensions: " + expectedSetSizeDimensions.size());
} }
if (expectedFramesDelivered > 0) { if (expectedFramesDelivered > 0) {
stillWaitingForExpectations.add( stillWaitingForExpectations.add(
@ -506,7 +515,7 @@ public class PeerConnectionTest extends TestCase {
// serialized SDP, because the C++ API doesn't auto-translate. // serialized SDP, because the C++ API doesn't auto-translate.
// Drop |label| params from {Audio,Video}Track-related APIs once // Drop |label| params from {Audio,Video}Track-related APIs once
// https://code.google.com/p/webrtc/issues/detail?id=1253 is fixed. // https://code.google.com/p/webrtc/issues/detail?id=1253 is fixed.
offeringExpectations.expectSetSize(640, 480); offeringExpectations.expectSetSize();
WeakReference<MediaStream> oLMS = addTracksToPC( WeakReference<MediaStream> oLMS = addTracksToPC(
factory, offeringPC, videoSource, "oLMS", "oLMSv0", "oLMSa0", factory, offeringPC, videoSource, "oLMS", "oLMSv0", "oLMSa0",
offeringExpectations); offeringExpectations);
@ -532,7 +541,7 @@ public class PeerConnectionTest extends TestCase {
assertTrue(sdpLatch.await()); assertTrue(sdpLatch.await());
assertNull(sdpLatch.getSdp()); assertNull(sdpLatch.getSdp());
answeringExpectations.expectSetSize(640, 480); answeringExpectations.expectSetSize();
WeakReference<MediaStream> aLMS = addTracksToPC( WeakReference<MediaStream> aLMS = addTracksToPC(
factory, answeringPC, videoSource, "aLMS", "aLMSv0", "aLMSa0", factory, answeringPC, videoSource, "aLMS", "aLMSv0", "aLMSa0",
answeringExpectations); answeringExpectations);
@ -581,8 +590,8 @@ public class PeerConnectionTest extends TestCase {
// chosen arbitrarily). // chosen arbitrarily).
offeringExpectations.expectFramesDelivered(10); offeringExpectations.expectFramesDelivered(10);
answeringExpectations.expectFramesDelivered(10); answeringExpectations.expectFramesDelivered(10);
offeringExpectations.expectSetSize(640, 480); offeringExpectations.expectSetSize();
answeringExpectations.expectSetSize(640, 480); answeringExpectations.expectSetSize();
} }
offeringExpectations.expectIceConnectionChange( offeringExpectations.expectIceConnectionChange(

View File

@ -294,6 +294,10 @@ int32_t DeviceInfoLinux::FillCapabilityMap(int fd)
{ {
cap->rawType = kVideoYUY2; cap->rawType = kVideoYUY2;
} }
else if (videoFormats[fmts] == V4L2_PIX_FMT_YUV420)
{
cap->rawType = kVideoI420;
}
else if (videoFormats[fmts] == V4L2_PIX_FMT_MJPEG) else if (videoFormats[fmts] == V4L2_PIX_FMT_MJPEG)
{ {
cap->rawType = kVideoMJPEG; cap->rawType = kVideoMJPEG;