Package com.google.android.exoplayer2.effect

## 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, implement `GlTextureProcessor` 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 a `SingleFrameGlTextureProcessor` 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 the `GlTextureProcessor.ErrorListener`.
    `void` | `setInputListener​(GlTextureProcessor.InputListener inputListener)` | Sets the `GlTextureProcessor.InputListener`.
    `void` | `setOutputListener​(GlTextureProcessor.OutputListener outputListener)` | Sets the `GlTextureProcessor.OutputListener`.
    `void` | `signalEndOfCurrentInputStream()` | Notifies the `GlTextureProcessor` that no further input frames belonging to the current input stream will be queued.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SingleFrameGlTextureProcessor

          public SingleFrameGlTextureProcessor​(boolean useHdr)

      Creates a `SingleFrameGlTextureProcessor` instance.
      Parameters:
        `useHdr` - Whether input textures come from an HDR source. If `true`, colors will be in linear RGB BT.2020. If `false`, 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 the `GlTextureProcessor.InputListener`.
      Specified by:
        `setInputListener` in interface `GlTextureProcessor`

    - #### setOutputListener

          public final void setOutputListener​(GlTextureProcessor.OutputListener outputListener)

      Description copied from interface: `GlTextureProcessor`
      Sets the `GlTextureProcessor.OutputListener`.
      Specified by:
        `setOutputListener` in interface `GlTextureProcessor`

    - #### setErrorListener

          public final void setErrorListener​(GlTextureProcessor.ErrorListener errorListener)

      Description copied from interface: `GlTextureProcessor`
      Sets the `GlTextureProcessor.ErrorListener`.
      Specified by:
        `setErrorListener` in interface `GlTextureProcessor`

    - #### 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 calls `GlTextureProcessor.InputListener.onInputFrameProcessed(TextureInfo)`. The caller should not overwrite or release the texture before the `GlTextureProcessor` has finished processing it.

      This method must only be called when the `GlTextureProcessor` can accept an input frame.

      Specified by:
        `queueInputFrame` in interface `GlTextureProcessor`
      Parameters:
        `inputTexture` - A `TextureInfo` 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 interface `GlTextureProcessor`

    - #### signalEndOfCurrentInputStream

          public final void signalEndOfCurrentInputStream()

      Description copied from interface: `GlTextureProcessor`
      Notifies the `GlTextureProcessor` 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 interface `GlTextureProcessor`

    - #### release

          @CallSuper
          public void release()
                       throws FrameProcessingException

      Description copied from interface: `GlTextureProcessor`
      Releases all resources.
      Specified by:
        `release` in interface `GlTextureProcessor`
      Throws:
        `FrameProcessingException` - If an error occurs while releasing resources.