Add adaptive packet loss handling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using VoiceCat.Server.Data;
|
||||
using VoiceCat.Protocol;
|
||||
using Voicecat.V1;
|
||||
using static VoiceCat.Tests.ServerTests;
|
||||
|
||||
@@ -11,7 +12,8 @@ public class ChannelManagementTests
|
||||
using (var store = new AccountStore(Path.Combine(fixture.Directory, "voicecat.db")))
|
||||
await store.CreateAccountAsync("Admin", "secret", true);
|
||||
Client client = await fixture.ConnectAsync();
|
||||
client.Send(new() { ClientHello = new() { ProtoVersion = 2 } });
|
||||
var hello = new ClientHello { ProtoVersion = 2 }; hello.Features.Add(ProtocolFeatures.AdaptivePacketLoss);
|
||||
client.Send(new() { ClientHello = hello });
|
||||
await client.ReadUntilAsync(e => e.ServerHello is not null);
|
||||
client.Send(new() { AuthRequest = new() { Password = new() { Username = "Admin", Password = "secret" } } });
|
||||
Assert.True((await client.ReadUntilAsync(e => e.AuthResult is not null)).AuthResult.Ok);
|
||||
@@ -114,6 +116,7 @@ public class ChannelManagementTests
|
||||
music.Audio.Dtx = true;
|
||||
music.Audio.Fec = true;
|
||||
music.Audio.Dred = true;
|
||||
music.Audio.PacketLossMode = PacketLossMode.PacketLossAutoStable;
|
||||
music.Audio.Complexity = 10;
|
||||
Assert.True(await ResultAsync(admin, new() { EditChannel = new() { Channel = music } }));
|
||||
}
|
||||
@@ -126,6 +129,36 @@ public class ChannelManagementTests
|
||||
Assert.True(audio.Dtx);
|
||||
Assert.True(audio.Fec);
|
||||
Assert.True(audio.Dred);
|
||||
Assert.Equal(PacketLossMode.PacketLossAutoStable, audio.PacketLossMode);
|
||||
Assert.Equal(10U, audio.Complexity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LegacyAdministratorEditsPreserveAutomaticPacketLossMode()
|
||||
{
|
||||
await using var fixture = new ServerFixture();
|
||||
await using var current = await AdminAsync(fixture);
|
||||
Channel music;
|
||||
using (var store = new AccountStore(Path.Combine(fixture.Directory, "voicecat.db")))
|
||||
{
|
||||
music = store.LoadChannels().Single(channel => channel.Name == "Music Room");
|
||||
music.Audio.PacketLossMode = PacketLossMode.PacketLossAutoBalanced;
|
||||
}
|
||||
Assert.True(await ResultAsync(current, new() { EditChannel = new() { Channel = music } }));
|
||||
|
||||
await using Client legacy = await fixture.ConnectAsync();
|
||||
legacy.Send(new() { ClientHello = new() { ProtoVersion = 2 } });
|
||||
await legacy.ReadUntilAsync(envelope => envelope.ServerHello is not null);
|
||||
legacy.Send(new() { AuthRequest = new() { Password = new() { Username = "Admin", Password = "secret" } } });
|
||||
Assert.True((await legacy.ReadUntilAsync(envelope => envelope.AuthResult is not null)).AuthResult.Ok);
|
||||
await legacy.ReadUntilAsync(envelope => envelope.ServerState is not null);
|
||||
music.Audio.PacketLossMode = PacketLossMode.PacketLossManual;
|
||||
music.Audio.ExpectedPacketLoss = 23;
|
||||
Assert.True(await ResultAsync(legacy, new() { EditChannel = new() { Channel = music } }));
|
||||
|
||||
using var verify = new AccountStore(Path.Combine(fixture.Directory, "voicecat.db"));
|
||||
AudioConfig saved = verify.LoadChannels().Single(channel => channel.Id == music.Id).Audio;
|
||||
Assert.Equal(PacketLossMode.PacketLossAutoBalanced, saved.PacketLossMode);
|
||||
Assert.Equal(23U, saved.ExpectedPacketLoss);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user