mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Move System.IO
in using
s on some classes
This commit is contained in:
parent
cce6c6983c
commit
e10657169e
7 changed files with 21 additions and 15 deletions
|
@ -1,10 +1,11 @@
|
||||||
using System;
|
using FFMpegCore.Pipes;
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFMpegCore.Pipes;
|
|
||||||
|
|
||||||
namespace FFMpegCore.Extend
|
namespace FFMpegCore.Extend
|
||||||
{
|
{
|
||||||
|
@ -24,7 +25,7 @@ public BitmapVideoFrameWrapper(Bitmap bitmap)
|
||||||
Format = ConvertStreamFormat(bitmap.PixelFormat);
|
Format = ConvertStreamFormat(bitmap.PixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Serialize(System.IO.Stream stream)
|
public void Serialize(Stream stream)
|
||||||
{
|
{
|
||||||
var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat);
|
var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat);
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public void Serialize(System.IO.Stream stream)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SerializeAsync(System.IO.Stream stream, CancellationToken token)
|
public async Task SerializeAsync(Stream stream, CancellationToken token)
|
||||||
{
|
{
|
||||||
var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat);
|
var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat);
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
using System.Threading;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FFMpegCore.Pipes
|
namespace FFMpegCore.Pipes
|
||||||
{
|
{
|
||||||
public interface IPipeSink
|
public interface IPipeSink
|
||||||
{
|
{
|
||||||
Task ReadAsync(System.IO.Stream inputStream, CancellationToken cancellationToken);
|
Task ReadAsync(Stream inputStream, CancellationToken cancellationToken);
|
||||||
string GetFormat();
|
string GetFormat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FFMpegCore.Pipes
|
namespace FFMpegCore.Pipes
|
||||||
|
@ -9,6 +10,6 @@ namespace FFMpegCore.Pipes
|
||||||
public interface IPipeSource
|
public interface IPipeSource
|
||||||
{
|
{
|
||||||
string GetStreamArguments();
|
string GetStreamArguments();
|
||||||
Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken);
|
Task WriteAsync(Stream outputStream, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FFMpegCore.Pipes
|
namespace FFMpegCore.Pipes
|
||||||
|
@ -12,7 +13,7 @@ public interface IVideoFrame
|
||||||
int Height { get; }
|
int Height { get; }
|
||||||
string Format { get; }
|
string Format { get; }
|
||||||
|
|
||||||
void Serialize(System.IO.Stream pipe);
|
void Serialize(Stream pipe);
|
||||||
Task SerializeAsync(System.IO.Stream pipe, CancellationToken token);
|
Task SerializeAsync(Stream pipe, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FFMpegCore.Exceptions;
|
using FFMpegCore.Exceptions;
|
||||||
|
@ -46,7 +47,7 @@ public string GetStreamArguments()
|
||||||
return $"-f rawvideo -r {FrameRate.ToString(CultureInfo.InvariantCulture)} -pix_fmt {StreamFormat} -s {Width}x{Height}";
|
return $"-f rawvideo -r {FrameRate.ToString(CultureInfo.InvariantCulture)} -pix_fmt {StreamFormat} -s {Width}x{Height}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken)
|
public async Task WriteAsync(Stream outputStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (_framesEnumerator.Current != null)
|
if (_framesEnumerator.Current != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ public StreamPipeSink(Stream destination)
|
||||||
Writer = (inputStream, cancellationToken) => inputStream.CopyToAsync(destination, BlockSize, cancellationToken);
|
Writer = (inputStream, cancellationToken) => inputStream.CopyToAsync(destination, BlockSize, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task ReadAsync(System.IO.Stream inputStream, CancellationToken cancellationToken)
|
public Task ReadAsync(Stream inputStream, CancellationToken cancellationToken)
|
||||||
=> Writer(inputStream, cancellationToken);
|
=> Writer(inputStream, cancellationToken);
|
||||||
|
|
||||||
public string GetFormat() => Format;
|
public string GetFormat() => Format;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Threading;
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FFMpegCore.Pipes
|
namespace FFMpegCore.Pipes
|
||||||
|
@ -19,6 +20,6 @@ public StreamPipeSource(System.IO.Stream source)
|
||||||
|
|
||||||
public string GetStreamArguments() => StreamFormat;
|
public string GetStreamArguments() => StreamFormat;
|
||||||
|
|
||||||
public Task WriteAsync(System.IO.Stream outputStream, CancellationToken cancellationToken) => Source.CopyToAsync(outputStream, BlockSize, cancellationToken);
|
public Task WriteAsync(Stream outputStream, CancellationToken cancellationToken) => Source.CopyToAsync(outputStream, BlockSize, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue