From b0e3d157d35b60f283b32b84151d3dff0cac0717 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Tue, 27 Oct 2020 00:49:28 +0100 Subject: [PATCH] Cleanup Former-commit-id: 6b1e411bfe1fc745327f56a546abc7685744927e --- FFMpegCore.Test/ArgumentBuilderTest.cs | 1 - FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/InputArgument.cs | 5 ++--- FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/OutputArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/PipeArgument.cs | 4 ++-- FFMpegCore/FFMpeg/FFMpegArguments.cs | 2 +- FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs | 1 - FFMpegCore/FFProbe/IMediaAnalysis.cs | 1 - 12 files changed, 11 insertions(+), 15 deletions(-) diff --git a/FFMpegCore.Test/ArgumentBuilderTest.cs b/FFMpegCore.Test/ArgumentBuilderTest.cs index 6c79d98..f4dbfe9 100644 --- a/FFMpegCore.Test/ArgumentBuilderTest.cs +++ b/FFMpegCore.Test/ArgumentBuilderTest.cs @@ -2,7 +2,6 @@ using System; using FFMpegCore.Arguments; using FFMpegCore.Enums; -using FFMpegCore.Exceptions; namespace FFMpegCore.Test { diff --git a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs index d43988f..9c6ffa2 100644 --- a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs @@ -18,7 +18,7 @@ public ConcatArgument(IEnumerable 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)}\""; diff --git a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs index e915c77..5651802 100644 --- a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs @@ -21,7 +21,7 @@ public DemuxConcatArgument(IEnumerable 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}\""; diff --git a/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs b/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs index 6998d5c..99def82 100644 --- a/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs @@ -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(); } } \ No newline at end of file diff --git a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs index 0ec3cd9..68c34b4 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs @@ -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}\""; diff --git a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs index 990995a..17d0372 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs @@ -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) diff --git a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs index ec9db7c..c2aad38 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs @@ -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() { } diff --git a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs index f762752..ebf1e7f 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs @@ -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) diff --git a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs index 77db5db..16f9674 100644 --- a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs @@ -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; } } } diff --git a/FFMpegCore/FFMpeg/FFMpegArguments.cs b/FFMpegCore/FFMpeg/FFMpegArguments.cs index b2cffd1..44e20d2 100644 --- a/FFMpegCore/FFMpeg/FFMpegArguments.cs +++ b/FFMpegCore/FFMpeg/FFMpegArguments.cs @@ -67,7 +67,7 @@ internal void Pre() foreach (var argument in Arguments.OfType()) argument.Pre(); } - internal async Task During(CancellationToken? cancellationToken = null) + internal async Task During(CancellationToken cancellationToken = default) { var inputOutputArguments = Arguments.OfType(); await Task.WhenAll(inputOutputArguments.Select(io => io.During(cancellationToken))).ConfigureAwait(false); diff --git a/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs b/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs index cce4547..c680c3e 100644 --- a/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs +++ b/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using System.Runtime.InteropServices; namespace FFMpegCore.Pipes diff --git a/FFMpegCore/FFProbe/IMediaAnalysis.cs b/FFMpegCore/FFProbe/IMediaAnalysis.cs index 04e2ae3..660d776 100644 --- a/FFMpegCore/FFProbe/IMediaAnalysis.cs +++ b/FFMpegCore/FFProbe/IMediaAnalysis.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace FFMpegCore {