Slight renaming

This commit is contained in:
Malte Rosenbjerg 2020-05-11 00:50:49 +02:00
parent b854d5b43b
commit f896ec126f
7 changed files with 16 additions and 39 deletions

View file

@ -24,7 +24,7 @@ public override async Task ProcessDataAsync(CancellationToken token)
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
if (!Pipe.IsConnected)
throw new TaskCanceledException();
await Writer.WriteDataAsync(Pipe, token).ConfigureAwait(false);
await Writer.CopyAsync(Pipe, token).ConfigureAwait(false);
}
}
}

View file

@ -21,7 +21,7 @@ public override async Task ProcessDataAsync(CancellationToken token)
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
if (!Pipe.IsConnected)
throw new TaskCanceledException();
await Reader.ReadDataAsync(Pipe, token).ConfigureAwait(false);
await Reader.CopyAsync(Pipe, token).ConfigureAwait(false);
}
}
}

View file

@ -5,8 +5,7 @@ namespace FFMpegCore.Pipes
{
public interface IPipeDataReader
{
void ReadData(System.IO.Stream stream);
Task ReadDataAsync(System.IO.Stream stream, CancellationToken token);
Task CopyAsync(System.IO.Stream inputStream, CancellationToken cancellationToken);
string GetFormat();
}
}

View file

@ -9,7 +9,6 @@ namespace FFMpegCore.Pipes
public interface IPipeDataWriter
{
string GetFormat();
void WriteData(System.IO.Stream pipe);
Task WriteDataAsync(System.IO.Stream pipe, CancellationToken token);
Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken);
}
}

View file

@ -45,31 +45,18 @@ public string GetFormat()
return $"-f rawvideo -r {FrameRate} -pix_fmt {StreamFormat} -s {Width}x{Height}";
}
public void WriteData(System.IO.Stream stream)
public async Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken)
{
if (_framesEnumerator.Current != null)
{
CheckFrameAndThrow(_framesEnumerator.Current);
_framesEnumerator.Current.Serialize(stream);
await _framesEnumerator.Current.SerializeAsync(outputStream, cancellationToken).ConfigureAwait(false);
}
while (_framesEnumerator.MoveNext())
{
CheckFrameAndThrow(_framesEnumerator.Current!);
_framesEnumerator.Current!.Serialize(stream);
}
}
public async Task WriteDataAsync(System.IO.Stream stream, CancellationToken token)
{
if (_framesEnumerator.Current != null)
{
await _framesEnumerator.Current.SerializeAsync(stream, token).ConfigureAwait(false);
}
while (_framesEnumerator.MoveNext())
{
await _framesEnumerator.Current!.SerializeAsync(stream, token).ConfigureAwait(false);
await _framesEnumerator.Current!.SerializeAsync(outputStream, cancellationToken).ConfigureAwait(false);
}
}

View file

@ -5,24 +5,18 @@ namespace FFMpegCore.Pipes
{
public class StreamPipeDataReader : IPipeDataReader
{
public System.IO.Stream DestanationStream { get; private set; }
public System.IO.Stream Destination { get; }
public int BlockSize { get; set; } = 4096;
public string Format { get; set; } = string.Empty;
public StreamPipeDataReader(System.IO.Stream destanationStream)
public StreamPipeDataReader(System.IO.Stream destination)
{
DestanationStream = destanationStream;
Destination = destination;
}
public void ReadData(System.IO.Stream stream) =>
stream.CopyTo(DestanationStream, BlockSize);
public Task CopyAsync(System.IO.Stream inputStream, CancellationToken cancellationToken) =>
inputStream.CopyToAsync(Destination, BlockSize, cancellationToken);
public Task ReadDataAsync(System.IO.Stream stream, CancellationToken token) =>
stream.CopyToAsync(DestanationStream, BlockSize, token);
public string GetFormat()
{
return Format;
}
public string GetFormat() => Format;
}
}

View file

@ -12,14 +12,12 @@ public class StreamPipeDataWriter : IPipeDataWriter
public int BlockSize { get; } = 4096;
public string StreamFormat { get; } = string.Empty;
public StreamPipeDataWriter(System.IO.Stream stream)
public StreamPipeDataWriter(System.IO.Stream source)
{
Source = stream;
Source = source;
}
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 Task CopyAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) => Source.CopyToAsync(outputStream, BlockSize, cancellationToken);
public string GetFormat() => StreamFormat;
}