diff --git a/docs/obs-stem-plugin.md b/docs/obs-stem-plugin.md index df55e6a..22b6a7a 100644 --- a/docs/obs-stem-plugin.md +++ b/docs/obs-stem-plugin.md @@ -135,9 +135,22 @@ muninn.obs_stream_catalog ``` Muninn owns that catalog as typed CultCache state. OBS owns only the selected -scene source and media rendering. The source does not probe devices and does -not activate streams by itself; use Muninn's explicit activation command before -selecting a stream that requires capture resources. +scene source and media rendering. When a selected stream uses Muninn's RUDP +media profile, the source publishes the same typed +`muninn.capture_stream_command` that an operator would publish manually. Raven +Muninn `serve` still owns whether capture starts and which local FFmpeg/WASAPI +children exist. + +For `rudp://` stream URLs, the plugin binds the advertised media port, accepts +the CultNet RUDP handshake, acknowledges packets, reassembles RUDP fragments, +decodes typed `muninn.media_video_access_unit.v1` and +`muninn.media_audio_packet.v1` records, and lowers elementary H.264 plus ADTS +AAC into local loopback UDP sockets for OBS FFmpeg child sources. The bridge +does not impose a global packet-sequence FIFO over the media lane: CultNet RUDP +media is reliable but unordered, so frame ids, chunk ids, and the advertised +`assembly_deadline_ms` own video reconstruction. Incomplete video frames expire +inside that budget and emit `muninn.media_receiver_feedback.v1` keyframe +pressure instead of stalling newer media behind an obsolete sequence gap. ## Install diff --git a/native/obs_stem_source/mimir_obs_muninn_source.cpp b/native/obs_stem_source/mimir_obs_muninn_source.cpp index 1b049bd..693f442 100644 --- a/native/obs_stem_source/mimir_obs_muninn_source.cpp +++ b/native/obs_stem_source/mimir_obs_muninn_source.cpp @@ -546,7 +546,6 @@ private: const int received = recvfrom(socket_, reinterpret_cast(buffer.data()), static_cast(buffer.size()), 0, reinterpret_cast(&remote), &remote_len); if (received <= 0) { - flush_forward_payloads(video_socket, video_addr, audio_socket, audio_addr, bridge_sequence); expire_rudp_packet_fragments(std::chrono::steady_clock::now()); expire_video_assemblies(std::chrono::steady_clock::now(), bridge_sequence); continue; @@ -599,13 +598,10 @@ private: } if (packet_type == 1) { - pending_payloads_.clear(); video_assemblies_.clear(); packet_fragments_.reset(); ack_tracker_.reset(); ack_tracker_.remember(sequence); - gap_wait_started_.reset(); - next_data_sequence_ = sequence + 1; packets_forwarded_ = 0; bytes_forwarded_ = 0; payloads_decoded_dropped_ = 0; @@ -639,13 +635,13 @@ private: payload_len); } if (delivered) { - if (!next_data_sequence_) { - next_data_sequence_ = delivered->first; - } - if (delivered->first >= *next_data_sequence_) { - pending_payloads_[delivered->first] = std::move(delivered->second); - flush_forward_payloads(video_socket, video_addr, audio_socket, audio_addr, bridge_sequence); - } + forward_payload(delivered->second.data(), + static_cast(delivered->second.size()), + video_socket, + video_addr, + audio_socket, + audio_addr, + bridge_sequence); } const auto [ack, ack_mask] = ack_tracker_.state(); send_control_packet(4, 0x00, bridge_sequence++, ack, ack_mask, remote); @@ -856,43 +852,6 @@ private: } } - void flush_forward_payloads(SOCKET video_socket, - const sockaddr_in &video_addr, - SOCKET audio_socket, - const sockaddr_in &audio_addr, - uint32_t &bridge_sequence) - { - if (!next_data_sequence_) { - return; - } - while (true) { - const auto found = pending_payloads_.find(*next_data_sequence_); - if (found == pending_payloads_.end()) { - if (pending_payloads_.empty()) { - gap_wait_started_.reset(); - return; - } - const auto now = std::chrono::steady_clock::now(); - if (!gap_wait_started_) { - gap_wait_started_ = now; - return; - } - const auto waited = std::chrono::duration_cast(now - *gap_wait_started_); - if (waited >= std::chrono::milliseconds(parts_.gap_wait_ms) || pending_payloads_.size() > 16) { - *next_data_sequence_ = pending_payloads_.begin()->first; - gap_wait_started_.reset(); - continue; - } - return; - } - gap_wait_started_.reset(); - const auto &payload = found->second; - forward_payload(payload.data(), static_cast(payload.size()), video_socket, video_addr, audio_socket, audio_addr, bridge_sequence); - pending_payloads_.erase(found); - ++(*next_data_sequence_); - } - } - void send_control_packet(uint8_t packet_type, uint8_t flags, uint32_t sequence, uint32_t ack, uint32_t ack_mask, const sockaddr_in &remote) { const std::string channel = "control"; @@ -955,12 +914,9 @@ private: std::atomic running_{false}; std::thread worker_; muninn_rudp_url::RudpUrlParts parts_; - std::map> pending_payloads_; std::map video_assemblies_; muninn_rudp_fragments::FragmentAssembler packet_fragments_; muninn_rudp_ack::AckTracker ack_tracker_; - std::optional next_data_sequence_; - std::optional gap_wait_started_; uint64_t packets_forwarded_ = 0; uint64_t bytes_forwarded_ = 0; uint64_t payloads_decoded_dropped_ = 0; diff --git a/state/evidence.jsonl b/state/evidence.jsonl index b0a7ee2..29d2554 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -377,3 +377,4 @@ {"ts": "2026-06-03T05:36:16+01:00", "type": "implementation", "status": "ok", "note": "Fensalir daemon status now marks Move sync as waiting when the process identity is valid but move-sync/online-sync.jsonl is missing or empty. Hot-restarted Fensalir; Eve dashboard reported Online Daemons 5/6 while health stayed caught-up, matching the live state: relay, recorder, Fensalir, Well, and Move worker are alive, but Move score has no Realtek loopback frames yet."} {"ts": "2026-06-04T11:07:48+01:00", "type": "decision", "status": "ok", "note": "Existing Well captures are synchronization evidence, not continuous media bodies: future recording/streaming daemons must drink typed stream-frame/body refs from the Well, while the Well owns ingest, clock mapping, source heartbeat/reacquire, and operator-alert publication only."} {"ts": "2026-06-07T17:23:25+01:00", "type": "implementation", "status": "ok", "note": "Added Mimir.RavenDaemon as Raven-local capture mux supervisor: publishes mimir.raven_capture_mux_state.v1 via CultMesh/CultCache, exposes Eve dashboard state on 8801, and reuses FFmpeg/WASAPI for display plus Realtek loopback mux to Starfire over WireGuard."} +{"ts": "2026-06-18T23:29:22+01:00", "type": "decision", "status": "ok", "note": "Muninn OBS RUDP receive bridge demoted packet sequence from media ordering authority. CultNet media packets remain reliable/unordered; the plugin now forwards decoded typed media payloads immediately, while video frame_id/chunk_id plus assembly_deadline_ms own reconstruction and receiver feedback requests keyframes for expired incomplete frames."}