Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5848089
Show call controls in the call window only
James-Chapman Nov 25, 2026
2e7e885
Count only a call window that shows as open
James-Chapman Nov 25, 2026
4c4b8eb
Forget the call window state when a call ends or the session changes
James-Chapman Nov 25, 2026
a9ad62a
Count any call window open that worked, and test the open replies
James-Chapman Nov 25, 2026
dcb7d58
Test an older open that fails while a newer one waits
James-Chapman Nov 25, 2026
3455681
Import callWindow.ts with its extension
James-Chapman Nov 25, 2026
066971f
Name the Declined note in the short call bar's description
James-Chapman Nov 25, 2026
fddab7b
Say where the fallback video tiles show in ADR-0060
James-Chapman Nov 25, 2026
c9b4491
Let the call window list and change the call devices
James-Chapman Nov 25, 2026
16e51c9
Choose the large video and change devices in the call window
James-Chapman Nov 25, 2026
8e1dfe8
Write the newline ID in the call window device test as an escape
James-Chapman Nov 25, 2026
2670449
Add the call statistics messages to the call protocol
James-Chapman Nov 25, 2026
ee66d9a
Read call statistics in the worker only while the core asks
James-Chapman Nov 25, 2026
e323a6c
Add the call statistics DTOs
James-Chapman Nov 25, 2026
315f1d7
Forward call statistics from the core only while the call window asks
James-Chapman Nov 25, 2026
36607e4
Let the call window turn call statistics on and off
James-Chapman Nov 25, 2026
646c01c
Show call technical details in the call window
James-Chapman Nov 25, 2026
0c95d19
Record ADR-0066 for showing call statistics on request
James-Chapman Nov 25, 2026
876e065
Name the edit type in the statistics bound test
James-Chapman Nov 25, 2026
62d0a4e
Move the statistics switch to tag 17 and wire version 12
James-Chapman Nov 25, 2026
1a09f57
Use a version past the current one in the garbage frame test
James-Chapman Nov 25, 2026
a9aba9b
Address the call window review: statistics, device panel, tile repaint
James-Chapman Nov 25, 2026
8ae45fe
Address the third review of the call window view
James-Chapman Nov 25, 2026
daa606e
Name the complex test types in the statistics tests
James-Chapman Nov 25, 2026
da30a04
Turn call statistics off when the session ends
James-Chapman Nov 25, 2026
6a30430
Count a new page for call statistics when the page starts
James-Chapman Nov 25, 2026
a314e93
Send the page's count with each call statistics request
James-Chapman Nov 25, 2026
1082ad5
Stop call statistics at session end during a join too
James-Chapman Nov 25, 2026
ca920e3
Describe the session-end statistics switch in the core guidance
James-Chapman Nov 25, 2026
f3e825f
Keep required-nullable contract fields out of Sonar rule S9334
James-Chapman Nov 25, 2026
1fa2a0d
State why the S9334 exception covers whole files
James-Chapman Nov 25, 2026
b45748e
Name the AGENTS files that state the S9334 review rule
James-Chapman Nov 25, 2026
b952786
Drop the second Reader::u16 that the main merge brought
James-Chapman Nov 25, 2026
1becd43
Give the statistics test slots main's microphone channel
James-Chapman Nov 25, 2026
ce9dbd7
Keep the device change note in the short call bar
James-Chapman Nov 25, 2026
982960c
Keep the camera and screen share notes in the short call bar
James-Chapman Nov 25, 2026
5f4687c
Record the failed call page gap in ADR-0060
James-Chapman Nov 25, 2026
33b7877
Address the fourth call window review: stats off, bounds, device label
James-Chapman Nov 25, 2026
1d9bb4c
Address the fifth call window review: strict readers, one reading in …
James-Chapman Nov 25, 2026
7bb5a4f
Wait for the call page to say it is ready, and keep Leave
James-Chapman Nov 25, 2026
f282926
Hold the page count across a statistics read
James-Chapman Nov 25, 2026
b3bf4af
Show the call window open while it waits, and test the ready guard
James-Chapman Nov 25, 2026
0c2ddd4
Merge PR 99's branch into the call window view
James-Chapman Nov 25, 2026
5cf7a79
Isolate the device ID in a statistics caption, and refuse a page with…
James-Chapman Nov 25, 2026
f2649ea
Escape the hostile device ID in its test, and drop a try that caught …
James-Chapman Nov 25, 2026
fc4eb67
Read the statistics page count once, when the start's turn comes
James-Chapman Nov 26, 2026
25c64c6
Close the details for another room's call, and refuse repeated stats …
James-Chapman Nov 26, 2026
a3ec870
Merge main into the call statistics branch
James-Chapman Nov 26, 2026
7f90883
Count the call statistics commands and stale readings correctly
James-Chapman Nov 26, 2026
74286b6
Merge main (PR 102) into the call statistics branch
James-Chapman Nov 26, 2026
ba0388b
Refuse call protocol version 12 after the merge
James-Chapman Nov 26, 2026
1c425cf
Expect call protocol version 13 in the tile limit test
James-Chapman Nov 26, 2026
cfa1b80
Close the details when a new call follows an ended one in the same room
James-Chapman Nov 26, 2026
5b41701
Say that the caller, not the stats writer, leaves out bad entries
James-Chapman Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/call-protocol/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This crate defines the bounded binary messages between the key-holding core and
- Devices and levels (ADR-0059): wire version 10 added `ToWorker::TestDevice { test, device }` (a first message only, like `ListDevices`; `DeviceTest` is a closed set), `ToWorker::SetDevices { recording, playout, camera }` (the camera choice applies from the next camera start; `DevicesSet` answers for the microphone and speaker only), `FromWorker::ParticipantLevel { connection, identity, level }`, `FromWorker::ParticipantMuted { connection, identity, muted }` and `FromWorker::DevicesSet { failure }` (0 for none, else a `FailureCode`). `SoundLevel` is now the own microphone's level.
- Microphone settings (ADR-0062): wire version 11 added `ToWorker::SetMicrophone { auto_level, mic_gain }` (tag 16, no answer), and `Join` ends with `auto_level` and `mic_gain` (two bytes). `Reader::mic_gain` refuses a gain over `MAX_MIC_GAIN_PERCENT` (400) or off the step of `MIC_GAIN_STEP_PERCENT` (5); use `valid_mic_gain` wherever a gain is used.
- Screen targets (ADR-0053 amendment of 25 November 2026, ADR-0064): wire version 12 changed `SetScreen`'s `ScreenTarget::Monitor` (tag 2) from a list index to the Windows GDI device name (`MonitorName`: a length byte, then 1 to `MAX_MONITOR_NAME` (32) printable ASCII bytes other than space: 0x21 to 0x7E, `u8::is_ascii_graphic`; a name with a space is an invalid value), the width and height, and the monitor's rectangle (`DesktopRect`: four big-endian `i32` edges, each side 1 to `MAX_MONITOR_SIDE`, each edge within `MAX_DESKTOP_COORDINATE` of 0), and added `ScreenTarget::Display { id, width, height }` (tag 3, the macOS CoreGraphics display ID, never 0). `Reader::monitor_size` refuses a side outside 1 to `MAX_MONITOR_SIDE`. Tag 1 (`Portal { node }`) is unchanged.
- Call statistics (ADR-0066): wire version 13 added `ToWorker::SetStats { on }` (tag 17) and `FromWorker::Stats(CallStats)` (`src/stats.rs`). The message is closed and numeric: integers with a unit and a bound that the reader checks (`MAX_STATS_*`), `Option` for a value that is not known yet, at most `MAX_PARTICIPANTS` remote entries and `MAX_STATS_CONNECTIONS` connection entries, each participant (connection and identity) and each connection at most once. It carries no address, port, candidate type, SSRC, codec or other text beyond the already validated identities. The writer cuts each list to its limit and writes every entry as given; the caller (`mapping::stats` in the worker) leaves out an entry that the reader would refuse and clamps the numbers, because the reader refuses the whole message for one such entry. Tag 16 and wire version 11 are the microphone settings above (ADR-0062). The next wire change takes tag 18 and the next free version. The `MAX_STATS_*` bounds are repeated as `CALL_STATS_*` in `crates/contracts`; `crates/core/src/calls/stats.rs` checks at compile time that they match.
- Coordinate wire changes with `crates/core` and `crates/call-worker` (planned), and bump the version byte.

