213 lines
7.6 KiB
Java
213 lines
7.6 KiB
Java
package sushi.hardcore.droidfs.video_recording;
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.camera.core.impl.Config;
|
|
import androidx.camera.core.impl.ImageFormatConstants;
|
|
import androidx.camera.core.impl.ImageOutputConfig;
|
|
import androidx.camera.core.impl.OptionsBundle;
|
|
import androidx.camera.core.impl.UseCaseConfig;
|
|
import androidx.camera.core.internal.ThreadConfig;
|
|
|
|
/**
|
|
* Config for a video capture use case.
|
|
*
|
|
* <p>In the earlier stage, the VideoCapture is deprioritized.
|
|
*/
|
|
@SuppressLint("RestrictedApi")
|
|
public final class VideoCaptureConfig
|
|
implements UseCaseConfig<VideoCapture>,
|
|
ImageOutputConfig,
|
|
ThreadConfig {
|
|
|
|
// Option Declarations:
|
|
// *********************************************************************************************
|
|
|
|
public static final Option<Integer> OPTION_VIDEO_FRAME_RATE =
|
|
Option.create("camerax.core.videoCapture.recordingFrameRate", int.class);
|
|
public static final Option<Integer> OPTION_BIT_RATE =
|
|
Option.create("camerax.core.videoCapture.bitRate", int.class);
|
|
public static final Option<Integer> OPTION_INTRA_FRAME_INTERVAL =
|
|
Option.create("camerax.core.videoCapture.intraFrameInterval", int.class);
|
|
public static final Option<Integer> OPTION_AUDIO_BIT_RATE =
|
|
Option.create("camerax.core.videoCapture.audioBitRate", int.class);
|
|
public static final Option<Integer> OPTION_AUDIO_SAMPLE_RATE =
|
|
Option.create("camerax.core.videoCapture.audioSampleRate", int.class);
|
|
public static final Option<Integer> OPTION_AUDIO_CHANNEL_COUNT =
|
|
Option.create("camerax.core.videoCapture.audioChannelCount", int.class);
|
|
public static final Option<Integer> OPTION_AUDIO_MIN_BUFFER_SIZE =
|
|
Option.create("camerax.core.videoCapture.audioMinBufferSize", int.class);
|
|
|
|
// *********************************************************************************************
|
|
|
|
private final OptionsBundle mConfig;
|
|
|
|
public VideoCaptureConfig(@NonNull OptionsBundle config) {
|
|
mConfig = config;
|
|
}
|
|
|
|
/**
|
|
* Returns the recording frames per second.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getVideoFrameRate(int valueIfMissing) {
|
|
return retrieveOption(OPTION_VIDEO_FRAME_RATE, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the recording frames per second.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getVideoFrameRate() {
|
|
return retrieveOption(OPTION_VIDEO_FRAME_RATE);
|
|
}
|
|
|
|
/**
|
|
* Returns the encoding bit rate.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getBitRate(int valueIfMissing) {
|
|
return retrieveOption(OPTION_BIT_RATE, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the encoding bit rate.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getBitRate() {
|
|
return retrieveOption(OPTION_BIT_RATE);
|
|
}
|
|
|
|
/**
|
|
* Returns the number of seconds between each key frame.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getIFrameInterval(int valueIfMissing) {
|
|
return retrieveOption(OPTION_INTRA_FRAME_INTERVAL, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the number of seconds between each key frame.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getIFrameInterval() {
|
|
return retrieveOption(OPTION_INTRA_FRAME_INTERVAL);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio encoding bit rate.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getAudioBitRate(int valueIfMissing) {
|
|
return retrieveOption(OPTION_AUDIO_BIT_RATE, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio encoding bit rate.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getAudioBitRate() {
|
|
return retrieveOption(OPTION_AUDIO_BIT_RATE);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio sample rate.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getAudioSampleRate(int valueIfMissing) {
|
|
return retrieveOption(OPTION_AUDIO_SAMPLE_RATE, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio sample rate.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getAudioSampleRate() {
|
|
return retrieveOption(OPTION_AUDIO_SAMPLE_RATE);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio channel count.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getAudioChannelCount(int valueIfMissing) {
|
|
return retrieveOption(OPTION_AUDIO_CHANNEL_COUNT, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio channel count.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getAudioChannelCount() {
|
|
return retrieveOption(OPTION_AUDIO_CHANNEL_COUNT);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio minimum buffer size, in bytes.
|
|
*
|
|
* @param valueIfMissing The value to return if this configuration option has not been set.
|
|
* @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
|
|
* configuration.
|
|
*/
|
|
public int getAudioMinBufferSize(int valueIfMissing) {
|
|
return retrieveOption(OPTION_AUDIO_MIN_BUFFER_SIZE, valueIfMissing);
|
|
}
|
|
|
|
/**
|
|
* Returns the audio minimum buffer size, in bytes.
|
|
*
|
|
* @return The stored value, if it exists in this configuration.
|
|
* @throws IllegalArgumentException if the option does not exist in this configuration.
|
|
*/
|
|
public int getAudioMinBufferSize() {
|
|
return retrieveOption(OPTION_AUDIO_MIN_BUFFER_SIZE);
|
|
}
|
|
|
|
/**
|
|
* Retrieves the format of the image that is fed as input.
|
|
*
|
|
* <p>This should always be PRIVATE for VideoCapture.
|
|
*/
|
|
@Override
|
|
public int getInputFormat() {
|
|
return ImageFormatConstants.INTERNAL_DEFINED_IMAGE_FORMAT_PRIVATE;
|
|
}
|
|
|
|
@NonNull
|
|
@Override
|
|
public Config getConfig() {
|
|
return mConfig;
|
|
}
|
|
}
|