ViewfinderSurfaceRequest

@RequiresApi(value = 21)
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

Public functions

CameraViewfinder.ImplementationMode?

Returns the ImplementationMode.

Int

Returns the camera lens facing.

Size

Returns the resolution of the requested Surface.

Int

Returns the sensor orientation.

Unit

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

Protected functions

Unit

Public functions

getImplementationMode

Added in 1.3.0
fun getImplementationMode(): CameraViewfinder.ImplementationMode?

Returns the ImplementationMode.

The value is set by setImplementationMode.

Returns
CameraViewfinder.ImplementationMode?

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

getLensFacing

Added in 1.3.0
@ViewfinderSurfaceRequest.LensFacingValue
fun getLensFacing(): Int

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
fun getResolution(): Size

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
Size

The guaranteed supported resolution.

getSensorOrientation

Added in 1.3.0
@ViewfinderSurfaceRequest.SensorOrientationDegreesValue
fun getSensorOrientation(): Int

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
fun markSurfaceSafeToRelease(): Unit

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 functions

finalize

protected fun finalize(): Unit