Skip to content

Commit

Permalink
fix: Replace bitRateModifier -> bitRateMultiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Oct 30, 2024
1 parent 411fd58 commit e97bb88
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ data class CameraConfiguration(
// Output<T> types, those need to be comparable
data class CodeScanner(val codeTypes: List<CodeType>)
data class Photo(val isMirrored: Boolean, val enableHdr: Boolean, val photoQualityBalance: QualityBalance)
data class Video(val isMirrored: Boolean, val enableHdr: Boolean, val bitRateOverride: Double?, val bitRateModifier: Double?)
data class Video(val isMirrored: Boolean, val enableHdr: Boolean, val bitRateOverride: Double?, val bitRateMultiplier: Double?)
data class FrameProcessor(val isMirrored: Boolean, val pixelFormat: PixelFormat)
data class Audio(val nothing: Unit)
data class Preview(val surfaceProvider: SurfaceProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ internal fun CameraSession.configureOutputs(configuration: CameraConfiguration)
val bps = bitRateOverride * 1_000_000
recorder.setTargetVideoEncodingBitRate(bps.toInt())
}
videoConfig.config.bitRateModifier?.let { bitRateModifier ->
videoConfig.config.bitRateMultiplier?.let { bitRateMultiplier ->
val currentBitRate = recorder.build().targetVideoEncodingBitRate
val targetBitRate = currentBitRate.toDouble() * bitRateModifier
val targetBitRate = currentBitRate.toDouble() * bitRateMultiplier
val bps = targetBitRate * 1_000_000
recorder.setTargetVideoEncodingBitRate(bps.toInt())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CameraView(context: Context) :
var videoHdr = false
var photoHdr = false
var videoBitRateOverride: Double? = null
var videoBitRateModifier: Double? = null
var videoBitRateMultiplier: Double? = null

// TODO: Use .BALANCED once CameraX fixes it https://issuetracker.google.com/issues/337214687
var photoQualityBalance = QualityBalance.SPEED
Expand Down Expand Up @@ -184,7 +184,7 @@ class CameraView(context: Context) :
if (video || enableFrameProcessor) {
config.video =
CameraConfiguration.Output.Enabled.create(
CameraConfiguration.Video(isMirrored, videoHdr, videoBitRateOverride, videoBitRateModifier)
CameraConfiguration.Video(isMirrored, videoHdr, videoBitRateOverride, videoBitRateMultiplier)
)
} else {
config.video = CameraConfiguration.Output.Disabled.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ class CameraViewManager : ViewGroupManager<CameraView>() {
}
}

@ReactProp(name = "videoBitRateModifier", defaultDouble = -1.0)
fun setVideoBitRateModifier(view: CameraView, videoBitRateModifier: Double) {
if (videoBitRateModifier != -1.0) {
view.videoBitRateModifier = videoBitRateModifier
@ReactProp(name = "videoBitRateMultiplier", defaultDouble = -1.0)
fun setVideoBitRateMultiplier(view: CameraView, videoBitRateMultiplier: Double) {
if (videoBitRateMultiplier != -1.0) {
view.videoBitRateMultiplier = videoBitRateMultiplier
} else {
view.videoBitRateModifier = null
view.videoBitRateMultiplier = null
}
}

Expand Down
4 changes: 2 additions & 2 deletions package/ios/Core/Types/RecordVideoOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct RecordVideoOptions {
*/
var bitRateMultiplier: Double?

init(fromJSValue dictionary: NSDictionary, bitRateOverride: Double? = nil, bitRateModifier: Double? = nil) throws {
init(fromJSValue dictionary: NSDictionary, bitRateOverride: Double? = nil, bitRateMultiplier: Double? = nil) throws {
// File Type (.mov or .mp4)
if let fileTypeOption = dictionary["fileType"] as? String {
fileType = try AVFileType(withString: fileTypeOption)
Expand All @@ -40,7 +40,7 @@ struct RecordVideoOptions {
// BitRate Override
self.bitRateOverride = bitRateOverride
// BitRate Multiplier
self.bitRateModifier = bitRateModifier
self.bitRateMultiplier = bitRateMultiplier
// Custom Path
let fileExtension = fileType.descriptor ?? "mov"
if let customPath = dictionary["path"] as? String {
Expand Down
2 changes: 1 addition & 1 deletion package/ios/React/CameraView+RecordVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension CameraView: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureAud
do {
let options = try RecordVideoOptions(fromJSValue: options,
bitRateOverride: videoBitRateOverride,
videoBitRateModifier: videoBitRateModifier)
videoBitRateMultiplier: videoBitRateMultiplier)

// Start Recording with success and error callbacks
cameraSession.startRecording(
Expand Down
4 changes: 2 additions & 2 deletions package/ios/React/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class CameraView: UIView, CameraSessionDelegate, PreviewViewDelegat
@objc var lowLightBoost = false
@objc var outputOrientation: NSString?
@objc var videoBitRateOverride: NSNumber?
@objc var videoBitRateModifier: NSNumber?
@objc var videoBitRateMultiplier: NSNumber?

// other props
@objc var isActive = false
Expand Down Expand Up @@ -213,7 +213,7 @@ public final class CameraView: UIView, CameraSessionDelegate, PreviewViewDelegat
enableHdr: videoHdr,
enableFrameProcessor: enableFrameProcessor,
bitRateOverride: videoBitRateOverride,
bitRateModifier: videoBitRateModifier))
bitRateMultiplier: videoBitRateMultiplier))
} else {
config.video = .disabled
}
Expand Down
2 changes: 1 addition & 1 deletion package/ios/React/CameraViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ @interface RCT_EXTERN_REMAP_MODULE (CameraView, CameraViewManager, RCTViewManage
RCT_EXPORT_VIEW_PROPERTY(videoStabilizationMode, NSString);
RCT_EXPORT_VIEW_PROPERTY(pixelFormat, NSString);
RCT_EXPORT_VIEW_PROPERTY(videoBitRateOverride, NSNumber);
RCT_EXPORT_VIEW_PROPERTY(videoBitRateModifier, NSNumber);
RCT_EXPORT_VIEW_PROPERTY(videoBitRateMultiplier, NSNumber);
// other props
RCT_EXPORT_VIEW_PROPERTY(torch, NSString);
RCT_EXPORT_VIEW_PROPERTY(zoom, NSNumber);
Expand Down

0 comments on commit e97bb88

Please sign in to comment.