## Checks
Expand Down
51 changes: 43 additions & 8 deletions crates/call-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ use persephone_media_protocol::{
};
use zeroize::Zeroizing;

pub const VERSION: u8 = 12;
mod stats;
pub use stats::{
AudioReceiveStats, AudioSendStats, CallStats, ConnectionStats, MAX_STATS_CONNECTIONS,
MAX_STATS_FPS, MAX_STATS_KBPS, MAX_STATS_MS, MAX_STATS_SIDE, QualityLimit, RemoteStats,
VideoReceiveStats, VideoSendStats,
};

pub const VERSION: u8 = 13;
pub const MAX_MESSAGE_BYTES: usize = 64 * 1024;
/// Longest diagnostic record target (ADR-0058).
pub const MAX_DIAGNOSTIC_TARGET_BYTES: usize = 64;
Expand Down Expand Up @@ -392,6 +399,11 @@ pub enum ToWorker {
playout: Option<String>,
camera: Option<String>,
},
/// Start or stop sending [`FromWorker::Stats`], at most one a second
/// (ADR-0066). Off when the worker starts. No answer.
SetStats {
on: bool,
},
}

/// The device that [`ToWorker::TestDevice`] tests. A closed set.
Expand Down Expand Up @@ -512,6 +524,7 @@ impl std::fmt::Debug for ToWorker {
.field("recording", recording)
.field("playout", playout)
.finish(),
Self::SetStats { on } => f.debug_struct("SetStats").field("on", on).finish(),
}
}
}
Expand Down Expand Up @@ -872,6 +885,11 @@ pub enum FromWorker {
target: String,
message: String,
},
/// The call's statistics, as numbers with units (ADR-0066). Sent at
/// most once a second, and only while [`ToWorker::SetStats`] is on. The
/// off drops a reading that waits; one that the worker was already
/// writing can still follow the off, and the core drops it.
Stats(CallStats),
}

