Example for post https://habr.com/ru/post/480878/ about of interaction android camera api v2, glsurafceview, mediacodec and surfaces.
This sample of outputting camera preview on screen with overlay custom drawable and capability record result video to file. For composition video.
For composition video used OpenGL + external texture, for record used MediaCodec + EGLSurface Common scheme:
Because camera api, glsurfaceview, mediacodec etc have async api we wrap work with them in state machines: