Dolda2000 GitWeb
/
kaka
/
cakelight.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a LED controller that consumes LED frames from the modes
[kaka/cakelight.git]
/
src
/
kaka
/
cakelight
/
VideoMode.java
diff --git
a/src/kaka/cakelight/VideoMode.java
b/src/kaka/cakelight/VideoMode.java
index
e0dc386
..
e4b9400
100644
(file)
--- a/
src/kaka/cakelight/VideoMode.java
+++ b/
src/kaka/cakelight/VideoMode.java
@@
-5,7
+5,7
@@
import java.io.IOException;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.Optional;
import java.util.function.Consumer;
-public class VideoMode
implements Mode,
Consumer<Optional<File>> {
+public class VideoMode
extends Mode implements
Consumer<Optional<File>> {
private Configuration config;
private Thread thread;
private Consumer<Frame> frameConsumer;
private Configuration config;
private Thread thread;
private Consumer<Frame> frameConsumer;
@@
-34,8
+34,9
@@
public class VideoMode implements Mode, Consumer<Optional<File>> {
public void run() {
try (FrameGrabber grabber = FrameGrabber.from(videoDevice, config)) {
while (!isInterrupted()) {
public void run() {
try (FrameGrabber grabber = FrameGrabber.from(videoDevice, config)) {
while (!isInterrupted()) {
-// Optional<Frame> frame = grabber.grabFrame();
- grabber.grabFrame().ifPresent(frameConsumer);
+ Optional<Frame> frame = grabber.grabFrame();
+ if (frameConsumer != null) frame.ifPresent(frameConsumer);
+ frame.ifPresent(VideoMode.this::onFrame);
// timeIt("frame", grabber::grabFrame);
// TODO: process frame
// TODO: save where the LedController can access it
// timeIt("frame", grabber::grabFrame);
// TODO: process frame
// TODO: save where the LedController can access it
@@
-48,10
+49,15
@@
public class VideoMode implements Mode, Consumer<Optional<File>> {
thread.start();
}
thread.start();
}
- public void onFrame(Consumer<Frame> consumer) {
+ public void on
Video
Frame(Consumer<Frame> consumer) {
frameConsumer = consumer;
}
frameConsumer = consumer;
}
+ private void onFrame(Frame frame) {
+ assert frameListener != null;
+ frameListener.accept(frame.getLedFrame());
+ }
+
@Override
public void accept(Optional<File> videoDevice) {
// Should only happen when this mode is active!
@Override
public void accept(Optional<File> videoDevice) {
// Should only happen when this mode is active!