class SurfaceTextureWrapper extends SurfaceTexture {
public SurfaceTextureWrapper() {
super(genSurfaceTexture());
}
private static int genSurfaceTexture() {
int[] args = new int[1];
GLES20.glGenTextures(args.length, args, 0);
int textureHandle = args[0];
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureHandle);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
return textureHandle;
}
}
usage sample
(使用样本)
exoPlayer.setVideoSurface(new Surface(new SurfaceTextureWrapper());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…