From 2c120c96d79d2837e443e21f897ceaa6802fd990 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 13:47:40 +0200 Subject: [PATCH 1/6] Correct the Muninn maps against git (RR Cut 0) teardown-map.md: mark the extraction-era claims as history in place (pin, symbol counts, diamond, live-exercise note) and correct the false claim that the sender turns keyframe requests into an IDR. muninn-media-streaming.md: preset p5, 848-byte chunks, 30 ms resend inside the latency-budget expiry. Docs only. Co-Authored-By: Claude Sonnet 5 --- docs/muninn-media-streaming.md | 8 +++---- docs/teardown-map.md | 40 ++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/muninn-media-streaming.md b/docs/muninn-media-streaming.md index d3105ff..e2f411b 100644 --- a/docs/muninn-media-streaming.md +++ b/docs/muninn-media-streaming.md @@ -237,7 +237,7 @@ a temporary PCM/AAC compatibility bridge. Recommended first LAN profile: - Profile id: `muninn.rudp.low_latency_h264_lan.v1`. -- Video: H.264 NVENC, `p1`, ultra-low-latency tune, CBR high enough that LAN +- Video: H.264 NVENC, `p5` (`main.rs:10279`), ultra-low-latency tune, CBR high enough that LAN bandwidth is not the constraint, no B-frames, no lookahead, short GOP or intra-refresh, periodic IDR/keyframe on feedback pressure. - VBV: derive `bufsize` from roughly one frame of bitrate @@ -247,7 +247,7 @@ Recommended first LAN profile: temporary PCM/AAC bridge with separate packet identity and clock. - Transport: payload elementary access units as typed media records, never a muxed container as the unit of truth. -- Packet size: default typed media chunks are `480` bytes. That leaves headroom +- Packet size: default typed media chunks are `848` bytes (`main.rs:81`). That leaves headroom for CultNet/MessagePack/RUDP headers inside a normal Ethernet MTU so the OBS bridge does not depend on IP fragmentation or private RUDP fragment reassembly. The sender also sets CultNet RUDP `max_fragment_bytes` to `1431` @@ -255,8 +255,8 @@ Recommended first LAN profile: minus the five-byte `media` channel id), so oversized typed records fragment in CultNet deliberately instead of falling through to accidental IP fragmentation. -- Resend cadence: sender RUDP media resends are scheduled every `5` ms while - the packet is still inside the `75` ms reliable-expiry budget. +- Resend cadence: sender RUDP media resends are scheduled every `30` ms (`main.rs:94`) while + the packet is still inside its expiry, which is the request's latency budget (default `2,000` ms, `main.rs:95`). - Control: sender may adapt bitrate, keyframe cadence, chunk size, and playout budget from receiver feedback; the receiver must not silently stretch latency to preserve visual perfection. diff --git a/docs/teardown-map.md b/docs/teardown-map.md index 6890d45..5cd5629 100644 --- a/docs/teardown-map.md +++ b/docs/teardown-map.md @@ -1,6 +1,6 @@ -# Muninn Teardown Map (pre-rebuild) +# Muninn Teardown Map (history of the extraction) -Date: 2026-09-09. Working map for extracting Muninn from Odin into a dedicated repo. +Date: 2026-09-09. Working map for extracting Muninn from Odin into a dedicated repo. Muninn now lives in `GameCult/Muninn`; the body below was written at `Odin\crates\muninn-daemon` and is annotated in place where git has since contradicted it. Line counts at `e70db69`: `main.rs` 15,134 and `media_packetizer.rs` 2,633 under `crates/muninn-daemon/src/`. ## What Muninn is (operator, 2026-09-09) @@ -21,7 +21,7 @@ Independently confirmed in gamecult-ops `scripts/idunn/idunn-deployment-targets. - `src/media_packetizer.rs` 4,244 lines Sibling crates: `muninn-move-tracker` (308), `muninn-psmoveapi-tracker` (359). -CultLib pin: `c13b6ba0` (2026-09-05), 3 commits behind CultLib HEAD `d1a9edad`. +CultLib pin at the time of writing: `c13b6ba0` (2026-09-05), 3 commits behind CultLib HEAD `d1a9edad`. Live pin: `c2a9a6e` (`crates/muninn-daemon/Cargo.toml:18-20`). ## Authorities currently fused in main.rs @@ -47,7 +47,7 @@ Adding a sensor touches one file and zero core code. ## Schema ownership (decided) -19 `muninn.*` schemas, 38 declarations, currently in `odin-core/src/documents.rs`. +19 `muninn.*` schemas, 38 declarations, at the time of writing in `odin-core/src/documents.rs`. The four media schemas have since moved to CultLib as `gamecult.media_*`; the other `muninn.*` records are still imported from odin-core. Muninn's contracts owned by Odin = inversion. Move to CultLib, following `a539d4f` (Idunn/Odin authority contracts returned to CultLib) and `c13b6ba` (IdunnDaemonHealthTrustBindingRecord into cultnet-rs). @@ -62,7 +62,7 @@ obs_stream_catalog, quest_access, telemetry_surface, transport_profile. ## Coupling -Muninn -> odin-core: ONE import block, 20 symbols (main.rs). +Muninn -> odin-core: ONE import block, 20 symbols (main.rs) at the time of writing; 21 at `e70db69` (`main.rs:27-37`). odin-core / odin-daemon / sleipnir-daemon -> Muninn: NONE. Crate boundary cuts clean. @@ -447,7 +447,7 @@ cultnet-rs and cultnet-ts but not the receiver. Working: subscription over `cultnet-rs`, drained and handed across a C ABI. 9 Rust tests, 14 C checks (the C side loads the cdylib dynamically and verifies -the header's claims, rather than assuming them). Pinned to CultLib `d1a9eda`. +the header's claims, rather than assuming them). Pinned to CultLib `d1a9eda` at the time of writing; now `c2a9a6e` (Ratatoskr `crates/ratatoskr-core/Cargo.toml:16-18`). ### The next blocking piece @@ -460,8 +460,9 @@ The receiver-side reassembly code that was kept in `media_packetizer.rs` as the seed for Ratatoskr moved there on 2026-09-10 (`Ratatoskr` 2618184, `crates/ratatoskr-core/src/video.rs`) and was cut here (705 lines: frame assembly, the assembly set, reassembly, expired-frame feedback, their tests). -Muninn now holds only the producer half: packetize, XOR stripe parity, and the -feedback *builder* its sender tests exercise. The contract's erasure code is +Muninn holds the producer half (packetize, XOR stripe parity, the feedback +*builder* its sender tests exercise) and still carries receiver residue: `AudioPacketBuffer` +and the whole-stream Annex B helpers in `media_packetizer.rs`, which only tests call. The contract's erasure code is XOR stripes, one recovered chunk per stripe; the C++ receiver's GF(256) block solver reads fields the v2 record does not carry and stayed in Mimir. @@ -608,22 +609,24 @@ Three repos where there was one crate, and a contract neither of them owns. | Repo | Role | State | |---|---|---| -| CultLib `main` `05e0925` | the contract | media records, wire envelope, validation, channel delivery | +| CultLib `main` `05e0925` at the time of writing (media contract unchanged since `c2a9a6e`; `main` is now `069ecc3`) | the contract | media records, wire envelope, validation, channel delivery | | Muninn | producer | speaks the shared contract; blocked on one pin (below) | | Ratatoskr | consumer | decodes the envelope; builds clean, no conflicts | -### The one thing blocking a clean Muninn build +### The one thing blocking a clean Muninn build (history; resolved) + +Resolved 2026-09-11 (see the Raven section below): `Cargo.lock` is tracked (`60ed6b2`) and the pins are the build. The build resolves `odin-core` from Odin `3e96c6c`, which no Odin branch holds; only the tag `attic/claude-cultlib-pin-c2a9a6e` keeps it reachable. The text below is the state on 2026-09-10. `odin-core` pins CultLib `c13b6ba`; Muninn needs `05e0925`. Cargo resolves two `cultcache-rs` copies and `DatabaseEntry` from one is not `DatabaseEntry` from the other. -Muninn cannot resolve this alone: it uses 23 odin-core symbols, and while 16 are +Muninn cannot resolve this alone: it used 23 odin-core symbols (21 at `e70db69`), and while 16 are its own records that belong here (capture stream, command boundary, HID controller state, five Move records, OBS catalog, Quest access, telemetry -surface, transport profile), 7 are genuinely Odin's — `discover_provider_endpoints`, +surface, transport profile), 7 were genuinely Odin's — `discover_provider_endpoints`, `OdinDocuments`, `OdinEndpointQuery`, Eve advertisement and surface records, -`IdunnDaemonHealthRecord`. +`IdunnDaemonHealthRecord`. At `e70db69` four remain imported: `EveProviderAdvertisementRecord`, `EveSurfaceStateRecord`, `IdunnDaemonHealthRecord`, `OdinDocuments`. Muninn's two bodies were collapsed 2026-09-10 (Odin d41c744 dropped its workspace copy of the three crates and the actuator scripts). The Idunn @@ -653,10 +656,8 @@ one once the patch is gone. Muninn-specific `obs_stream_catalog` / `capture_stream_command` stay published beside them until nothing reads them. The old plugin's CLI shell-out and `.cc` snapshot are not ported. The connection direction was - inverted the same day (section above). **Not yet exercised live:** Raven - runs a pre-b679fc2 Muninn; the next Raven deploy ships this repository - (gamecult-ops rebound the targets 2026-09-10) and needs - `MUNINN_MEDIA_RUDP_ADVERTISE` set. + inverted the same day (section above). Exercised live 2026-09-10/11 on `bc43e1b` and later + (measurements below); the 2026-09-10 note that Raven ran a pre-b679fc2 Muninn is history. 3. **Opus.** Unblocked and measured at 16.8x. `-f aac` in the receiver becomes codec-driven; framing follows the `aac-adts-padded-v1` precedent (2-byte big-endian length prefix). @@ -664,8 +665,9 @@ one once the patch is gone. `feedback.rs`). The producer's repair cache and keyframe counter now have a live counterpart. `build_receiver_feedback` moved to CultLib (34c8ea7) and stopped implying a keyframe request from missing chunks (4160ab5): a repair - request is the alternative to one, and the sender turns every new keyframe - request into an IDR. + request is the alternative to one. The sender counts keyframe requests and logs them; + it does not force an IDR (`main.rs:3036-3048`). Recovery today is the fixed all-IDR GOP + of `framerate/4` frames. ### Deliberate breaks, both recorded as passing tests From f2a5db9eec293d6d2084ab8e8de1a001555f988f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 13:50:38 +0200 Subject: [PATCH 2/6] Subtract receiver residue from the producer (RR Cut 1) Delete AudioPacketBuffer (receiver jitter buffer), the whole-stream Annex B helpers (packetize_video_annex_b_stream, its options structs and wire wrappers) and encode/decode_record_payload; only tests called them. Re-home the packetizer-behaviour tests onto VideoAnnexBStreamSendState. Drop the five audio_packet_buffer tests and the legacy-feedback decode test (CultLib pins key 10 default in receiver_feedback_decodes_records_written_before_its_last_field). Co-Authored-By: Claude Sonnet 5 --- crates/muninn-daemon/src/main.rs | 80 +- crates/muninn-daemon/src/media_packetizer.rs | 745 +++---------------- 2 files changed, 145 insertions(+), 680 deletions(-) diff --git a/crates/muninn-daemon/src/main.rs b/crates/muninn-daemon/src/main.rs index cba71f0..6263f07 100644 --- a/crates/muninn-daemon/src/main.rs +++ b/crates/muninn-daemon/src/main.rs @@ -12344,33 +12344,40 @@ mod tests { assert_eq!(muninn_rudp_video_gop_frames(&sixty_fps), 15); } + fn send_single_access_unit( + config: crate::media_packetizer::VideoAnnexBStreamSendConfig, + access_unit: &[u8], + ) -> Vec { + let mut sender = crate::media_packetizer::VideoAnnexBStreamSendState::new(config).unwrap(); + let mut payloads = sender.push("2026-06-18T00:00:00Z", access_unit).unwrap(); + payloads.extend(sender.finish("2026-06-18T00:00:00Z").unwrap()); + payloads + } + #[test] fn default_rudp_media_packet_size_keeps_late_typed_video_wire_under_udp_mtu() { let mut access_unit = Vec::new(); access_unit.extend_from_slice(&[0, 0, 0, 1, 0x65]); access_unit.resize(MUNINN_RUDP_MEDIA_PACKET_BYTES, 0x80); - let payloads = crate::media_packetizer::video_annex_b_stream_send_payloads( - crate::media_packetizer::VideoAnnexBStreamWireOptions { - packetize: crate::media_packetizer::VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 1_000_000, - first_pts_ticks: 3_000_000_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES, - }, - stored_at: "2026-06-18T00:00:00Z", - source_runtime_id: "muninn-test", - source_role: "media-test", + let payloads = send_single_access_unit( + crate::media_packetizer::VideoAnnexBStreamSendConfig { + stream_id: "muninn.raven.av.rudp".to_string(), + session_id: "session-1".to_string(), + codec: "h264".to_string(), + first_frame_id: 1_000_000, + first_pts_ticks: 3_000_000_000, + frame_duration_ticks: 3_000, + timebase_num: 1, + timebase_den: 90_000, + deadline_delay_ticks: 1_800, + max_payload_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES, + max_pending_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES * 2, + source_runtime_id: "muninn-test".to_string(), + source_role: "media-test".to_string(), }, &access_unit, - ) - .unwrap(); + ); assert_eq!(payloads.len(), 1); assert!( @@ -12392,27 +12399,24 @@ mod tests { access_unit.extend_from_slice(&[0, 0, 0, 1, 0x65]); access_unit.resize(MUNINN_RUDP_MEDIA_PACKET_BYTES * 64, 0x80); - let payloads = crate::media_packetizer::video_annex_b_stream_send_payloads( - crate::media_packetizer::VideoAnnexBStreamWireOptions { - packetize: crate::media_packetizer::VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "raven:2026-06-19T14-56-23Z:video", - codec: "h264", - first_frame_id: 1_000_000, - first_pts_ticks: 3_000_000_000, - frame_duration_ticks: 1_500, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_500, - max_payload_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES, - }, - stored_at: "2026-06-19T14:56:23Z", - source_runtime_id: "raven", - source_role: "muninn.rudp.video", + let payloads = send_single_access_unit( + crate::media_packetizer::VideoAnnexBStreamSendConfig { + stream_id: "muninn.raven.av.rudp".to_string(), + session_id: "raven:2026-06-19T14-56-23Z:video".to_string(), + codec: "h264".to_string(), + first_frame_id: 1_000_000, + first_pts_ticks: 3_000_000_000, + frame_duration_ticks: 1_500, + timebase_num: 1, + timebase_den: 90_000, + deadline_delay_ticks: 1_500, + max_payload_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES, + max_pending_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES * 65, + source_runtime_id: "raven".to_string(), + source_role: "muninn.rudp.video".to_string(), }, &access_unit, - ) - .unwrap(); + ); assert!(payloads.len() > 1); let largest = payloads diff --git a/crates/muninn-daemon/src/media_packetizer.rs b/crates/muninn-daemon/src/media_packetizer.rs index 25449b9..ee9aab7 100644 --- a/crates/muninn-daemon/src/media_packetizer.rs +++ b/crates/muninn-daemon/src/media_packetizer.rs @@ -159,26 +159,6 @@ pub struct VideoFramePacketizeOptions<'a> { pub max_payload_bytes: usize, } -pub struct VideoAnnexBStreamPacketizeOptions<'a> { - pub stream_id: &'a str, - pub session_id: &'a str, - pub codec: &'a str, - pub first_frame_id: u64, - pub first_pts_ticks: i64, - pub frame_duration_ticks: u32, - pub timebase_num: u32, - pub timebase_den: u32, - pub deadline_delay_ticks: i64, - pub max_payload_bytes: usize, -} - -pub struct VideoAnnexBStreamWireOptions<'a> { - pub packetize: VideoAnnexBStreamPacketizeOptions<'a>, - pub stored_at: &'a str, - pub source_runtime_id: &'a str, - pub source_role: &'a str, -} - pub struct VideoAnnexBStreamSendConfig { pub stream_id: String, pub session_id: String, @@ -214,7 +194,6 @@ pub struct AudioPacketWireOptions<'a> { pub source_role: &'a str, } - pub struct AudioPcmStreamSendConfig { pub stream_id: String, pub session_id: String, @@ -232,12 +211,6 @@ pub struct AudioPcmStreamSendConfig { pub source_role: String, } - - - - - - #[derive(Clone, Debug, PartialEq, Eq)] pub struct MuninnMediaSendPayload { pub channel_id: &'static str, @@ -402,8 +375,6 @@ impl VideoAnnexBStreamSendState { } } - - pub struct AudioPcmStreamSendState { config: AudioPcmStreamSendConfig, pending: Vec, @@ -552,9 +523,6 @@ impl AudioPcmStreamSendState { } } - - - pub fn packetize_video_access_unit( options: VideoFramePacketizeOptions<'_>, access_unit: &VideoAccessUnit, @@ -753,57 +721,6 @@ fn video_wire_records_with_parity( Ok(wire_records) } -pub fn packetize_video_annex_b_stream( - options: VideoAnnexBStreamPacketizeOptions<'_>, - input: &[u8], -) -> Result> { - if options.frame_duration_ticks == 0 { - return Err(anyhow!("frame_duration_ticks must be greater than zero")); - } - if options.deadline_delay_ticks < 0 { - return Err(anyhow!("deadline_delay_ticks must be non-negative")); - } - - let access_units = video_annex_b_access_units(options.codec, input)?; - let mut records = Vec::new(); - for (index, access_unit) in access_units.iter().enumerate() { - let frame_offset = u64::try_from(index).context("video frame index overflow")?; - let frame_id = options - .first_frame_id - .checked_add(frame_offset) - .ok_or_else(|| anyhow!("video frame_id overflow"))?; - let pts_offset = i64::try_from(index) - .ok() - .and_then(|index| index.checked_mul(i64::from(options.frame_duration_ticks))) - .ok_or_else(|| anyhow!("video pts_ticks overflow"))?; - let pts_ticks = options - .first_pts_ticks - .checked_add(pts_offset) - .ok_or_else(|| anyhow!("video pts_ticks overflow"))?; - let deadline_ticks = pts_ticks - .checked_add(options.deadline_delay_ticks) - .ok_or_else(|| anyhow!("video deadline_ticks overflow"))?; - - records.extend(packetize_video_access_unit( - VideoFramePacketizeOptions { - stream_id: options.stream_id, - session_id: options.session_id, - codec: options.codec, - frame_id, - pts_ticks, - duration_ticks: options.frame_duration_ticks, - timebase_num: options.timebase_num, - timebase_den: options.timebase_den, - deadline_ticks, - max_payload_bytes: options.max_payload_bytes, - }, - access_unit, - )?); - } - - Ok(records) -} - pub fn packetize_audio_packet( options: AudioPacketizeOptions<'_>, payload: &[u8], @@ -844,145 +761,6 @@ pub fn packetize_audio_packet( }) } -#[derive(Default)] -pub struct AudioPacketBuffer { - stream_id: Option, - session_id: Option, - codec: Option, - timebase_num: Option, - timebase_den: Option, - next_packet_id: Option, - emitted_any: bool, - packets: BTreeMap, -} - -impl AudioPacketBuffer { - pub fn insert(&mut self, packet: GameCultMediaAudioPacketRecord) -> Result<()> { - self.require_matching_audio_stream(&packet)?; - if packet.payload.is_empty() { - return Err(anyhow!("audio packet buffer payload must be non-empty")); - } - if self.packets.contains_key(&packet.packet_id) { - return Err(anyhow!( - "audio packet buffer has duplicate packet_id {}", - packet.packet_id - )); - } - match self.next_packet_id { - None => self.next_packet_id = Some(packet.packet_id), - Some(next_packet_id) if packet.packet_id < next_packet_id && !self.emitted_any => { - self.next_packet_id = Some(packet.packet_id); - } - Some(next_packet_id) if packet.packet_id < next_packet_id => { - return Err(anyhow!( - "audio packet buffer received stale packet_id {} before next expected {}", - packet.packet_id, - next_packet_id - )); - } - _ => {} - } - self.packets.insert(packet.packet_id, packet); - Ok(()) - } - - pub fn pop_ready_packets(&mut self) -> Vec { - let Some(mut next_packet_id) = self.next_packet_id else { - return Vec::new(); - }; - let mut ready = Vec::new(); - while let Some(packet) = self.packets.remove(&next_packet_id) { - ready.push(packet); - next_packet_id = next_packet_id.saturating_add(1); - } - if !ready.is_empty() { - self.emitted_any = true; - } - self.next_packet_id = Some(next_packet_id); - ready - } - - pub fn expire_late_packets(&mut self, now_ticks: i64) -> Vec { - let expired_ids = self - .packets - .iter() - .filter_map(|(packet_id, packet)| { - if packet.deadline_ticks <= now_ticks { - Some(*packet_id) - } else { - None - } - }) - .collect::>(); - for packet_id in &expired_ids { - self.packets.remove(packet_id); - } - if let Some(next_packet_id) = self.next_packet_id { - if expired_ids.contains(&next_packet_id) { - self.next_packet_id = self.packets.keys().next().copied(); - } - } - expired_ids - } - - pub fn pending_packet_count(&self) -> usize { - self.packets.len() - } - - fn require_matching_audio_stream( - &mut self, - packet: &GameCultMediaAudioPacketRecord, - ) -> Result<()> { - if packet.stream_id.is_empty() { - return Err(anyhow!("audio packet buffer stream_id must be non-empty")); - } - if packet.session_id.is_empty() { - return Err(anyhow!("audio packet buffer session_id must be non-empty")); - } - if packet.codec.is_empty() { - return Err(anyhow!("audio packet buffer codec must be non-empty")); - } - if packet.timebase_num == 0 || packet.timebase_den == 0 { - return Err(anyhow!("audio packet buffer timebase must be non-zero")); - } - - match ( - self.stream_id.as_deref(), - self.session_id.as_deref(), - self.codec.as_deref(), - self.timebase_num, - self.timebase_den, - ) { - (None, None, None, None, None) => { - self.stream_id = Some(packet.stream_id.clone()); - self.session_id = Some(packet.session_id.clone()); - self.codec = Some(packet.codec.clone()); - self.timebase_num = Some(packet.timebase_num); - self.timebase_den = Some(packet.timebase_den); - Ok(()) - } - ( - Some(stream_id), - Some(session_id), - Some(codec), - Some(timebase_num), - Some(timebase_den), - ) if stream_id == packet.stream_id - && session_id == packet.session_id - && codec == packet.codec - && timebase_num == packet.timebase_num - && timebase_den == packet.timebase_den => - { - Ok(()) - } - _ => Err(anyhow!( - "audio packet buffer received mixed stream metadata" - )), - } - } -} - - /// Muninn's producer name on the wire. The envelope in CultLib takes this as a /// parameter so it never has to know any producer; this is where Muninn says /// who it is, once. @@ -1014,27 +792,6 @@ pub fn encode_media_wire_records( .collect() } -pub fn encode_video_annex_b_stream_wire_records( - options: VideoAnnexBStreamWireOptions<'_>, - input: &[u8], -) -> Result>> { - let records = packetize_video_annex_b_stream(options.packetize, input)?; - let wire_records = video_wire_records_with_parity(&records)?; - encode_media_wire_records( - &wire_records, - options.stored_at, - options.source_runtime_id, - options.source_role, - ) -} - -pub fn video_annex_b_stream_send_payloads( - options: VideoAnnexBStreamWireOptions<'_>, - input: &[u8], -) -> Result> { - encode_video_annex_b_stream_wire_records(options, input).map(wire_payloads_to_media_send) -} - pub fn encode_audio_packet_wire_record( options: AudioPacketWireOptions<'_>, payload: &[u8], @@ -1076,27 +833,6 @@ fn wire_payload_to_media_send(payload: Vec) -> MuninnMediaSendPayload { } } - -fn encode_record_payload(record: &T) -> Result> { - rmp_serde::to_vec(record).map_err(Into::into) -} - - - - -fn decode_record_payload(payload: &[u8]) -> Result { - rmp_serde::from_slice(payload).map_err(Into::into) -} - - - - - - - - - - fn normalized_video_codec(codec: &str) -> Option<&'static str> { match codec.trim().to_ascii_lowercase().as_str() { "h264" | "h.264" | "avc" | "avc1" | "video/avc" => Some("h264"), @@ -1106,8 +842,6 @@ fn normalized_video_codec(codec: &str) -> Option<&'static str> { } } - - fn annex_b_nal_units<'a>( input: &'a [u8], codec_name: &str, @@ -1530,101 +1264,6 @@ mod tests { Ok(()) } - #[test] - fn packetizes_annex_b_stream_into_timed_video_records() -> Result<()> { - let mut stream = Vec::new(); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x65, 0x80]); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x41, 0x80]); - - let records = packetize_video_annex_b_stream( - VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "avc", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: 16, - }, - &stream, - )?; - - assert_eq!(records.len(), 2); - assert_eq!(records[0].frame_id, 9); - assert_eq!(records[0].pts_ticks, 27_000); - assert_eq!(records[0].deadline_ticks, 28_800); - assert!(records[0].keyframe); - assert_eq!(records[1].frame_id, 10); - assert_eq!(records[1].pts_ticks, 30_000); - assert_eq!(records[1].deadline_ticks, 31_800); - assert_eq!(records[1].dependency_frame_id, Some(9)); - assert_eq!(records[1].codec, "avc"); - Ok(()) - } - - #[test] - fn packetizes_non_reference_h264_p_frames_without_dependency() -> Result<()> { - let mut stream = Vec::new(); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x65, 0x80]); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x01, 0x80]); - - let records = packetize_video_annex_b_stream( - VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: 16, - }, - &stream, - )?; - - assert_eq!(records.len(), 2); - assert!(records[0].keyframe); - assert_eq!(records[0].dependency_frame_id, None); - assert!(!records[1].keyframe); - assert_eq!(records[1].dependency_frame_id, None); - Ok(()) - } - - #[test] - fn rejects_negative_annex_b_stream_deadline_delay() { - let error = packetize_video_annex_b_stream( - VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: -1, - max_payload_bytes: 4, - }, - &[0, 0, 0, 1, 0x65, 0x80], - ) - .unwrap_err(); - - assert!( - error - .to_string() - .contains("deadline_delay_ticks must be non-negative") - ); - } - #[test] fn rejects_zero_duration_video_access_units() { let access_unit = VideoAccessUnit { @@ -1799,123 +1438,6 @@ mod tests { ); } - fn audio_packet(packet_id: u64, deadline_ticks: i64) -> GameCultMediaAudioPacketRecord { - packetize_audio_packet( - AudioPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "opus", - packet_id, - pts_ticks: (packet_id as i64) * 960, - duration_ticks: 960, - timebase_num: 1, - timebase_den: 48_000, - deadline_ticks, - }, - &[0xf8, 0xff, packet_id as u8], - ) - .unwrap() - } - - #[test] - fn audio_packet_buffer_emits_contiguous_packets_in_order() -> Result<()> { - let mut buffer = AudioPacketBuffer::default(); - - buffer.insert(audio_packet(7, 10_000))?; - buffer.insert(audio_packet(9, 12_000))?; - let ready = buffer.pop_ready_packets(); - - assert_eq!( - ready - .iter() - .map(|packet| packet.packet_id) - .collect::>(), - vec![7] - ); - assert_eq!(buffer.pending_packet_count(), 1); - - buffer.insert(audio_packet(8, 11_000))?; - let ready = buffer.pop_ready_packets(); - - assert_eq!( - ready - .iter() - .map(|packet| packet.packet_id) - .collect::>(), - vec![8, 9] - ); - assert_eq!(buffer.pending_packet_count(), 0); - Ok(()) - } - - #[test] - fn audio_packet_buffer_tracks_lowest_packet_before_first_emit() -> Result<()> { - let mut buffer = AudioPacketBuffer::default(); - - buffer.insert(audio_packet(9, 12_000))?; - buffer.insert(audio_packet(7, 10_000))?; - buffer.insert(audio_packet(8, 11_000))?; - - let ready = buffer.pop_ready_packets(); - - assert_eq!( - ready - .iter() - .map(|packet| packet.packet_id) - .collect::>(), - vec![7, 8, 9] - ); - assert_eq!(buffer.pending_packet_count(), 0); - Ok(()) - } - - #[test] - fn audio_packet_buffer_rejects_stale_packets_after_emit() -> Result<()> { - let mut buffer = AudioPacketBuffer::default(); - - buffer.insert(audio_packet(7, 10_000))?; - assert_eq!(buffer.pop_ready_packets().len(), 1); - let error = buffer.insert(audio_packet(6, 9_000)).unwrap_err(); - - assert!(error.to_string().contains("stale packet_id")); - Ok(()) - } - - #[test] - fn audio_packet_buffer_expires_late_packets() -> Result<()> { - let mut buffer = AudioPacketBuffer::default(); - - buffer.insert(audio_packet(7, 10_000))?; - buffer.insert(audio_packet(8, 12_000))?; - - let expired = buffer.expire_late_packets(10_000); - - assert_eq!(expired, vec![7]); - assert_eq!(buffer.pending_packet_count(), 1); - assert_eq!( - buffer - .pop_ready_packets() - .into_iter() - .map(|packet| packet.packet_id) - .collect::>(), - vec![8] - ); - Ok(()) - } - - #[test] - fn audio_packet_buffer_rejects_mixed_stream_metadata() -> Result<()> { - let mut buffer = AudioPacketBuffer::default(); - let mut mixed = audio_packet(8, 12_000); - mixed.session_id = "session-2".to_string(); - - buffer.insert(audio_packet(7, 10_000))?; - let error = buffer.insert(mixed).unwrap_err(); - - assert!(error.to_string().contains("mixed stream metadata")); - Ok(()) - } - #[test] fn media_wire_round_trips_video_document() -> Result<()> { let access_unit = VideoAccessUnit { @@ -1989,129 +1511,6 @@ mod tests { Ok(()) } - #[test] - fn media_wire_batches_annex_b_video_records() -> Result<()> { - let mut stream = Vec::new(); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x65, 0x80]); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x41, 0x80]); - let records = packetize_video_annex_b_stream( - VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: 16, - }, - &stream, - )?; - let wire_records = records - .iter() - .cloned() - .map(GameCultMediaWireRecord::Video) - .collect::>(); - - let wire = encode_media_wire_records( - &wire_records, - "2026-06-18T00:00:00Z", - "muninn-test", - "media-test", - )?; - - assert_eq!(wire.len(), 2); - assert_eq!(decode_media_wire_record(&wire[0])?, wire_records[0]); - assert_eq!(decode_media_wire_record(&wire[1])?, wire_records[1]); - Ok(()) - } - - #[test] - fn media_wire_encodes_annex_b_stream_for_sender() -> Result<()> { - let mut stream = Vec::new(); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x65, 0x80]); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x41, 0x80]); - - let wire = encode_video_annex_b_stream_wire_records( - VideoAnnexBStreamWireOptions { - packetize: VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: 16, - }, - stored_at: "2026-06-18T00:00:00Z", - source_runtime_id: "muninn-test", - source_role: "media-test", - }, - &stream, - )?; - - assert_eq!(wire.len(), 2); - let first = decode_media_wire_record(&wire[0])?; - let second = decode_media_wire_record(&wire[1])?; - let GameCultMediaWireRecord::Video(first) = first else { - panic!("expected video media record"); - }; - let GameCultMediaWireRecord::Video(second) = second else { - panic!("expected video media record"); - }; - assert_eq!(first.frame_id, 9); - assert_eq!(first.deadline_ticks, 28_800); - assert_eq!(second.frame_id, 10); - assert_eq!(second.deadline_ticks, 31_800); - Ok(()) - } - - #[test] - fn media_send_payloads_pin_video_to_media_channel() -> Result<()> { - let mut stream = Vec::new(); - stream.extend_from_slice(&start_code()); - stream.extend_from_slice(&[0x65, 0x80]); - - let payloads = video_annex_b_stream_send_payloads( - VideoAnnexBStreamWireOptions { - packetize: VideoAnnexBStreamPacketizeOptions { - stream_id: "muninn.raven.av.rudp", - session_id: "session-1", - codec: "h264", - first_frame_id: 9, - first_pts_ticks: 27_000, - frame_duration_ticks: 3_000, - timebase_num: 1, - timebase_den: 90_000, - deadline_delay_ticks: 1_800, - max_payload_bytes: 16, - }, - stored_at: "2026-06-18T00:00:00Z", - source_runtime_id: "muninn-test", - source_role: "media-test", - }, - &stream, - )?; - - assert_eq!(payloads.len(), 1); - assert_eq!(payloads[0].channel_id, MUNINN_MEDIA_RUDP_CHANNEL); - let GameCultMediaWireRecord::Video(record) = decode_media_wire_record(&payloads[0].payload)? - else { - panic!("expected video media record"); - }; - assert_eq!(record.frame_id, 9); - Ok(()) - } - fn stream_send_config() -> VideoAnnexBStreamSendConfig { VideoAnnexBStreamSendConfig { stream_id: "muninn.raven.av.rudp".to_string(), @@ -2130,6 +1529,109 @@ mod tests { } } + /// Push two access units through the sender and return every video data + /// record (parity excluded) it put on the wire, in order. + fn sent_video_records( + config: VideoAnnexBStreamSendConfig, + second_slice_header: u8, + ) -> Result> { + let mut stream = Vec::new(); + stream.extend_from_slice(&start_code()); + stream.extend_from_slice(&[0x65, 0x80]); + stream.extend_from_slice(&start_code()); + stream.extend_from_slice(&[second_slice_header, 0x80]); + let mut sender = VideoAnnexBStreamSendState::new(config)?; + let mut payloads = sender.push("2026-06-18T00:00:00Z", &stream)?; + payloads.extend(sender.finish("2026-06-18T00:00:00Z")?); + let mut records = Vec::new(); + for payload in &payloads { + if let GameCultMediaWireRecord::Video(record) = + decode_media_wire_record(&payload.payload)? + { + records.push(record); + } + } + Ok(records) + } + + #[test] + fn annex_b_stream_send_state_times_records_from_the_configured_clock() -> Result<()> { + let mut config = stream_send_config(); + config.codec = "avc".to_string(); + + let records = sent_video_records(config, 0x41)?; + + assert_eq!(records.len(), 2); + assert_eq!(records[0].frame_id, 9); + assert_eq!(records[0].pts_ticks, 27_000); + assert_eq!(records[0].deadline_ticks, 28_800); + assert!(records[0].keyframe); + assert_eq!(records[1].frame_id, 10); + assert_eq!(records[1].pts_ticks, 30_000); + assert_eq!(records[1].deadline_ticks, 31_800); + assert_eq!(records[1].dependency_frame_id, Some(9)); + assert_eq!(records[1].codec, "avc"); + Ok(()) + } + + #[test] + fn annex_b_stream_send_state_leaves_non_reference_p_frames_without_dependency() -> Result<()> { + let records = sent_video_records(stream_send_config(), 0x01)?; + + assert_eq!(records.len(), 2); + assert!(records[0].keyframe); + assert_eq!(records[0].dependency_frame_id, None); + assert!(!records[1].keyframe); + assert_eq!(records[1].dependency_frame_id, None); + Ok(()) + } + + #[test] + fn annex_b_stream_send_state_rejects_negative_deadline_delay() { + let mut config = stream_send_config(); + config.deadline_delay_ticks = -1; + + let error = match VideoAnnexBStreamSendState::new(config) { + Ok(_) => panic!("a negative deadline delay must not create a sender"), + Err(error) => error, + }; + + assert!( + error + .to_string() + .contains("deadline_delay_ticks must be non-negative") + ); + } + + #[test] + fn media_wire_batches_sender_records_and_reencodes_them_identically() -> Result<()> { + let mut stream = Vec::new(); + stream.extend_from_slice(&start_code()); + stream.extend_from_slice(&[0x65, 0x80]); + stream.extend_from_slice(&start_code()); + stream.extend_from_slice(&[0x41, 0x80]); + let mut sender = VideoAnnexBStreamSendState::new(stream_send_config())?; + let mut payloads = sender.push("2026-06-18T00:00:00Z", &stream)?; + payloads.extend(sender.finish("2026-06-18T00:00:00Z")?); + assert!(payloads.len() >= 2); + let wire_records = payloads + .iter() + .map(|payload| decode_media_wire_record(&payload.payload)) + .collect::>>()?; + + let wire = encode_media_wire_records( + &wire_records, + "2026-06-18T00:00:00Z", + "muninn-test", + "media-test", + )?; + + assert_eq!(wire.len(), payloads.len()); + for (encoded, original) in wire.iter().zip(&payloads) { + assert_eq!(encoded, &original.payload); + } + Ok(()) + } #[test] fn annex_b_stream_send_state_emits_only_completed_frames() -> Result<()> { @@ -2212,10 +1714,6 @@ mod tests { Ok(()) } - - - - #[test] fn media_wire_encodes_audio_packet_for_sender() -> Result<()> { let wire = encode_audio_packet_wire_record( @@ -2464,43 +1962,6 @@ mod tests { Ok(()) } - #[test] - fn feedback_payload_decodes_legacy_record_without_chunk_keys() -> Result<()> { - #[derive(serde::Serialize)] - struct LegacyFeedbackRecord { - stream_id: String, - session_id: String, - receiver_id: String, - highest_decodable_frame_id: Option, - missing_frame_ids: Vec, - late_frame_ids: Vec, - requested_keyframe: bool, - jitter_us: i64, - decode_queue_us: i64, - observed_at: String, - } - - let payload = encode_record_payload(&LegacyFeedbackRecord { - stream_id: "muninn.raven.av.rudp".to_string(), - session_id: "session-1".to_string(), - receiver_id: "starfire.obs".to_string(), - highest_decodable_frame_id: Some(41), - missing_frame_ids: vec![42], - late_frame_ids: vec![40], - requested_keyframe: true, - jitter_us: 750, - decode_queue_us: 2_000, - observed_at: "2026-06-18T00:00:00Z".to_string(), - })?; - - let decoded: GameCultMediaReceiverFeedbackRecord = decode_record_payload(&payload)?; - - assert_eq!(decoded.missing_video_chunk_keys, Vec::::new()); - assert_eq!(decoded.missing_frame_ids, vec![42]); - assert!(decoded.requested_keyframe); - Ok(()) - } - #[test] fn media_wire_rejects_mismatched_record_key() -> Result<()> { let record = packetize_audio_packet( From a189363c2331edec132d2a4a50e53813467bbf41 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 13:51:01 +0200 Subject: [PATCH 3/6] Drop imports the receiver residue left unused Co-Authored-By: Claude Sonnet 5 --- crates/muninn-daemon/src/media_packetizer.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/muninn-daemon/src/media_packetizer.rs b/crates/muninn-daemon/src/media_packetizer.rs index ee9aab7..5d36d1e 100644 --- a/crates/muninn-daemon/src/media_packetizer.rs +++ b/crates/muninn-daemon/src/media_packetizer.rs @@ -1,12 +1,10 @@ use anyhow::{Context, Result, anyhow}; use cultnet_rs::{ CultNetMessage, CultNetWireContract, GAMECULT_MEDIA_AUDIO_PACKET_SCHEMA, - GameCultMediaAudioPacketRecord, - GameCultMediaReceiverFeedbackRecord, GameCultMediaVideoAccessUnitRecord, + GameCultMediaAudioPacketRecord, GameCultMediaVideoAccessUnitRecord, GameCultMediaVideoParityShardRecord, decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, }; -use serde::{Serialize, de::DeserializeOwned}; use std::collections::BTreeMap; /// Re-exported so this module stays the one place Muninn's media code imports From 4af6c8fac4cd24a46f772c5f723068ce7fa6f7b0 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 13:59:53 +0200 Subject: [PATCH 4/6] Move test-only cultnet imports into the tests module Co-Authored-By: Claude Sonnet 5 --- crates/muninn-daemon/src/media_packetizer.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/muninn-daemon/src/media_packetizer.rs b/crates/muninn-daemon/src/media_packetizer.rs index 5d36d1e..9fe62c5 100644 --- a/crates/muninn-daemon/src/media_packetizer.rs +++ b/crates/muninn-daemon/src/media_packetizer.rs @@ -1,9 +1,7 @@ use anyhow::{Context, Result, anyhow}; use cultnet_rs::{ - CultNetMessage, CultNetWireContract, GAMECULT_MEDIA_AUDIO_PACKET_SCHEMA, GameCultMediaAudioPacketRecord, GameCultMediaVideoAccessUnitRecord, - GameCultMediaVideoParityShardRecord, decode_cultnet_message_from_slice, - encode_cultnet_message_to_vec, + GameCultMediaVideoParityShardRecord, }; use std::collections::BTreeMap; @@ -1024,7 +1022,11 @@ impl<'a> BitReader<'a> { #[cfg(test)] mod tests { use super::*; - use cultnet_rs::{ReceiverFeedbackOptions, VideoChunkKey, build_receiver_feedback}; + use cultnet_rs::{ + CultNetMessage, CultNetWireContract, GAMECULT_MEDIA_AUDIO_PACKET_SCHEMA, + ReceiverFeedbackOptions, VideoChunkKey, build_receiver_feedback, + decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, + }; fn start_code() -> [u8; 4] { [0, 0, 0, 1] From 88f9ed7ccdbdbef5a6c4c56f849d9f85d3171394 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 16:02:33 +0200 Subject: [PATCH 5/6] Collapse the video parity wire builder to one frame; test stale-identity pruning without bluetoothctl video_wire_records_with_parity keeps only its single-frame caller. The stale move-identity prune is split out of reconcile_move_identity_records so its test no longer shells out to the host Bluetooth binary. Co-Authored-By: Claude Sonnet 5 --- crates/muninn-daemon/src/main.rs | 10 +++++- crates/muninn-daemon/src/media_packetizer.rs | 32 +++++--------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/crates/muninn-daemon/src/main.rs b/crates/muninn-daemon/src/main.rs index 6263f07..7857ad3 100644 --- a/crates/muninn-daemon/src/main.rs +++ b/crates/muninn-daemon/src/main.rs @@ -1827,7 +1827,14 @@ fn reconcile_move_identity_records( ) -> Result<()> { publish_move_identity_records(node, options, sources)?; publish_bluetooth_move_identity_records(node, options, active)?; + prune_stale_move_identity_records(node, options, sources) +} +fn prune_stale_move_identity_records( + node: &mut cultmesh_rs::CultMeshNode, + options: &Options, + sources: &[MoveStateSource], +) -> Result<()> { let current_ids = current_move_identity_records_from_sources(options, sources)? .into_iter() .map(|identity| identity.identity_id) @@ -14325,7 +14332,8 @@ Device 00:07:04:A8:00:D0 (public) hidraw_path: "windows-psmove://current".to_string(), }]; - reconcile_move_identity_records(&mut node, &options, ¤t, &[]).unwrap(); + publish_move_identity_records(&mut node, &options, ¤t).unwrap(); + prune_stale_move_identity_records(&mut node, &options, ¤t).unwrap(); assert!( node.get::("starfire:move-0006f523e2d1:move-identity") diff --git a/crates/muninn-daemon/src/media_packetizer.rs b/crates/muninn-daemon/src/media_packetizer.rs index 9fe62c5..d814944 100644 --- a/crates/muninn-daemon/src/media_packetizer.rs +++ b/crates/muninn-daemon/src/media_packetizer.rs @@ -688,31 +688,15 @@ pub fn build_video_parity_shards( } fn video_wire_records_with_parity( - records: &[GameCultMediaVideoAccessUnitRecord], + frame_records: &[GameCultMediaVideoAccessUnitRecord], ) -> Result> { - let mut wire_records = Vec::new(); - let mut offset = 0_usize; - while offset < records.len() { - let first = &records[offset]; - let mut end = offset + 1; - while end < records.len() - && records[end].stream_id == first.stream_id - && records[end].session_id == first.session_id - && records[end].frame_id == first.frame_id - { - end += 1; - } - let frame_records = &records[offset..end]; - wire_records.extend( - frame_records - .iter() - .cloned() - .map(GameCultMediaWireRecord::Video), - ); - for parity in build_video_parity_shards(frame_records)? { - wire_records.push(GameCultMediaWireRecord::VideoParity(parity)); - } - offset = end; + let mut wire_records: Vec = frame_records + .iter() + .cloned() + .map(GameCultMediaWireRecord::Video) + .collect(); + for parity in build_video_parity_shards(frame_records)? { + wire_records.push(GameCultMediaWireRecord::VideoParity(parity)); } Ok(wire_records) } From b607592be28eae636607cd3457b409903fb52d47 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 16:02:33 +0200 Subject: [PATCH 6/6] Correct keyframe, GOP, and provenance claims in the media docs Co-Authored-By: Claude Sonnet 5 --- docs/muninn-media-streaming.md | 3 ++- docs/teardown-map.md | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/muninn-media-streaming.md b/docs/muninn-media-streaming.md index e2f411b..0eefb53 100644 --- a/docs/muninn-media-streaming.md +++ b/docs/muninn-media-streaming.md @@ -239,7 +239,8 @@ Recommended first LAN profile: - Profile id: `muninn.rudp.low_latency_h264_lan.v1`. - Video: H.264 NVENC, `p5` (`main.rs:10279`), ultra-low-latency tune, CBR high enough that LAN bandwidth is not the constraint, no B-frames, no lookahead, short GOP or - intra-refresh, periodic IDR/keyframe on feedback pressure. + intra-refresh, keyframe actuation on feedback pressure (not built: keyframe requests are only + counted and logged today; Cut 6 builds it). - VBV: derive `bufsize` from roughly one frame of bitrate (`bitrate_kbps / framerate`) instead of a large fixed encoder reservoir. The point is bounded latency, not hoarding compressed video in a nicer hat. diff --git a/docs/teardown-map.md b/docs/teardown-map.md index 5cd5629..69356c3 100644 --- a/docs/teardown-map.md +++ b/docs/teardown-map.md @@ -609,13 +609,13 @@ Three repos where there was one crate, and a contract neither of them owns. | Repo | Role | State | |---|---|---| -| CultLib `main` `05e0925` at the time of writing (media contract unchanged since `c2a9a6e`; `main` is now `069ecc3`) | the contract | media records, wire envelope, validation, channel delivery | +| CultLib `main` `05e0925` at the time of writing (media contract unchanged since `c2a9a6e`) | the contract | media records, wire envelope, validation, channel delivery | | Muninn | producer | speaks the shared contract; blocked on one pin (below) | | Ratatoskr | consumer | decodes the envelope; builds clean, no conflicts | ### The one thing blocking a clean Muninn build (history; resolved) -Resolved 2026-09-11 (see the Raven section below): `Cargo.lock` is tracked (`60ed6b2`) and the pins are the build. The build resolves `odin-core` from Odin `3e96c6c`, which no Odin branch holds; only the tag `attic/claude-cultlib-pin-c2a9a6e` keeps it reachable. The text below is the state on 2026-09-10. +Resolved 2026-09-11 (see the Raven section below): `Cargo.lock` is tracked (`70d267f`) and the pins are the build. The build resolves `odin-core` from Odin `3e96c6c`, which no Odin branch holds; only the tag `attic/claude-cultlib-pin-c2a9a6e` keeps it reachable. The text below is the state on 2026-09-10. `odin-core` pins CultLib `c13b6ba`; Muninn needs `05e0925`. Cargo resolves two `cultcache-rs` copies and `DatabaseEntry` from one is not `DatabaseEntry` from @@ -656,7 +656,7 @@ one once the patch is gone. Muninn-specific `obs_stream_catalog` / `capture_stream_command` stay published beside them until nothing reads them. The old plugin's CLI shell-out and `.cc` snapshot are not ported. The connection direction was - inverted the same day (section above). Exercised live 2026-09-10/11 on `bc43e1b` and later + inverted the same day (section above). First live frames on `58e8663` (2026-09-10); exercised through 2026-09-11 on `bc43e1b` and later (measurements below); the 2026-09-10 note that Raven ran a pre-b679fc2 Muninn is history. 3. **Opus.** Unblocked and measured at 16.8x. `-f aac` in the receiver becomes codec-driven; framing follows the `aac-adts-padded-v1` precedent (2-byte @@ -666,8 +666,9 @@ one once the patch is gone. live counterpart. `build_receiver_feedback` moved to CultLib (34c8ea7) and stopped implying a keyframe request from missing chunks (4160ab5): a repair request is the alternative to one. The sender counts keyframe requests and logs them; - it does not force an IDR (`main.rs:3036-3048`). Recovery today is the fixed all-IDR GOP - of `framerate/4` frames. + it does not force an IDR (`main.rs:3036-3048`). Recovery today is the fixed GOP: + every GOP keyframe is an IDR, at a GOP of `framerate/4` frames (`-forced-idr 1`, `-g`, + `-keyint_min`, `main.rs:10405-10410`); not every frame. ### Deliberate breaks, both recorded as passing tests