Route Muninn capture activation over RUDP commands

This commit is contained in:
Meta Vens 2026-06-18 15:12:16 +01:00
commit a61368a711
6 changed files with 1393 additions and 162 deletions

File diff suppressed because it is too large Load diff

View file

@ -33,6 +33,7 @@ pub const IDUNN_RUNTIME_TRANSPORT_CHECK_SCHEMA: &str = "idunn.runtime_transport_
pub const IDUNN_RUDP_HEALTH_INGRESS_SCHEMA: &str = "idunn.rudp_health_ingress.v1";
pub const MUNINN_TELEMETRY_SURFACE_SCHEMA: &str = "muninn.telemetry_surface.v1";
pub const MUNINN_CAPTURE_STREAM_SCHEMA: &str = "muninn.capture_stream.v1";
pub const MUNINN_CAPTURE_STREAM_COMMAND_SCHEMA: &str = "muninn.capture_stream_command.v1";
pub const MUNINN_OBS_STREAM_CATALOG_SCHEMA: &str = "muninn.obs_stream_catalog.v1";
pub const MUNINN_MOVE_MARKER_CANDIDATE_SCHEMA: &str = "muninn.move_marker_candidate.v1";
pub const MUNINN_MOVE_CONTROLLER_STATE_SCHEMA: &str = "muninn.move_controller_state.v1";
@ -707,6 +708,42 @@ pub struct MuninnCaptureStreamRecord {
pub updated_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "muninn.capture_stream_command",
schema = "muninn.capture_stream_command.v1"
)]
pub struct MuninnCaptureStreamCommandRecord {
#[cultcache(key = 0)]
pub command_id: String,
#[cultcache(key = 1)]
pub host_id: String,
#[cultcache(key = 2)]
pub stream_id: String,
#[cultcache(key = 3)]
pub state: String,
#[cultcache(key = 4)]
pub action: String,
#[cultcache(key = 5)]
pub target_host: String,
#[cultcache(key = 6)]
pub port: u16,
#[cultcache(key = 7)]
pub obs_target_host: Option<String>,
#[cultcache(key = 8)]
pub obs_port: u16,
#[cultcache(key = 9)]
pub media_transport: String,
#[cultcache(key = 10)]
pub media_packet_bytes: u32,
#[cultcache(key = 11)]
pub requested_by: String,
#[cultcache(key = 12)]
pub detail: String,
#[cultcache(key = 13)]
pub updated_at: String,
}
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "muninn.telemetry_surface",
@ -966,6 +1003,7 @@ cultmesh_rs::cultmesh_documents!(OdinDocuments {
IdunnRudpHealthIngressRecord => IDUNN_RUDP_HEALTH_INGRESS_SCHEMA,
MuninnTelemetrySurfaceRecord => MUNINN_TELEMETRY_SURFACE_SCHEMA,
MuninnCaptureStreamRecord => MUNINN_CAPTURE_STREAM_SCHEMA,
MuninnCaptureStreamCommandRecord => MUNINN_CAPTURE_STREAM_COMMAND_SCHEMA,
MuninnObsStreamCatalogRecord => MUNINN_OBS_STREAM_CATALOG_SCHEMA,
MuninnMoveMarkerCandidateRecord => MUNINN_MOVE_MARKER_CANDIDATE_SCHEMA,
MuninnMoveControllerStateRecord => MUNINN_MOVE_CONTROLLER_STATE_SCHEMA,

View file

@ -6,7 +6,8 @@ param(
[string] $LogRoot = "C:\Meta\Odin\logs\muninn",
[string] $Ffmpeg = "C:\Users\Madman's Lullaby\AppData\Local\Microsoft\WinGet\Links\ffmpeg.exe",
[string] $TargetHost = "10.77.0.2",
[int] $Port = 5200,
[int] $Port = 5204,
[string] $MediaTransport = "rudp",
[string] $ObsTargetHost = "10.77.0.2",
[int] $ObsPort = 5204,
[string] $AudioDevice = "Realtek",
@ -123,14 +124,16 @@ $activatePsPath = Join-Path $muninnDir "activate-raven-av-srt.ps1"
$activateVbsPath = Join-Path $muninnDir "activate-raven-av-srt-hidden.vbs"
$activateArguments = @(
"activate",
"request-stream",
"--store", $StorePath,
"--host", "raven",
"--stream", "muninn.raven.av.srt",
"--stream", "muninn.raven.av.rudp",
"--stream-action", "start",
"--target-host", $TargetHost,
"--port", $Port.ToString()
"--port", $Port.ToString(),
"--media-transport", $MediaTransport
)
if ($NoObsTarget.IsPresent -or ($TargetHost -eq $ObsTargetHost -and $Port -eq $ObsPort)) {
if ($NoObsTarget.IsPresent -or $MediaTransport -ne "srt" -or ($TargetHost -eq $ObsTargetHost -and $Port -eq $ObsPort)) {
$activateArguments += "--no-obs-target"
} else {
$activateArguments += @("--obs-target-host", $ObsTargetHost, "--obs-port", $ObsPort.ToString())
@ -202,7 +205,7 @@ foreach (`$path in @(
Get-CimInstance Win32_Process |
Where-Object {
(`$_.Name -ieq "muninn.exe" -and `$_.CommandLine -like "*activate*") -or
(`$_.Name -like "muninn*.exe" -and `$_.CommandLine -like "*activate*") -or
(`$_.Name -ieq "ffmpeg.exe" -and `$_.CommandLine -like "*srt://$TargetHost*") -or
(`$_.Name -ieq "powershell.exe" -and `$_.CommandLine -like "*wasapi-loopback-capture.ps1*")
} |

View file

@ -2,6 +2,9 @@ param(
[string] $RavenHost = "raven",
[string] $MuninnExe = "C:\Meta\Odin\Muninn\muninn.exe",
[string] $StorePath = "C:\Meta\Odin\state\muninn.telemetry.cc",
[string] $ActivateStorePath = "C:\Meta\Odin\state\muninn.activate.cc",
[string] $LogRoot = "C:\Meta\Odin\logs\muninn",
[int] $MaxStoreAgeSeconds = 180,
[string] $IdunnRudpHealth = "10.77.0.2:17870"
)
@ -94,9 +97,6 @@ foreach (`$expectation in `$taskExpectations) {
if (`$psContent -notmatch 'Start-Process') {
throw "`$(`$expectation.Ps) does not launch a hidden process"
}
if (`$expectation.Name -eq "GameCult-Muninn-Activate" -and `$psContent -notmatch 'muninn\.exe') {
throw "`$(`$expectation.Ps) does not launch muninn.exe"
}
if (`$expectation.Name -eq "GameCult-Muninn-VideoProof" -and `$psContent -notmatch 'ffmpeg\.exe') {
throw "`$(`$expectation.Ps) does not launch ffmpeg.exe"
}
@ -119,6 +119,8 @@ if (`$null -eq `$process) {
}
foreach (`$pattern in @(
"--host raven",
"--activate-store $ActivateStorePath",
"--capture-command-rudp-bind 0.0.0.0:17872",
"--idunn-rudp-health $IdunnRudpHealth",
"--idunn-daemon muninn",
"--idunn-health-contract muninn.cultnet-rudp-remote-telemetry-health"
@ -127,11 +129,29 @@ foreach (`$pattern in @(
throw "Muninn serve process is missing expected command-line segment `${pattern}: `$(`$process.CommandLine)"
}
}
`$healthArgs = @(
"--health",
"--store", "$StorePath"
)
& "$MuninnExe" @healthArgs
`$conflictingWriter = Get-CimInstance Win32_Process |
Where-Object {
`$_.Name -like "muninn*.exe" -and
`$_.ProcessId -ne `$process.ProcessId -and
`$_.ParentProcessId -ne `$process.ProcessId -and
`$_.CommandLine -like "*activate*" -and
`$_.CommandLine -like "*$StorePath*"
} |
Select-Object -First 1
if (`$null -ne `$conflictingWriter) {
throw "Conflicting Muninn activate writer still targets ${StorePath}: `$(`$conflictingWriter.CommandLine)"
}
if (-not (Test-Path -LiteralPath "$StorePath")) {
throw "Muninn telemetry store is missing at $StorePath"
}
`$storeAgeSeconds = (([DateTime]::UtcNow) - (Get-Item -LiteralPath "$StorePath").LastWriteTimeUtc).TotalSeconds
if (`$storeAgeSeconds -gt $MaxStoreAgeSeconds) {
throw "Muninn telemetry store is stale (`$([math]::Round(`$storeAgeSeconds))s old)"
}
`$servePidPath = Join-Path "$LogRoot" "muninn-serve.pid"
if (-not (Test-Path -LiteralPath `$servePidPath)) {
throw "Muninn serve PID file is missing at `$servePidPath"
}
"@
Invoke-RavenUploadedPowerShell -RavenHost $RavenHost -RemoteScriptContent $remoteScript -TempPrefix "odin-raven-muninn-health"

View file

@ -7,13 +7,16 @@ param(
[string] $LoopbackScript = "C:\Meta\Odin\Muninn\scripts\wasapi-loopback-capture.ps1",
[string] $Ffmpeg = "C:\Users\Madman's Lullaby\AppData\Local\Microsoft\WinGet\Links\ffmpeg.exe",
[string] $TargetHost = "10.77.0.2",
[int] $Port = 5200,
[int] $Port = 5204,
[string] $MediaTransport = "rudp",
[string] $ObsTargetHost = "10.77.0.2",
[int] $ObsPort = 5204,
[string] $AudioDevice = "Realtek",
[string] $IdunnRudpHealth = "10.77.0.2:17870",
[string] $IdunnDaemon = "muninn",
[string] $IdunnHealthContract = "muninn.cultnet-rudp-remote-telemetry-health"
[string] $IdunnHealthContract = "muninn.cultnet-rudp-remote-telemetry-health",
[string] $CaptureCommandRudpBind = "0.0.0.0:17872",
[string] $CaptureCommandRudpTarget = "127.0.0.1:17872"
)
$ErrorActionPreference = "Stop"
@ -185,23 +188,36 @@ $videoProofVbsPath = Join-Path $muninnDir "muninn-raven-video-to-starfire-obs-hi
$serveArguments = @(
"serve",
"--store", $StorePath,
"--activate-store", $ActivateStorePath,
"--log-root", $LogRoot,
"--host", "raven",
"--stream", "muninn.raven.av.rudp",
"--target-host", $TargetHost,
"--port", $Port.ToString(),
"--media-transport", $MediaTransport,
"--audio-device", $AudioDevice,
"--ffmpeg", $Ffmpeg,
"--loopback-script", $LoopbackScript,
"--interval-seconds", "15",
"--capture-command-rudp-bind", $CaptureCommandRudpBind,
"--idunn-rudp-health", $IdunnRudpHealth,
"--idunn-daemon", $IdunnDaemon,
"--idunn-health-contract", $IdunnHealthContract
)
$activateArguments = @(
"activate",
"--store", $ActivateStorePath,
"request-stream",
"--store", $StorePath,
"--activate-store", $ActivateStorePath,
"--capture-command-rudp-target", $CaptureCommandRudpTarget,
"--host", "raven",
"--stream", "muninn.raven.av.srt",
"--stream", "muninn.raven.av.rudp",
"--stream-action", "start",
"--target-host", $TargetHost,
"--port", $Port.ToString()
"--port", $Port.ToString(),
"--media-transport", $MediaTransport
)
if ($TargetHost -eq $ObsTargetHost -and $Port -eq $ObsPort) {
if ($MediaTransport -ne "srt" -or ($TargetHost -eq $ObsTargetHost -and $Port -eq $ObsPort)) {
$activateArguments += "--no-obs-target"
} else {
$activateArguments += @("--obs-target-host", $ObsTargetHost, "--obs-port", $ObsPort.ToString())
@ -318,13 +334,15 @@ foreach (`$path in @(
}
Get-CimInstance Win32_Process |
Where-Object { `$_.Name -ieq "muninn.exe" } |
Where-Object { `$_.Name -like "muninn*.exe" } |
ForEach-Object {
& taskkill.exe /PID `$_.ProcessId /T /F | Out-Null
}
New-Item -ItemType Directory -Force -Path "$LogRoot" | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path -Parent "$StorePath") | Out-Null
& netsh.exe advfirewall firewall delete rule name="GameCult Muninn Capture Command RUDP" | Out-Null 2>`$null
& netsh.exe advfirewall firewall add rule name="GameCult Muninn Capture Command RUDP" dir=in action=allow protocol=UDP localport=17872 | Out-Null
function Register-HiddenVbsTask {
param(

View file

@ -7,9 +7,11 @@ function defineOdinDocuments(defineDocumentType) {
return {
interfaceBindingDefinition: null,
idunnDaemonHealthDefinition: null,
muninnCaptureStreamCommandDefinition: null,
muninnCaptureStreamDefinition: null,
muninnCommandBoundaryDefinition: null,
muninnMoveControllerStateDefinition: null,
muninnMoveIdentityDefinition: null,
muninnMoveLightCommandDefinition: null,
muninnMoveMarkerCandidateDefinition: null,
muninnObsStreamCatalogDefinition: null,
@ -86,6 +88,15 @@ function defineOdinDocuments(defineDocumentType) {
name: (value) => value?.stream_id || value?.streamId || "capture-stream",
schema: parseObjectDocument("Muninn capture stream"),
});
const muninnCaptureStreamCommandDefinition = defineDocumentType({
type: "muninn.capture_stream_command",
schemaName: "muninn.capture_stream_command",
schemaId: "muninn.capture_stream_command.v1",
schemaVersion: "muninn.capture_stream_command.v1",
global: false,
name: (value) => value?.command_id || value?.commandId || value?.stream_id || value?.streamId || "capture-stream-command",
schema: parseObjectDocument("Muninn capture stream command"),
});
const muninnCommandBoundaryDefinition = defineDocumentType({
type: "muninn.command_boundary",
schemaName: "muninn.command_boundary",
@ -104,6 +115,15 @@ function defineOdinDocuments(defineDocumentType) {
name: (value) => value?.stream_id || value?.streamId || value?.move_id || value?.moveId || "move-controller-state",
schema: parseObjectDocument("Muninn Move controller state"),
});
const muninnMoveIdentityDefinition = defineDocumentType({
type: "muninn.move_identity",
schemaName: "muninn.move_identity",
schemaId: "muninn.move_identity.v1",
schemaVersion: "muninn.move_identity.v1",
global: false,
name: (value) => value?.identity_id || value?.identityId || value?.move_id || value?.moveId || "move-identity",
schema: parseObjectDocument("Muninn Move identity"),
});
const muninnMoveLightCommandDefinition = defineDocumentType({
type: "muninn.move_light_command",
schemaName: "muninn.move_light_command",
@ -277,9 +297,11 @@ function defineOdinDocuments(defineDocumentType) {
return {
interfaceBindingDefinition,
idunnDaemonHealthDefinition,
muninnCaptureStreamCommandDefinition,
muninnCaptureStreamDefinition,
muninnCommandBoundaryDefinition,
muninnMoveControllerStateDefinition,
muninnMoveIdentityDefinition,
muninnMoveLightCommandDefinition,
muninnMoveMarkerCandidateDefinition,
muninnObsStreamCatalogDefinition,