Issue in passing Egl configured surface to native and push the data

£可爱£侵袭症+ 提交于 2019-12-04 20:24:08

At the same time i want to retrieve the data from this Surface and pass it to the encoder

You can't retrieve data from a Surface. Surfaces are the producer side of a producer-consumer pair.

You're getting the "already connected" errors because you're attempting to attach a second producer to the Surface.

(If you want to pick nits, BufferQueue will re-use buffers without clearing them, so the producer can often see the data from a frame or two back. But since the producer created those frames in the first place, there's not much value in pulling them back out. And there is no guarantee that BufferQueue won't give you an empty buffer, or present them out of order.)

The good news is that, for a SurfaceTexture, the consumer is in-process and the data is accessible as a GLES "external" texture. The TextureView class provides a convenient getBitmap() method that renders the most recent frame into a Bitmap, allowing direct access to the pixels. (You can do something similar by rendering the texture to an off-screen pbuffer and reading the pixels out with glReadPixels().)

So to implement the solution you want, the easiest thing would be to just use the TextureView call to get a Bitmap.

More information about Surfaces can be found in the graphics architecture doc.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!