-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
F3201.java
99 lines (79 loc) · 2.04 KB
/
F3201.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package com.github.sarxos.webcam.ds.ipcam.device.zavio;
import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;
import com.github.sarxos.webcam.WebcamException;
import com.github.sarxos.webcam.ds.ipcam.IpCamDevice;
import com.github.sarxos.webcam.ds.ipcam.IpCamMode;
/**
* F3201 Compact IP Camera from Zavio.
*
* @author Bartosz Firyn (SarXos)
*/
public class F3201 extends IpCamDevice {
public static final Dimension SIZE_HD_1080 = new Dimension(1280, 1024);
public static final Dimension SIZE_HD_720 = new Dimension(1280, 720);
public static final Dimension SIZE_QVGA = new Dimension(320, 240);
//@formatter:off
private static final Dimension[] SIZES = new Dimension[] {
SIZE_HD_1080,
SIZE_HD_720,
SIZE_QVGA,
};
//@formatter:on
private URL base = null;
public F3201(String name, String urlBase) {
this(name, toURL(urlBase));
}
public F3201(String name, URL base) {
super(name, null, IpCamMode.PULL);
this.base = base;
}
@Override
public Dimension[] getSizes() {
return SIZES;
}
@Override
public void setSize(Dimension size) {
int index = -1;
for (int i = 0; i < SIZES.length; i++) {
if (SIZES[i].equals(size)) {
index = i;
break;
}
}
if (index == -1) {
throw new IllegalArgumentException(String.format("Incorrect size %s", size));
}
super.setSize(size);
}
@Override
public URL getURL() {
int index = -1;
for (int i = 0; i < SIZES.length; i++) {
if (SIZES[i].equals(getSize())) {
index = i;
break;
}
}
int profile = 0;
switch (index) {
case 0:
profile = 0;
break;
case 1:
profile = 3;
break;
case 2:
profile = 4;
break;
}
long time = System.currentTimeMillis();
String url = String.format("%s/cgi-bin/view/image?pro_%d&%d", base, profile, time);
try {
return new URL(url);
} catch (MalformedURLException e) {
throw new WebcamException(String.format("Incorrect URL %s", url), e);
}
}
}