diff options
author | James Kuszmaul <jabukuszmaul+collab@gmail.com> | 2015-03-05 11:10:47 -0500 |
---|---|---|
committer | James Kuszmaul <jabukuszmaul+collab@gmail.com> | 2015-03-05 11:13:25 -0500 |
commit | f8a3bfff6fb9f84a80f32b1da3f0156864e00252 (patch) | |
tree | b253a3d241c164c88815fba034beb51494354d07 | |
parent | 1418898a611a9dbc5051840c2252088fcd922b66 (diff) |
Changed Simple Camera to default to mDNS "axis-camera.local".
Change-Id: I498861b9fe7dc62aeb35b60ea1aa1e1407ecf0d1
-rw-r--r-- | smartdashboard/src/edu/wpi/first/smartdashboard/gui/elements/VideoStreamViewerExtension.java | 20 |
1 files 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; i<START_BYTES.length;){ int b = stream.read(); @@ -80,7 +80,7 @@ public class VideoStreamViewerExtension extends StaticWidget { } for(int i = 0; i<START_BYTES.length;++i) imageBuffer.write(START_BYTES[i]); - + for(int i = 0; i<END_BYTES.length;){ int b = stream.read(); imageBuffer.write(b); @@ -89,27 +89,27 @@ public class VideoStreamViewerExtension extends StaticWidget { else i = 0; } - + fpsCounter++; if(System.currentTimeMillis()-lastFPSCheck>500){ 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() { |