5

I am able render YUVI420 frame on GLSurfaceView using openGL but my requirement is to render frame on SurfaceTexture. Basically I want to produce frame to SurfaceTexture not like render to TextureView etc., I have YUV data stream coming from WebRTC, and I want this stream to be in SurfaceTexture so that later I can access it in EXTERNAL_TEXTURE_OES at consumer level. I could not found any source about producing frames on SurfaceTexture. Is it possible to produce YUV frames to SurfaceTexure?

Afsar edrisy
  • 1,985
  • 12
  • 28

1 Answers1

-2

You can convert the YUVI420 frames into a byteArray, draw it on a canvas and put it on the TextureView

val canvas: Canvas = textureView.lockCanvas()
canvas.drawBitmap(sourceBitmap, 200f, 100f, Paint())
textureView.unlockCanvasAndPost(canvas)
  • ```sourceBitmap``` is YUVI420 or RGB frame ? will it be available to consumer of SurfaceTexture ? – Afsar edrisy Jan 22 '20 at 04:57
  • The sourceBitmap is YUVI420 but it can be converted at any time. I have found this question/answer https://stackoverflow.com/questions/30510928/convert-android-camera2-api-yuv-420-888-to-rgb – Benjamin Stürmer Jan 22 '20 at 06:21
  • Hey I know how to convert to RGB just go trough the documentation of SurfaceTexture. SurfaceTexture uses ```EXTERNAL_TEXTURE_OES``` which uses YUV format. Conversion to RGB is slow operation & this is not the answer to this problem see [SurfaceTexture](https://developer.android.com/reference/android/graphics/SurfaceTexture?authuser=1). TextureView I know how to render YUV as well Bitmap using EGL Context. – Afsar edrisy Jan 22 '20 at 06:28
  • Sorry that wasn't clear in the initial Question. There was only a requirement to ignore OpenGL for conversion. But you're right, my conclusion doesn't fit that additional requirement. – Benjamin Stürmer Jan 23 '20 at 16:28