mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
StreamPipeDataWriter & StreamPipeDataReader using Stream.CopyTo
This commit is contained in:
parent
b007e9105a
commit
f132a3b731
2 changed files with 8 additions and 32 deletions
|
@ -16,21 +16,11 @@ public StreamPipeDataReader(System.IO.Stream destanationStream)
|
||||||
DestanationStream = destanationStream;
|
DestanationStream = destanationStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadData(System.IO.Stream stream)
|
public void ReadData(System.IO.Stream stream) =>
|
||||||
{
|
stream.CopyTo(DestanationStream, BlockSize);
|
||||||
int read;
|
|
||||||
var buffer = new byte[BlockSize];
|
|
||||||
while ((read = stream.Read(buffer, 0, buffer.Length)) != 0)
|
|
||||||
DestanationStream.Write(buffer, 0, buffer.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ReadDataAsync(System.IO.Stream stream)
|
public Task ReadDataAsync(System.IO.Stream stream) =>
|
||||||
{
|
stream.CopyToAsync(DestanationStream, BlockSize);
|
||||||
int read;
|
|
||||||
var buffer = new byte[BlockSize];
|
|
||||||
while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) != 0)
|
|
||||||
await DestanationStream.WriteAsync(buffer, 0, buffer.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetFormat()
|
public string GetFormat()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,25 +19,11 @@ public StreamPipeDataWriter(System.IO.Stream stream)
|
||||||
Source = stream;
|
Source = stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteData(System.IO.Stream pipe)
|
public void WriteData(System.IO.Stream pipe)=>
|
||||||
{
|
Source.CopyTo(pipe, BlockSize);
|
||||||
var buffer = new byte[BlockSize];
|
|
||||||
int read;
|
|
||||||
while ((read = Source.Read(buffer, 0, buffer.Length)) != 0)
|
|
||||||
{
|
|
||||||
pipe.Write(buffer, 0, read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task WriteDataAsync(System.IO.Stream pipe)
|
public Task WriteDataAsync(System.IO.Stream pipe) =>
|
||||||
{
|
Source.CopyToAsync(pipe, BlockSize);
|
||||||
var buffer = new byte[BlockSize];
|
|
||||||
int read;
|
|
||||||
while ((read = await Source.ReadAsync(buffer, 0, buffer.Length)) != 0)
|
|
||||||
{
|
|
||||||
await pipe.WriteAsync(buffer, 0, read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetFormat()
|
public string GetFormat()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue