5#ifndef WPIUTIL_WPI_RAWFRAME_H_
6#define WPIUTIL_WPI_RAWFRAME_H_
19#ifdef WPI_RAWFRAME_JNI
64 size_t capacity,
void* cbdata,
65 void (*freeFunc)(
void* cbdata,
void* data,
89 rhs.freeFunc =
nullptr;
90 rhs.freeCbData =
nullptr;
97 rhs.freeFunc =
nullptr;
98 rhs.freeCbData =
nullptr;
117#ifdef WPI_RAWFRAME_JNI
118template <std::same_as<wpi::RawFrame> T>
119void SetFrameData(JNIEnv* env, jclass rawFrameCls, jobject jframe,
120 const T& frame,
bool newData) {
122 static jmethodID setData = env->GetMethodID(rawFrameCls,
"setDataJNI",
123 "(Ljava/nio/ByteBuffer;IIII)V");
125 jframe, setData, env->NewDirectByteBuffer(frame.data, frame.size),
126 static_cast<jint
>(frame.width),
static_cast<jint
>(frame.height),
127 static_cast<jint
>(frame.stride),
static_cast<jint
>(frame.pixelFormat));
129 static jmethodID setInfo =
130 env->GetMethodID(rawFrameCls,
"setInfoJNI",
"(IIII)V");
131 env->CallVoidMethod(jframe, setInfo,
static_cast<jint
>(frame.width),
132 static_cast<jint
>(frame.height),
133 static_cast<jint
>(frame.stride),
134 static_cast<jint
>(frame.pixelFormat));
int WPI_AllocateRawFrameData(WPI_RawFrame *frame, size_t requestedSize)
WPI_PixelFormat
Pixel formats.
Definition: RawFrame.h:49
@ WPI_PIXFMT_YUYV
Definition: RawFrame.h:52
@ WPI_PIXFMT_Y16
Definition: RawFrame.h:56
@ WPI_PIXFMT_UYVY
Definition: RawFrame.h:57
@ WPI_PIXFMT_MJPEG
Definition: RawFrame.h:51
@ WPI_PIXFMT_GRAY
Definition: RawFrame.h:55
@ WPI_PIXFMT_RGB565
Definition: RawFrame.h:53
@ WPI_PIXFMT_BGR
Definition: RawFrame.h:54
@ WPI_PIXFMT_UNKNOWN
Definition: RawFrame.h:50
void WPI_SetRawFrameData(WPI_RawFrame *frame, void *data, size_t size, size_t capacity, void *cbdata, void(*freeFunc)(void *cbdata, void *data, size_t capacity))
void WPI_FreeRawFrameData(WPI_RawFrame *frame)
struct WPI_RawFrame WPI_RawFrame
Raw Frame.
Definition: ntcore_cpp.h:26
Raw Frame.
Definition: RawFrame.h:32
int pixelFormat
Definition: RawFrame.h:40
void * freeCbData
Definition: RawFrame.h:37
void(* freeFunc)(void *cbdata, void *data, size_t capacity)
Definition: RawFrame.h:36
size_t capacity
Definition: RawFrame.h:38
uint8_t * data
Definition: RawFrame.h:34
size_t size
Definition: RawFrame.h:39
int height
Definition: RawFrame.h:42
int stride
Definition: RawFrame.h:43
int width
Definition: RawFrame.h:41
Definition: RawFrame.h:74
RawFrame(RawFrame &&rhs) noexcept
Definition: RawFrame.h:87
RawFrame & operator=(const RawFrame &)=delete
void SetData(void *data, size_t size, size_t capacity, void *cbdata, void(*freeFunc)(void *cbdata, void *data, size_t capacity))
Definition: RawFrame.h:104
RawFrame & operator=(RawFrame &&rhs) noexcept
Definition: RawFrame.h:94
bool Reserve(size_t size)
Definition: RawFrame.h:110
RawFrame(const RawFrame &)=delete
RawFrame()
Definition: RawFrame.h:75
~RawFrame()
Definition: RawFrame.h:114