Set Muninn RUDP media fragment ceiling

This commit is contained in:
Meta Vens 2026-06-18 22:23:07 +01:00
commit cd3d201eda
2 changed files with 27 additions and 2 deletions

View file

@ -58,6 +58,11 @@ const MUNINN_MEDIA_SEND_QUEUE_DEADLINE_MS: u64 = 75;
const MUNINN_RUDP_MEDIA_PROFILE_ID: &str = "muninn.rudp.low_latency_h264_lan.v1";
const MUNINN_RUDP_MEDIA_VIDEO_BITRATE_KBPS: u32 = 12_000;
const MUNINN_RUDP_MEDIA_PACKET_BYTES: usize = 480;
const MUNINN_RUDP_IPV4_UDP_PAYLOAD_BYTES: usize = 1_472;
const MUNINN_RUDP_FIXED_HEADER_BYTES: usize = 36;
const MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES: usize = MUNINN_RUDP_IPV4_UDP_PAYLOAD_BYTES
- MUNINN_RUDP_FIXED_HEADER_BYTES
- crate::media_packetizer::MUNINN_MEDIA_RUDP_CHANNEL.len();
const MUNINN_RUDP_MEDIA_RELIABLE_EXPIRE_AFTER_MS: u64 = 75;
const MUNINN_RUDP_MEDIA_RECEIVER_ASSEMBLY_DEADLINE_MS: u64 = 75;
const MUNINN_RUDP_MEDIA_RECEIVER_GAP_WAIT_MS: u64 = 8;
@ -144,6 +149,7 @@ struct MuninnRudpMediaProfile {
video_tune: &'static str,
video_bitrate_kbps: u32,
media_packet_bytes: usize,
max_fragment_bytes: usize,
video_b_frames: u8,
video_rc_lookahead: u8,
sender_queue_deadline_ms: u64,
@ -1542,6 +1548,7 @@ fn open_media_rudp_transport(options: &Options) -> Result<CultNetRudpSocketTrans
MUNINN_MEDIA_RUDP_CONNECTION_ID,
);
options.resend_delay_ms = 5;
options.max_fragment_bytes = Some(media_profile.max_fragment_bytes as u32);
options.media_reliable_expire_after_ms =
Some(media_profile.sender_reliable_expire_after_ms);
options
@ -1813,6 +1820,7 @@ fn publish_runtime_boundary_records(
"video_maxrate": muninn_rudp_video_bitrate_arg(&media_profile),
"video_bufsize": muninn_rudp_video_vbv_buffer_arg(options, &media_profile),
"media_packet_bytes": media_profile.media_packet_bytes,
"max_fragment_bytes": media_profile.max_fragment_bytes,
"video_b_frames": media_profile.video_b_frames,
"video_rate_control": "cbr",
"video_rc_lookahead": media_profile.video_rc_lookahead,
@ -5049,6 +5057,7 @@ fn muninn_rudp_media_profile() -> MuninnRudpMediaProfile {
video_tune: "ull",
video_bitrate_kbps: MUNINN_RUDP_MEDIA_VIDEO_BITRATE_KBPS,
media_packet_bytes: MUNINN_RUDP_MEDIA_PACKET_BYTES,
max_fragment_bytes: MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES,
video_b_frames: 0,
video_rc_lookahead: 0,
sender_queue_deadline_ms: MUNINN_MEDIA_SEND_QUEUE_DEADLINE_MS,
@ -6111,10 +6120,16 @@ mod tests {
assert_eq!(payloads.len(), 1);
assert!(
payloads[0].payload.len() <= 1_472,
payloads[0].payload.len() <= MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES,
"typed media payload was {} bytes",
payloads[0].payload.len()
);
assert!(
payloads[0].payload.len()
+ MUNINN_RUDP_FIXED_HEADER_BYTES
+ crate::media_packetizer::MUNINN_MEDIA_RUDP_CHANNEL.len()
<= MUNINN_RUDP_IPV4_UDP_PAYLOAD_BYTES
);
}
#[test]
@ -6911,6 +6926,12 @@ Device 00:07:04:A8:00:D0 (public)
.and_then(|value| value.as_u64()),
Some(MUNINN_RUDP_MEDIA_PACKET_BYTES as u64)
);
assert_eq!(
media_profile
.get("max_fragment_bytes")
.and_then(|value| value.as_u64()),
Some(MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES as u64)
);
assert_eq!(
media_profile
.get("receiver_gap_wait_ms")

View file

@ -164,7 +164,11 @@ Recommended first LAN profile:
- Packet size: default typed media chunks are `480` bytes. 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.
reassembly. The sender also sets CultNet RUDP `max_fragment_bytes` to `1431`
bytes (`1472` byte IPv4 UDP payload budget minus `36` RUDP fixed header bytes
minus the five-byte `media` channel id), so oversized typed records fragment
in CultNet deliberately instead of falling through to accidental IP
fragmentation.
- 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.