Closed inventionsbyhamid closed 4 years ago
Could you show your code as an example?
And is requestRender called?
Here is the link https://github.com/inventionsbyhamid/AndroidInstantVideo/tree/screen_display I have created a separate activity "ScreenPublisherActivity" to just draw the screen preview. Not able to figure out why nothing gets drawn on the texture view.
I check and the onFrameAvailable is not called, I am wondering why
It seems that the surface in ImageReader works fine. Need to look into the source code of it.
I try to use
surfaceTexture.setDefaultBufferSize(width, height);
And it works. Add this line before set onFrameAvailable listener:
displayTextureView.setSurfaceTextureCreatedListener(new GLMultiTexProducerView.SurfaceTextureCreatedListener() {
@Override
public void onCreated(List<GLTexture> producedTextureList) {
GLTexture texture = producedTextureList.get(0);
surfaceTexture = texture.getSurfaceTexture();
RawTexture outsideTexture = texture.getRawTexture();
width = outsideTexture.getWidth();
height = outsideTexture.getHeight();
surfaceTexture.setDefaultBufferSize(width, height);
surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
Log.i(TAG, "onFrameAvailable");
displayTextureView.requestRender();
}
}, mHandler);
mSurface = new Surface(surfaceTexture);
if(mVirtualDisplay != null) {
mVirtualDisplay.setSurface(mSurface);
}
}
});
It works fine. Thanks for the help!
We can display screen using the following sample: https://github.com/android/media-samples/tree/master/ScreenCapture
MediaProjection requires to give a surface to draw screen frames. I am modifying the TestCameraPublisherActivity to also include the screen display on the textureview. When I pass the surface obtained in the SurfaceTextureCreatedListener to media projection, nothing is drawn when i use canvasGL.drawSurfaceTexture, I also set the onFrameAvailable on the SurfaceTexture and can see that it is being called for screen display.
Any help as to why drawing the screen display surface texture does not show on the preview?