This is a follow-up question of this question.
This is my TextureView
code:
public class VideoTextureView extends TextureView implements SurfaceTextureListener{
private static final String LOG_TAG = VideoTextureView.class.getSimpleName();
private MediaCodecDecoder mMediaDecoder;
private MediaCodecAsyncDecoder mMediaAsyncDecoder;
public VideoTextureView(Context context, AttributeSet attrs) {
super(context, attrs);
setSurfaceTextureListener(this);
Log.d(LOG_TAG, "Video texture created.");
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.d(LOG_TAG, "Surface Available: " + width + " x " + height);
mMediaDecoder = new MediaCodecDecoder();
mMediaDecoder.Start();
mMediaDecoder.SetSurface(new Surface(getSurfaceTexture()));
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
// TODO Auto-generated method stub
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
mMediaDecoder.Stop();
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
// TODO Auto-generated method stub
}
}
My question - Is my TextureView
implementation okay for rendering H264 streams decoded by MediaCodec
? Or do I need to do EGL setup or anything else?
Thanks in advance!
My TextureView
implementation is okay as I tried with SurfaceView
too and found same result. And as @fadden said -
EGL setup is only required if you're rendering with GLES. TextureView combines a SurfaceTexture with a custom View, and does the GLES rendering for you. Which is why the View must be hardware-accelerated for TextureView to work.
Thanks to @fadden.