chore: Organize code
This commit is contained in:
parent
ad33dd91b1
commit
3699ccde94
@ -3,6 +3,7 @@ package com.mrousavy.camera.core.capture
|
|||||||
import android.hardware.camera2.CameraCharacteristics
|
import android.hardware.camera2.CameraCharacteristics
|
||||||
import android.hardware.camera2.CameraDevice
|
import android.hardware.camera2.CameraDevice
|
||||||
import android.hardware.camera2.CaptureRequest
|
import android.hardware.camera2.CaptureRequest
|
||||||
|
import android.os.Build
|
||||||
import android.util.Range
|
import android.util.Range
|
||||||
import com.mrousavy.camera.core.CameraDeviceDetails
|
import com.mrousavy.camera.core.CameraDeviceDetails
|
||||||
import com.mrousavy.camera.core.InvalidFpsError
|
import com.mrousavy.camera.core.InvalidFpsError
|
||||||
@ -14,7 +15,7 @@ import com.mrousavy.camera.types.Torch
|
|||||||
import com.mrousavy.camera.types.VideoStabilizationMode
|
import com.mrousavy.camera.types.VideoStabilizationMode
|
||||||
|
|
||||||
class RepeatingCaptureRequest(
|
class RepeatingCaptureRequest(
|
||||||
val enableVideoPipeline: Boolean,
|
private val enableVideoPipeline: Boolean,
|
||||||
torch: Torch = Torch.OFF,
|
torch: Torch = Torch.OFF,
|
||||||
private val fps: Int? = null,
|
private val fps: Int? = null,
|
||||||
private val videoStabilizationMode: VideoStabilizationMode = VideoStabilizationMode.OFF,
|
private val videoStabilizationMode: VideoStabilizationMode = VideoStabilizationMode.OFF,
|
||||||
@ -34,9 +35,11 @@ class RepeatingCaptureRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getBestDigitalStabilizationMode(deviceDetails: CameraDeviceDetails): Int {
|
private fun getBestDigitalStabilizationMode(deviceDetails: CameraDeviceDetails): Int {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
if (deviceDetails.digitalStabilizationModes.contains(CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION)) {
|
if (deviceDetails.digitalStabilizationModes.contains(CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION)) {
|
||||||
return CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION
|
return CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_PREVIEW_STABILIZATION
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_ON
|
return CameraCharacteristics.CONTROL_VIDEO_STABILIZATION_MODE_ON
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,17 +90,15 @@ class RepeatingCaptureRequest(
|
|||||||
if (!format.videoStabilizationModes.contains(videoStabilizationMode)) {
|
if (!format.videoStabilizationModes.contains(videoStabilizationMode)) {
|
||||||
throw InvalidVideoStabilizationMode(videoStabilizationMode)
|
throw InvalidVideoStabilizationMode(videoStabilizationMode)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
when (videoStabilizationMode) {
|
when (videoStabilizationMode) {
|
||||||
VideoStabilizationMode.OFF -> {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
VideoStabilizationMode.STANDARD -> {
|
VideoStabilizationMode.STANDARD -> {
|
||||||
builder.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, getBestDigitalStabilizationMode(deviceDetails))
|
builder.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE, getBestDigitalStabilizationMode(deviceDetails))
|
||||||
}
|
}
|
||||||
VideoStabilizationMode.CINEMATIC, VideoStabilizationMode.CINEMATIC_EXTENDED -> {
|
VideoStabilizationMode.CINEMATIC, VideoStabilizationMode.CINEMATIC_EXTENDED -> {
|
||||||
builder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON)
|
builder.set(CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE, CaptureRequest.LENS_OPTICAL_STABILIZATION_MODE_ON)
|
||||||
}
|
}
|
||||||
|
else -> throw InvalidVideoStabilizationMode(videoStabilizationMode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
|
Loading…
Reference in New Issue
Block a user