feat: 完善机巢图传、拍摄阶段与任务交互

- 完善双路 RTC 接收、首帧切换及拍摄结束后的本地播放释放
- 对齐无人机状态枚举与正常拍完返航标记,新增到达后本地倒计时
- 补充准备页电量与前往回执,进入任务时移除准备页路由
- 对齐拍摄中和拍摄完成原型布局,移除详情按钮
- 补充隔离测试、接口记录与项目约定

验证:最近 157 项相关模拟器隔离测试通过,Release 无签名编译通过;未调用真实飞控或图传。
This commit is contained in:
2026-11-03 16:43:23 +08:00
parent 0ed0077ec4
commit 54210925f0
33 changed files with 3242 additions and 205 deletions
@@ -0,0 +1,99 @@
import UIKit
@preconcurrency import VolcEngineRTC
/// 接收端最小能力,隔离测试无需初始化 SDK 或使用真实凭证。
@MainActor
protocol DroneDockRTCReceivingEngine: AnyObject {
/// 创建一个独立接收房间并转交事件。
func makeRoom(_ id: String, onEvent: @escaping @Sendable (DroneDockVolcEvent) -> Void) -> (any DroneDockRTCReceivingRoom)?
/// 按 SDK 提供的流 ID 绑定或解绑画布。
func setVideoView(_ view: UIView?, streamID: String) -> Int
/// 销毁引擎及本地接收资源。
func destroy()
}
/// 单路只收视频的房间;不提供发布、采集或设备控制能力。
@MainActor
protocol DroneDockRTCReceivingRoom: AnyObject {
/// 使用与当前用户匹配的凭证入房。
func join(_ configuration: DroneDockVolcLiveConfiguration) -> Int
/// 同用户凭证续期。
func updateToken(_ token: String) -> Int
/// 订阅或取消订阅远端视频。
func subscribeVideo(_ streamID: String, subscribe: Bool) -> Int
/// 退出并销毁接收房间。
func destroy()
}
/// 火山 SDK 适配器;真实创建点再次拦截 Debug,测试不能通过注入绕开保护。
@MainActor
final class DroneDockVolcEngineAdapter: DroneDockRTCReceivingEngine {
private let engine: ByteRTCEngine
private let delegate: DroneDockVolcDelegate
private init(engine: ByteRTCEngine, delegate: DroneDockVolcDelegate) {
self.engine = engine
self.delegate = delegate
}
/// 仅在构建策略允许真实图传时构造 SDK。
static func make(appID: String, onEvent: @escaping @Sendable (DroneDockVolcEvent) -> Void) -> (any DroneDockRTCReceivingEngine)? {
guard !DeviceCommandDebugPolicy.blocksLiveRequests else { return nil }
let delegate = DroneDockVolcDelegate(emit: onEvent)
let config = ByteRTCEngineConfig()
config.appID = appID
guard let engine = ByteRTCEngine.createRTCEngine(config, delegate: delegate) else { return nil }
return DroneDockVolcEngineAdapter(engine: engine, delegate: delegate)
}
/// 每个房间独立保留回调桥接,避免弱引用导致事件丢失。
func makeRoom(_ id: String, onEvent: @escaping @Sendable (DroneDockVolcEvent) -> Void) -> (any DroneDockRTCReceivingRoom)? {
guard let room = engine.createRTCRoom(id) else { return nil }
return DroneDockVolcRoomAdapter(room: room, delegate: DroneDockVolcDelegate(emit: onEvent))
}
/// 画布只依赖发布回调的 streamID,不假定远端流索引为零。
func setVideoView(_ view: UIView?, streamID: String) -> Int {
let canvas = ByteRTCVideoCanvas()
canvas.view = view
canvas.renderMode = .fit
return Int(engine.setRemoteVideoCanvas(streamID, withCanvas: canvas))
}
/// 房间由接收器先释放,再销毁共享引擎。
func destroy() {
engine.delegate = nil
ByteRTCEngine.destroyRTCEngine()
}
}
/// 将只收视频的房间配置封装在 SDK 边界,所有回调由接收器切回主线程。
@MainActor
private final class DroneDockVolcRoomAdapter: DroneDockRTCReceivingRoom {
private let room: ByteRTCRoom
private let delegate: DroneDockVolcDelegate
init(room: ByteRTCRoom, delegate: DroneDockVolcDelegate) {
self.room = room
self.delegate = delegate
room.setRTCRoomDelegate(delegate)
}
func join(_ configuration: DroneDockVolcLiveConfiguration) -> Int {
let config = ByteRTCRoomConfig()
config.isPublishAudio = false
config.isPublishVideo = false
config.isAutoSubscribeAudio = false
config.isAutoSubscribeVideo = false
let user = ByteRTCUserInfo()
user.userId = configuration.userID
return Int(room.joinRoom(configuration.token, userInfo: user, userVisibility: false, roomConfig: config))
}
func updateToken(_ token: String) -> Int { Int(room.updateToken(token)) }
func subscribeVideo(_ streamID: String, subscribe: Bool) -> Int { Int(room.subscribeStreamVideo(streamID, subscribe: subscribe)) }
func destroy() {
room.setRTCRoomDelegate(nil)
room.destroy()
}
}