public final class

VideoCapture.Builder

extends java.lang.Object

implements UseCaseConfig.Builder<VideoCapture, VideoCaptureConfig, VideoCapture.Builder>, ImageOutputConfig.Builder<VideoCapture.Builder>, ThreadConfig.Builder<VideoCapture.Builder>

 java.lang.Object

↳androidx.camera.core.VideoCapture.Builder

Overview

Builder for a VideoCapture.

Summary

Constructors
publicBuilder()

Creates a new Builder object.

Methods
public VideoCapturebuild()

Builds an immutable VideoCaptureConfig from the current state.

public static VideoCapture.BuilderfromConfig(VideoCaptureConfig configuration)

Generates a Builder from another Config object

public MutableConfiggetMutableConfig()

public VideoCaptureConfiggetUseCaseConfig()

public VideoCapture.BuildersetAudioBitRate(int bitRate)

Sets the bit rate of the audio stream.

public VideoCapture.BuildersetAudioChannelCount(int channelCount)

Sets the number of audio channels.

public VideoCapture.BuildersetAudioMinBufferSize(int minBufferSize)

Sets the audio min buffer size.

public VideoCapture.BuildersetAudioSampleRate(int sampleRate)

Sets the sample rate of the audio stream.

public VideoCapture.BuildersetBackgroundExecutor(java.util.concurrent.Executor executor)

Sets the default executor that will be used for background tasks.

public VideoCapture.BuildersetBitRate(int bitRate)

Sets the encoding bit rate.

public VideoCapture.BuildersetCameraSelector(CameraSelector cameraSelector)

public VideoCapture.BuildersetCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public VideoCapture.BuildersetDefaultCaptureConfig(CaptureConfig captureConfig)

public VideoCapture.BuildersetDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

public VideoCapture.BuildersetDefaultSessionConfig(SessionConfig sessionConfig)

public VideoCapture.BuildersetIFrameInterval(int interval)

Sets number of seconds between each key frame in seconds.

public VideoCapture.BuildersetMaxResolution(Size resolution)

public VideoCapture.BuildersetSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public VideoCapture.BuildersetSupportedResolutions(java.util.List<> resolutions)

public VideoCapture.BuildersetSurfaceOccupancyPriority(int priority)

