Accept Eve media observations over CultMesh
This commit is contained in:
parent
54b77566c4
commit
76e9a80fa8
3 changed files with 74 additions and 1 deletions
|
|
@ -116,3 +116,10 @@ dotnet run --project .\src\Mimir.EveSensorReceiver\Mimir.EveSensorReceiver.cspro
|
|||
The receiver accepts `mimir.eve_sensor_observation.v1` MessagePack packets on
|
||||
that lane. The device remains an observation source; Mimir owns synchronization
|
||||
and interpretation.
|
||||
|
||||
The same receiver also accepts `mimir.eve_media_observation.v1` MessagePack
|
||||
packets. Periwinkle publishes low-rate camera luma frames as
|
||||
`periwinkle-camera` and microphone PCM blocks as `periwinkle-mic` on the
|
||||
CultMesh observation lane. The legacy iPad Eve camera and mic uplinks have
|
||||
matching binary media document support while their existing `eve-camera` and
|
||||
`eve-mic` ports remain usable.
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
|
||||
if (frame.Opcode == 0x2)
|
||||
{
|
||||
if (TryValidateCultMeshObservation(frame.Payload, out var normalizedObservation))
|
||||
if (TryValidateCultMeshObservation(frame.Payload, out var normalizedObservation)
|
||||
|| TryValidateCultMeshMediaObservation(frame.Payload, out normalizedObservation))
|
||||
{
|
||||
Console.WriteLine(normalizedObservation);
|
||||
Console.Out.Flush();
|
||||
|
|
@ -187,6 +188,48 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
}
|
||||
}
|
||||
|
||||
private bool TryValidateCultMeshMediaObservation(byte[] payload, out string normalized)
|
||||
{
|
||||
normalized = "";
|
||||
try
|
||||
{
|
||||
var observation = MessagePackSerializer.Deserialize<MimirEveMediaObservationDocument>(payload);
|
||||
if (!string.Equals(observation.StreamId, options.SourceId, StringComparison.Ordinal) &&
|
||||
!string.Equals(options.ExpectedType, "cultmesh-observation", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
normalized = JsonSerializer.Serialize(new
|
||||
{
|
||||
type = "cultmesh-media-observation",
|
||||
document = "mimir.eve_media_observation.v1",
|
||||
observation.ObservationId,
|
||||
observation.DeviceId,
|
||||
observation.StreamId,
|
||||
observation.Kind,
|
||||
observation.Sequence,
|
||||
observation.SensorTimestampNs,
|
||||
observation.ElapsedRealtimeNs,
|
||||
observation.WallClockUtc,
|
||||
observation.ClockDomainId,
|
||||
observation.Format,
|
||||
observation.Width,
|
||||
observation.Height,
|
||||
observation.SampleRate,
|
||||
observation.Channels,
|
||||
observation.FrameCount,
|
||||
observation.PayloadEncoding,
|
||||
PayloadBytes = observation.Payload.Length,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<HttpRequest> ReadHttpRequestAsync(NetworkStream stream)
|
||||
{
|
||||
var bytes = new List<byte>();
|
||||
|
|
|
|||
|
|
@ -240,6 +240,29 @@ public sealed record MimirEveSensorObservationDocument(
|
|||
[property: Key(13)] double? Y,
|
||||
[property: Key(14)] int? Accuracy);
|
||||
|
||||
[CultDocument("mimir.eve_media_observation", "mimir.eve_media_observation.v1")]
|
||||
[MessagePackObject]
|
||||
public sealed record MimirEveMediaObservationDocument(
|
||||
[property: Key(0)]
|
||||
[property: CultName]
|
||||
string ObservationId,
|
||||
[property: Key(1)] string DeviceId,
|
||||
[property: Key(2)] string StreamId,
|
||||
[property: Key(3)] string Kind,
|
||||
[property: Key(4)] long Sequence,
|
||||
[property: Key(5)] long SensorTimestampNs,
|
||||
[property: Key(6)] long ElapsedRealtimeNs,
|
||||
[property: Key(7)] string WallClockUtc,
|
||||
[property: Key(8)] string ClockDomainId,
|
||||
[property: Key(9)] string Format,
|
||||
[property: Key(10)] int? Width,
|
||||
[property: Key(11)] int? Height,
|
||||
[property: Key(12)] int? SampleRate,
|
||||
[property: Key(13)] int? Channels,
|
||||
[property: Key(14)] int? FrameCount,
|
||||
[property: Key(15)] string PayloadEncoding,
|
||||
[property: Key(16)] byte[] Payload);
|
||||
|
||||
public static class MimirCultMeshContractFactory
|
||||
{
|
||||
public static MimirBioacousticCodebookState CreateCodebookState(
|
||||
|
|
|
|||
Loading…
Reference in a new issue