File tree Expand file tree Collapse file tree
src/main/java/io/github/doblon8/openpnp/capture Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package io .github .doblon8 .openpnp .capture ;
2+
3+ import static io .github .doblon8 .openpnp .capture .bindings .openpnp_capture .Cap_closeStream ;
4+ import static io .github .doblon8 .openpnp .capture .bindings .openpnp_capture .Cap_isOpenStream ;
5+
6+ public class CaptureStream {
7+ private final CaptureContext context ;
8+ private final int id ;
9+
10+ public CaptureStream (CaptureContext context , int id ) {
11+ this .context = context ;
12+ this .id = id ;
13+ }
14+
15+ /**
16+ * Check if a stream is open, i.e. is capturing data.
17+ *
18+ * @return true if the stream is open, false otherwise.
19+ */
20+ public boolean isOpen () {
21+ var result = Cap_isOpenStream (context .getSegment (), id );
22+ return result == 1 ;
23+ }
24+
25+ /**
26+ * Close a capture stream.
27+ *
28+ * @throws CaptureException if an error occurs while closing the capture stream.
29+ */
30+ public void close () {
31+ int result = Cap_closeStream (context .getSegment (), id );
32+ CaptureResult captureResult = CaptureResult .values ()[result ];
33+ if (captureResult != CaptureResult .OK ) {
34+ throw new CaptureException ("Error closing capture stream: " + result );
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments