feat(protocol): negotiate display and native input
This commit is contained in:
@@ -103,6 +103,44 @@ do {
|
||||
)
|
||||
fatalError("invalid allocation bounds were accepted")
|
||||
} catch { }
|
||||
let displayMode = try DisplayMode(resolutionWidth: 2560, resolutionHeight: 1440, fps: 120)
|
||||
for invalid in [
|
||||
{ try DisplayMode(resolutionWidth: 319, resolutionHeight: 1440, fps: 120) },
|
||||
{ try DisplayMode(resolutionWidth: 2560, resolutionHeight: 199, fps: 120) },
|
||||
{ try DisplayMode(resolutionWidth: 2560, resolutionHeight: 1440, fps: 241) },
|
||||
] {
|
||||
do {
|
||||
_ = try invalid()
|
||||
fatalError("invalid display mode was accepted")
|
||||
} catch { }
|
||||
}
|
||||
let allocationPolicy = try AllocationPolicy(
|
||||
minimumKbps: 1000, targetKbps: 2000, maximumKbps: 3000, tier: "standard",
|
||||
audience: "versevdi-gateway", protocolValue: "verse", protocolVersion: 1,
|
||||
grantTtlSeconds: 60, reservationLeaseSeconds: 300
|
||||
)
|
||||
let legacyDisplayRequest = try SessionRequest(
|
||||
clientDeviceId: "device-1", deviceKeyId: "key-1", poolId: "pool-1",
|
||||
idempotencyKey: "request-1", policySnapshot: allocationPolicy,
|
||||
requestedDisplayMode: nil
|
||||
).encodeJSON()
|
||||
guard !String(data: legacyDisplayRequest, encoding: .utf8)!.contains("requested_display_mode") else {
|
||||
fatalError("legacy request encoded an absent display mode")
|
||||
}
|
||||
let displayRequest = try SessionRequest(
|
||||
clientDeviceId: "device-1", deviceKeyId: "key-1", poolId: "pool-1",
|
||||
idempotencyKey: "request-1", policySnapshot: allocationPolicy,
|
||||
requestedDisplayMode: displayMode
|
||||
)
|
||||
guard try SessionRequest.decodeJSON(displayRequest.encodeJSON()).requestedDisplayMode == displayMode else {
|
||||
fatalError("display mode did not round-trip")
|
||||
}
|
||||
var nullDisplayRequest = try JSONSerialization.jsonObject(with: displayRequest.encodeJSON()) as! [String: Any]
|
||||
nullDisplayRequest["requested_display_mode"] = NSNull()
|
||||
do {
|
||||
_ = try SessionRequest.decodeJSON(try JSONSerialization.data(withJSONObject: nullDisplayRequest))
|
||||
fatalError("explicit null display mode was accepted")
|
||||
} catch { }
|
||||
let streamPolicy = try ProviderStreamPolicy(
|
||||
resolutionWidth: 2560, resolutionHeight: 1440, fps: 120,
|
||||
codec: "HEVC", bitrateKbps: 40000, audioEnabled: true
|
||||
@@ -218,6 +256,24 @@ fn main() {
|
||||
assert!(AllocationPolicy::new(
|
||||
100, 50, 25, "standard".into(), "audience".into(), "verse".into(), 1, 60, 300,
|
||||
).is_err());
|
||||
let display_mode = DisplayMode::new(2560, 1440, 120).unwrap();
|
||||
assert!(DisplayMode::new(319, 1440, 120).is_err());
|
||||
assert!(DisplayMode::new(2560, 199, 120).is_err());
|
||||
assert!(DisplayMode::new(2560, 1440, 241).is_err());
|
||||
let allocation_policy = AllocationPolicy::new(
|
||||
1000, 2000, 3000, "standard".into(), "versevdi-gateway".into(),
|
||||
"verse".into(), 1, 60, 300,
|
||||
).unwrap();
|
||||
let legacy_display_request = SessionRequest::new(
|
||||
"device-1".into(), "key-1".into(), "pool-1".into(), "request-1".into(),
|
||||
allocation_policy.clone(), None,
|
||||
).unwrap();
|
||||
assert!(legacy_display_request.requestedDisplayMode().is_none());
|
||||
let display_request = SessionRequest::new(
|
||||
"device-1".into(), "key-1".into(), "pool-1".into(), "request-1".into(),
|
||||
allocation_policy, Some(display_mode.clone()),
|
||||
).unwrap();
|
||||
assert_eq!(display_request.requestedDisplayMode(), &Some(display_mode));
|
||||
assert!(ProviderStreamPolicy::new(
|
||||
2560, 1440, 120, "HEVC".into(), 40000, true,
|
||||
).is_ok());
|
||||
|
||||
Reference in New Issue
Block a user