Port audio sync delay measurement

This commit is contained in:
Meta Vens 2026-05-22 01:22:36 +01:00
commit 45de299606
13 changed files with 349 additions and 12 deletions

View file

@ -153,6 +153,8 @@ public sealed class MimirFrameEventProcessStreamSource : IMimirStreamSource
}
var sequence = frameEvent.Sequence ?? fallbackSequence++;
var data = DecodePayload(frameEvent.SamplesBase64, byteLength);
sample = new MimirStreamSample(
sourceId,
sampleKind,
@ -162,12 +164,30 @@ public sealed class MimirFrameEventProcessStreamSource : IMimirStreamSource
sequence,
payloadHandle,
byteLength,
default,
data,
videoFrame,
audioBlock);
return true;
}
private static ReadOnlyMemory<byte> DecodePayload(string? base64, int expectedBytes)
{
if (string.IsNullOrWhiteSpace(base64))
{
return default;
}
try
{
var data = Convert.FromBase64String(base64);
return expectedBytes <= 0 || data.Length == expectedBytes ? data : default;
}
catch (FormatException)
{
return default;
}
}
private bool AcceptsSourceId(string sourceId)
{
if (Options.AcceptedSourceIds is { Count: > 0 } acceptedSourceIds)
@ -308,6 +328,8 @@ public sealed class MimirFrameEventProcessStreamSource : IMimirStreamSource
public int FrameCount { get; set; }
public string? SamplesBase64 { get; set; }
public ulong NativeHandle { get; set; }
public string? NativeHandleKind { get; set; }