feat(agent,server): v2 secure-session-core Task 7 - HW H.264 + negotiated raw fallback
All checks were successful
All checks were successful
SPEC-002 Phase 1 Task 7 (the last), code-reviewed APPROVED, locally verified (cargo fmt + clippy -D warnings exit 0 + cargo test --workspace 89 pass + build). - Encoder trait + factory: RawEncoder (salvaged, UNCHANGED) and H264Encoder, selected by negotiation; factory falls back to raw on H.264 init failure. - Negotiation: agent advertises supports_h264 (MFTEnumEx HW probe, cached) in AgentStatus; server picks the codec via select_video_codec(supports, prefer) and stamps StartStream.video_codec; agent re-guards on local HW. Policy constant DEFAULT_PREFER_H264 = false, so RAW is negotiated for every session today - H.264 stays dormant until live hardware validation (Task 8). - MF H.264 encoder (h264.rs, FIRST-CUT / compile-verified-only): HW encoder MFT, BGRA->NV12 (color.rs, unit-tested), sync drain, fall-back-to-raw on any failure. - Viewer H.264 decoder (decoder.rs, FIRST-CUT): MF decoder on a dedicated COM thread; drops+logs on failure, raw render path untouched. - proto additive: VideoCodec enum, StartStream.video_codec=3, SessionResponse.video_codec=5, AgentStatus.supports_h264=11. - Raw+Zstd path byte-for-byte unchanged; remains the guaranteed default/fallback. Review confirmed unsafe impl Send for H264Encoder is sound (single-owned &mut on the block_on thread; session future never spawned) and every MF failure degrades to raw. H.264 is NOT claimed functional - compile/clippy/build-verified only; live validation + force-IDR + the no-spawn-invariant doc are Task 8 go-live gates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,23 @@ message SessionResponse {
|
||||
string session_id = 2;
|
||||
string error = 3;
|
||||
DisplayInfo display_info = 4;
|
||||
// Negotiated video codec for this session (Task 7). The plan models the
|
||||
// codec selection here; however the LIVE server->agent handshake in v2 is
|
||||
// done over WebSocket query params + StartStream (SessionRequest/
|
||||
// SessionResponse are not exchanged on the wire today), so the codec the
|
||||
// agent actually applies is carried on StartStream.video_codec below. This
|
||||
// field is kept for spec parity / future use; raw is the safe default.
|
||||
VideoCodec video_codec = 5;
|
||||
}
|
||||
|
||||
// Negotiated video codec (Task 7). RAW = salvaged BGRA+Zstd+dirty-rects, the
|
||||
// guaranteed fallback and current default. H264 = hardware Media Foundation
|
||||
// encode, the negotiated upgrade (compile-verified; validated on hardware in
|
||||
// plan Task 8). H265/HEVC is future opt-in (TODO).
|
||||
enum VideoCodec {
|
||||
VIDEO_CODEC_RAW = 0; // Raw BGRA + Zstd (safe default / fallback)
|
||||
VIDEO_CODEC_H264 = 1; // Hardware H.264 via Media Foundation
|
||||
VIDEO_CODEC_H265 = 2; // Future / opt-in (not implemented)
|
||||
}
|
||||
|
||||
enum SessionType {
|
||||
@@ -268,6 +285,13 @@ message Disconnect {
|
||||
message StartStream {
|
||||
string viewer_id = 1; // ID of viewer requesting stream
|
||||
int32 display_id = 2; // Which display to stream (0 = primary)
|
||||
// Negotiated codec for this stream (Task 7). The server selects this from
|
||||
// the agent's advertised capability (AgentStatus.supports_h264) and its
|
||||
// policy (DEFAULT_PREFER_H264, currently false so we never ship unvalidated
|
||||
// H.264 as the default). The agent builds its encoder from this value;
|
||||
// VIDEO_CODEC_RAW (0, the default for older servers) keeps the salvaged
|
||||
// raw+Zstd path. On any H.264 init failure the agent falls back to raw.
|
||||
VideoCodec video_codec = 3;
|
||||
}
|
||||
|
||||
// Server commands agent to stop streaming
|
||||
@@ -287,6 +311,12 @@ message AgentStatus {
|
||||
string organization = 8; // Company/organization name
|
||||
string site = 9; // Site/location name
|
||||
repeated string tags = 10; // Tags for categorization
|
||||
// HW-encode capability (Task 7). True when the agent enumerated a HARDWARE
|
||||
// H.264 encoder MFT at startup (MFTEnumEx, MFT_CATEGORY_VIDEO_ENCODER,
|
||||
// MFVideoFormat_H264, hardware flag). The server uses this for codec
|
||||
// negotiation (see StartStream.video_codec). Detected once and cached;
|
||||
// false on non-Windows / no HW encoder / MF unavailable.
|
||||
bool supports_h264 = 11;
|
||||
}
|
||||
|
||||
// Server commands agent to uninstall itself
|
||||
|
||||
Reference in New Issue
Block a user