完善 OTG 相机有线传图:支持 Sony/Canon 自动识别,页面 detach 保持会话以便再次进入复连。
引入进程级 CameraTetheringSession 与共享 USB Browser;离开传图页仅取消 UI 回调,App 终止时再完整 shutdown 释放 PTP 与 Browser 资源。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
import Foundation
|
||||
import ImageCaptureCore
|
||||
|
||||
/// USB Vendor ID 常量,用于自动识别相机品牌。
|
||||
enum CameraUSBVendorID {
|
||||
static let sony: Int = 0x054C
|
||||
static let canon: Int = 0x04A9
|
||||
static let nikon: Int = 0x04B0
|
||||
}
|
||||
|
||||
extension CameraBrand {
|
||||
/// 根据 ICCameraDevice 的 USB Vendor ID 识别品牌。
|
||||
static func detect(from camera: ICCameraDevice) -> CameraBrand? {
|
||||
switch Int(camera.usbVendorID) {
|
||||
case CameraUSBVendorID.sony:
|
||||
return .sony
|
||||
case CameraUSBVendorID.canon:
|
||||
return .canon
|
||||
case CameraUSBVendorID.nikon:
|
||||
return .nikon
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user