mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Simplified ContainsInputOutput implementation
Former-commit-id: 1d51163a05
This commit is contained in:
parent
b0aedbad87
commit
e462b424eb
3 changed files with 16 additions and 8 deletions
|
@ -72,7 +72,7 @@ private void ConvertFromStreamPipe(VideoType type, ArgumentContainer container)
|
||||||
var input = VideoInfo.FromFileInfo(VideoLibrary.LocalVideoWebm);
|
var input = VideoInfo.FromFileInfo(VideoLibrary.LocalVideoWebm);
|
||||||
using (var inputStream = System.IO.File.OpenRead(input.FullName))
|
using (var inputStream = System.IO.File.OpenRead(input.FullName))
|
||||||
{
|
{
|
||||||
var pipeSource = new StreamPipeSource(inputStream);
|
var pipeSource = new StreamPipeDataWriter(inputStream);
|
||||||
var arguments = new ArgumentContainer { new InputPipeArgument(pipeSource) };
|
var arguments = new ArgumentContainer { new InputPipeArgument(pipeSource) };
|
||||||
foreach (var arg in container)
|
foreach (var arg in container)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ public void ConvertFromPipe(VideoType type, ArgumentContainer container, PixelFo
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var videoFramesSource = new RawVideoPipeSource(BitmapSource.CreateBitmaps(128, fmt, 256, 256));
|
var videoFramesSource = new RawVideoPipeDataWriter(BitmapSource.CreateBitmaps(128, fmt, 256, 256));
|
||||||
var arguments = new ArgumentContainer { new InputPipeArgument(videoFramesSource) };
|
var arguments = new ArgumentContainer { new InputPipeArgument(videoFramesSource) };
|
||||||
foreach (var arg in container)
|
foreach (var arg in container)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,10 +102,8 @@ public void Add(params Argument[] values)
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool ContainsInputOutput()
|
public bool ContainsInputOutput()
|
||||||
{
|
{
|
||||||
return ((ContainsKey(typeof(InputArgument)) && !ContainsKey(typeof(ConcatArgument)) && !ContainsKey(typeof(InputPipeArgument))) ||
|
return CountExistedKeys(typeof(InputArgument), typeof(ConcatArgument), typeof(InputPipeArgument)) == 1 &&
|
||||||
(!ContainsKey(typeof(InputArgument)) && ContainsKey(typeof(ConcatArgument)) && !ContainsKey(typeof(InputPipeArgument))) ||
|
CountExistedKeys(typeof(OutputArgument), typeof(OutputPipeArgument)) == 1;
|
||||||
(!ContainsKey(typeof(InputArgument)) && !ContainsKey(typeof(ConcatArgument)) && ContainsKey(typeof(InputPipeArgument))))
|
|
||||||
&& ContainsKey(typeof(OutputArgument));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -118,6 +116,16 @@ public bool ContainsKey(Type key)
|
||||||
return _args.ContainsKey(key);
|
return _args.ContainsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int CountExistedKeys(params Type[] types)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for(int i =0; i < types.Length; i++)
|
||||||
|
if (_args.ContainsKey(types[i]))
|
||||||
|
count++;
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<Type, Argument>[] array, int arrayIndex)
|
public void CopyTo(KeyValuePair<Type, Argument>[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
_args.CopyTo(array, arrayIndex);
|
_args.CopyTo(array, arrayIndex);
|
||||||
|
|
|
@ -75,7 +75,7 @@ public async Task<VideoInfo> ParseVideoInfoAsync(VideoInfo info)
|
||||||
public VideoInfo ParseVideoInfo(System.IO.Stream stream)
|
public VideoInfo ParseVideoInfo(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
var info = new VideoInfo();
|
var info = new VideoInfo();
|
||||||
var streamPipeSource = new StreamPipeSource(stream);
|
var streamPipeSource = new StreamPipeDataWriter(stream);
|
||||||
var pipeArgument = new InputPipeArgument(streamPipeSource);
|
var pipeArgument = new InputPipeArgument(streamPipeSource);
|
||||||
|
|
||||||
var instance = new Instance(_ffprobePath, BuildFFProbeArguments(pipeArgument.PipePath)) { DataBufferCapacity = _outputCapacity };
|
var instance = new Instance(_ffprobePath, BuildFFProbeArguments(pipeArgument.PipePath)) { DataBufferCapacity = _outputCapacity };
|
||||||
|
@ -105,7 +105,7 @@ public VideoInfo ParseVideoInfo(System.IO.Stream stream)
|
||||||
public async Task<VideoInfo> ParseVideoInfoAsync(System.IO.Stream stream)
|
public async Task<VideoInfo> ParseVideoInfoAsync(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
var info = new VideoInfo();
|
var info = new VideoInfo();
|
||||||
var streamPipeSource = new StreamPipeSource(stream);
|
var streamPipeSource = new StreamPipeDataWriter(stream);
|
||||||
var pipeArgument = new InputPipeArgument(streamPipeSource);
|
var pipeArgument = new InputPipeArgument(streamPipeSource);
|
||||||
|
|
||||||
var instance = new Instance(_ffprobePath, BuildFFProbeArguments(pipeArgument.PipePath)) { DataBufferCapacity = _outputCapacity };
|
var instance = new Instance(_ffprobePath, BuildFFProbeArguments(pipeArgument.PipePath)) { DataBufferCapacity = _outputCapacity };
|
||||||
|
|
Loading…
Reference in a new issue