Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer creation from another buffer #132

Open
hauges opened this issue Jan 11, 2019 · 5 comments
Open

Buffer creation from another buffer #132

hauges opened this issue Jan 11, 2019 · 5 comments

Comments

@hauges
Copy link

hauges commented Jan 11, 2019

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?

@neilcsmith-net
Copy link
Member

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.

@hauges
Copy link
Author

hauges commented Jan 14, 2019

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
Copy link
Author

hauges commented Jan 14, 2019

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

@neilcsmith-net
Copy link
Member

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!

@hauges
Copy link
Author

hauges commented Jan 14, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants