Skip to content Skip to sidebar Skip to footer

How To Understand The Underneath Of Setdisplay/setsurface/setprewviewdisplay/setpreviewtexture For Android

Since Android api level 1, We can attach a MediaPlayer or Camera to the Surface with setDisplay or setPrewviewDisplay, then image data can be transfered to gpu and processed much f

Solution 1:

The data is not produced on the CPU side. The camera and hardware video codecs store their data in buffers allocated by the kernel gralloc mechanism (referenced from native code through the non-public GraphicBuffer). Surfaces communicate through BufferQueue objects, which pass the frames around by handle, without copying the data itself.

It's up to the OEM to ensure that the camera, video codecs, and GPU can use common formats. The YUV output by the video codec must be something that the GLES implementation can handle as an external texture. This is also why EGL_RECORDABLE_ANDROID is needed when sending GLES rendering to a MediaCodec... need to let the EGL implementation know that the frame it's rendering must be recognizable by the video codec.

Post a Comment for "How To Understand The Underneath Of Setdisplay/setsurface/setprewviewdisplay/setpreviewtexture For Android"