[domistream] Video packetizer: frame header, FEC blocks with Cauchy parity over whole packets, sequence numbers, optional AES-GCM sealing (VideoCipher::encrypt)

This commit is contained in:
2026-12-04 12:24:40 +01:00
parent e1abd7d060
commit b62443ef28
5 changed files with 327 additions and 39 deletions
+9 -3
View File
@@ -482,9 +482,10 @@ fn fec_plan_properties() {
#[test]
fn minimum_parity_raises_the_written_percentage() {
// One data shard at 0 % with at least 2 parity packets: 200 % is the smallest percentage giving m = 2.
// One data shard at 0 % with at least 2 parity packets: 101 % is the smallest percentage giving
// m = ceil(1 * 101 / 100) = 2.
let plan = plan_fec_blocks(1, 0, 2).unwrap();
assert_eq!((plan[0].data_shards, plan[0].parity_shards, plan[0].fec_percentage), (1, 2, 200));
assert_eq!((plan[0].data_shards, plan[0].parity_shards, plan[0].fec_percentage), (1, 2, 101));
// 3 shards, at least 2: 34 % (ceil(1.02) = 2), not 67 % (which would give 3).
let plan = plan_fec_blocks(3, 0, 2).unwrap();
assert_eq!((plan[0].parity_shards, plan[0].fec_percentage), (2, 34));
@@ -622,6 +623,11 @@ fn reordered_and_duplicated() {
(0..rng.below(window.len() + 1)).map(|_| window[rng.below(window.len())].clone()).collect();
window.extend(dups);
rng.shuffle(&mut window);
if datagrams.is_empty() {
// The receiver starts at the frame of the first datagram it sees: let that be frame 0's.
let first = window.iter().position(|d| pair[0].datagrams.contains(d));
window.swap(0, first.expect("a datagram of frame 0"));
}
datagrams.extend(window);
}
// And a few stale duplicates of earlier frames at the end.
@@ -640,7 +646,7 @@ fn sequence_numbers_continue_across_frames_and_wrap() {
let mut seq = 0xFFF0u16;
let mut sent = Vec::new();
for i in 0..10u32 {
let s = send(&mut tx, &mut rng, u32::MAX - 4 + i, 48 * 3);
let s = send(&mut tx, &mut rng, (u32::MAX - 4).wrapping_add(i), 48 * 3);
seq = check_layout(&s, 64, 50, 0, false, seq);
sent.push(s);
}