// Tags of core to worker messages.
Expand All @@ -891,6 +909,7 @@ const TO_SET_DIAGNOSTICS: u8 = 13;
const TO_TEST_DEVICE: u8 = 14;
const TO_SET_DEVICES: u8 = 15;
const TO_SET_MICROPHONE: u8 = 16;
const TO_SET_STATS: u8 = 17;

// Tags of worker to core messages.
const FROM_READY: u8 = 1;
Expand All @@ -915,6 +934,7 @@ const FROM_SOUND_LEVEL: u8 = 19;
const FROM_PARTICIPANT_LEVEL: u8 = 20;
const FROM_PARTICIPANT_MUTED: u8 = 21;
const FROM_DEVICES_SET: u8 = 22;
const FROM_STATS: u8 = 23;

#[derive(Clone, Copy)]
enum CharRule {
Expand Down Expand Up @@ -1317,6 +1337,10 @@ impl ToWorker {
put_str(&mut out, playout.as_deref().unwrap_or(""));
put_str(&mut out, camera.as_deref().unwrap_or(""));
}
Self::SetStats { on } => {
out.push(TO_SET_STATS);
out.push(u8::from(*on));
}
}
out
}
Expand Down Expand Up @@ -1450,6 +1474,7 @@ impl ToWorker {
playout: reader.device_choice()?,
camera: reader.device_choice()?,
},
TO_SET_STATS => Self::SetStats { on: reader.bool()? },
_ => return Err(DecodeError::UnknownTag),
};
reader.finish()?;
Expand Down Expand Up @@ -1623,6 +1648,10 @@ impl FromWorker {
put_str(&mut out, target);
put_str(&mut out, message);
}
Self::Stats(stats) => {
out.push(FROM_STATS);
stats::put_stats(&mut out, stats);
}
Self::VideoStopped { tile } => {
out.push(FROM_VIDEO_STOPPED);
out.push(*tile);
Expand Down Expand Up @@ -1737,6 +1766,7 @@ impl FromWorker {
}
Self::VideoFrame { tile, rotation }
}
FROM_STATS => Self::Stats(stats::read_stats(&mut reader)?),
_ => return Err(DecodeError::UnknownTag),
};
reader.finish()?;
Expand Down Expand Up @@ -1954,6 +1984,7 @@ pub fn write_video_frame<W: Write>(

#[cfg(test)]
mod tests {
use super::stats::tests::full_stats;
use super::*;
use std::io::Cursor;

Expand Down Expand Up @@ -2157,6 +2188,8 @@ mod tests {
},
ToWorker::SetDiagnostics { on: true },
ToWorker::SetDiagnostics { on: false },
ToWorker::SetStats { on: true },
ToWorker::SetStats { on: false },
ToWorker::TestDevice {
test: DeviceTest::Microphone,
device: None,
Expand Down Expand Up @@ -2326,6 +2359,8 @@ mod tests {
target: "t".to_owned(),
message: String::new(),
},
FromWorker::Stats(CallStats::default()),
FromWorker::Stats(full_stats()),
FromWorker::VideoStopped { tile: 0 },
FromWorker::VideoStopped { tile: 4 },
FromWorker::VideoStopped { tile: SCREEN_TILE },
Expand Down Expand Up @@ -2406,7 +2441,7 @@ mod tests {
width: 0,
height: 0,
};
write_frame(&mut wire, header, &[99, 1]).unwrap();
write_frame(&mut wire, header, &[VERSION + 1, 1]).unwrap();
let result: Result<FromWorker, _> =
read_message(&mut Cursor::new(wire), &ResourceBudgets::default());
assert_eq!(result, Err(ReadError::Decode(DecodeError::UnknownVersion)));
Expand Down Expand Up @@ -2545,11 +2580,11 @@ mod tests {
Err(DecodeError::UnknownTag)
);
assert_eq!(
ToWorker::decode(&[VERSION, 17]),
ToWorker::decode(&[VERSION, 18]),
Err(DecodeError::UnknownTag)
);
assert_eq!(
FromWorker::decode(&[VERSION, 23]),
FromWorker::decode(&[VERSION, 24]),
Err(DecodeError::UnknownTag)
);
assert_eq!(FromWorker::decode(&[]), Err(DecodeError::Truncated));
Expand Down Expand Up @@ -3167,7 +3202,7 @@ mod tests {
/// 640x360 at 15 per second.
#[test]
fn given_tiles_when_limits_asked_then_screen_differs_from_camera() {
assert_eq!((VIDEO_TILES, SCREEN_TILE, VERSION), (6, 5, 12));
assert_eq!((VIDEO_TILES, SCREEN_TILE, VERSION), (6, 5, 13));
assert_eq!(MAX_SCREEN_BYTES, 3_686_400);
assert_eq!(MAX_SCREEN_PIXELS, 921_600);
for tile in 0..SCREEN_TILE {
Expand Down Expand Up @@ -3645,13 +3680,13 @@ mod tests {
);
}

/// GIVEN a message of the previous wire versions (6 to 11)
/// GIVEN a message of the previous wire versions (6 to 12)
/// WHEN it is decoded in either direction
/// THEN the version is refused.
#[test]
fn given_older_wire_versions_when_decoded_then_they_are_refused() {
assert_eq!(VERSION, 12);
for old in [6, 7, 8, 9, 10, 11] {
assert_eq!(VERSION, 13);
for old in [6, 7, 8, 9, 10, 11, 12] {
assert_eq!(
ToWorker::decode(&[old, TO_LEAVE]),
Err(DecodeError::UnknownVersion)
Expand Down
Loading