Add LocalCast render packet descriptor binding
This commit is contained in:
parent
34694e6108
commit
9eb40cf6c4
2 changed files with 72 additions and 0 deletions
|
|
@ -53,6 +53,21 @@ public struct LocalCastNativeAudioBlockDescriptor
|
|||
public ulong ChannelLayoutHash;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LocalCastNativeRenderPacketDescriptor
|
||||
{
|
||||
public ulong PointBufferHandle;
|
||||
public uint PointCount;
|
||||
public uint PointStrideBytes;
|
||||
public uint TargetWidth;
|
||||
public uint TargetHeight;
|
||||
public ulong SourceTimeMinNs;
|
||||
public ulong SourceTimeMaxNs;
|
||||
public ulong PresentTimeNs;
|
||||
public ulong AudioAlignmentTimeNs;
|
||||
public ulong MetadataHandle;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct LocalCastNativeRuntimeStatus
|
||||
{
|
||||
|
|
@ -92,6 +107,12 @@ public interface ILocalCastNativeProducer : IDisposable
|
|||
ulong arrivalNs,
|
||||
in LocalCastNativeAudioBlockDescriptor descriptor,
|
||||
out LocalCastNativeSampleHandle sample);
|
||||
|
||||
bool TryPushRenderPacket(
|
||||
ulong timestampNs,
|
||||
ulong arrivalNs,
|
||||
in LocalCastNativeRenderPacketDescriptor descriptor,
|
||||
out LocalCastNativeSampleHandle sample);
|
||||
}
|
||||
|
||||
public sealed class LocalCastNativeRuntime : ILocalCastNativeRuntime
|
||||
|
|
@ -198,6 +219,16 @@ public sealed class LocalCastNativeProducer : ILocalCastNativeProducer
|
|||
return LocalCastNativeMethods.ProducerPushAudioBlock(handle, runtime.Handle, timestampNs, arrivalNs, in descriptor, out sample);
|
||||
}
|
||||
|
||||
public bool TryPushRenderPacket(
|
||||
ulong timestampNs,
|
||||
ulong arrivalNs,
|
||||
in LocalCastNativeRenderPacketDescriptor descriptor,
|
||||
out LocalCastNativeSampleHandle sample)
|
||||
{
|
||||
EnsureNotDisposed();
|
||||
return LocalCastNativeMethods.ProducerPushRenderPacket(handle, runtime.Handle, timestampNs, arrivalNs, in descriptor, out sample);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
|
|
@ -281,4 +312,14 @@ internal static class LocalCastNativeMethods
|
|||
ulong arrivalNs,
|
||||
in LocalCastNativeAudioBlockDescriptor descriptor,
|
||||
out LocalCastNativeSampleHandle sample);
|
||||
|
||||
[DllImport(LibraryName, EntryPoint = "localcast_producer_push_render_packet")]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
internal static extern bool ProducerPushRenderPacket(
|
||||
IntPtr producer,
|
||||
IntPtr runtime,
|
||||
ulong timestampNs,
|
||||
ulong arrivalNs,
|
||||
in LocalCastNativeRenderPacketDescriptor descriptor,
|
||||
out LocalCastNativeSampleHandle sample);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,37 @@ public sealed class LocalCastNativeReservoirTests
|
|||
Assert.Equal(77u, descriptor.ChannelLayoutHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RenderPacketDescriptorLayoutMatchesNativeAbi()
|
||||
{
|
||||
Assert.Equal(64, Marshal.SizeOf<LocalCastNativeRenderPacketDescriptor>());
|
||||
|
||||
var descriptor = new LocalCastNativeRenderPacketDescriptor
|
||||
{
|
||||
PointBufferHandle = 99,
|
||||
PointCount = 4096,
|
||||
PointStrideBytes = 64,
|
||||
TargetWidth = 1920,
|
||||
TargetHeight = 1080,
|
||||
SourceTimeMinNs = 1_000,
|
||||
SourceTimeMaxNs = 2_000,
|
||||
PresentTimeNs = 2_350,
|
||||
AudioAlignmentTimeNs = 2_300,
|
||||
MetadataHandle = 77,
|
||||
};
|
||||
|
||||
Assert.Equal(99u, descriptor.PointBufferHandle);
|
||||
Assert.Equal(4096u, descriptor.PointCount);
|
||||
Assert.Equal(64u, descriptor.PointStrideBytes);
|
||||
Assert.Equal(1920u, descriptor.TargetWidth);
|
||||
Assert.Equal(1080u, descriptor.TargetHeight);
|
||||
Assert.Equal(1_000u, descriptor.SourceTimeMinNs);
|
||||
Assert.Equal(2_000u, descriptor.SourceTimeMaxNs);
|
||||
Assert.Equal(2_350u, descriptor.PresentTimeNs);
|
||||
Assert.Equal(2_300u, descriptor.AudioAlignmentTimeNs);
|
||||
Assert.Equal(77u, descriptor.MetadataHandle);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RuntimeStatusLayoutUsesNativeSizeCounts()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue