|
16 | 16 | #include "wpi/timestamp.h"
|
17 | 17 |
|
18 | 18 | using namespace wpi::java;
|
19 |
| - |
20 | 19 | static bool mockTimeEnabled = false;
|
21 | 20 | static uint64_t mockNow = 0;
|
22 | 21 |
|
@@ -395,6 +394,35 @@ Java_edu_wpi_first_util_WPIUtilJNI_setRawFrameData
|
395 | 394 | f->pixelFormat = pixelFormat;
|
396 | 395 | }
|
397 | 396 |
|
| 397 | +/* |
| 398 | + * Class: edu_wpi_first_util_WPIUtilJNI |
| 399 | + * Method: setRawFrameData |
| 400 | + * Signature: (J[BIIIII)V |
| 401 | + */ |
| 402 | +JNIEXPORT void JNICALL |
| 403 | +Java_edu_wpi_first_util_WPIUtilJNI_setRawFrameData |
| 404 | + (JNIEnv* env, jclass, jlong frame, jbyteArray data, jint size, jint width, |
| 405 | + jint height, jint stride, jint pixelFormat) |
| 406 | +{ |
| 407 | + auto* f = reinterpret_cast<wpi::RawFrame*>(frame); |
| 408 | + if (!f) { |
| 409 | + wpi::ThrowNullPointerException(env, "frame is null"); |
| 410 | + return; |
| 411 | + } |
| 412 | + auto buf = env->GetByteArrayElements(env, data, size); |
| 413 | + if (!buf) { |
| 414 | + wpi::ThrowNullPointerException(env, "data is null"); |
| 415 | + return; |
| 416 | + } |
| 417 | + // there's no way to free a passed-in direct byte buffer |
| 418 | + f->SetData(buf, size, env->GetDirectBufferCapacity(data), nullptr, |
| 419 | + [](void*, void*, size_t) {}); |
| 420 | + f->width = width; |
| 421 | + f->height = height; |
| 422 | + f->stride = stride; |
| 423 | + f->pixelFormat = pixelFormat; |
| 424 | +} |
| 425 | + |
398 | 426 | /*
|
399 | 427 | * Class: edu_wpi_first_util_WPIUtilJNI
|
400 | 428 | * Method: setRawFrameInfo
|
|
0 commit comments