Add GetNextFrame timeout to CvSink and MjpegServer.

MjpegServer uses the timeout to generate keep-alives to any clients
(which helps detect disconnects and avoid stale client threads).

CvSink GrabFrame now defaults to a timeout, but the timeout can be
changed by the user, or the old no-timeout version is now available
as GrabFrameNoTimeout.
This commit is contained in:
Peter Johnson
2017-02-17 01:17:12 -08:00
parent 5e9575de66
commit 61e34621cc
14 changed files with 126 additions and 5 deletions

View File

@@ -1261,6 +1261,21 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrame
return rv;
}
/*
* Class: edu_wpi_cscore_CameraServerJNI
* Method: grabSinkFrameTimeout
* Signature: (IJD)J
*/
JNIEXPORT jlong JNICALL Java_edu_wpi_cscore_CameraServerJNI_grabSinkFrameTimeout
(JNIEnv *env, jclass, jint sink, jlong imageNativeObj, jdouble timeout)
{
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
auto rv = cs::GrabSinkFrameTimeout(sink, image, timeout, &status);
CheckStatus(env, status);
return rv;
}
/*
* Class: edu_wpi_cscore_CameraServerJNI
* Method: getSinkError