From f8a3bfff6fb9f84a80f32b1da3f0156864e00252 Mon Sep 17 00:00:00 2001 From: James Kuszmaul Date: Thu, 5 Mar 2015 11:10:47 -0500 Subject: Changed Simple Camera to default to mDNS "axis-camera.local". Change-Id: I498861b9fe7dc62aeb35b60ea1aa1e1407ecf0d1 --- .../gui/elements/VideoStreamViewerExtension.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/VideoStreamViewerExtension.java b/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/VideoStreamViewerExtension.java index c40f4c0..3186e43 100644 --- a/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/VideoStreamViewerExtension.java +++ b/smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/VideoStreamViewerExtension.java @@ -30,11 +30,11 @@ import javax.imageio.stream.ImageInputStream; public class VideoStreamViewerExtension extends StaticWidget { public static final String NAME = "Simple Camera Viewer"; - + private static final int[] START_BYTES = new int[]{0xFF, 0xD8}; private static final int[] END_BYTES = new int[]{0xFF, 0xD9}; - + private boolean ipChanged = true; private String ipString = null; private long lastFPSCheck = 0; @@ -62,14 +62,14 @@ public class VideoStreamViewerExtension extends StaticWidget { connection = url.openConnection(); connection.setReadTimeout(250); stream = connection.getInputStream(); - + while(!destroyed && !ipChanged){ while(System.currentTimeMillis()-lastRepaint<10){ stream.skip(stream.available()); Thread.sleep(1); } stream.skip(stream.available()); - + imageBuffer.reset(); for(int i = 0; i500){ lastFPSCheck = System.currentTimeMillis(); lastFPS = fpsCounter*2; fpsCounter = 0; } - + lastRepaint = System.currentTimeMillis(); ByteArrayInputStream tmpStream = new ByteArrayInputStream(imageBuffer.toByteArray()); imageToDraw = ImageIO.read(tmpStream); System.out.println(System.currentTimeMillis()-lastRepaint); repaint(); } - + } catch(Exception e){ imageToDraw = null; repaint(); e.printStackTrace(); } - + if(!ipChanged){ try { Thread.sleep(500); @@ -127,7 +127,7 @@ public class VideoStreamViewerExtension extends StaticWidget { private BufferedImage imageToDraw; private BGThread bgThread = new BGThread(); private final int team = DashboardPrefs.getInstance().team.getValue(); - public final IPAddressProperty ipProperty = new IPAddressProperty(this, "Camera IP Address", new int[]{10, (DashboardPrefs.getInstance().team.getValue() / 100), (DashboardPrefs.getInstance().team.getValue() % 100), 11}); + public final StringProperty ipProperty = new StringProperty(this, "Camera IP Address or mDNS name", "axis-camera.local"); @Override public void init() { -- cgit v1.2.3-54-g00ecf