SingleInputVideoGraph
@UnstableApi
public class SingleInputVideoGraph implements VideoGraph
A VideoGraph that handles one input stream.
Summary
Nested types |
|---|
public final class SingleInputVideoGraph.Factory implements VideoGraph.Factory |
Public constructors |
|---|
SingleInputVideoGraph(Creates an instance. |
Public methods |
|
|---|---|
void |
flush()Flushes the |
Surface |
getInputSurface(int inputIndex)Returns the input |
int |
getPendingInputFrameCount(int inputIndex)Returns the number of pending input frames at |
boolean |
Returns whether the |
void |
Initialize the VideoGraph}. |
boolean |
queueInputBitmap(Queues the input |
boolean |
queueInputTexture(Queues the input texture at |
void |
redraw()Updates an |
void |
registerInput(int inputIndex)Registers a new input to the |
boolean |
registerInputFrame(int inputIndex)Registers a new input frame at |
void |
registerInputStream(Informs the graph that a new input stream will be queued to the graph input corresponding to |
void |
release()Releases the associated resources. |
void |
renderOutputFrame(long renderTimeNs)Renders the output frame from the |
void |
setCompositionEffects(List<Effect> compositionEffects)Sets the Composition-level video effects that are applied after the effects on single |
void |
setCompositorSettings(VideoCompositorSettings videoCompositorSettings)Sets the |
void |
setOnInputFrameProcessedListener(Sets the |
void |
setOnInputSurfaceReadyListener(int inputIndex, Runnable listener)Sets a listener that's called when the |
void |
setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo)Sets the output surface and supporting information. |
void |
signalEndOfInput(int inputIndex)Informs that no further inputs should be accepted at |
Public constructors
SingleInputVideoGraph
public SingleInputVideoGraph(
Context context,
VideoFrameProcessor.Factory videoFrameProcessorFactory,
ColorInfo outputColorInfo,
VideoGraph.Listener listener,
DebugViewProvider debugViewProvider,
Executor listenerExecutor,
boolean renderFramesAutomatically
)
Creates an instance.
videoCompositorSettings must be DEFAULT.
Public methods
getInputSurface
public Surface getInputSurface(int inputIndex)
Returns the input Surface at inputIndex.
getPendingInputFrameCount
public int getPendingInputFrameCount(int inputIndex)
Returns the number of pending input frames at inputIndex that has not been processed yet.
hasProducedFrameWithTimestampZero
public boolean hasProducedFrameWithTimestampZero()
Returns whether the VideoGraph has produced a frame with zero presentation timestamp.
initialize
public void initialize()
Initialize the VideoGraph}.
This method must be called before calling other methods.
If the method throws, the caller must call #release.
This method must be called at most once.
queueInputBitmap
public boolean queueInputBitmap(
int inputIndex,
Bitmap inputBitmap,
TimestampIterator timestampIterator
)
Queues the input Bitmap at inputIndex.
| See also | |
|---|---|
queueInputBitmap |
queueInputTexture
public boolean queueInputTexture(
int inputIndex,
int textureId,
long presentationTimeUs
)
Queues the input texture at inputIndex.
| See also | |
|---|---|
queueInputTexture |
registerInput
public void registerInput(int inputIndex)
Registers a new input to the VideoGraph.
All inputs must be registered before rendering frames by calling registerInputFrame, queueInputBitmap or queueInputTexture.
If the method throws, the caller must call release.
| Parameters | |
|---|---|
int inputIndex |
The index of the input which could be used to order the inputs. The index must start from 0. |
registerInputFrame
public boolean registerInputFrame(int inputIndex)
Registers a new input frame at inputIndex.
| See also | |
|---|---|
registerInputFrame |
registerInputStream
public void registerInputStream(
int inputIndex,
@VideoFrameProcessor.InputType int inputType,
Format format,
List<Effect> effects,
long offsetToAddUs
)
Informs the graph that a new input stream will be queued to the graph input corresponding to inputIndex.
After registering the first input stream, this method must only be called for the same index after the last frame of the already-registered input stream has been registered, last bitmap queued or last texture id queued.
This method blocks the calling thread until the previous input stream corresponding to the same inputIndex has been fully registered internally.
| Parameters | |
|---|---|
int inputIndex |
The index of the input for which a new input stream should be registered. This index must start from 0. |
@VideoFrameProcessor.InputType int inputType |
The |
Format format |
The |
List<Effect> effects |
The list of |
long offsetToAddUs |
The offset that must be added to the frame presentation timestamps, in microseconds. This offset is not part of the input timestamps. It is added to the frame timestamps before processing, and is retained in the output timestamps. |
release
public void release()
Releases the associated resources.
This VideoGraph instance must not be used after this method is called.
renderOutputFrame
public void renderOutputFrame(long renderTimeNs)
Renders the output frame from the VideoGraph.
This method must be called only for frames that have become available, calling the method renders the frame that becomes available the earliest but not yet rendered.
| See also | |
|---|---|
renderOutputFrame |
setCompositionEffects
public void setCompositionEffects(List<Effect> compositionEffects)
Sets the Composition-level video effects that are applied after the effects on single input stream.
This method should be called before registerInputStream to set the desired composition level effects.
setCompositorSettings
public void setCompositorSettings(VideoCompositorSettings videoCompositorSettings)
Sets the VideoCompositorSettings.
This method should be called before registerInputStream to set the desired composition level VideoCompositorSettings.
Setting a custom VideoCompositorSettings where supportsMultipleInputs returns false throws an IllegalArgumentException.
setOnInputFrameProcessedListener
public void setOnInputFrameProcessedListener(
int inputIndex,
OnInputFrameProcessedListener listener
)
Sets the OnInputFrameProcessedListener at inputIndex.
setOnInputSurfaceReadyListener
public void setOnInputSurfaceReadyListener(int inputIndex, Runnable listener)
Sets a listener that's called when the input surface is ready to use at inputIndex.
setOutputSurfaceInfo
public void setOutputSurfaceInfo(@Nullable SurfaceInfo outputSurfaceInfo)
Sets the output surface and supporting information.
The new output SurfaceInfo is applied from the next output frame rendered onwards. If the output SurfaceInfo is null, the VideoGraph will stop rendering pending frames and resume rendering once a non-null SurfaceInfo 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 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.
signalEndOfInput
public void signalEndOfInput(int inputIndex)
Informs that no further inputs should be accepted at inputIndex.
| See also | |
|---|---|
signalEndOfInput |