public VideoCapture.BuildersetTargetAspectRatio(int aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

public VideoCapture.BuildersetTargetClass(java.lang.Class<VideoCapture> targetClass)

public VideoCapture.BuildersetTargetName(java.lang.String targetName)

Sets the name of the target object being configured, used only for debug logging.

public VideoCapture.BuildersetTargetResolution(Size resolution)

Sets the resolution of the intended target from this configuration.

public VideoCapture.BuildersetTargetRotation(int rotation)

Sets the rotation of the intended target for images from this configuration.

public VideoCapture.BuildersetUseCaseEventCallback(UseCase.EventCallback useCaseEventCallback)

public VideoCapture.BuildersetVideoFrameRate(int videoFrameRate)

Sets the recording frames per second.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new Builder object.

Methods

public static VideoCapture.Builder fromConfig(VideoCaptureConfig configuration)

Generates a Builder from another Config object

Parameters:

configuration: An immutable configuration to pre-populate this builder.

Returns:

The new Builder.

public MutableConfig getMutableConfig()

public VideoCaptureConfig getUseCaseConfig()

public VideoCapture build()

Builds an immutable VideoCaptureConfig from the current state.

Returns:

A VideoCaptureConfig populated with the current state.

public VideoCapture.Builder setVideoFrameRate(int videoFrameRate)

Sets the recording frames per second.

Parameters:

videoFrameRate: The requested interval in seconds.

Returns:

The current Builder.

public VideoCapture.Builder setBitRate(int bitRate)

Sets the encoding bit rate.

Parameters:

bitRate: The requested bit rate in bits per second.

Returns:

The current Builder.

public VideoCapture.Builder setIFrameInterval(int interval)

Sets number of seconds between each key frame in seconds.

Parameters:

interval: The requested interval in seconds.

Returns:

The current Builder.

public VideoCapture.Builder setAudioBitRate(int bitRate)

Sets the bit rate of the audio stream.

Parameters:

bitRate: The requested bit rate in bits/s.

Returns:

The current Builder.

public VideoCapture.Builder setAudioSampleRate(int sampleRate)

Sets the sample rate of the audio stream.

Parameters:

sampleRate: The requested sample rate in bits/s.

Returns:

The current Builder.

public VideoCapture.Builder setAudioChannelCount(int channelCount)

Sets the number of audio channels.

Parameters:

channelCount: The requested number of audio channels.

Returns:

The current Builder.

public VideoCapture.Builder setAudioMinBufferSize(int minBufferSize)

Sets the audio min buffer size.

Parameters:

minBufferSize: The requested audio minimum buffer size, in bytes.

Returns:

The current Builder.

public VideoCapture.Builder setTargetClass(java.lang.Class<VideoCapture> targetClass)

public VideoCapture.Builder setTargetName(java.lang.String targetName)

Sets the name of the target object being configured, used only for debug logging.

The name should be a value that can uniquely identify an instance of the object being configured.

If not set, the target name will default to an unique name automatically generated with the class canonical name and random UUID.

Parameters:

targetName: A unique string identifier for the instance of the class being configured.

Returns:

the current Builder.

public VideoCapture.Builder setTargetAspectRatio(int aspectRatio)

Sets the aspect ratio of the intended target for images from this configuration.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio is used as a hint when determining the resulting output aspect ratio which may differ from the request, possibly due to device constraints. Application code should check the resulting output's resolution.

If not set, resolutions with aspect ratio 4:3 will be considered in higher priority.

Parameters:

aspectRatio: A AspectRatio representing the ratio of the target's width and height.

Returns:

The current Builder.

public VideoCapture.Builder setTargetRotation(int rotation)

Sets the rotation of the intended target for images from this configuration.

This is one of four valid values: , , , . Rotation values are relative to the "natural" rotation, .

If not set, the target rotation will default to the value of Display of the default display at the time the use case is created. The use case is fully created once it has been attached to a camera.

Parameters:

rotation: The rotation of the intended target.

Returns:

The current Builder.

public VideoCapture.Builder setTargetResolution(Size resolution)

Sets the resolution of the intended target from this configuration.

The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.

It is not allowed to set both target aspect ratio and target resolution on the same use case.

The target aspect ratio will also be set the same as the aspect ratio of the provided . Make sure to set the target resolution with the correct orientation.

Parameters:

resolution: The target resolution to choose from supported output sizes list.

Returns:

The current Builder.

public VideoCapture.Builder setDefaultResolution(Size resolution)

Sets the default resolution of the intended target from this configuration.

Parameters:

resolution: The default resolution to choose from supported output sizes list.

Returns:

The current Builder.

public VideoCapture.Builder setMaxResolution(Size resolution)

public VideoCapture.Builder setSupportedResolutions(java.util.List<> resolutions)

public VideoCapture.Builder setBackgroundExecutor(java.util.concurrent.Executor executor)

Sets the default executor that will be used for background tasks.

If not set, the background executor will default to an automatically generated java.util.concurrent.Executor.

Parameters:

executor: The executor which will be used for background tasks.

Returns:

the current Builder.

public VideoCapture.Builder setDefaultSessionConfig(SessionConfig sessionConfig)

public VideoCapture.Builder setDefaultCaptureConfig(CaptureConfig captureConfig)

public VideoCapture.Builder setSessionOptionUnpacker(SessionConfig.OptionUnpacker optionUnpacker)

public VideoCapture.Builder setCaptureOptionUnpacker(CaptureConfig.OptionUnpacker optionUnpacker)

public VideoCapture.Builder setSurfaceOccupancyPriority(int priority)

public VideoCapture.Builder setCameraSelector(CameraSelector cameraSelector)

public VideoCapture.Builder setUseCaseEventCallback(UseCase.EventCallback useCaseEventCallback)