Skip to content

Commit

Permalink
feat(core): camera: add an API to set custom camera settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Nov 25, 2024
1 parent a24ce81 commit 86e1696
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class CameraController(
)
}

fun <T> getSetting(key: CaptureRequest.Key<T>?): T? {
fun <T> getSetting(key: CaptureRequest.Key<T?>): T? {
return captureRequest?.get(key)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import java.util.concurrent.TimeUnit
* Use to change camera settings.
* This object is returned by [DefaultCameraStreamer.videoSource.settings].
*/
class CameraSettings(context: Context, cameraController: CameraController) {
class CameraSettings(context: Context, private val cameraController: CameraController) {
/**
* Current camera flash API.
*/
Expand Down Expand Up @@ -101,6 +101,26 @@ class CameraSettings(context: Context, cameraController: CameraController) {
*/
val focusMetering =
FocusMetering(context, cameraController, zoom, focus, exposure, whiteBalance)

/**
* Directly gets a [CaptureResult] from the camera.
*
* @param key the key to get
* @return the value associated with the key
*/
fun <T> get(key: CaptureRequest.Key<T?>): T? {
return cameraController.getSetting(key)
}

/**
* Directly sets a [CaptureRequest] key to the camera.
*
* @param key the key to set
* @param value the value to set
*/
fun <T> set(key: CaptureRequest.Key<T>, value: T) {
cameraController.setRepeatingSetting(key, value)
}
}

class Flash(private val context: Context, private val cameraController: CameraController) {
Expand Down

0 comments on commit 86e1696

Please sign in to comment.