ViewfinderSurfaceRequest

@RequiresApi(value = 21)
public class ViewfinderSurfaceRequest


The request to get a Surface to display camera feed.

This request contains requirements for the surface resolution and camera device information from CameraCharacteristics.

Calling requestSurfaceAsync with this request will send the request to the surface provider, which is either a TextureView or SurfaceView and get a ListenableFuture of Surface.

Calling markSurfaceSafeToRelease will notify the surface provider that the surface is not needed and related resources can be released.

Summary

Nested types

Builder for ViewfinderSurfaceRequest.

Public methods

@Nullable CameraViewfinder.ImplementationMode

Returns the ImplementationMode.

int

Returns the camera lens facing.

@NonNull Size

Returns the resolution of the requested Surface.

int

Returns the sensor orientation.

void

Closes the viewfinder surface to mark it as safe to release.

Protected methods

void

Public methods

getImplementationMode

Added in 1.3.0
public @Nullable CameraViewfinder.ImplementationMode getImplementationMode()

Returns the ImplementationMode.

The value is set by setImplementationMode.

Returns
@Nullable CameraViewfinder.ImplementationMode

ImplementationMode. The value will be null if it's not set via setImplementationMode.

getLensFacing

Added in 1.3.0
@ViewfinderSurfaceRequest.LensFacingValue
public int getLensFacing()

Returns the camera lens facing.

The value is set by setLensFacing, which can be retrieved from CameraCharacteristics by key LENS_FACING.

Returns
int

The lens facing.

getResolution

Added in 1.3.0
public @NonNull Size getResolution()

Returns the resolution of the requested Surface.

The value is set by Builder. The surface which fulfills this request must have the resolution specified here in order to fulfill the resource requirements of the camera.

Returns
@NonNull Size

The guaranteed supported resolution.

getSensorOrientation

Added in 1.3.0
@ViewfinderSurfaceRequest.SensorOrientationDegreesValue
public int getSensorOrientation()

Returns the sensor orientation.

The value is set by setSensorOrientation, which can be retrieved from CameraCharacteristics by key SENSOR_ORIENTATION.

Returns
int

The sensor orientation.

markSurfaceSafeToRelease

Added in 1.3.0
public void markSurfaceSafeToRelease()

Closes the viewfinder surface to mark it as safe to release.

This method should be called by the user when the requested surface is not needed and related resources can be released.

Protected methods

finalize

protected void finalize()