Beispiel #1
0
        public async Task WriteAviHeaderTest()
        {
            byte[] expected = new byte[0x480c];

            using (Stream stream = File.OpenRead(@"VMware\VS2k5DebugDemo-01.avi"))
            {
                stream.Read(expected, 0, expected.Length);
            }

            bool isFirst = true;

            using (MemoryStream output = new MemoryStream())
            {
                var framebufferSource = new Mock <IVncFramebufferSource>();
                framebufferSource
                .Setup(f => f.Capture())
                .Returns(
                    () =>
                {
                    if (isFirst)
                    {
                        isFirst = false;
                        return(new VncFramebuffer("My Framebuffer", width: 0x4f4, height: 0x3c1, pixelFormat: VncPixelFormat.RGB32));
                    }
                    else
                    {
                        return(null);
                    }
                });

                VncAviWriter aviWriter = new VncAviWriter(framebufferSource.Object);
                aviWriter.ExpectedSize        = 0x0031dfe4;
                aviWriter.ExpectedTotalFrames = 0x13e;
                Assert.Equal(200_000, aviWriter.MicrosecondsPerFrame);
                await aviWriter.WriteAsync(output, CancellationToken.None).ConfigureAwait(false);

                byte[] actual = output.ToArray();
                File.WriteAllBytes("actual.bin", actual);

                Assert.Equal(expected, actual);
            }
        }
        /// <summary>
        /// Listen to the given <see cref="HttpContext"/>
        /// </summary>
        /// <returns>
        /// A <see cref="Task"/> corresponding to the listen process.
        /// </returns>
        public Task Listen(CancellationToken cancellation)
        {
            VncAviWriter writer = new VncAviWriter(this.FramebufferSource);

            return(writer.WriteAsync(this.Stream, cancellation));
        }