| 
									
										
										
										
											2021-02-19 16:28:05 +01:00
										 |  |  | // | 
					
						
							|  |  |  | //  AVCaptureDevice.Format.AutoFocusSystem+descriptor.swift | 
					
						
							| 
									
										
										
										
											2021-06-21 22:42:46 +02:00
										 |  |  | //  mrousavy | 
					
						
							| 
									
										
										
										
											2021-02-19 16:28:05 +01:00
										 |  |  | // | 
					
						
							|  |  |  | //  Created by Marc Rousavy on 29.12.20. | 
					
						
							| 
									
										
										
										
											2021-06-01 13:07:57 +02:00
										 |  |  | //  Copyright © 2020 mrousavy. All rights reserved. | 
					
						
							| 
									
										
										
										
											2021-02-19 16:28:05 +01:00
										 |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import AVFoundation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extension AVCaptureDevice.Format.AutoFocusSystem { | 
					
						
							|  |  |  |   init(withString string: String) throws { | 
					
						
							|  |  |  |     switch string { | 
					
						
							|  |  |  |     case "contrast-detection": | 
					
						
							|  |  |  |       self = .contrastDetection | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     case "phase-detection": | 
					
						
							|  |  |  |       self = .phaseDetection | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     case "none": | 
					
						
							|  |  |  |       self = .none | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       throw EnumParserError.invalidValue | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var descriptor: String { | 
					
						
							|  |  |  |     switch self { | 
					
						
							|  |  |  |     case .contrastDetection: | 
					
						
							|  |  |  |       return "contrast-detection" | 
					
						
							|  |  |  |     case .phaseDetection: | 
					
						
							|  |  |  |       return "phase-detection" | 
					
						
							|  |  |  |     case .none: | 
					
						
							|  |  |  |       return "none" | 
					
						
							|  |  |  |     @unknown default: | 
					
						
							|  |  |  |       fatalError("AVCaptureDevice.Format has unknown state.") | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |