MultipleInputVideoGraph


@UnstableApi
public abstract class MultipleInputVideoGraph implements VideoGraph


A VideoGraph that handles multiple input streams.

Summary

Protected constructors

MultipleInputVideoGraph(
    Context context,
    VideoFrameProcessor.Factory videoFrameProcessorFactory,
    ColorInfo outputColorInfo,
    DebugViewProvider debugViewProvider,
    VideoGraph.Listener listener,
    Executor listenerExecutor,
    VideoCompositorSettings videoCompositorSettings,
    List<Effect> compositionEffects,
    long initialTimestampOffsetUs,
    boolean renderFramesAutomatically
)

Public methods

VideoFrameProcessor
getProcessor(int inputIndex)

Returns the VideoFrameProcessor that handles the processing for an input registered via registerInput.

boolean

Returns whether the VideoGraph has produced a frame with zero presentation timestamp.

void

Initialize the VideoGraph}.

void
registerInput(@IntRange(from = 0) int inputIndex)

Registers a new input to the VideoGraph.

void

Releases the associated resources.

void

Sets the output surface and supporting information.

Protected fields

compositionVideoFrameProcessor

protected @Nullable VideoFrameProcessor compositionVideoFrameProcessor

initialTimestampOffsetUs

protected final long initialTimestampOffsetUs

Protected constructors

MultipleInputVideoGraph

protected MultipleInputVideoGraph(
    Context context,
    VideoFrameProcessor.Factory videoFrameProcessorFactory,
    ColorInfo outputColorInfo,
    DebugViewProvider debugViewProvider,
    VideoGraph.Listener listener,
    Executor listenerExecutor,
    VideoCompositorSettings videoCompositorSettings,
    List<Effect> compositionEffects,
    long initialTimestampOffsetUs,
    boolean renderFramesAutomatically
)

Public methods

getProcessor

public VideoFrameProcessor getProcessor(int inputIndex)

Returns the VideoFrameProcessor that handles the processing for an input registered via registerInput. If the inputIndex is not registered before, this method will throw an IllegalStateException.

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.

registerInput

public void registerInput(@IntRange(from = 0) int inputIndex)

Registers a new input to the VideoGraph.

A underlying processing VideoFrameProcessor is created every time this method is called.

All inputs must be registered before rendering frames to the underlying VideoFrameProcessor.

If the method throws, the caller must call release.

Parameters
@IntRange(from = 0) int inputIndex

The index of the input which could be used to order the inputs. The index must start from 0.

release

public void release()

Releases the associated resources.

This VideoGraph instance must not be used after this method is called.

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.

Protected methods

getCompositionVideoFrameProcessor

protected VideoFrameProcessor getCompositionVideoFrameProcessor()

getInitialTimestampOffsetUs

protected long getInitialTimestampOffsetUs()