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