Support avatar video sources for SRTP calls
Use the shared LibVLC audio-video pipeline for camera-free calls on Linux and Android. Add capability signaling, microphone-only Android capture, avatar lifecycle handling and regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
97e197996f
commit
f05dd48ac7
27 changed files with 604 additions and 86 deletions
|
|
@ -37,6 +37,31 @@ public sealed class CallTransportRoutingTests
|
|||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_page_keeps_srtp_avatar_call_and_received_video_available_without_camera_controls()
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling, loadAvatar: (_, _) => Task.FromResult<Bitmap?>(null))
|
||||
{
|
||||
RemoteVideo = new Border()
|
||||
};
|
||||
var chat = new ChatViewModel(settings: new Settings()) { LanCall = lan, IsConnected = true };
|
||||
var page = new CallPage { DataContext = new AudioCallPageViewModel(chat) };
|
||||
var window = new Window { Content = page };
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
Assert.True(page.FindControl<StackPanel>("LanCallPanel")!.IsVisible);
|
||||
Assert.False(page.FindControl<ComboBox>("LanCamera")!.IsVisible);
|
||||
Assert.False(page.FindControl<Button>("LanVideoInvite")!.IsVisible);
|
||||
Assert.True(page.FindControl<Button>("LanAudioInvite")!.IsEffectivelyVisible);
|
||||
var video = page.FindControl<ContentControl>("LanRemoteVideo")!;
|
||||
Assert.True(video.IsEffectivelyVisible);
|
||||
Assert.Same(lan.RemoteVideo, video.Content);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_page_shows_static_image_and_hides_video_and_srtp_controls()
|
||||
{
|
||||
|
|
@ -204,6 +229,8 @@ public sealed class CallTransportRoutingTests
|
|||
throw new NotSupportedException();
|
||||
public Task<CallSession> InviteLanAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task<CallSession> InviteLanAudioAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task AcceptAsync(Guid callId, CancellationToken ct = default) => throw new NotSupportedException();
|
||||
public Task EndAsync(Guid callId, CancellationToken ct = default)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,14 +34,15 @@ public sealed class AndroidLanCallTestActivity : Activity
|
|||
try
|
||||
{
|
||||
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(55));
|
||||
var outcome = await RunAsync(result, Intent?.GetStringExtra("wrongKey") == "true", timeout.Token);
|
||||
var outcome = await RunAsync(result, Intent?.GetStringExtra("wrongKey") == "true",
|
||||
Intent?.GetStringExtra("avatar") == "true", timeout.Token);
|
||||
File.WriteAllText(result, outcome);
|
||||
}
|
||||
catch (Exception error) { File.WriteAllText(result, "FAIL\n" + error); }
|
||||
finally { Finish(); }
|
||||
}
|
||||
|
||||
private async Task<string> RunAsync(string result, bool wrongKey, CancellationToken ct)
|
||||
private async Task<string> RunAsync(string result, bool wrongKey, bool avatar, CancellationToken ct)
|
||||
{
|
||||
StartActivity(new Intent(this, typeof(MainActivity)).AddFlags(ActivityFlags.NewTask));
|
||||
while (!MainActivity.IsForeground || (Avalonia.Application.Current as App)?.View == null)
|
||||
|
|
@ -60,6 +61,7 @@ public sealed class AndroidLanCallTestActivity : Activity
|
|||
var navigation = app.View!.FindControl<NavigationPage>("NavRoot")
|
||||
?? throw new InvalidOperationException("Main navigation unavailable.");
|
||||
var attached = false;
|
||||
var imagePath = Path.Combine(CacheDir!.AbsolutePath, $"lan-call-avatar-{Guid.NewGuid():N}.png");
|
||||
try
|
||||
{
|
||||
await peer.StartReceivingAsync(ct);
|
||||
|
|
@ -87,20 +89,30 @@ public sealed class AndroidLanCallTestActivity : Activity
|
|||
File.WriteAllText(result, "RUNNING\nstage=return SRTP sender");
|
||||
await peer.StartEncodedSendingAsync(call.Endpoint,
|
||||
pipe.ClientSafePipeHandle.DangerousGetHandle().ToInt32(), ct);
|
||||
File.WriteAllText(result, "RUNNING\nstage=enumerating cameras");
|
||||
var devices = AndroidLanCallMedia.GetDevices();
|
||||
var front = devices.Cameras.FirstOrDefault(c => c.Name == "Camera avant")
|
||||
?? throw new InvalidOperationException("Front camera required; no rear-camera fallback.");
|
||||
var endpoint = wrongKey ? peer.Endpoint with { Key = new string('0', 32) } : peer.Endpoint;
|
||||
File.WriteAllText(result, "RUNNING\nstage=front camera and SRTP");
|
||||
await Dispatcher.UIThread.InvokeAsync(() => call.StartSendingAsync(endpoint, front.Value, "microphone", ct));
|
||||
if (avatar)
|
||||
{
|
||||
using var image = PostIt.Helpers.ImageHelper.LoadFromResource(new Uri("avares://PostIt/Assets/Icon.png"));
|
||||
image.Save(imagePath, Avalonia.Media.Imaging.PngBitmapEncoderOptions.Default);
|
||||
File.WriteAllText(result, "RUNNING\nstage=avatar, microphone and SRTP without camera");
|
||||
await Dispatcher.UIThread.InvokeAsync(() => call.StartAvatarSendingAsync(endpoint, imagePath, "microphone", ct));
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllText(result, "RUNNING\nstage=enumerating cameras");
|
||||
var devices = AndroidLanCallMedia.GetDevices();
|
||||
var front = devices.Cameras.FirstOrDefault(c => c.Name == "Camera avant")
|
||||
?? throw new InvalidOperationException("Front camera required; no rear-camera fallback.");
|
||||
File.WriteAllText(result, "RUNNING\nstage=front camera and SRTP");
|
||||
await Dispatcher.UIThread.InvokeAsync(() => call.StartSendingAsync(endpoint, front.Value, "microphone", ct));
|
||||
}
|
||||
File.WriteAllText(result, "RUNNING\nstage=receiving camera and return media");
|
||||
var elapsed = Stopwatch.StartNew();
|
||||
while (elapsed.Elapsed < TimeSpan.FromSeconds(wrongKey ? 10 : 25))
|
||||
{
|
||||
if (call.Completion.IsCompleted) await call.Completion;
|
||||
if (peer.Completion.IsCompleted) await peer.Completion;
|
||||
if (!wrongKey && elapsed.Elapsed >= TimeSpan.FromSeconds(10) &&
|
||||
if (!wrongKey && elapsed.Elapsed >= TimeSpan.FromSeconds(12) &&
|
||||
decoded.Frames >= 100 && decoded.Samples > 144000 && call.HasRemoteMedia) break;
|
||||
await Task.Delay(100, ct);
|
||||
}
|
||||
|
|
@ -108,9 +120,9 @@ public sealed class AndroidLanCallTestActivity : Activity
|
|||
if (wrongKey ? decoded.Frames != 0 || decoded.Samples != 0
|
||||
: decoded.Frames < 100 || decoded.Samples <= 144000)
|
||||
throw new IOException($"Unexpected camera decode: frames={decoded.Frames}, samples={decoded.Samples}.");
|
||||
return $"PASS\nfrontCamera=true\nwrongKey={wrongKey}\n" +
|
||||
return $"PASS\nfrontCamera={!avatar}\navatar={avatar}\nwrongKey={wrongKey}\n" +
|
||||
$"cameraFrames={decoded.Frames}\ncameraAudioSamples={decoded.Samples}\nelapsedMs={elapsed.ElapsedMilliseconds}\nreturnAudioVideo=true\n" +
|
||||
"transport=SRTP/UDP loopback\npreview=attached\nsource=camera+microphone,return=explicit fixture\ncleanup=complete";
|
||||
$"transport=SRTP/UDP loopback\npreview=attached\nsource={(avatar ? "avatar" : "camera")}+microphone,return=explicit fixture\ncleanup=complete";
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -123,6 +135,7 @@ public sealed class AndroidLanCallTestActivity : Activity
|
|||
}
|
||||
File.WriteAllText(result, "RUNNING\nstage=dispose call");
|
||||
if (call != null) await Dispatcher.UIThread.InvokeAsync(async () => await call.DisposeAsync());
|
||||
File.Delete(imagePath);
|
||||
File.WriteAllText(result, "RUNNING\nstage=stop return peer");
|
||||
await peer.StopAsync();
|
||||
source.Dispose();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Media.Imaging;
|
||||
using PostIt.Helpers;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels.Chat;
|
||||
using PostIt.ViewModels;
|
||||
|
|
@ -115,21 +117,102 @@ public sealed class LanCallViewModelTests
|
|||
return vm;
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task Call_without_camera_sends_own_avatar_and_microphone_and_cleans_up(bool caller)
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var media = new FakeMedia();
|
||||
string? avatarUser = null;
|
||||
await using var vm = new LanCallViewModel(signaling, (_, _) => media, loadAvatar: (user, _) =>
|
||||
{
|
||||
avatarUser = user;
|
||||
return Task.FromResult<Bitmap?>(ImageHelper.LoadFromResource(new Uri("avares://PostIt/Assets/Icon.png")));
|
||||
})
|
||||
{
|
||||
Address = "127.0.0.1", Microphone = new("Mic", "default"),
|
||||
AllowAddressDisclosure = true, Room = "General", Target = "bob"
|
||||
};
|
||||
vm.Addresses.Add("127.0.0.1");
|
||||
if (caller) await vm.InviteAudioCommand.ExecuteAsync(null);
|
||||
else
|
||||
{
|
||||
signaling.Invite(vm, signaling.Call with { DisplayMode = CallDisplayMode.AudioOnly });
|
||||
await WaitAsync(() => vm.Incoming);
|
||||
await vm.AcceptCommand.ExecuteAsync(null);
|
||||
}
|
||||
Assert.True(vm.AudioOnly);
|
||||
Assert.Null(vm.Camera);
|
||||
if (caller) signaling.Ready();
|
||||
await WaitAsync(() => signaling.Sent.Count > 0);
|
||||
Assert.Equal(caller ? "alice" : "bob", avatarUser);
|
||||
Assert.Same(media.LocalVideo, vm.LocalVideo);
|
||||
Assert.Same(media.RemoteVideo, vm.RemoteVideo);
|
||||
Assert.False(media.Sending);
|
||||
signaling.RemoteEndpoint(signaling.Call.Id);
|
||||
await WaitAsync(() => media.Sending);
|
||||
Assert.Null(media.Camera);
|
||||
var imagePath = Assert.IsType<string>(media.AvatarPath);
|
||||
Assert.True(File.Exists(imagePath));
|
||||
await vm.HangupAsync();
|
||||
Assert.True(media.Disposed);
|
||||
Assert.False(File.Exists(imagePath));
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Audio_only_invitation_on_srtp_is_rejected_without_opening_media()
|
||||
public async Task Unavailable_own_avatar_ends_call_without_opening_media_or_camera()
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var created = false;
|
||||
await using var vm = Configure(signaling, (_, _) =>
|
||||
await using var vm = new LanCallViewModel(signaling, (_, _) =>
|
||||
{
|
||||
created = true;
|
||||
return new FakeMedia();
|
||||
});
|
||||
signaling.Invite(vm, signaling.Call with { DisplayMode = CallDisplayMode.AudioOnly });
|
||||
await WaitAsync(() => signaling.EndedCalls.Count != 0);
|
||||
}, loadAvatar: (_, _) => Task.FromResult<Bitmap?>(null))
|
||||
{
|
||||
Address = "127.0.0.1", Microphone = new("Mic", "default"),
|
||||
AllowAddressDisclosure = true, Room = "General", Target = "bob"
|
||||
};
|
||||
vm.Addresses.Add("127.0.0.1");
|
||||
await vm.InviteAudioCommand.ExecuteAsync(null);
|
||||
signaling.Ready();
|
||||
await WaitAsync(() => !vm.Busy);
|
||||
Assert.False(created);
|
||||
Assert.Empty(signaling.Sent);
|
||||
Assert.Contains("avatar est indisponible", vm.Status);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Hangup_cancels_pending_avatar_download_without_opening_media()
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var loading = false;
|
||||
var created = false;
|
||||
await using var vm = new LanCallViewModel(signaling, (_, _) =>
|
||||
{
|
||||
created = true;
|
||||
return new FakeMedia();
|
||||
}, loadAvatar: async (_, ct) =>
|
||||
{
|
||||
loading = true;
|
||||
await Task.Delay(Timeout.Infinite, ct);
|
||||
return null;
|
||||
})
|
||||
{
|
||||
Address = "127.0.0.1", Microphone = new("Mic", "default"),
|
||||
AllowAddressDisclosure = true, Room = "General", Target = "bob"
|
||||
};
|
||||
vm.Addresses.Add("127.0.0.1");
|
||||
await vm.InviteAudioCommand.ExecuteAsync(null);
|
||||
signaling.Ready();
|
||||
await WaitAsync(() => loading);
|
||||
await vm.HangupAsync().WaitAsync(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
Assert.False(created);
|
||||
Assert.False(vm.Busy);
|
||||
Assert.Contains("audio seul", vm.Status);
|
||||
Assert.Empty(signaling.Sent);
|
||||
Assert.Contains(signaling.Call.Id, signaling.EndedCalls);
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
|
|
@ -331,11 +414,20 @@ public sealed class LanCallViewModelTests
|
|||
public bool Sending { get; private set; }
|
||||
public bool Disposed { get; private set; }
|
||||
public bool DelayStartup { get; init; }
|
||||
public string? Camera { get; private set; }
|
||||
public string? AvatarPath { get; private set; }
|
||||
public async Task StartSendingAsync(LanCallEndpoint remote, string camera, string microphone, CancellationToken ct)
|
||||
{
|
||||
Sending = true;
|
||||
Camera = camera;
|
||||
if (DelayStartup) await Task.Delay(Timeout.Infinite, ct);
|
||||
}
|
||||
public Task StartAvatarSendingAsync(LanCallEndpoint remote, string imagePath, string microphone, CancellationToken ct)
|
||||
{
|
||||
Sending = true;
|
||||
AvatarPath = imagePath;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public void Fail() => _completion.TrySetException(new IOException("test media failure"));
|
||||
public ValueTask DisposeAsync() { Disposed = true; _completion.TrySetResult(); return ValueTask.CompletedTask; }
|
||||
}
|
||||
|
|
@ -347,18 +439,24 @@ public sealed class LanCallViewModelTests
|
|||
public event Action<CallEnded>? Ended;
|
||||
public event Action<Guid, CallSignal>? Signal;
|
||||
public event Action? Interrupted;
|
||||
public CallSession Call { get; } = Session();
|
||||
public CallSession Call { get; private set; } = Session();
|
||||
public List<CallSignal> Sent { get; } = [];
|
||||
public List<Guid> EndedCalls { get; } = [];
|
||||
public int Invites { get; private set; }
|
||||
public Task<CallSession> InviteLanAsync(string room, string user, CancellationToken ct = default)
|
||||
{ Invites++; return Task.FromResult(Call); }
|
||||
public Task<CallSession> InviteLanAudioAsync(string room, string user, CancellationToken ct = default)
|
||||
{
|
||||
Invites++;
|
||||
Call = Call with { DisplayMode = CallDisplayMode.AudioOnly };
|
||||
return Task.FromResult(Call);
|
||||
}
|
||||
public Task AcceptAsync(Guid id, CancellationToken ct = default) { Ready(); return Task.CompletedTask; }
|
||||
public Task EndAsync(Guid id, CancellationToken ct = default)
|
||||
{ EndedCalls.Add(id); Ended?.Invoke(new(id, "hangup")); return Task.CompletedTask; }
|
||||
public Task SendAsync(Guid id, CallSignal signal, CancellationToken ct = default)
|
||||
{ Sent.Add(signal); return Task.CompletedTask; }
|
||||
public void Invite(LanCallViewModel _, CallSession call) => Invitation?.Invoke(call);
|
||||
public void Invite(LanCallViewModel _, CallSession call) { Call = call; Invitation?.Invoke(call); }
|
||||
public void Ready() => Accepted?.Invoke(new(Call, []));
|
||||
public void RemoteEndpoint(Guid id) => Signal?.Invoke(id, new("rtp-endpoint",
|
||||
Endpoint: new("127.0.0.1", 5006, new string('c', 32), new string('d', 28))));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,120 @@ public sealed class LinuxLanCallMediaTests(ITestOutputHelper output)
|
|||
File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_MEDIA"));
|
||||
public static bool HasTsFixture => OperatingSystem.IsLinux() &&
|
||||
File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_TS"));
|
||||
public static bool HasAudioFixture => OperatingSystem.IsLinux() &&
|
||||
(File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_AUDIO")) ||
|
||||
!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("POSTIT_TEST_AUDIO_SOURCE"))) &&
|
||||
File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_IMAGE"));
|
||||
public static bool HasAacFixture => OperatingSystem.IsLinux() &&
|
||||
File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_AAC")) &&
|
||||
File.Exists(Environment.GetEnvironmentVariable("POSTIT_TEST_IMAGE"));
|
||||
|
||||
[Theory(Skip = "Set POSTIT_TEST_AAC to ADTS and POSTIT_TEST_IMAGE to an avatar; requires Linux LibVLC SRTP.",
|
||||
SkipUnless = nameof(HasAacFixture))]
|
||||
[InlineData("127.0.0.1")]
|
||||
[InlineData("::1")]
|
||||
public async Task Avatar_video_and_live_aac_pipe_use_the_same_libvlc_pipeline(string address)
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
var port = FreePort(address: address);
|
||||
await using var sender = new LibVlcLanCallMedia(address, port, headless: true);
|
||||
await using var receiver = new LibVlcLanCallMedia(address, FreePort(port, address), headless: true);
|
||||
using var decoded = new DecodedVideo(receiver.Receiver);
|
||||
using var pipe = new AnonymousPipeServerStream(PipeDirection.Out);
|
||||
await using var source = File.OpenRead(Environment.GetEnvironmentVariable("POSTIT_TEST_AAC")!);
|
||||
using var lifetime = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||
var pump = Task.Run(async () =>
|
||||
{
|
||||
var buffer = new byte[512];
|
||||
while (await source.ReadAsync(buffer, lifetime.Token) is var count && count > 0)
|
||||
{
|
||||
await pipe.WriteAsync(buffer.AsMemory(0, count), lifetime.Token);
|
||||
await Task.Delay(40, lifetime.Token);
|
||||
}
|
||||
}, ct);
|
||||
try
|
||||
{
|
||||
await receiver.StartReceivingAsync(ct);
|
||||
await sender.StartAvatarSendingAsync(receiver.Endpoint,
|
||||
Environment.GetEnvironmentVariable("POSTIT_TEST_IMAGE")!,
|
||||
$"fd/aac://{pipe.ClientSafePipeHandle.DangerousGetHandle().ToInt32()}", ct);
|
||||
await Task.Delay(TimeSpan.FromSeconds(12), ct);
|
||||
if (sender.Completion.IsCompleted) await sender.Completion;
|
||||
if (receiver.Completion.IsCompleted) await receiver.Completion;
|
||||
Assert.True(receiver.HasRemoteMedia);
|
||||
var frames = decoded.Frames;
|
||||
var samples = decoded.AudioSamples;
|
||||
await Task.Delay(1500, ct);
|
||||
Assert.True(decoded.Frames > frames);
|
||||
Assert.True(decoded.AudioSamples > samples);
|
||||
}
|
||||
finally
|
||||
{
|
||||
lifetime.Cancel();
|
||||
await sender.StopAsync();
|
||||
try { await pump; }
|
||||
catch (OperationCanceledException) when (lifetime.IsCancellationRequested) { }
|
||||
}
|
||||
}
|
||||
|
||||
[Theory(Skip = "Set POSTIT_TEST_AUDIO to WAV and POSTIT_TEST_IMAGE to an avatar; requires Linux LibVLC SRTP.",
|
||||
SkipUnless = nameof(HasAudioFixture))]
|
||||
[InlineData("127.0.0.1", false)]
|
||||
[InlineData("::1", false)]
|
||||
[InlineData("127.0.0.1", true)]
|
||||
[InlineData("::1", true)]
|
||||
public async Task Two_peers_receive_avatar_video_and_audio_beyond_default_image_duration_and_reject_wrong_keys(
|
||||
string address, bool wrongKey)
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
var port = FreePort(address: address);
|
||||
await using var first = new LibVlcLanCallMedia(address, port, headless: true);
|
||||
await using var second = new LibVlcLanCallMedia(address, FreePort(port, address), headless: true);
|
||||
using var firstDecoded = new DecodedVideo(first.Receiver);
|
||||
using var secondDecoded = new DecodedVideo(second.Receiver);
|
||||
await first.StartReceivingAsync(ct);
|
||||
await second.StartReceivingAsync(ct);
|
||||
var image = Environment.GetEnvironmentVariable("POSTIT_TEST_IMAGE")!;
|
||||
var audio = Environment.GetEnvironmentVariable("POSTIT_TEST_AUDIO_SOURCE");
|
||||
if (string.IsNullOrEmpty(audio))
|
||||
{
|
||||
var uri = new Uri(Path.GetFullPath(Environment.GetEnvironmentVariable("POSTIT_TEST_AUDIO")!)).AbsoluteUri;
|
||||
audio = "file/wav:" + uri["file:".Length..];
|
||||
}
|
||||
await first.StartAvatarSendingAsync(wrongKey ? second.Endpoint with { Key = new string('0', 32) }
|
||||
: second.Endpoint, image, audio, ct);
|
||||
await second.StartAvatarSendingAsync(first.Endpoint, image, audio, ct);
|
||||
var elapsed = Stopwatch.StartNew();
|
||||
while (elapsed.Elapsed < TimeSpan.FromSeconds(12))
|
||||
{
|
||||
if (first.Completion.IsCompleted) await first.Completion;
|
||||
if (second.Completion.IsCompleted) await second.Completion;
|
||||
await Task.Delay(100, ct);
|
||||
}
|
||||
var frames = firstDecoded.Frames;
|
||||
var samples = firstDecoded.AudioSamples;
|
||||
var secondFrames = secondDecoded.Frames;
|
||||
var secondSamples = secondDecoded.AudioSamples;
|
||||
await Task.Delay(1500, ct);
|
||||
output.WriteLine($"First: decoded={first.Statistics.DecodedAudio}, samples={firstDecoded.AudioSamples}; " +
|
||||
$"second: decoded={second.Statistics.DecodedAudio}, samples={secondDecoded.AudioSamples}");
|
||||
Assert.True(first.HasRemoteMedia);
|
||||
Assert.True(firstDecoded.AudioSamples > 4800);
|
||||
Assert.True(firstDecoded.Frames > frames);
|
||||
Assert.True(firstDecoded.AudioSamples > samples);
|
||||
if (wrongKey)
|
||||
{
|
||||
Assert.False(second.HasRemoteMedia);
|
||||
Assert.Equal(0, secondDecoded.AudioSamples);
|
||||
Assert.Equal(0, secondDecoded.Frames);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.True(second.HasRemoteMedia);
|
||||
Assert.True(secondDecoded.AudioSamples > secondSamples);
|
||||
Assert.True(secondDecoded.Frames > secondFrames);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory(Skip = "Requires Linux LibVLC.", SkipUnless = nameof(HasFixture))]
|
||||
[InlineData("127.0.0.1")]
|
||||
|
|
|
|||
|
|
@ -354,6 +354,8 @@ public sealed class WebRtcCallViewModelTests
|
|||
}
|
||||
public Task<CallSession> InviteLanAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new InvalidOperationException("Legacy LAN transport must not be used");
|
||||
public Task<CallSession> InviteLanAudioAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new InvalidOperationException("Legacy LAN transport must not be used");
|
||||
public Task AcceptAsync(Guid callId, CancellationToken ct = default) { Ready(); return Task.CompletedTask; }
|
||||
public Task EndAsync(Guid callId, CancellationToken ct = default)
|
||||
{ EndedCalls.Add(callId); return Task.CompletedTask; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue