Skip to content

Commit

Permalink
fix stabilization issue (#131)
Browse files Browse the repository at this point in the history
* fix stabilization issue where changed settings aren't applied to camera use case
* fixes #118
  • Loading branch information
Kimblebee authored Mar 5, 2024
1 parent 90b8586 commit 159d050
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,9 @@ constructor(

// set video stabilization

if (shouldVideoBeStabilized(sessionSettings, supportedStabilizationMode)) {
val isStabilized = when (sessionSettings.stabilizeVideoMode) {
Stabilization.ON -> true
Stabilization.OFF, Stabilization.UNDEFINED -> false
}
videoCaptureBuilder.setVideoStabilizationEnabled(isStabilized)
if (shouldVideoBeStabilized(sessionSettings, supportedStabilizationMode)
) {
videoCaptureBuilder.setVideoStabilizationEnabled(true)
}
return videoCaptureBuilder.build()
}
Expand All @@ -511,19 +508,12 @@ constructor(
supportedStabilizationModes: List<SupportedStabilizationMode>
): Boolean {
// video is supported by the device AND
// video is on OR preview is on
// video is on
return (supportedStabilizationModes.contains(SupportedStabilizationMode.HIGH_QUALITY)) &&
// high quality (video only) selected
(
// high quality (video only) selected
(
sessionSettings.stabilizeVideoMode == Stabilization.ON &&
sessionSettings.stabilizePreviewMode == Stabilization.UNDEFINED
) ||
// or on is selected
(
sessionSettings.stabilizePreviewMode == Stabilization.ON &&
sessionSettings.stabilizeVideoMode != Stabilization.OFF
)
sessionSettings.stabilizeVideoMode == Stabilization.ON &&
sessionSettings.stabilizePreviewMode == Stabilization.UNDEFINED
)
}

Expand All @@ -534,11 +524,7 @@ constructor(
val previewUseCaseBuilder = Preview.Builder()
// set preview stabilization
if (shouldPreviewBeStabilized(sessionSettings, supportedStabilizationModes)) {
val isStabilized = when (sessionSettings.stabilizePreviewMode) {
Stabilization.ON -> true
else -> false
}
previewUseCaseBuilder.setPreviewStabilizationEnabled(isStabilized)
previewUseCaseBuilder.setPreviewStabilizationEnabled(true)
}

return previewUseCaseBuilder.build().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.google.jetpackcamera.settings.ui.DefaultCameraFacing
import com.google.jetpackcamera.settings.ui.FlashModeSetting
import com.google.jetpackcamera.settings.ui.SectionHeader
import com.google.jetpackcamera.settings.ui.SettingsPageHeader
import com.google.jetpackcamera.settings.ui.StabilizationSetting

/**
* Screen used for the Settings feature.
Expand Down Expand Up @@ -76,15 +77,14 @@ fun SettingsList(uiState: SettingsUiState, viewModel: SettingsViewModel) {
)

// TODO: b/326140212 - stabilization setting not changing active stabilization mode
/*

StabilizationSetting(
currentVideoStabilization = uiState.cameraAppSettings.videoCaptureStabilization,
currentPreviewStabilization = uiState.cameraAppSettings.previewStabilization,
supportedStabilizationMode = uiState.cameraAppSettings.supportedStabilizationModes,
setVideoStabilization = viewModel::setVideoStabilization,
setPreviewStabilization = viewModel::setPreviewStabilization
)
*/

SectionHeader(title = stringResource(id = R.string.section_title_app_settings))

Expand Down

0 comments on commit 159d050

Please sign in to comment.