将 otg_swift OTG 引擎迁入 Core/CameraOTG,并接入旅拍有线传图与历史导入。
恢复 USB 相机连接、边拍边传、三品牌驱动与 SwiftUI 历史导入页,通过适配层对接现有本地上传与 OSS 管道。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
55
suixinkan/Core/CameraOTG/CameraOTG.md
Normal file
55
suixinkan/Core/CameraOTG/CameraOTG.md
Normal file
@ -0,0 +1,55 @@
|
||||
# CameraOTG
|
||||
|
||||
## 模块职责
|
||||
|
||||
提供 USB OTG 相机有线连接能力,支持 Sony / Canon / Nikon 三品牌:
|
||||
|
||||
- USB 设备发现、授权、Session 管理与设备缓存重连
|
||||
- 边拍边传(Sony PTP、Canon EOS GetEvent、Nikon catalog 轮询)
|
||||
- 相机历史照片枚举与下载(供旅拍相册历史导入页使用)
|
||||
|
||||
不包含 OSS 上传与后端 API;上传由 `Features/TravelAlbum` 的 `WiredCameraTransferPipeline` 负责。
|
||||
|
||||
## 核心类型
|
||||
|
||||
| 类型 | 职责 |
|
||||
| --- | --- |
|
||||
| `ConnectionManager` | 单例,ImageCaptureCore 设备发现与会话编排 |
|
||||
| `ConnectionState` | 连接状态机 |
|
||||
| `CameraDriver` | 品牌无关的枚举/下载协议 |
|
||||
| `CameraFactory` / `PlatformDetector` | 品牌识别与 Driver 创建 |
|
||||
| `OTGPhotoSink` | 照片落盘协议,由旅拍模块实现 |
|
||||
| `OTGPhotoFileWriter` | scoped 本地文件写入 |
|
||||
|
||||
## 品牌实现
|
||||
|
||||
| 品牌 | 边拍边传 | 历史导入 |
|
||||
| --- | --- | --- |
|
||||
| Sony | `SonyRemoteCaptureService` + SDIO PTP | `SonyCameraDriver`(需 MTP 模式) |
|
||||
| Canon | `CanonRemoteCaptureService` + EOS GetEvent | `CanonCameraDriver` |
|
||||
| Nikon | `NikonCatalogLiveCaptureService` + catalog 监听 | `NikonCameraDriver` |
|
||||
|
||||
## 连接流程
|
||||
|
||||
1. 有线传图页 `start` → `ConnectionManager.configureLiveTransfer` + `start`
|
||||
2. `ICDeviceBrowser` 发现相机 → 申请 contents/control 授权 → `requestOpenSession`
|
||||
3. `PlatformDetector` 识别品牌 → `CameraFactory.makeDriver`
|
||||
4. Sony 立即初始化 SDIO 远程会话;Canon/Nikon 边拍边传在 content catalog 就绪后启动
|
||||
5. 页面离开 `detach`:仅解绑 delegate,保留设备缓存;App 终止时 `disconnect`
|
||||
|
||||
## 与旅拍相册集成
|
||||
|
||||
- `OTGLiveTransferCoordinator` 实现 `ConnectionManagerDelegate` 与 `TravelAlbumOTGPhotoSink`
|
||||
- 边拍边传落盘 → `WiredCameraTransferPipeline.ingestDownloadedAsset` → OSS 上传(边拍边传模式)
|
||||
- 历史导入由 `CameraHistoryImportView` 独立 Sheet 呈现
|
||||
|
||||
## 依赖
|
||||
|
||||
- `ImageCaptureCore`(系统框架)
|
||||
- `PTPUtilities` 通用 PTP 容器编解码
|
||||
|
||||
## 注意事项
|
||||
|
||||
- Sony 历史导入需 MTP 模式;边拍边传使用 PC Remote 模式(见 `SonyMTPHelpContent`)
|
||||
- Canon 远程模式在 catalog 就绪后初始化,避免打断 SD 卡枚举
|
||||
- 不使用 ExternalAccessory / MFi,仅 ImageCaptureCore
|
||||
Reference in New Issue
Block a user