Repair Muninn receiver recovery contracts
This commit is contained in:
parent
45ead73ae3
commit
074ad4a69b
9 changed files with 124 additions and 9 deletions
|
|
@ -456,6 +456,14 @@ encoder keyframe actuation, production parity recovery, audio FEC/concealment,
|
|||
bounded long-disconnect edge admission, adaptive sender response, and the
|
||||
fault-injected socket timeline harness.
|
||||
|
||||
The production receiver follow-up fixed two contract contradictions: early
|
||||
video repair no longer declares the frame late (which had made Odin discard all
|
||||
repair requests), and the OBS audio decoder now consumes Muninn's actual float
|
||||
PCM contract rather than treating it as AAC. Audio reorder is bounded to 40 ms
|
||||
with short silence concealment. The next audio cut is Opus with explicit
|
||||
FEC/PLC; the next video cut is a controllable encoder owner that can force IDR
|
||||
without restarting the A/V session.
|
||||
|
||||
1. Replace the frame-event diagnostic bridge with concrete direct capture
|
||||
drivers for Leap stereo IR first, then the
|
||||
other cameras.
|
||||
|
|
|
|||
|
|
@ -31,3 +31,10 @@ target_compile_features(muninn_rudp_url_tests PRIVATE cxx_std_20)
|
|||
target_include_directories(muninn_rudp_url_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_test(NAME muninn_rudp_url_tests COMMAND muninn_rudp_url_tests)
|
||||
|
||||
add_executable(muninn_media_wire_tests
|
||||
tests/muninn_media_wire_tests.cpp)
|
||||
target_compile_features(muninn_media_wire_tests PRIVATE cxx_std_20)
|
||||
target_include_directories(muninn_media_wire_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_test(NAME muninn_media_wire_tests COMMAND muninn_media_wire_tests)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ constexpr uint32_t MuninnMaxRudpVideoBitrateKbps = 100000;
|
|||
constexpr uint32_t MuninnMaxRudpLatencyBudgetMs = 2000;
|
||||
constexpr uint32_t MuninnMaxRudpAudioReorderMs = 2000;
|
||||
constexpr size_t MuninnAudioReorderMaxPackets = 128;
|
||||
constexpr uint64_t MuninnAudioConcealmentMaxPackets = 4;
|
||||
constexpr size_t MuninnAudioQueueMaxPackets = 32;
|
||||
constexpr const char *MuninnDisabledVideoSourceId = "video:none";
|
||||
constexpr const char *MuninnDisabledAudioSourceId = "audio:none";
|
||||
|
|
@ -975,6 +976,7 @@ private:
|
|||
audio_packets_reordered_ = 0;
|
||||
audio_packets_skipped_ = 0;
|
||||
audio_packets_stale_ = 0;
|
||||
audio_packets_concealed_ = 0;
|
||||
media_sequence_initialized_ = false;
|
||||
last_media_sequence_ = 0;
|
||||
media_sequence_gap_events_ = 0;
|
||||
|
|
@ -1020,6 +1022,7 @@ private:
|
|||
audio_packets_reordered_ = 0;
|
||||
audio_packets_skipped_ = 0;
|
||||
audio_packets_stale_ = 0;
|
||||
audio_packets_concealed_ = 0;
|
||||
media_sequence_initialized_ = false;
|
||||
last_media_sequence_ = 0;
|
||||
media_sequence_gap_events_ = 0;
|
||||
|
|
@ -1250,7 +1253,20 @@ private:
|
|||
if (gap_expired || queue_overflow) {
|
||||
const uint64_t first_available = pending_audio_packets_.begin()->first;
|
||||
if (first_available > next_audio_packet_id_) {
|
||||
audio_packets_skipped_ += first_available - next_audio_packet_id_;
|
||||
const uint64_t missing_packets = first_available - next_audio_packet_id_;
|
||||
const uint64_t concealment_packets =
|
||||
std::min(missing_packets, MuninnAudioConcealmentMaxPackets);
|
||||
const std::vector<uint8_t> silence(
|
||||
pending_audio_packets_.begin()->second.payload.size(), 0);
|
||||
for (uint64_t index = 0; index < concealment_packets; ++index) {
|
||||
if (!send_audio_packet(audio_socket, audio_addr, silence)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
forwarded_bytes += silence.size();
|
||||
forwarded_any = true;
|
||||
++audio_packets_concealed_;
|
||||
}
|
||||
audio_packets_skipped_ += missing_packets - concealment_packets;
|
||||
next_audio_packet_id_ = first_available;
|
||||
}
|
||||
audio_gap_started_at_ = std::chrono::steady_clock::time_point::min();
|
||||
|
|
@ -1652,6 +1668,7 @@ private:
|
|||
iterator->second,
|
||||
missing_chunk_keys,
|
||||
needs_decoder_recovery,
|
||||
true,
|
||||
bridge_sequence);
|
||||
if (needs_decoder_recovery) {
|
||||
waiting_for_video_keyframe_ = true;
|
||||
|
|
@ -1711,7 +1728,7 @@ private:
|
|||
if (missing_chunk_keys.empty()) {
|
||||
return;
|
||||
}
|
||||
send_receiver_feedback_if_due(assembly, missing_chunk_keys, false, bridge_sequence);
|
||||
send_receiver_feedback_if_due(assembly, missing_chunk_keys, false, false, bridge_sequence);
|
||||
assembly.repair_requested = true;
|
||||
}
|
||||
|
||||
|
|
@ -1738,6 +1755,7 @@ private:
|
|||
void send_receiver_feedback_if_due(const MuninnVideoFrameAssembly &assembly,
|
||||
const std::vector<std::string> &missing_chunk_keys,
|
||||
bool requested_keyframe,
|
||||
bool late_frame,
|
||||
uint32_t &bridge_sequence)
|
||||
{
|
||||
if (!last_remote_ || assembly.stream_id.empty() || assembly.session_id.empty()) {
|
||||
|
|
@ -1751,9 +1769,15 @@ private:
|
|||
}
|
||||
last_keyframe_request_ms_.store(now);
|
||||
}
|
||||
const std::string observed_at = "unix:" + std::to_string(steady_millis());
|
||||
const std::string observed_at = muninn_media_wire::feedback_observed_at();
|
||||
const auto payload = muninn_media_wire::encode_receiver_feedback_payload(
|
||||
assembly.stream_id, assembly.session_id, assembly.frame_id, missing_chunk_keys, requested_keyframe, observed_at);
|
||||
assembly.stream_id,
|
||||
assembly.session_id,
|
||||
assembly.frame_id,
|
||||
missing_chunk_keys,
|
||||
requested_keyframe,
|
||||
late_frame,
|
||||
observed_at);
|
||||
send_media_packet(payload, bridge_sequence++, *last_remote_);
|
||||
}
|
||||
|
||||
|
|
@ -1917,6 +1941,7 @@ private:
|
|||
uint64_t audio_packets_reordered_ = 0;
|
||||
uint64_t audio_packets_skipped_ = 0;
|
||||
uint64_t audio_packets_stale_ = 0;
|
||||
uint64_t audio_packets_concealed_ = 0;
|
||||
std::string audio_stream_id_;
|
||||
std::string audio_session_id_;
|
||||
bool next_audio_packet_ready_ = false;
|
||||
|
|
@ -2278,7 +2303,11 @@ public:
|
|||
"-analyzeduration",
|
||||
"0",
|
||||
"-f",
|
||||
"aac",
|
||||
"f32le",
|
||||
"-ac",
|
||||
"2",
|
||||
"-ar",
|
||||
"48000",
|
||||
"-i",
|
||||
audio_url,
|
||||
"-vn",
|
||||
|
|
|
|||
|
|
@ -172,12 +172,18 @@ inline void write_u64_array(MsgpackWriter &writer, const std::vector<uint64_t> &
|
|||
}
|
||||
}
|
||||
|
||||
inline std::vector<uint64_t> receiver_feedback_late_frame_ids(uint64_t frame_id, bool late_frame)
|
||||
{
|
||||
return late_frame ? std::vector<uint64_t>{frame_id} : std::vector<uint64_t>{};
|
||||
}
|
||||
|
||||
inline std::vector<uint8_t> encode_receiver_feedback_payload(
|
||||
const std::string &stream_id,
|
||||
const std::string &session_id,
|
||||
uint64_t frame_id,
|
||||
const std::vector<std::string> &missing_chunk_keys,
|
||||
bool requested_keyframe,
|
||||
bool late_frame,
|
||||
const std::string &observed_at)
|
||||
{
|
||||
MsgpackWriter record;
|
||||
|
|
@ -191,7 +197,7 @@ inline std::vector<uint8_t> encode_receiver_feedback_payload(
|
|||
record.write_nil();
|
||||
}
|
||||
write_u64_array(record, {});
|
||||
write_u64_array(record, {frame_id});
|
||||
write_u64_array(record, receiver_feedback_late_frame_ids(frame_id, late_frame));
|
||||
record.write_bool(requested_keyframe);
|
||||
record.write_i64(0);
|
||||
record.write_i64(0);
|
||||
|
|
@ -247,6 +253,7 @@ inline std::vector<uint8_t> encode_receiver_feedback_payload(
|
|||
frame_id,
|
||||
missing_chunk_keys,
|
||||
requested_keyframe,
|
||||
requested_keyframe,
|
||||
feedback_observed_at());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ inline constexpr uint32_t DefaultAudioRudpConnectionId = 0x6d750004;
|
|||
inline constexpr uint32_t DefaultReliableExpireAfterMs = 75;
|
||||
inline constexpr uint32_t DefaultVideoAssemblyDeadlineMs = 75;
|
||||
inline constexpr uint32_t DefaultGapWaitMs = 8;
|
||||
inline constexpr uint32_t DefaultAudioReorderMs = 2000;
|
||||
inline constexpr uint32_t DefaultAudioReorderMs = 40;
|
||||
inline constexpr uint32_t DefaultSenderResendDelayMs = 5;
|
||||
inline constexpr uint32_t MaxLatencyBudgetMs = 2000;
|
||||
|
||||
|
|
|
|||
54
native/obs_stem_source/tests/muninn_media_wire_tests.cpp
Normal file
54
native/obs_stem_source/tests/muninn_media_wire_tests.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "muninn_media_wire.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
void require(bool condition, const char *message)
|
||||
{
|
||||
if (!condition) {
|
||||
std::cerr << message << '\n';
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const auto early = muninn_media_wire::receiver_feedback_late_frame_ids(42, false);
|
||||
require(early.empty(), "early repair feedback marked a live frame late");
|
||||
|
||||
const auto expired = muninn_media_wire::receiver_feedback_late_frame_ids(42, true);
|
||||
require(expired.size() == 1 && expired.front() == 42,
|
||||
"expired feedback did not name the late frame");
|
||||
|
||||
const auto early_wire = muninn_media_wire::encode_receiver_feedback_payload(
|
||||
"muninn.raven.av.rudp",
|
||||
"raven:session:video",
|
||||
42,
|
||||
{"42:3"},
|
||||
false,
|
||||
false,
|
||||
"unix-ms:1000");
|
||||
const auto expired_wire = muninn_media_wire::encode_receiver_feedback_payload(
|
||||
"muninn.raven.av.rudp",
|
||||
"raven:session:video",
|
||||
42,
|
||||
{"42:3"},
|
||||
true,
|
||||
true,
|
||||
"unix-ms:1000");
|
||||
require(!early_wire.empty() && !expired_wire.empty(), "feedback wire encoding was empty");
|
||||
require(early_wire != expired_wire, "early and expired feedback encoded identically");
|
||||
if (argc == 2 && std::string(argv[1]) == "--emit-early-hex") {
|
||||
for (const auto byte : early_wire) {
|
||||
std::cout << std::hex << std::setw(2) << std::setfill('0')
|
||||
<< static_cast<unsigned int>(byte);
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -51,8 +51,8 @@ int main()
|
|||
"minimal RUDP URL did not keep the default assembly deadline");
|
||||
require(fallback->audio_reorder_ms == muninn_rudp_url::DefaultAudioReorderMs,
|
||||
"minimal RUDP URL did not keep the default audio reorder wait");
|
||||
require(fallback->audio_reorder_ms == 2000,
|
||||
"minimal RUDP URL did not use the full default audio reorder budget");
|
||||
require(fallback->audio_reorder_ms == 40,
|
||||
"minimal RUDP URL did not use the bounded realtime audio reorder budget");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,3 +189,4 @@
|
|||
{"ts": "2026-07-14T01:13:34+01:00", "type": "verification", "status": "ok", "note": "2026-07-14 Odin d0eded6 deployed to Nightwing Muninn (SHA-256 a604fedaf90b26a49db6594b16b8b3499e3aed540152c6fda9dd9dbe87d37d39). Post-deploy 10 s Mimir window: 555 frames, 2246 observations, 443 stereo pairs; radius P01 improved from ~0.707 px to 3.13/3.64 px and candidate confidence is explicitly uncalibrated 0.5 on both Eyes. Eye 1 honestly saw only two plausible stationary IDs. Artifact: artifacts/move-calibration/muninn-post-admission-filter-20260714.mpack."}
|
||||
{"ts": "2026-07-16T20:03:50+01:00", "type": "decision", "status": "ok", "note": "Moonlight common-c study at commit 82e2514 found Muninn already has media-aware packetization, deadlines, parity, receiver feedback, repair caching, and keyframe pressure. Preserve those foundations; close feedback into sender policy, replace the two-second realtime default with consumer-derived deadlines, and split Sleipnir input into replaceable latest state versus ordered non-replaceable edges. Research: docs/research/moonlight-muninn-sleipnir-study-2026-07-16.md."}
|
||||
{"ts": "2026-07-16T20:29:03+01:00", "type": "verification", "status": "ok", "note": "Moonlight-derived reliability cut implemented in Odin against experimental CultLib snapshot 8965f3c0: HID epoch/latest-state/ordered-edge/application-ack semantics; wall clock demoted from ordering; Muninn A/V uses CultNet realtime lane with 100ms default LAN deadline; bounded producer/pending queues; expiring and receiver-late-aware repair cache; decode-chain-only keyframe pressure. Verification passed 168 Muninn, 25 Sleipnir, and 35 vendored experimental CultNet tests."}
|
||||
{"ts": "2026-07-16T20:48:32+01:00", "type": "verification", "status": "ok", "note": "Production Muninn receiver audit fixed two live contract failures: early video repair feedback no longer places live frames in late_frame_ids (which made Odin refuse every repair), with a C++-emitted fixture decoded by Rust; OBS local audio decoder now consumes Muninn's actual f32le stereo 48kHz packets rather than AAC, default reorder is 40ms instead of 2000ms, and short gaps receive bounded silence concealment. Native plugin build and two CTests passed; Odin cross-fixture tests passed."}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,15 @@ invariants:
|
|||
are temporary smoke/bootstrap edges only.
|
||||
|
||||
accepted_design:
|
||||
- The 2026-07-16 production receiver audit cut two false contracts. Native
|
||||
Mimir/OBS early video repair feedback no longer marks live frames late, so
|
||||
Odin can actually return cached missing chunks; only assembly expiry emits
|
||||
`late_frame_ids`. A C++-generated feedback fixture now decodes in Odin's
|
||||
Rust tests. Muninn's typed audio body is 10 ms `pcm-f32le-interleaved`, so
|
||||
the OBS bridge now opens its local decoder as `f32le` stereo 48 kHz instead
|
||||
of AAC, uses a 40 ms reorder budget instead of 2000 ms, and emits bounded
|
||||
silence packets for short unrecoverable gaps to preserve cadence. Opus
|
||||
FEC/PLC remains required before audio reaches Moonlight-level loss quality.
|
||||
- Odin's 2026-07-16 Moonlight-derived reliability cut now runs Muninn and
|
||||
Sleipnir against the experimental CultLib runtime snapshot at `8965f3c0`.
|
||||
HID latest state and ordered button edges have separate epoch/sequence and
|
||||
|
|
|
|||
Loading…
Reference in a new issue