2016-08-26 09:01:54 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2016-11-05 22:11:55 -07:00
|
|
|
package edu.wpi.cscore;
|
2016-08-25 23:13:48 -07:00
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* A source that represents a MJPEG-over-HTTP (IP) camera.
|
|
|
|
|
*/
|
2017-01-01 14:24:13 -08:00
|
|
|
public class HttpCamera extends VideoCamera {
|
|
|
|
|
public enum HttpCameraKind {
|
2016-11-28 00:22:15 -08:00
|
|
|
kUnknown(0), kMJPGStreamer(1), kCSCore(2), kAxis(3);
|
|
|
|
|
private int value;
|
|
|
|
|
|
2017-01-01 14:24:13 -08:00
|
|
|
private HttpCameraKind(int value) {
|
2016-11-28 00:22:15 -08:00
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-01 14:24:13 -08:00
|
|
|
public static HttpCameraKind getHttpCameraKindFromInt(int kind) {
|
2016-11-28 00:22:15 -08:00
|
|
|
switch (kind) {
|
2017-01-01 14:24:13 -08:00
|
|
|
case 1: return HttpCameraKind.kMJPGStreamer;
|
|
|
|
|
case 2: return HttpCameraKind.kCSCore;
|
|
|
|
|
case 3: return HttpCameraKind.kAxis;
|
|
|
|
|
default: return HttpCameraKind.kUnknown;
|
2016-11-28 00:22:15 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Create a source for a MJPEG-over-HTTP (IP) camera.
|
|
|
|
|
* @param name Source name (arbitrary unique identifier)
|
|
|
|
|
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
|
|
|
|
|
*/
|
2016-12-04 00:08:47 -08:00
|
|
|
public HttpCamera(String name, String url) {
|
2017-01-01 14:24:13 -08:00
|
|
|
super(CameraServerJNI.createHttpCamera(name, url, HttpCameraKind.kUnknown.getValue()));
|
2016-11-28 00:22:15 -08:00
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Create a source for a MJPEG-over-HTTP (IP) camera.
|
|
|
|
|
* @param name Source name (arbitrary unique identifier)
|
|
|
|
|
* @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
|
|
|
|
|
* @param kind Camera kind (e.g. kAxis)
|
|
|
|
|
*/
|
2017-01-01 14:24:13 -08:00
|
|
|
public HttpCamera(String name, String url, HttpCameraKind kind) {
|
2016-11-28 00:22:15 -08:00
|
|
|
super(CameraServerJNI.createHttpCamera(name, url, kind.getValue()));
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Create a source for a MJPEG-over-HTTP (IP) camera.
|
|
|
|
|
* @param name Source name (arbitrary unique identifier)
|
|
|
|
|
* @param urls Array of Camera URLs
|
|
|
|
|
*/
|
2016-11-28 00:22:15 -08:00
|
|
|
public HttpCamera(String name, String[] urls) {
|
2017-01-01 14:24:13 -08:00
|
|
|
super(CameraServerJNI.createHttpCameraMulti(name, urls, HttpCameraKind.kUnknown.getValue()));
|
2016-11-28 00:22:15 -08:00
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Create a source for a MJPEG-over-HTTP (IP) camera.
|
|
|
|
|
* @param name Source name (arbitrary unique identifier)
|
|
|
|
|
* @param urls Array of Camera URLs
|
|
|
|
|
* @param kind Camera kind (e.g. kAxis)
|
|
|
|
|
*/
|
2017-01-01 14:24:13 -08:00
|
|
|
public HttpCamera(String name, String[] urls, HttpCameraKind kind) {
|
2016-11-28 00:22:15 -08:00
|
|
|
super(CameraServerJNI.createHttpCameraMulti(name, urls, kind.getValue()));
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Get the kind of HTTP camera.
|
|
|
|
|
* Autodetection can result in returning a different value than the camera
|
|
|
|
|
* was created with.
|
|
|
|
|
*/
|
2017-01-01 14:24:13 -08:00
|
|
|
public HttpCameraKind getHttpCameraKind() {
|
|
|
|
|
return getHttpCameraKindFromInt(CameraServerJNI.getHttpCameraKind(m_handle));
|
2016-11-28 00:22:15 -08:00
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Change the URLs used to connect to the camera.
|
|
|
|
|
*/
|
2016-12-23 13:20:09 -08:00
|
|
|
public void setUrls(String[] urls) {
|
2016-11-28 00:22:15 -08:00
|
|
|
CameraServerJNI.setHttpCameraUrls(m_handle, urls);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-11 21:56:14 -08:00
|
|
|
/**
|
|
|
|
|
* Get the URLs used to connect to the camera.
|
|
|
|
|
*/
|
2016-12-23 13:20:09 -08:00
|
|
|
public String[] getUrls() {
|
2016-11-28 00:22:15 -08:00
|
|
|
return CameraServerJNI.getHttpCameraUrls(m_handle);
|
2016-08-25 23:13:48 -07:00
|
|
|
}
|
|
|
|
|
}
|