public static class VideoFrameStruct extends com.sun.jna.Structure {
public static class ByReference extends VideoFrameStruct implements com.sun.jna.Structure.ByReference {}
public volatile VideoInfoStruct.ByReference info;
public volatile int /*VideoFrameFlags*/ flags; // maybe just int?
public volatile Buffer buffer;
public volatile Pointer meta;
public volatile int id;
public volatile Pointer[] data = new Pointer[GST_VIDEO_MAX_PLANES];
public volatile GstBufferAPI.MapInfoStruct[] map = new GstBufferAPI.MapInfoStruct[GST_VIDEO_MAX_PLANES];
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{
"info", "flags", "buffer", "meta", "id", "data", "map"
});
}
}
But I get either sefgaults or "Array fields must be initialized" errors (if I don't explicitly create the arrays as shown above).
Any pointers will be appreciated :-)
VideoFrameStruct.ByReference frame = new VideoFrameStruct.ByReference();
boolean res = GSTVIDEO_API.gst_video_frame_map(frame, info, buffer, flags);
> However, I'm still not sure how to obtain a valid reference to a VideoFrameStruct structure. The C code using GstVideoFrame looks like:
>
> GstVideoFrame v_frame;
> if (!gst_video_frame_map (&v_frame, &v_info, buf, flags)) {
> g_warning ("Failed to map the video buffer");
> }
>
> which I'm mapping as:
>
> VideoFrameStruct.ByReference frame = new VideoFrameStruct.ByReference();
>
> boolean res = GSTVIDEO_API.gst_video_frame_map(frame, info, buffer, flags);
>
>
> Although my gst_video_frame_map() call from Java does not generate more segfaults, the frame structure is essentially empty, i.e.: the buffer and meta fields are null, as well as all the entries in data.
You can manually call Structure.read() after the call; while that is not the final solution, it _will_ indicate whether the native code is actually populating your native memory. Normally JNA will do this for you automatically.
guint id = *(guint *) cframe.data[0];
would translate as:
int id = jframe.data[0].getPointer(0).getInt(0)