import java.util.Optional;
import java.util.function.Consumer;
-public class VideoMode extends Mode implements Consumer<Optional<File>> {
+public class VideoMode extends Mode {
private Configuration config;
private Thread thread;
private Consumer<Frame> frameConsumer;
public VideoMode() {
deviceListener = new VideoDeviceListener();
- deviceListener.onVideoDeviceChange(this);
+ deviceListener.onVideoDeviceChange(this::onVideoDeviceChange);
}
@Override
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
}
} catch (IOException e) {
e.printStackTrace();
}
private void onFrame(Frame frame) {
- assert frameListener != null;
- frameListener.accept(frame.getLedFrame());
+ updateWithFrame(frame.getLedFrame());
}
- @Override
- public void accept(Optional<File> videoDevice) {
+ public void onVideoDeviceChange(Optional<File> videoDevice) {
// Should only happen when this mode is active!
if (thread != null) {
thread.interrupt();