FFMpegCore/FFMpegCore/FFMpeg/Pipes/StreamPipeDataWriter.cs
2020-05-11 00:34:17 +02:00

26 lines
815 B
C#

using System.Threading;
using System.Threading.Tasks;
namespace FFMpegCore.Pipes
{
/// <summary>
/// Implementation of <see cref="IPipeDataWriter"/> used for stream redirection
/// </summary>
public class StreamPipeDataWriter : IPipeDataWriter
{
public System.IO.Stream Source { get; }
public int BlockSize { get; } = 4096;
public string StreamFormat { get; } = string.Empty;
public StreamPipeDataWriter(System.IO.Stream stream)
{
Source = stream;
}
public void WriteData(System.IO.Stream pipe) => Source.CopyTo(pipe, BlockSize);
public Task WriteDataAsync(System.IO.Stream pipe, CancellationToken token) => Source.CopyToAsync(pipe, BlockSize, token);
public string GetFormat() => StreamFormat;
}
}