chore: Rename CodeScanner
to CodeScannerOptions
in native (#2010)
* chore: Rename `CodeScanner` to `CodeScannerOptions` on native * chore: Rename `CodeScanner` on iOS * fix: Unwrap `options` * Format
This commit is contained in:
@@ -179,8 +179,8 @@ public final class CameraView: UIView, CameraSessionDelegate {
|
||||
|
||||
// Code Scanner
|
||||
if let codeScannerOptions {
|
||||
let codeScanner = try CodeScanner(fromJsValue: codeScannerOptions)
|
||||
config.codeScanner = .enabled(config: codeScanner)
|
||||
let options = try CodeScannerOptions(fromJsValue: codeScannerOptions)
|
||||
config.codeScanner = .enabled(config: CameraConfiguration.CodeScanner(options: options))
|
||||
} else {
|
||||
config.codeScanner = .disabled
|
||||
}
|
||||
|
@@ -150,6 +150,13 @@ class CameraConfiguration {
|
||||
struct Audio: Equatable {
|
||||
// no props for audio at the moment
|
||||
}
|
||||
|
||||
/**
|
||||
A CodeScanner Output configuration
|
||||
*/
|
||||
struct CodeScanner: Equatable {
|
||||
var options: CodeScannerOptions
|
||||
}
|
||||
}
|
||||
|
||||
extension CameraConfiguration.Video {
|
||||
|
@@ -126,14 +126,15 @@ extension CameraSession {
|
||||
let codeScannerOutput = AVCaptureMetadataOutput()
|
||||
|
||||
// 1. Configure
|
||||
try codeScanner.codeTypes.forEach { type in
|
||||
let options = codeScanner.options
|
||||
try codeScanner.options.codeTypes.forEach { type in
|
||||
if !codeScannerOutput.availableMetadataObjectTypes.contains(type) {
|
||||
throw CameraError.codeScanner(.codeTypeNotSupported(codeType: type.descriptor))
|
||||
}
|
||||
}
|
||||
codeScannerOutput.setMetadataObjectsDelegate(self, queue: CameraQueues.codeScannerQueue)
|
||||
codeScannerOutput.metadataObjectTypes = codeScanner.codeTypes
|
||||
if let rectOfInterest = codeScanner.regionOfInterest {
|
||||
codeScannerOutput.metadataObjectTypes = options.codeTypes
|
||||
if let rectOfInterest = options.regionOfInterest {
|
||||
codeScannerOutput.rectOfInterest = rectOfInterest
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// CodeScanner.swift
|
||||
// CodeScannerOptions.swift
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Marc Rousavy on 03.10.23.
|
||||
@@ -9,7 +9,7 @@
|
||||
import AVFoundation
|
||||
import Foundation
|
||||
|
||||
struct CodeScanner: Equatable {
|
||||
struct CodeScannerOptions: Equatable {
|
||||
let codeTypes: [AVMetadataObject.ObjectType]
|
||||
let interval: Int
|
||||
let regionOfInterest: CGRect?
|
@@ -76,7 +76,7 @@
|
||||
B8DB3BCA263DC4D8004C18D7 /* RecordingSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB3BC9263DC4D8004C18D7 /* RecordingSession.swift */; };
|
||||
B8DB3BCC263DC97E004C18D7 /* AVFileType+descriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8DB3BCB263DC97E004C18D7 /* AVFileType+descriptor.swift */; };
|
||||
B8F127D02ACF054A00B39EA3 /* CMVideoDimensions+toCGSize.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8F127CF2ACF054A00B39EA3 /* CMVideoDimensions+toCGSize.swift */; };
|
||||
B8FF60AE2ACC9731009D612F /* CodeScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FF60AD2ACC9731009D612F /* CodeScanner.swift */; };
|
||||
B8FF60AE2ACC9731009D612F /* CodeScannerOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FF60AD2ACC9731009D612F /* CodeScannerOptions.swift */; };
|
||||
B8FF60B12ACC981B009D612F /* AVMetadataObject.ObjectType+descriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8FF60B02ACC981B009D612F /* AVMetadataObject.ObjectType+descriptor.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
B8F0825F2A60491900C17EB6 /* FrameProcessor.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameProcessor.mm; sourceTree = "<group>"; };
|
||||
B8F127CF2ACF054A00B39EA3 /* CMVideoDimensions+toCGSize.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CMVideoDimensions+toCGSize.swift"; sourceTree = "<group>"; };
|
||||
B8F7DDD1266F715D00120533 /* Frame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Frame.m; sourceTree = "<group>"; };
|
||||
B8FF60AD2ACC9731009D612F /* CodeScanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodeScanner.swift; sourceTree = "<group>"; };
|
||||
B8FF60AD2ACC9731009D612F /* CodeScannerOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodeScannerOptions.swift; sourceTree = "<group>"; };
|
||||
B8FF60B02ACC981B009D612F /* AVMetadataObject.ObjectType+descriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AVMetadataObject.ObjectType+descriptor.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B80175EB2ABDEBD000E7DE90 /* ResizeMode.swift */,
|
||||
B8FF60AD2ACC9731009D612F /* CodeScanner.swift */,
|
||||
B8FF60AD2ACC9731009D612F /* CodeScannerOptions.swift */,
|
||||
B88103DE2AD6FB230087F063 /* Orientation.swift */,
|
||||
B88103E02AD7046E0087F063 /* Torch.swift */,
|
||||
B8A1AEC92AD8034E00169C0D /* RecordVideoOptions.swift */,
|
||||
@@ -488,7 +488,7 @@
|
||||
B88685ED2AD6A5E600E93869 /* CameraSession+CodeScanner.swift in Sources */,
|
||||
B8D22CDC2642DB4D00234472 /* AVAssetWriterInputPixelBufferAdaptor+initWithVideoSettings.swift in Sources */,
|
||||
B84760DF2608F57D004C3180 /* CameraQueues.swift in Sources */,
|
||||
B8FF60AE2ACC9731009D612F /* CodeScanner.swift in Sources */,
|
||||
B8FF60AE2ACC9731009D612F /* CodeScannerOptions.swift in Sources */,
|
||||
B8446E502ABA14C900E56077 /* CameraDevicesManager.m in Sources */,
|
||||
B887518F25E0102000DB86D6 /* AVCaptureOutput+mirror.swift in Sources */,
|
||||
B88751A425E0102000DB86D6 /* AVCaptureDevice.Format.AutoFocusSystem+descriptor.swift in Sources */,
|
||||
|
Reference in New Issue
Block a user