import java.util.Date;
import java.util.List;
import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
// Will be filled with only 1 address.
@config private IoTSet<IoTDeviceAddress> cam_addresses;
+ public AmcrestCamera(String _credentialUsername, String _credentialPassword, IoTSet<IoTDeviceAddress> _camAddresses) throws RemoteException {
+ credentialUsername = _credentialUsername;
+ credentialPassword = _credentialPassword;
+ cam_addresses = _camAddresses;
+ }
public AmcrestCamera(String _credentialUsername, String _credentialPassword) throws RemoteException {
credentialUsername = _credentialUsername;
httpConnection.setDoInput(true);
httpConnection.setRequestProperty("Authorization", httpAuthCredentials);
httpConnection.connect();
-
+
InputStream is = httpConnection.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
DataInputStream din = new DataInputStream(bis);
-
+
// wait for a response
try {
Thread.sleep(1000);
return false;
// e.printStackTrace();
}
-
+
httpConnection.disconnect();
} catch (IOException e) {
return false;
camUrlString += "&Encode[0].MainFormat[0].Video.Height=480&Encode[0].MainFormat[0].Video.Width=640";
}
-
try {
String credsPreBase64 = credentialUsername + ":" + credentialPassword;
return; // already started
}
-
-
doEnd.set(false);
if (!streamConnect()) {
String httpAuthCredentials = "Basic " + credsBase64;
IoTHTTP httpConnection = new IoTHTTP(deviceAddress);
- httpConnection.setURL("/cgi-bin/mjpg/video.cgi?");
+ httpConnection.setURL("/cgi-bin/mjpg/video.cgi?channel=0&subtype=1");
+ //httpConnection.setURL("/cgi-bin/mjpg/video.cgi?channel=0&subtype=1", credentialUsername, credentialPassword);
httpConnection.openConnection();
httpConnection.setDoInput(true);
httpConnection.setRequestProperty("Authorization", httpAuthCredentials);
}
}
+
+ /* TODO: Uncomment this part to do camera test
+ public static void main(String[] args) throws Exception {
+
+ System.out.println("Running AmcrestCamera!");
+
+ IoTDeviceAddress iotDevAdd = new IoTDeviceAddress(args[0], 12345, 80, false, false);
+ Set<IoTDeviceAddress> set = new HashSet<IoTDeviceAddress>();
+ set.add(iotDevAdd);
+ IoTSet<IoTDeviceAddress> iotset = new IoTSet<IoTDeviceAddress>(set);
+
+ AmcrestCamera cam = new AmcrestCamera(args[1], args[2], iotset);
+ cam.init();
+ cam.setFPS(15);
+ cam.setResolution(Resolution.RES_VGA);
+ cam.start();
+
+ while (true) {
+
+ }
+ }*/
}