Skip to content

Commit cae58bf

Browse files
committed
Updated JPEGEncoder
Added nice static methods for construction. The constructors would have been too confusing.
1 parent 38bcf49 commit cae58bf

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/au/edu/jcu/v4l4j/encoder/JPEGEncoder.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88

99
public class JPEGEncoder extends AbstractVideoFrameEncoder {
1010

11-
static {
12-
try {
13-
System.loadLibrary("v4l4j");
14-
} catch (UnsatisfiedLinkError e) {
15-
System.err.println("Cant load v4l4j JNI library");
16-
throw e;
17-
}
11+
protected int quality;
12+
13+
public static JPEGEncoder from(int width, int height, ImagePalette from) {
14+
return new JPEGEncoder(width, height, from);
1815
}
1916

20-
protected int quality;
17+
public static JPEGEncoder to(int width, int height, ImagePalette to) {
18+
return new JPEGEncoder(width, height, ImagePalette.JPEG, to);
19+
}
20+
21+
protected JPEGEncoder(int width, int height, ImagePalette from, ImagePalette to) {
22+
super(width, height, from, to);
23+
}
2124

2225
public JPEGEncoder(int width, int height, ImagePalette from) {
2326
super(width, height, from, ImagePalette.JPEG);
@@ -35,6 +38,7 @@ public void setQuality(int quality) {
3538
quality = V4L4JConstants.MAX_JPEG_QUALITY;
3639
this.quality = quality;
3740
}
41+
3842
@Override
3943
public VideoFrame encode(BaseVideoFrame frame) throws V4L4JException {
4044
super.putBuffer(frame.getBytes(), frame.getFrameLength());

0 commit comments

Comments
 (0)