FakeStreamConfigurationMap


public final class FakeStreamConfigurationMap implements StreamConfigurationMapWrapper


A fake implementation of StreamConfigurationMapWrapper for testing.

This class enables a developer to specify a table of input and output formats, along with the properties associated with them.

Example

val fakeMap = FakeStreamConfigurationMap(
outputsTable = linkedMapOf(
OutputKey(ImageFormat.YUV_420_888, Size(1920, 1080)) to OutputValues(),
OutputKey(ImageFormat.JPEG, Size(1920, 1080)) to OutputValues(
stallDuration = 200000000L // 200ms stall duration for JPEG
)
)
)

Summary

Nested types

Defines a single entry for a valid input format for testing purposes.

Key used to identify an output configuration in FakeStreamConfigurationMap.

Values associated with an output configuration in FakeStreamConfigurationMap.

Public methods

@NonNull List<@NonNull Size>
@NonNull List<@NonNull Range<@NonNull Integer>>
@NonNull List<@NonNull Range<@NonNull Integer>>
@NonNull List<@NonNull Size>
@NonNull List<@NonNull Size>
@NonNull List<@NonNull Integer>
@NonNull List<@NonNull Size>
getInputSizes(int format)
@NonNull List<@NonNull Integer>
long
getOutputMinFrameDuration(int format, @NonNull Size size)
long
<T extends Object> getOutputMinFrameDuration(
    @NonNull Class<@NonNull T> klass,
    @NonNull Size size
)
@NonNull List<@NonNull Size>
getOutputSizes(int format)
@NonNull List<@NonNull Size>
<T extends Object> getOutputSizes(@NonNull Class<@NonNull T> klass)
long
getOutputStallDuration(int format, @NonNull Size size)
long
<T extends Object> getOutputStallDuration(
    @NonNull Class<@NonNull T> klass,
    @NonNull Size size
)
@NonNull List<@NonNull Integer>
boolean
boolean
<T extends Object> isOutputSupportedFor(@NonNull Class<@NonNull T> klass)

Converting this method to non-static for testability.

boolean
T
<T extends Object> unwrapAs(@NonNull Class<@NonNull T> type)

Attempts to unwrap this object into the specified underlying type.

Public constructors

FakeStreamConfigurationMap

public FakeStreamConfigurationMap(
    @NonNull LinkedHashMap<@NonNull FakeStreamConfigurationMap.OutputKey, @NonNull FakeStreamConfigurationMap.OutputValues> outputsTable,
    @NonNull List<@NonNull FakeStreamConfigurationMap.InputTableEntry> inputTable,
    @NonNull Map<@NonNull Integer, @NonNull List<@NonNull Integer>> outputFormatsForInputFormats,
    @NonNull Set<@NonNull Class<@NonNull ?>> outputClassTypes
)
Parameters
@NonNull LinkedHashMap<@NonNull FakeStreamConfigurationMap.OutputKey, @NonNull FakeStreamConfigurationMap.OutputValues> outputsTable

The map of supported outputs, mapping OutputKey to OutputValues. Must be a LinkedHashMap to preserve insertion order. Used by output-related queries (e.g., getOutputFormats, getOutputSizes, getOutputMinFrameDuration).

@NonNull List<@NonNull FakeStreamConfigurationMap.InputTableEntry> inputTable

The list of supported inputs. Used by getInputFormats and getInputSizes.

@NonNull Map<@NonNull Integer, @NonNull List<@NonNull Integer>> outputFormatsForInputFormats

Mapping of input formats to their valid output formats. Used by getValidOutputFormatsForInput.

@NonNull Set<@NonNull Class<@NonNull ?>> outputClassTypes

Set of class types that are supported as outputs. Used by isOutputSupportedFor (class-based queries) and getOutputMinFrameDuration (class-based queries). Class-based queries internally map to GraphicsImageFormat.PRIVATE.

Public methods

getHighResolutionOutputSizes

Added in 1.7.0-alpha03
public @NonNull List<@NonNull SizegetHighResolutionOutputSizes(int format)

getHighSpeedVideoFpsRanges

Added in 1.7.0-alpha03
public @NonNull List<@NonNull Range<@NonNull Integer>> getHighSpeedVideoFpsRanges()

getHighSpeedVideoFpsRangesFor

Added in 1.7.0-alpha03
public @NonNull List<@NonNull Range<@NonNull Integer>> getHighSpeedVideoFpsRangesFor(@NonNull Size size)

getHighSpeedVideoSizes

Added in 1.7.0-alpha03
public @NonNull List<@NonNull SizegetHighSpeedVideoSizes()

getHighSpeedVideoSizesFor

Added in 1.7.0-alpha03
public @NonNull List<@NonNull SizegetHighSpeedVideoSizesFor(@NonNull Range<@NonNull Integer> fpsRange)

getInputFormats

Added in 1.7.0-alpha03
public @NonNull List<@NonNull IntegergetInputFormats()
See also
getInputFormats

getInputSizes

Added in 1.7.0-alpha03
public @NonNull List<@NonNull SizegetInputSizes(int format)
See also
getInputSizes

getOutputFormats

Added in 1.7.0-alpha03
public @NonNull List<@NonNull IntegergetOutputFormats()
See also
getOutputFormats

getOutputMinFrameDuration

Added in 1.7.0-alpha03
public long getOutputMinFrameDuration(int format, @NonNull Size size)

getOutputMinFrameDuration

Added in 1.7.0-alpha03
public long <T extends Object> getOutputMinFrameDuration(
    @NonNull Class<@NonNull T> klass,
    @NonNull Size size
)

getOutputSizes

Added in 1.7.0-alpha03
public @NonNull List<@NonNull SizegetOutputSizes(int format)
See also
getOutputSizes

getOutputSizes

Added in 1.7.0-alpha03
public @NonNull List<@NonNull Size> <T extends Object> getOutputSizes(@NonNull Class<@NonNull T> klass)
See also
getOutputSizes

getOutputStallDuration

Added in 1.7.0-alpha03
public long getOutputStallDuration(int format, @NonNull Size size)

getOutputStallDuration

Added in 1.7.0-alpha03
public long <T extends Object> getOutputStallDuration(
    @NonNull Class<@NonNull T> klass,
    @NonNull Size size
)

getValidOutputFormatsForInput

Added in 1.7.0-alpha03
public @NonNull List<@NonNull IntegergetValidOutputFormatsForInput(int inputFormat)

isOutputSupportedFor

Added in 1.7.0-alpha03
public boolean isOutputSupportedFor(int format)

isOutputSupportedFor

Added in 1.7.0-alpha03
public boolean <T extends Object> isOutputSupportedFor(@NonNull Class<@NonNull T> klass)

Converting this method to non-static for testability.

isOutputSupportedFor

Added in 1.7.0-alpha03
public boolean isOutputSupportedFor(@NonNull Surface surface)

unwrapAs

Added in 1.7.0-alpha03
public T <T extends Object> unwrapAs(@NonNull Class<@NonNull T> type)

Attempts to unwrap this object into the specified underlying type.

Callers should use this method to retrieve the wrapped platform object.

Implementation Notes

  • If the requested type is not supported by this wrapper, this method must return null.

  • Implementations designed for testing (e.g., fakes, mocks, or no-op wrappers) should return null to signal that no real underlying object is available.

Parameters
<T extends Object>

The expected type of the underlying object.

@NonNull Class<@NonNull T> type

The Class representing the expected type of the underlying object.

Returns
T

The underlying object cast to T, or null if the object cannot be unwrapped into the requested type.