Android resize VirtualDisplay

I have several problems (actually more, but more important) with the Android MediaProjection API. Reading the graphic architecture will not help, so I just want to understand if I missed something in my code stream.

Let's pretend that:

  • I have a dedicated GL rendering stream initialized with the GL texture generated on it. I set the default buffer size for WxH for texture.

  • I am creating a SurfaceTexture using a GL texture and a surface for this surface texture.

  • Create a WxH-sized virtual display through MediaProjection and set its surface to the above surface.

Problem 1: everything works either perfectly (full frames arrive correctly) or not (all frames are black, or only half of each frame is visible, for example, the same half for all frames or some parts of the screen are repeated with other parts, sometimes even skewed).

Problem 2: the time spent on some GL full-screen games, after a FIXED amount of time (about 4 minutes), all incoming frames are frozen (for example, I get “new” frames, but actually the same image). Reading that with glReadPixels confirms the results - the problem is that the actual display goes past this frame. The only way to make it “restore” is to call the status bar or navigation bar, which instantly starts sending me the correct frames. Of course, after 4 minutes this happens again ...

3: resize() VirtualDisplay, setDefaultBUfferSize() GL, 90% , m # 1 ( / , ...)

updateTextureImage → GL , , , - GL- - ... ?

, VirtualDisplay MediaCodec ( GL) - . update , MediaCodec , , , , ( , VirtualDisplay - .)

, - VirtualDisplay, . , MediaProjection ... ...

PS: Nexus 6 Android 6.0.1.

+4
1

, SurfaceTexture ( GL). . , BufferQueue SurfaceTexture , 1 2 onFrameAvailable release() VirtualDisplay (, stop(), ).

- : . Home, ( ). - / /2 SurfaceTexture, VirtualDisplay. - .

, VirtualDisplay.resize() , SurfaceTexture.

+1

All Articles