mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add AxisCamera wrapper class.
This takes hosts (IP or DNS name) rather than URLs, making it easier to use. Also add more overloads to resolve ambiguities encountered when using std::string and const char*, and also add overloads for std::initializer_list<T> so braced initializer lists can be used.
This commit is contained in:
37
java/src/edu/wpi/cscore/AxisCamera.java
Normal file
37
java/src/edu/wpi/cscore/AxisCamera.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2016. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
package edu.wpi.cscore;
|
||||
|
||||
/// A source that represents an Axis IP camera.
|
||||
public class AxisCamera extends HttpCamera {
|
||||
private static String hostToUrl(String host) {
|
||||
return "http://" + host + "/mjpg/video.mjpg";
|
||||
}
|
||||
|
||||
private static String[] hostToUrl(String[] hosts) {
|
||||
String[] urls = new String[hosts.length];
|
||||
for (int i = 0; i < hosts.length; i++) {
|
||||
urls[i] = hostToUrl(hosts[i]);
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
/// Create a source for an Axis IP camera.
|
||||
/// @param name Source name (arbitrary unique identifier)
|
||||
/// @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
public AxisCamera(String name, String host) {
|
||||
super(name, hostToUrl(host), CameraKind.kAxis);
|
||||
}
|
||||
|
||||
/// Create a source for an Axis IP camera.
|
||||
/// @param name Source name (arbitrary unique identifier)
|
||||
/// @param hosts Array of Camera host IPs/DNS names
|
||||
public AxisCamera(String name, String[] hosts) {
|
||||
super(name, hostToUrl(hosts), CameraKind.kAxis);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user