feat: Add pixelFormat
field (#559)
* Add `mediaSubType` field to device formats * Create FourCharCode `toString` extension * Move pixelFormat -> `AVCaptureDevice.Format+toDictionary` * `mediaSubType` -> `pixelFormat` + non-optional * ts pixelFormat `string` -> specific formats * Add default pixelFormat value of `420v` on Android Co-authored-by: tcoldwell72 <31568400+tcoldwell72@users.noreply.github.com>
This commit is contained in:
@@ -42,12 +42,13 @@ extension AVCaptureDevice.Format {
|
||||
"maxFrameRate": $0.maxFrameRate,
|
||||
]
|
||||
},
|
||||
"pixelFormat": CMFormatDescriptionGetMediaSubType(formatDescription).toString()
|
||||
]
|
||||
|
||||
if #available(iOS 13.0, *) {
|
||||
dict["isHighestPhotoQualitySupported"] = self.isHighestPhotoQualitySupported
|
||||
}
|
||||
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
17
ios/Extensions/FourCharCode+toString.swift
Normal file
17
ios/Extensions/FourCharCode+toString.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// FourCharCode+toString.swift
|
||||
// VisionCamera
|
||||
//
|
||||
// Created by Thomas Coldwell on 28/10/2021.
|
||||
// Based off this SO answer: https://stackoverflow.com/a/25625744
|
||||
//
|
||||
|
||||
extension FourCharCode {
|
||||
func toString() -> String {
|
||||
var s: String = String (UnicodeScalar((self >> 24) & 255)!)
|
||||
s.append(String(UnicodeScalar((self >> 16) & 255)!))
|
||||
s.append(String(UnicodeScalar((self >> 8) & 255)!))
|
||||
s.append(String(UnicodeScalar(self & 255)!))
|
||||
return (s)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user