-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathCameraFFM.java
More file actions
84 lines (65 loc) · 4.18 KB
/
Copy pathCameraFFM.java
File metadata and controls
84 lines (65 loc) · 4.18 KB
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
package javaforce.ffm;
import java.lang.foreign.*;
import java.lang.invoke.*;
import static java.lang.foreign.ValueLayout.*;
import javaforce.*;
import javaforce.ffm.*;
import javaforce.api.*;
/** CameraAPI FFM implementation.
*
* Generated by GenFFM - DO NOT EDIT
*/
public class CameraFFM implements CameraAPI {
private FFM ffm;
private static CameraFFM instance;
public static synchronized CameraFFM getInstance() {
if (instance == null) {
instance = new CameraFFM();
if (!instance.ffm_init()) {
JFLog.log("CameraFFM init failed!");
instance = null;
}
}
return instance;
}
private MethodHandle cameraStart;
public boolean cameraStart(long a1,int a2,int a3,int a4) { try { boolean _ret_value_ = (boolean)cameraStart.invokeExact(a1,a2,a3,a4);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle cameraStop;
public boolean cameraStop(long a1) { try { boolean _ret_value_ = (boolean)cameraStop.invokeExact(a1);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle cameraUninit;
public boolean cameraUninit(long a1) { try { boolean _ret_value_ = (boolean)cameraUninit.invokeExact(a1);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return false;} }
private MethodHandle cameraGetHeight;
public int cameraGetHeight(long a1) { try { int _ret_value_ = (int)cameraGetHeight.invokeExact(a1);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle cameraGetWidth;
public int cameraGetWidth(long a1) { try { int _ret_value_ = (int)cameraGetWidth.invokeExact(a1);return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private MethodHandle cameraGetFrame;
public int[] cameraGetFrame(long a1) { try { FFM.createFFMArray();cameraGetFrame.invokeExact(a1);return (int[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle cameraListDevices;
public java.lang.String[] cameraListDevices(long a1) { try { FFM.createFFMArray();cameraListDevices.invokeExact(a1);return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle cameraListModes;
public java.lang.String[] cameraListModes(long a1,int a2) { try { FFM.createFFMArray();cameraListModes.invokeExact(a1,a2);return (java.lang.String[])FFM.getArray(); } catch (Throwable t) { JFLog.log(t); return null;} }
private MethodHandle cameraInit;
public long cameraInit() { try { long _ret_value_ = (long)cameraInit.invokeExact();return _ret_value_; } catch (Throwable t) { JFLog.log(t); return -1;} }
private boolean ffm_init() {
if (FFM.debug) JFLog.log("CameraFFM init started");
MethodHandle init;
ffm = FFM.getInstance();
Library[] libs = new Library[] {new Library("v4l2")};
Library.findLibraries(null, libs);
Arena arena = Arena.ofAuto();
init = ffm.getFunction("CameraAPIinit", ffm.getFunctionDesciptor(ValueLayout.JAVA_BOOLEAN,ADDRESS));
if (init == null) return false;
try {if (!(boolean)init.invokeExact(libs[0].getPath(arena))) return false;} catch (Throwable t) {JFLog.log(t); return false;}
cameraStart = ffm.getFunctionPtr("_cameraStart", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG,JAVA_INT,JAVA_INT,JAVA_INT));
cameraStop = ffm.getFunctionPtr("_cameraStop", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG));
cameraUninit = ffm.getFunctionPtr("_cameraUninit", ffm.getFunctionDesciptor(JAVA_BOOLEAN,JAVA_LONG));
cameraGetHeight = ffm.getFunctionPtr("_cameraGetHeight", ffm.getFunctionDesciptor(JAVA_INT,JAVA_LONG));
cameraGetWidth = ffm.getFunctionPtr("_cameraGetWidth", ffm.getFunctionDesciptor(JAVA_INT,JAVA_LONG));
cameraGetFrame = ffm.getFunctionPtr("_cameraGetFrame", ffm.getFunctionDesciptorVoid(JAVA_LONG));
cameraListDevices = ffm.getFunctionPtr("_cameraListDevices", ffm.getFunctionDesciptorVoid(JAVA_LONG));
cameraListModes = ffm.getFunctionPtr("_cameraListModes", ffm.getFunctionDesciptorVoid(JAVA_LONG,JAVA_INT));
cameraInit = ffm.getFunctionPtr("_cameraInit", ffm.getFunctionDesciptor(JAVA_LONG));
if (FFM.debug) JFLog.log("CameraFFM init complete");
return true;
}
}