Skip to content

Commit

Permalink
Implement Android
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Jul 12, 2024
1 parent 7e70c1f commit cd9e6e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ data class CameraConfiguration(
var format: CameraDeviceFormat? = null,

// Side-Props
var fps: Int? = null,
var minFps: Int? = null,
var maxFps: Int? = null,
var enableLowLightBoost: Boolean = false,
var torch: Torch = Torch.OFF,
var videoStabilizationMode: VideoStabilizationMode = VideoStabilizationMode.OFF,
Expand All @@ -54,9 +55,8 @@ data class CameraConfiguration(

val targetFpsRange: Range<Int>?
get() {
val maxFps = fps ?: return null
val format = format ?: throw PropRequiresFormatToBeNonNullError("fps")
val minFps = format.minFps.toInt()
val minFps = minFps ?: return null
val maxFps = maxFps ?: return null
return Range(minFps, maxFps)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class CameraView(context: Context) :

// props that require format reconfiguring
var format: CameraDeviceFormat? = null
var fps: Int? = null
var minFps: Int? = null
var maxFps: Int? = null
var videoStabilizationMode: VideoStabilizationMode? = null
var videoHdr = false
var photoHdr = false
Expand Down Expand Up @@ -218,7 +219,8 @@ class CameraView(context: Context) :
config.format = format

// Side-Props
config.fps = fps
config.minFps = minFps
config.maxFps = maxFps
config.enableLowLightBoost = lowLightBoost
config.torch = torch
config.exposure = exposure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,17 @@ class CameraViewManager : ViewGroupManager<CameraView>() {
// TODO: Change when TurboModules release.
// We're treating -1 as "null" here, because when I make the fps parameter
// of type "Int?" the react bridge throws an error.
@ReactProp(name = "fps", defaultInt = -1)
fun setFps(view: CameraView, fps: Int) {
view.fps = if (fps > 0) fps else null
@ReactProp(name = "minFps", defaultInt = -1)
fun setMinFps(view: CameraView, minFps: Int) {
view.minFps = if (minFps > 0) minFps else null
}

// TODO: Change when TurboModules release.
// We're treating -1 as "null" here, because when I make the fps parameter
// of type "Int?" the react bridge throws an error.
@ReactProp(name = "maxFps", defaultInt = -1)
fun setMaxFps(view: CameraView, maxFps: Int) {
view.maxFps = if (maxFps > 0) maxFps else null
}

@ReactProp(name = "photoHdr")
Expand Down

0 comments on commit cd9e6e7

Please sign in to comment.