Class SingleFrameGlTextureProcessor
- java.lang.Object
-
- com.google.android.exoplayer2.effect.SingleFrameGlTextureProcessor
-
- All Implemented Interfaces:
GlTextureProcessor
public abstract class SingleFrameGlTextureProcessor extends Object implements GlTextureProcessor
Manages a GLSL shader program for processing a frame. Implementations generally copy input pixels into an output frame, with changes to pixels specific to the implementation.SingleFrameGlTextureProcessor
implementations must produce exactly one output frame per input frame with the same presentation timestamp. For more flexibility, implementGlTextureProcessor
directly.All methods in this class must be called on the thread that owns the OpenGL context.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.effect.GlTextureProcessor
GlTextureProcessor.ErrorListener, GlTextureProcessor.InputListener, GlTextureProcessor.OutputListener
-
-
Constructor Summary
Constructors Constructor Description SingleFrameGlTextureProcessor(boolean useHdr)
Creates aSingleFrameGlTextureProcessor
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Pair<Integer,Integer>
configure(int inputWidth, int inputHeight)
Configures the texture processor based on the input dimensions.abstract void
drawFrame(int inputTexId, long presentationTimeUs)
Draws one frame.void
queueInputFrame(TextureInfo inputTexture, long presentationTimeUs)
Processes an input frame if possible.void
release()
Releases all resources.void
releaseOutputFrame(TextureInfo outputTexture)
Notifies the texture processor that the frame on the given output texture is no longer used and can be overwritten.void
setErrorListener(GlTextureProcessor.ErrorListener errorListener)
Sets theGlTextureProcessor.ErrorListener
.void
setInputListener(GlTextureProcessor.InputListener inputListener)
Sets theGlTextureProcessor.InputListener
.void
setOutputListener(GlTextureProcessor.OutputListener outputListener)
Sets theGlTextureProcessor.OutputListener
.void
signalEndOfCurrentInputStream()
Notifies theGlTextureProcessor
that no further input frames belonging to the current input stream will be queued.
-
-
-
Constructor Detail
-
SingleFrameGlTextureProcessor
public SingleFrameGlTextureProcessor(boolean useHdr)
Creates aSingleFrameGlTextureProcessor
instance.- Parameters:
useHdr
- Whether input textures come from an HDR source. Iftrue
, colors will be in linear RGB BT.2020. Iffalse
, colors will be in linear RGB BT.709.
-
-
Method Detail
-
configure
public abstract Pair<Integer,Integer> configure(int inputWidth, int inputHeight)
Configures the texture processor based on the input dimensions.This method must be called before drawing the first frame and before drawing subsequent frames with different input dimensions.
- Parameters:
inputWidth
- The input width, in pixels.inputHeight
- The input height, in pixels.- Returns:
- The output width and height of frames processed through
drawFrame(int, long)
.
-
drawFrame
public abstract void drawFrame(int inputTexId, long presentationTimeUs) throws FrameProcessingException
Draws one frame.This method may only be called after the texture processor has been
configured
. The caller is responsible for focussing the correct render target before calling this method.A minimal implementation should tell OpenGL to use its shader program, bind the shader program's vertex attributes and uniforms, and issue a drawing command.
- Parameters:
inputTexId
- Identifier of a 2D OpenGL texture containing the input frame.presentationTimeUs
- The presentation timestamp of the current frame, in microseconds.- Throws:
FrameProcessingException
- If an error occurs while processing or drawing the frame.
-
setInputListener
public final void setInputListener(GlTextureProcessor.InputListener inputListener)
Description copied from interface:GlTextureProcessor
Sets theGlTextureProcessor.InputListener
.- Specified by:
setInputListener
in interfaceGlTextureProcessor
-
setOutputListener
public final void setOutputListener(GlTextureProcessor.OutputListener outputListener)
Description copied from interface:GlTextureProcessor
Sets theGlTextureProcessor.OutputListener
.- Specified by:
setOutputListener
in interfaceGlTextureProcessor
-
setErrorListener
public final void setErrorListener(GlTextureProcessor.ErrorListener errorListener)
Description copied from interface:GlTextureProcessor
Sets theGlTextureProcessor.ErrorListener
.- Specified by:
setErrorListener
in interfaceGlTextureProcessor
-
queueInputFrame
public final void queueInputFrame(TextureInfo inputTexture, long presentationTimeUs)
Description copied from interface:GlTextureProcessor
Processes an input frame if possible.The
GlTextureProcessor
owns the accepted frame until it callsGlTextureProcessor.InputListener.onInputFrameProcessed(TextureInfo)
. The caller should not overwrite or release the texture before theGlTextureProcessor
has finished processing it.This method must only be called when the
GlTextureProcessor
can accept an input frame.- Specified by:
queueInputFrame
in interfaceGlTextureProcessor
- Parameters:
inputTexture
- ATextureInfo
describing the texture containing the input frame.presentationTimeUs
- The presentation timestamp of the input frame, in microseconds.
-
releaseOutputFrame
public final void releaseOutputFrame(TextureInfo outputTexture)
Description copied from interface:GlTextureProcessor
Notifies the texture processor that the frame on the given output texture is no longer used and can be overwritten.- Specified by:
releaseOutputFrame
in interfaceGlTextureProcessor
-
signalEndOfCurrentInputStream
public final void signalEndOfCurrentInputStream()
Description copied from interface:GlTextureProcessor
Notifies theGlTextureProcessor
that no further input frames belonging to the current input stream will be queued.Input frames that are queued after this method is called belong to a different input stream, so presentation timestamps may reset to start from a smaller presentation timestamp than the last frame of the previous input stream.
- Specified by:
signalEndOfCurrentInputStream
in interfaceGlTextureProcessor
-
release
@CallSuper public void release() throws FrameProcessingException
Description copied from interface:GlTextureProcessor
Releases all resources.- Specified by:
release
in interfaceGlTextureProcessor
- Throws:
FrameProcessingException
- If an error occurs while releasing resources.
-
-