We are making video stream application on java. We use JNI on h264 encode and decode , but the most big problem on java is All data must send from Java to JNI by copying. There is solution that is called ByteBuffers but on ByteBuffers when the data returned back to java. I need to return data back to byte[] for manupilating data.Again it is making copying.
There is ByteBuffer get method: ByteBuffer bb; ... bb.get(0); //but this is very slow to get data by index on the loops... byte data[] = new byte[bb.limit()]; bb.get(data); // this one is "copying" again to manupilating data.
So , i need to pass ByteBuffer to JNI method pass again to manupilating data without copying.
is there any solution to get byte[] from jni to java make data without copying ? I heard about GetPrimitiveArrayCritical , but some people call its freezing JVM Garbage collector.
What about mappedbytebuffer on java ? can we make shared data to use directly as byte[] array on java.