Sharing Android SurfaceTexture between two processes

Is it possible to split SurfaceTexture between two processes, for example Activity and Service?

I would like to create an Activity with a TextureView and update its SurfaceTexture from a separate service.

While I am creating a SurfaceTexture with the generated OpenGL texture (via glGenTextures), then I set this surface texture to my TextureView:

mSurfaceTexture = new SurfaceTexture(texture_id);
mTextureView.setSurfaceTexture(mSurfaceTexture);

The camera preview display for this SurfaceTexture in action works fine:

mCamera = Camera.open();
mCamera.setPreviewTexture(mTextureView.getSurfaceTexture());
mCamera.startPreview();

I would like to do the same, but from a separate service, passing it texture_file, for example:

mCamera = Camera.open();
mCamera.setPreviewTexture(new SurfaceTexture(texture_id));
mCamera.startPreview();

The reason is because I have a separate process that calls private api, which requires a SurfaceTexture to stream some content, and this process is accessed via helpl from the application.

thanks

+4
1

, , , API.

, ...

A -. SurfaceTexture . , SurfaceTexture, OpenGL ES.

, API, , , Surface . , SurfaceView, Surface , surfaceCreated() - BufferQueue (SurfaceFlinger), Binder IPC . MediaCodec, mediaserver.

, SurfaceView SurfaceTexture, , , , MediaCodec. IPC mediaserver. . SurfaceFlinger , SurfaceView, SurfaceTexture .

, , SurfaceTexture , Surface Surface . , IPC SurfaceTexture , GLES.

AIDL, , .

. EGLContexts, , , , .

, , doc.

+4

Source: https://habr.com/ru/post/1612315/


All Articles