Dolda2000 GitWeb
/
kaka
/
cakelight.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Moved config.properties out of the repo
[kaka/cakelight.git]
/
src
/
kaka
/
cakelight
/
VideoMode.java
diff --git
a/src/kaka/cakelight/VideoMode.java
b/src/kaka/cakelight/VideoMode.java
index
e0dc386
..
ca0bd53
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
{
private Configuration config;
private Thread thread;
private Consumer<Frame> frameConsumer;
private Configuration config;
private Thread thread;
private Consumer<Frame> frameConsumer;
@@
-13,7
+13,7
@@
public class VideoMode implements Mode, Consumer<Optional<File>> {
public VideoMode() {
deviceListener = new VideoDeviceListener();
public VideoMode() {
deviceListener = new VideoDeviceListener();
- deviceListener.onVideoDeviceChange(this);
+ deviceListener.onVideoDeviceChange(this
::onVideoDeviceChange
);
}
@Override
}
@Override
@@
-34,11
+34,10
@@
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);
// timeIt("frame", grabber::grabFrame);
- // TODO: process frame
- // TODO: save where the LedController can access it
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
@@
-48,12
+47,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;
}
- @Override
- public void accept(Optional<File> videoDevice) {
+ private void onFrame(Frame frame) {
+ updateWithFrame(frame.getLedFrame());
+ }
+
+ public void onVideoDeviceChange(Optional<File> videoDevice) {
// Should only happen when this mode is active!
if (thread != null) {
thread.interrupt();
// Should only happen when this mode is active!
if (thread != null) {
thread.interrupt();