Interface FrameProcessor
-
- All Known Implementing Classes:
GlEffectsFrameProcessor
public interface FrameProcessor
Interface for a frame processor that applies changes to individual video frames.The changes are specified by
Effect
instances passed toFrameProcessor.Factory.create(android.content.Context, com.google.android.exoplayer2.util.FrameProcessor.Listener, java.util.List<com.google.android.exoplayer2.util.Effect>, com.google.android.exoplayer2.util.DebugViewProvider, com.google.android.exoplayer2.video.ColorInfo, boolean)
.Manages its input
Surface
, which can be accessed viagetInputSurface()
. The outputSurface
must be set by the caller usingsetOutputSurfaceInfo(SurfaceInfo)
.The caller must register input frames before rendering them to the input
Surface
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
FrameProcessor.Factory
A factory forFrameProcessor
instances.static interface
FrameProcessor.Listener
Listener for asynchronous frame processing events.
-
Field Summary
Fields Modifier and Type Field Description static long
DROP_OUTPUT_FRAME
Indicates the frame should be dropped afterreleaseOutputFrame(long)
is invoked.static long
RELEASE_OUTPUT_FRAME_IMMEDIATELY
Indicates the frame should be released immediately afterreleaseOutputFrame(long)
is invoked.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Surface
getInputSurface()
Returns the inputSurface
, whereFrameProcessor
consumes input frames from.int
getPendingInputFrameCount()
Returns the number of input frames that have been registered but not processed off the input surface yet.void
registerInputFrame()
Informs theFrameProcessor
that a frame will be queued to its input surface.void
release()
Releases all resources.void
releaseOutputFrame(long releaseTimeNs)
Releases the oldest unreleased output frame that has become available at the givenreleaseTimeNs
.void
setInputFrameInfo(FrameInfo inputFrameInfo)
Sets information about the input frames.void
setOutputSurfaceInfo(SurfaceInfo outputSurfaceInfo)
Sets the output surface and supporting information.void
signalEndOfInput()
Informs theFrameProcessor
that no further input frames should be accepted.
-
-
-
Field Detail
-
RELEASE_OUTPUT_FRAME_IMMEDIATELY
static final long RELEASE_OUTPUT_FRAME_IMMEDIATELY
Indicates the frame should be released immediately afterreleaseOutputFrame(long)
is invoked.- See Also:
- Constant Field Values
-
DROP_OUTPUT_FRAME
static final long DROP_OUTPUT_FRAME
Indicates the frame should be dropped afterreleaseOutputFrame(long)
is invoked.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInputSurface
Surface getInputSurface()
Returns the inputSurface
, whereFrameProcessor
consumes input frames from.
-
setInputFrameInfo
void setInputFrameInfo(FrameInfo inputFrameInfo)
Sets information about the input frames.The new input information is applied from the next frame registered onwards.
Pixels are expanded using the
FrameInfo.pixelWidthHeightRatio
so that the output frames' pixels have a ratio of 1.The caller should update
FrameInfo.streamOffsetUs
when switching input streams to ensure that frame timestamps are always monotonically increasing.
-
registerInputFrame
void registerInputFrame()
Informs theFrameProcessor
that a frame will be queued to its input surface.Must be called before rendering a frame to the frame processor's input surface.
- Throws:
IllegalStateException
- If called aftersignalEndOfInput()
or beforesetInputFrameInfo(FrameInfo)
.
-
getPendingInputFrameCount
int getPendingInputFrameCount()
Returns the number of input frames that have been registered but not processed off the input surface yet.
-
setOutputSurfaceInfo
void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo)
Sets the output surface and supporting information. When output frames are released and not dropped, they will be rendered to this outputSurfaceInfo
.The new output
SurfaceInfo
is applied from the next output frame rendered onwards. If the outputSurfaceInfo
isnull
, theFrameProcessor
will stop rendering pending frames and resume rendering once a non-nullSurfaceInfo
is set.If the dimensions given in
SurfaceInfo
do not match the output size after applying the final effect the frames are resized before rendering to the surface and letter/pillar-boxing is applied.The caller is responsible for tracking the lifecycle of the
SurfaceInfo.surface
including calling this method with a new surface if it is destroyed. When this method returns, the previous output surface is no longer being used and can safely be released by the caller.
-
releaseOutputFrame
void releaseOutputFrame(long releaseTimeNs)
Releases the oldest unreleased output frame that has become available at the givenreleaseTimeNs
.This will either render the output frame to the output surface, or drop the frame, per
releaseTimeNs
.This method must only be called if
releaseFramesAutomatically
was set tofalse
using theFrameProcessor.Factory
and should be called exactly once for each frame that becomes available.The
releaseTimeNs
may be passed toEGLExt.eglPresentationTimeANDROID(android.opengl.EGLDisplay, android.opengl.EGLSurface, long)
depending on the implementation.- Parameters:
releaseTimeNs
- The release time to use for the frame, in nanoseconds. The release time can be before of after the current system time. UseDROP_OUTPUT_FRAME
to drop the frame, orRELEASE_OUTPUT_FRAME_IMMEDIATELY
to release the frame immediately.
-
signalEndOfInput
void signalEndOfInput()
Informs theFrameProcessor
that no further input frames should be accepted.- Throws:
IllegalStateException
- If called more than once.
-
release
void release()
Releases all resources.If the frame processor is released before it has ended, it will attempt to cancel processing any input frames that have already become available. Input frames that become available after release are ignored.
This method blocks until all resources are released or releasing times out.
-
-