This commit is contained in:
Malte Rosenbjerg 2020-10-27 00:49:28 +01:00
parent 31685da18a
commit 6b1e411bfe
12 changed files with 11 additions and 15 deletions

View file

@ -2,7 +2,6 @@
using System;
using FFMpegCore.Arguments;
using FFMpegCore.Enums;
using FFMpegCore.Exceptions;
namespace FFMpegCore.Test
{

View file

@ -18,7 +18,7 @@ public ConcatArgument(IEnumerable<string> values)
}
public void Pre() { }
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
public void Post() { }
public string Text => $"-i \"concat:{string.Join(@"|", Values)}\"";

View file

@ -21,7 +21,7 @@ public DemuxConcatArgument(IEnumerable<string> values)
private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt");
public void Pre() => File.WriteAllLines(_tempFileName, Values);
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
public void Post() => File.Delete(_tempFileName);
public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\"";

View file

@ -6,7 +6,7 @@ namespace FFMpegCore.Arguments
public interface IInputOutputArgument : IArgument
{
void Pre();
Task During(CancellationToken? cancellationToken = null);
Task During(CancellationToken cancellationToken = default);
void Post();
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
@ -27,7 +26,7 @@ public void Pre()
throw new FileNotFoundException("Input file not found", FilePath);
}
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
public void Post() { }
public string Text => $"-i \"{FilePath}\"";

View file

@ -19,7 +19,7 @@ public InputPipeArgument(IPipeSource writer) : base(PipeDirection.Out)
public override string Text => $"-y {Writer.GetFormat()} -i \"{PipePath}\"";
public override async Task ProcessDataAsync(CancellationToken token)
protected override async Task ProcessDataAsync(CancellationToken token)
{
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
if (!Pipe.IsConnected)

View file

@ -25,7 +25,7 @@ public void Pre()
if (!Overwrite && File.Exists(Path))
throw new FFMpegException(FFMpegExceptionType.File, "Output file already exists and overwrite is disabled");
}
public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
public Task During(CancellationToken cancellationToken = default) => Task.CompletedTask;
public void Post()
{
}

View file

@ -16,7 +16,7 @@ public OutputPipeArgument(IPipeSink reader) : base(PipeDirection.In)
public override string Text => $"\"{PipePath}\" -y";
public override async Task ProcessDataAsync(CancellationToken token)
protected override async Task ProcessDataAsync(CancellationToken token)
{
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
if (!Pipe.IsConnected)

View file

@ -34,7 +34,7 @@ public void Post()
Pipe = null!;
}
public async Task During(CancellationToken? cancellationToken = null)
public async Task During(CancellationToken cancellationToken = default)
{
try
{
@ -46,7 +46,7 @@ public async Task During(CancellationToken? cancellationToken = null)
Post();
}
public abstract Task ProcessDataAsync(CancellationToken token);
protected abstract Task ProcessDataAsync(CancellationToken token);
public abstract string Text { get; }
}
}

View file

@ -67,7 +67,7 @@ internal void Pre()
foreach (var argument in Arguments.OfType<IInputOutputArgument>())
argument.Pre();
}
internal async Task During(CancellationToken? cancellationToken = null)
internal async Task During(CancellationToken cancellationToken = default)
{
var inputOutputArguments = Arguments.OfType<IInputOutputArgument>();
await Task.WhenAll(inputOutputArguments.Select(io => io.During(cancellationToken))).ConfigureAwait(false);

View file

@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace FFMpegCore.Pipes

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace FFMpegCore
{