Class BaseGlShaderProgram
- java.lang.Object
-
- com.google.android.exoplayer2.effect.BaseGlShaderProgram
-
- All Implemented Interfaces:
GlShaderProgram
- Direct Known Subclasses:
SingleFrameGlShaderProgram
@Deprecated public abstract class BaseGlShaderProgram extends Object implements GlShaderProgram
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.A base implementation ofGlShaderProgram
.BaseGlShaderProgram
manages an output texture pool, whose size is configurable on construction. An implementation should manage a GLSL shader program for processing frames. OverridedrawFrame(int, long)
to customize drawing. Implementations generally copy input pixels into an output frame, with changes to pixels specific to the implementation.BaseShaderProgram
implementations can produce any number of output frames per input frame with the same presentation timestamp.SingleFrameGlShaderProgram
can be used to implement aGlShaderProgram
that produces exactly one output frame per input frame.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.GlShaderProgram
GlShaderProgram.ErrorListener, GlShaderProgram.InputListener, GlShaderProgram.OutputListener
-
-
Field Summary
Fields Modifier and Type Field Description protected GlShaderProgram.InputListener
inputListener
Deprecated.
-
Constructor Summary
Constructors Constructor Description BaseGlShaderProgram(boolean useHdr, int texturePoolCapacity)
Deprecated.Creates aBaseGlShaderProgram
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract Size
configure(int inputWidth, int inputHeight)
Deprecated.Configures the instance based on the input dimensions.abstract void
drawFrame(int inputTexId, long presentationTimeUs)
Deprecated.Draws one frame.void
flush()
Deprecated.Flushes theGlShaderProgram
.void
queueInputFrame(GlTextureInfo inputTexture, long presentationTimeUs)
Deprecated.Processes an input frame if possible.void
release()
Deprecated.Releases all resources.void
releaseOutputFrame(GlTextureInfo outputTexture)
Deprecated.Notifies theGlShaderProgram
that the frame on the given output texture is no longer used and can be overwritten.void
setErrorListener(Executor errorListenerExecutor, GlShaderProgram.ErrorListener errorListener)
Deprecated.Sets theGlShaderProgram.ErrorListener
.void
setGlObjectsProvider(GlObjectsProvider glObjectsProvider)
Deprecated.Sets theGlObjectsProvider
.void
setInputListener(GlShaderProgram.InputListener inputListener)
Deprecated.Sets theGlShaderProgram.InputListener
.void
setOutputListener(GlShaderProgram.OutputListener outputListener)
Deprecated.Sets theGlShaderProgram.OutputListener
.void
signalEndOfCurrentInputStream()
Deprecated.Notifies theGlShaderProgram
that no further input frames belonging to the current input stream will be queued.
-
-
-
Field Detail
-
inputListener
protected GlShaderProgram.InputListener inputListener
Deprecated.
-
-
Constructor Detail
-
BaseGlShaderProgram
public BaseGlShaderProgram(boolean useHdr, int texturePoolCapacity)
Deprecated.Creates aBaseGlShaderProgram
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.texturePoolCapacity
- The capacity of the texture pool. For example, if implementing a texture cache, the size should be the number of textures to cache.
-
-
Method Detail
-
configure
public abstract Size configure(int inputWidth, int inputHeight) throws VideoFrameProcessingException
Deprecated.Configures the instance 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)
. - Throws:
VideoFrameProcessingException
- If an error occurs while configuring.
-
drawFrame
public abstract void drawFrame(int inputTexId, long presentationTimeUs) throws VideoFrameProcessingException
Deprecated.Draws one frame.This method may only be called after the shader program 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:
VideoFrameProcessingException
- If an error occurs while processing or drawing the frame.
-
setInputListener
public void setInputListener(GlShaderProgram.InputListener inputListener)
Deprecated.Description copied from interface:GlShaderProgram
Sets theGlShaderProgram.InputListener
.The
GlShaderProgram.InputListener
should be invoked on the thread that owns the parent OpenGL context. For example,DefaultVideoFrameProcessor
invokes theGlShaderProgram.InputListener
methods on its internal thread.- Specified by:
setInputListener
in interfaceGlShaderProgram
-
setOutputListener
public void setOutputListener(GlShaderProgram.OutputListener outputListener)
Deprecated.Description copied from interface:GlShaderProgram
Sets theGlShaderProgram.OutputListener
.The
GlShaderProgram.OutputListener
should be invoked on the thread that owns the parent OpenGL context. For example,DefaultVideoFrameProcessor
invokes theGlShaderProgram.OutputListener
methods on its internal thread.- Specified by:
setOutputListener
in interfaceGlShaderProgram
-
setErrorListener
public void setErrorListener(Executor errorListenerExecutor, GlShaderProgram.ErrorListener errorListener)
Deprecated.Description copied from interface:GlShaderProgram
Sets theGlShaderProgram.ErrorListener
.The
GlShaderProgram.ErrorListener
is invoked on the providedExecutor
.- Specified by:
setErrorListener
in interfaceGlShaderProgram
-
setGlObjectsProvider
public void setGlObjectsProvider(GlObjectsProvider glObjectsProvider)
Deprecated.Description copied from interface:GlShaderProgram
Sets theGlObjectsProvider
.This method should not be called after any of the frame processing methods.
- Specified by:
setGlObjectsProvider
in interfaceGlShaderProgram
-
queueInputFrame
public void queueInputFrame(GlTextureInfo inputTexture, long presentationTimeUs)
Deprecated.Description copied from interface:GlShaderProgram
Processes an input frame if possible.The
GlShaderProgram
owns the accepted frame until it callsGlShaderProgram.InputListener.onInputFrameProcessed(GlTextureInfo)
. The caller should not overwrite or release the texture before theGlShaderProgram
has finished processing it.This method must only be called when the
GlShaderProgram
can accept an input frame.- Specified by:
queueInputFrame
in interfaceGlShaderProgram
- Parameters:
inputTexture
- AGlTextureInfo
describing the texture containing the input frame.presentationTimeUs
- The presentation timestamp of the input frame, in microseconds.
-
releaseOutputFrame
public void releaseOutputFrame(GlTextureInfo outputTexture)
Deprecated.Description copied from interface:GlShaderProgram
Notifies theGlShaderProgram
that the frame on the given output texture is no longer used and can be overwritten.- Specified by:
releaseOutputFrame
in interfaceGlShaderProgram
-
signalEndOfCurrentInputStream
public void signalEndOfCurrentInputStream()
Deprecated.Description copied from interface:GlShaderProgram
Notifies theGlShaderProgram
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.
- Specified by:
signalEndOfCurrentInputStream
in interfaceGlShaderProgram
-
flush
@CallSuper public void flush()
Deprecated.Description copied from interface:GlShaderProgram
Flushes theGlShaderProgram
.The
GlShaderProgram
should reclaim the ownership of its allocated textures, notify itsGlShaderProgram.InputListener
about the flush event, and report its availability if necessary.- Specified by:
flush
in interfaceGlShaderProgram
-
release
@CallSuper public void release() throws VideoFrameProcessingException
Deprecated.Description copied from interface:GlShaderProgram
Releases all resources.- Specified by:
release
in interfaceGlShaderProgram
- Throws:
VideoFrameProcessingException
- If an error occurs while releasing resources.
-
-