Add native video frame ingest descriptor
This commit is contained in:
parent
a22fa0745c
commit
493b9ac3c7
14 changed files with 89 additions and 5 deletions
|
|
@ -19,7 +19,8 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
long arrivalNs,
|
||||
ulong payloadHandle,
|
||||
int byteLength = 0,
|
||||
ReadOnlyMemory<byte> data = default)
|
||||
ReadOnlyMemory<byte> data = default,
|
||||
MimirVideoFrameDescriptor? videoFrame = null)
|
||||
{
|
||||
samples.Enqueue(new MimirStreamSample(
|
||||
Descriptor.SourceId,
|
||||
|
|
@ -30,7 +31,27 @@ public sealed class MimirNativeIngestStreamSource : IMimirStreamSource
|
|||
sequence++,
|
||||
payloadHandle,
|
||||
byteLength,
|
||||
data));
|
||||
data,
|
||||
videoFrame));
|
||||
}
|
||||
|
||||
public void PushVideoFrame(
|
||||
MimirVideoFrameDescriptor frame,
|
||||
long arrivalNs,
|
||||
ReadOnlyMemory<byte> data = default)
|
||||
{
|
||||
if (Descriptor.Kind != MimirStreamKind.Video)
|
||||
{
|
||||
throw new InvalidOperationException("Video frames can only be pushed into a video stream source.");
|
||||
}
|
||||
|
||||
Push(
|
||||
frame.DeviceTimestampNs,
|
||||
arrivalNs,
|
||||
frame.NativeHandle,
|
||||
data.Length,
|
||||
data,
|
||||
frame);
|
||||
}
|
||||
|
||||
public bool TryRead(out MimirStreamSample sample)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ public sealed class MimirProcessStreamSource : IMimirStreamSource
|
|||
sequence++,
|
||||
0,
|
||||
buffer.Length,
|
||||
buffer));
|
||||
buffer,
|
||||
null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ public sealed class MimirRuntimeConfiguration
|
|||
|
||||
private static IMimirStreamSource? TryCreateSource(MimirStreamConfig stream)
|
||||
{
|
||||
if (string.Equals(stream.Adapter, "native", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new MimirNativeIngestStreamSource(ToDescriptor(stream));
|
||||
}
|
||||
|
||||
if (!string.Equals(stream.Adapter, "process", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ public readonly record struct MimirStreamSample(
|
|||
ulong Sequence,
|
||||
ulong PayloadHandle,
|
||||
int ByteLength = 0,
|
||||
ReadOnlyMemory<byte> Data = default);
|
||||
ReadOnlyMemory<byte> Data = default,
|
||||
MimirVideoFrameDescriptor? VideoFrame = null);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
public enum MimirVideoPixelFormat
|
||||
{
|
||||
Unknown,
|
||||
Gray8,
|
||||
R8,
|
||||
Rg8,
|
||||
Bgra8,
|
||||
Nv12,
|
||||
LeapStereoIr,
|
||||
}
|
||||
|
||||
public sealed record MimirVideoFrameDescriptor(
|
||||
int Width,
|
||||
int Height,
|
||||
MimirVideoPixelFormat PixelFormat,
|
||||
int StrideBytes,
|
||||
long DeviceTimestampNs,
|
||||
ulong NativeHandle = 0,
|
||||
string NativeHandleKind = "");
|
||||
Loading…
Reference in a new issue