chore: Lint

This commit is contained in:
Marc Rousavy 2021-12-10 09:44:54 +01:00
parent c3039c94c6
commit 9301430165
6 changed files with 22 additions and 22 deletions

View File

@ -38,7 +38,7 @@ extension CameraView {
// Audio Input // Audio Input
do { do {
if let audioDeviceInput = self.audioDeviceInput { if let audioDeviceInput = audioDeviceInput {
audioCaptureSession.removeInput(audioDeviceInput) audioCaptureSession.removeInput(audioDeviceInput)
self.audioDeviceInput = nil self.audioDeviceInput = nil
} }
@ -61,7 +61,7 @@ extension CameraView {
} }
// Audio Output // Audio Output
if let audioOutput = self.audioOutput { if let audioOutput = audioOutput {
audioCaptureSession.removeOutput(audioOutput) audioCaptureSession.removeOutput(audioOutput)
self.audioOutput = nil self.audioOutput = nil
} }

View File

@ -40,7 +40,7 @@ extension CameraView {
} }
// If preset is set, use preset. Otherwise use format. // If preset is set, use preset. Otherwise use format.
if let preset = self.preset { if let preset = preset {
var sessionPreset: AVCaptureSession.Preset? var sessionPreset: AVCaptureSession.Preset?
do { do {
sessionPreset = try AVCaptureSession.Preset(withString: preset) sessionPreset = try AVCaptureSession.Preset(withString: preset)
@ -64,7 +64,7 @@ extension CameraView {
// pragma MARK: Capture Session Inputs // pragma MARK: Capture Session Inputs
// Video Input // Video Input
do { do {
if let videoDeviceInput = self.videoDeviceInput { if let videoDeviceInput = videoDeviceInput {
captureSession.removeInput(videoDeviceInput) captureSession.removeInput(videoDeviceInput)
self.videoDeviceInput = nil self.videoDeviceInput = nil
} }
@ -87,7 +87,7 @@ extension CameraView {
// pragma MARK: Capture Session Outputs // pragma MARK: Capture Session Outputs
// Photo Output // Photo Output
if let photoOutput = self.photoOutput { if let photoOutput = photoOutput {
captureSession.removeOutput(photoOutput) captureSession.removeOutput(photoOutput)
self.photoOutput = nil self.photoOutput = nil
} }
@ -121,7 +121,7 @@ extension CameraView {
} }
// Video Output + Frame Processor // Video Output + Frame Processor
if let videoOutput = self.videoOutput { if let videoOutput = videoOutput {
captureSession.removeOutput(videoOutput) captureSession.removeOutput(videoOutput)
self.videoOutput = nil self.videoOutput = nil
} }
@ -159,7 +159,7 @@ extension CameraView {
do { do {
try device.lockForConfiguration() try device.lockForConfiguration()
if let fps = self.fps?.int32Value { if let fps = fps?.int32Value {
let supportsGivenFps = device.activeFormat.videoSupportedFrameRateRanges.contains { range in let supportsGivenFps = device.activeFormat.videoSupportedFrameRateRanges.contains { range in
return range.includes(fps: Double(fps)) return range.includes(fps: Double(fps))
} }
@ -195,7 +195,7 @@ extension CameraView {
device.automaticallyEnablesLowLightBoostWhenAvailable = lowLightBoost!.boolValue device.automaticallyEnablesLowLightBoostWhenAvailable = lowLightBoost!.boolValue
} }
} }
if let colorSpace = self.colorSpace as String? { if let colorSpace = colorSpace as String? {
guard let avColorSpace = try? AVCaptureColorSpace(string: colorSpace), guard let avColorSpace = try? AVCaptureColorSpace(string: colorSpace),
device.activeFormat.supportedColorSpaces.contains(avColorSpace) else { device.activeFormat.supportedColorSpaces.contains(avColorSpace) else {
invokeOnError(.format(.invalidColorSpace(colorSpace: colorSpace))) invokeOnError(.format(.invalidColorSpace(colorSpace: colorSpace)))
@ -219,7 +219,7 @@ extension CameraView {
*/ */
final func configureFormat() { final func configureFormat() {
ReactLogger.log(level: .info, message: "Configuring Format...") ReactLogger.log(level: .info, message: "Configuring Format...")
guard let filter = self.format else { guard let filter = format else {
// Format Filter was null. Ignore it. // Format Filter was null. Ignore it.
return return
} }

View File

@ -45,7 +45,7 @@ extension CameraView {
} }
func removePinchGestureRecognizer() { func removePinchGestureRecognizer() {
if let pinchGestureRecognizer = self.pinchGestureRecognizer { if let pinchGestureRecognizer = pinchGestureRecognizer {
removeGestureRecognizer(pinchGestureRecognizer) removeGestureRecognizer(pinchGestureRecognizer)
self.pinchGestureRecognizer = nil self.pinchGestureRecognizer = nil
} }

View File

@ -342,7 +342,7 @@ public final class CameraView: UIView {
// pragma MARK: Event Invokers // pragma MARK: Event Invokers
internal final func invokeOnError(_ error: CameraError, cause: NSError? = nil) { internal final func invokeOnError(_ error: CameraError, cause: NSError? = nil) {
ReactLogger.log(level: .error, message: "Invoking onError(): \(error.message)") ReactLogger.log(level: .error, message: "Invoking onError(): \(error.message)")
guard let onError = self.onError else { return } guard let onError = onError else { return }
var causeDictionary: [String: Any]? var causeDictionary: [String: Any]?
if let cause = cause { if let cause = cause {
@ -362,13 +362,13 @@ public final class CameraView: UIView {
internal final func invokeOnInitialized() { internal final func invokeOnInitialized() {
ReactLogger.log(level: .info, message: "Camera initialized!") ReactLogger.log(level: .info, message: "Camera initialized!")
guard let onInitialized = self.onInitialized else { return } guard let onInitialized = onInitialized else { return }
onInitialized([String: Any]()) onInitialized([String: Any]())
} }
internal final func invokeOnFrameProcessorPerformanceSuggestionAvailable(currentFps: Double, suggestedFps: Double) { internal final func invokeOnFrameProcessorPerformanceSuggestionAvailable(currentFps: Double, suggestedFps: Double) {
ReactLogger.log(level: .info, message: "Frame Processor Performance Suggestion available!") ReactLogger.log(level: .info, message: "Frame Processor Performance Suggestion available!")
guard let onFrameProcessorPerformanceSuggestionAvailable = self.onFrameProcessorPerformanceSuggestionAvailable else { return } guard let onFrameProcessorPerformanceSuggestionAvailable = onFrameProcessorPerformanceSuggestionAvailable else { return }
if lastSuggestedFrameProcessorFps == suggestedFps { return } if lastSuggestedFrameProcessorFps == suggestedFps { return }
if suggestedFps == currentFps { return } if suggestedFps == currentFps { return }

View File

@ -42,7 +42,7 @@ extension AVCaptureDevice.Format {
"maxFrameRate": $0.maxFrameRate, "maxFrameRate": $0.maxFrameRate,
] ]
}, },
"pixelFormat": CMFormatDescriptionGetMediaSubType(formatDescription).toString() "pixelFormat": CMFormatDescriptionGetMediaSubType(formatDescription).toString(),
] ]
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {

View File

@ -7,11 +7,11 @@
// //
extension FourCharCode { extension FourCharCode {
func toString() -> String { func toString() -> String {
var s: String = String (UnicodeScalar((self >> 24) & 255)!) var s = String(UnicodeScalar((self >> 24) & 255)!)
s.append(String(UnicodeScalar((self >> 16) & 255)!)) s.append(String(UnicodeScalar((self >> 16) & 255)!))
s.append(String(UnicodeScalar((self >> 8) & 255)!)) s.append(String(UnicodeScalar((self >> 8) & 255)!))
s.append(String(UnicodeScalar(self & 255)!)) s.append(String(UnicodeScalar(self & 255)!))
return (s) return (s)
} }
} }