diff --git a/java/lib/CameraServerJNI.cpp b/java/lib/CameraServerJNI.cpp index 0518f2e404..01951488b6 100644 --- a/java/lib/CameraServerJNI.cpp +++ b/java/lib/CameraServerJNI.cpp @@ -889,7 +889,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSinkEnabled /* * Class: edu_wpi_cscore_CameraServerJNI * Method: addListener - * Signature: (Ledu/wpi/cameraserver/CameraServerJNI/ConnectionListenerFunction;IZ)I + * Signature: (Ljava/util/function/Consumer;IZ)I */ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener (JNIEnv *envouter, jclass, jobject listener, jint eventMask, jboolean immediateNotify) @@ -904,8 +904,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_addListener if (!cls) return 0; // method ids, on the other hand, are safe to retain - jmethodID mid = envouter->GetMethodID(cls, "apply", - "(Ledu/wpi/cameraserver/VideoEvent;)V"); + jmethodID mid = envouter->GetMethodID(cls, "accept", "(Ljava/lang/Object;)V"); if (!mid) return 0; CS_Status status = 0; diff --git a/java/src/edu/wpi/cscore/CameraServerJNI.java b/java/src/edu/wpi/cscore/CameraServerJNI.java index 380e30ffce..26cce88f8c 100644 --- a/java/src/edu/wpi/cscore/CameraServerJNI.java +++ b/java/src/edu/wpi/cscore/CameraServerJNI.java @@ -13,6 +13,7 @@ import java.io.OutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; +import java.util.function.Consumer; import org.opencv.core.Core; public class CameraServerJNI { @@ -164,7 +165,7 @@ public class CameraServerJNI { // // Listener Functions // - public static native int addListener(VideoListenerFunction listener, + public static native int addListener(Consumer listener, int eventMask, boolean immediateNotify); public static native void removeListener(int handle); diff --git a/java/src/edu/wpi/cscore/VideoListener.java b/java/src/edu/wpi/cscore/VideoListener.java index 395005030d..b62a867dfc 100644 --- a/java/src/edu/wpi/cscore/VideoListener.java +++ b/java/src/edu/wpi/cscore/VideoListener.java @@ -7,6 +7,8 @@ package edu.wpi.cscore; +import java.util.function.Consumer; + /// An event listener. This calls back to a desigated callback function when /// an event matching the specified mask is generated by the library. public class VideoListener { @@ -15,7 +17,7 @@ public class VideoListener { /// @param eventMask Bitmask of VideoEvent.Type values /// @param immediateNotify Whether callback should be immediately called with /// a representative set of events for the current library state. - public VideoListener(VideoListenerFunction listener, int eventMask, + public VideoListener(Consumer listener, int eventMask, boolean immediateNotify) { m_handle = CameraServerJNI.addListener(listener, eventMask, immediateNotify); } diff --git a/java/src/edu/wpi/cscore/VideoListenerFunction.java b/java/src/edu/wpi/cscore/VideoListenerFunction.java deleted file mode 100644 index 34130c4935..0000000000 --- a/java/src/edu/wpi/cscore/VideoListenerFunction.java +++ /dev/null @@ -1,12 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2016. All Rights Reserved. */ -/* Open Source Software - may be modified and shared by FRC teams. The code */ -/* must be accompanied by the FIRST BSD license file in the root directory of */ -/* the project. */ -/*----------------------------------------------------------------------------*/ - -package edu.wpi.cscore; - -public interface VideoListenerFunction { - void apply(VideoEvent event); -}