gst1-java-core icon indicating copy to clipboard operation
gst1-java-core copied to clipboard

Buffer creation from another buffer

Open hauges opened this issue 7 years ago • 5 comments

I want to construct a new org.freedesktop.gstreamer.Buffer object with data from another Buffer. For example, with the python library, I could do something like this:

buffer = gst.Buffer(otherBuffer.data)

Is there any way I could do this using the java library?

hauges avatar Jan 11 '19 19:01 hauges

Is that copying the buffer data or creating a buffer that wraps the same data? Can you provide a link, ideally to the C API equivalent. You should be able to copy by creating a buffer and mapping the ByteBuffers, one with write, I think. You might also look at the GstBufferAPI in lowlevel to see if it provides anything extra you need.

neilcsmith-net avatar Jan 11 '19 20:01 neilcsmith-net

I want to copy the buffer data and create a new buffer containing that data along with other data I pull from my system. I thinkGstBufferAPI.MapInfoStruct may be what I'm looking for (it has a data field), but I am too unfamiliar with the com.sun.jna.Pointer API to create a new GstBufferAPI.MapInfoStruct.

I couldn't find an equivalent C API, but this is the python documentation on buffer.data.

hauges avatar Jan 14 '19 13:01 hauges

It also appears there is no way I can inject a MapInfoStruct into a Buffer.

hauges avatar Jan 14 '19 13:01 hauges

You don't need to use the structs, but we are missing low level mappings for copying.

You should be able to map the source buffer to get the ByteBuffer, create a new Buffer of that size, map the new buffer as writable, copy one ByteBuffer into the other, and unmap both. Not tried it though!

neilcsmith-net avatar Jan 14 '19 13:01 neilcsmith-net

Thanks so much! Unfortunately my testing for this is now blocked by #133

hauges avatar Jan 14 '19 18:01 hauges