33 lines
1 KiB
C#
33 lines
1 KiB
C#
|
|
using System.Runtime.CompilerServices;
|
||
|
|
using Surveillance.Client.Media;
|
||
|
|
using Surveillance.Media.FFmpegCore;
|
||
|
|
using Xunit;
|
||
|
|
|
||
|
|
namespace Surveillance.Media.FFmpegCore.Tests;
|
||
|
|
|
||
|
|
public sealed class FfmpegCoreLiveVideoDecoderTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public async Task RejectsDecodedFramesAboveConfiguredMemoryLimit()
|
||
|
|
{
|
||
|
|
var decoder = new FfmpegCoreLiveVideoDecoder();
|
||
|
|
var stream = new VideoStreamDescriptor(VideoCodec.H264, 4097, 4096);
|
||
|
|
|
||
|
|
await Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () =>
|
||
|
|
{
|
||
|
|
await foreach (var _ in decoder.DecodeAsync(
|
||
|
|
stream,
|
||
|
|
EmptyPackets(TestContext.Current.CancellationToken),
|
||
|
|
TestContext.Current.CancellationToken))
|
||
|
|
{
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
private static async IAsyncEnumerable<EncodedVideoPacket> EmptyPackets(
|
||
|
|
[EnumeratorCancellation] CancellationToken cancellationToken = default)
|
||
|
|
{
|
||
|
|
await Task.CompletedTask;
|
||
|
|
yield break;
|
||
|
|
}
|
||
|
|
}
|