feat(protocol): freeze M4 native session RC6 contract

This commit is contained in:
sechmachine
2026-08-13 07:18:03 +07:00
parent 4693102b3c
commit 8eacc4fda9
35 changed files with 5334 additions and 473 deletions
+11
View File
@@ -26,6 +26,8 @@ func evaluate(_ version: String, _ kind: String, _ input: String) -> String {
guard (try? SessionRequest(
clientDeviceId: values["client_device_id"] ?? "", deviceKeyId: values["device_key_id"] ?? "",
poolId: values["pool_id"] ?? "", idempotencyKey: values["idempotency_key"] ?? "",
videoProfiles: [try! VideoProfile(codec: "h264", bitDepth: 8, chromaSubsampling: "4:2:0", colorSpace: "bt709-limited", transferFunction: "sdr")],
bitratePreference: try! BitratePreference(mode: "auto", targetKbps: nil),
requestedDisplayMode: nil
)) != nil else { return "invalid:required" }
return "valid"
@@ -136,6 +138,9 @@ func classifyGatewayInput(_ encoded: String) -> String {
let height = Int(body[6]) * 256 + Int(body[7])
return width > 0 && height > 0 && x < width && y < height ? "valid" : "invalid:field"
case 7: return body.count == 4 ? "valid" : "invalid:length"
case 8:
guard body.count == 8 else { return "invalid:length" }
return body[0] <= 15 && body[3] <= 3 ? "valid" : "invalid:field"
default: return "invalid:kind"
}
}
@@ -156,6 +161,12 @@ func classifyGatewayFeedback(_ encoded: String) -> String {
case 2:
return validFECStatus(body) ? "valid" : "invalid:field"
case 3: return body.isEmpty ? "valid" : "invalid:length"
case 4:
guard body.count == 24 else { return "invalid:length" }
return body[0...15].contains(where: { $0 != 0 }) && body[16...23].contains(where: { $0 != 0 }) ? "valid" : "invalid:field"
case 5:
guard body.count == 16 else { return "invalid:length" }
return body.contains(where: { $0 != 0 }) ? "valid" : "invalid:field"
default: return "invalid:type"
}
}