-
- All Implemented Interfaces:
-
android.graphics.SurfaceTexture.OnFrameAvailableListener
public final class CodecOutputSurface implements SurfaceTexture.OnFrameAvailableListener
Holds state associated with a Surface used for MediaCodec decoder output.
The constructor for this class will prepare GL, create a SurfaceTexture, and then create a Surface for that SurfaceTexture. The Surface can be passed to MediaCodec.configure() to receive decoder output. When a frame arrives, we latch the texture with updateTexImage(), then render the texture with GL to a pbuffer.
By default, the Surface will be using a BufferQueue in asynchronous mode, so we can potentially drop frames.
-
-
Field Summary
Fields Modifier and Type Field Description private SurfaceTexturesurfaceTextureprivate Surfacesurfaceprivate Integerwidthprivate Integerheight
-
Constructor Summary
Constructors Constructor Description CodecOutputSurface(Integer width, Integer height)
-
Method Summary
Modifier and Type Method Description final SurfaceTexturegetSurfaceTexture()final UnitsetSurfaceTexture(SurfaceTexture surfaceTexture)final SurfacegetSurface()final UnitsetSurface(Surface surface)final IntegergetWidth()final UnitsetWidth(Integer width)final IntegergetHeight()final UnitsetHeight(Integer height)final Unitrelease()Discard all resources held by this class, notably the EGL context. final UnitmakeCurrent()Makes our EGL context and surface current. final UnitawaitNewImage()Latches the next buffer into the texture. final UnitdrawImage(Boolean invert)Draws the data from SurfaceTexture onto the current EGL surface. UnitonFrameAvailable(SurfaceTexture st)final UnitsaveFrame(String filename, Integer photoQuality)Saves the current frame to disk as a JPEG image. -
-
Method Detail
-
getSurfaceTexture
final SurfaceTexture getSurfaceTexture()
-
setSurfaceTexture
final Unit setSurfaceTexture(SurfaceTexture surfaceTexture)
-
getSurface
final Surface getSurface()
-
setSurface
final Unit setSurface(Surface surface)
-
makeCurrent
final Unit makeCurrent()
Makes our EGL context and surface current.
-
awaitNewImage
final Unit awaitNewImage()
Latches the next buffer into the texture. Must be called from the thread that created the CodecOutputSurface object. (More specifically, it must be called on the thread with the EGLContext that contains the GL texture object used by SurfaceTexture.)
-
drawImage
final Unit drawImage(Boolean invert)
Draws the data from SurfaceTexture onto the current EGL surface.
- Parameters:
invert- if set, render the image with Y inverted (0,0 in top left)
-
onFrameAvailable
Unit onFrameAvailable(SurfaceTexture st)
-
-
-
-