mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
parent
0f27130e8a
commit
b0e3d157d3
12 changed files with 11 additions and 15 deletions
|
@ -2,7 +2,6 @@
|
|||
using System;
|
||||
using FFMpegCore.Arguments;
|
||||
using FFMpegCore.Enums;
|
||||
using FFMpegCore.Exceptions;
|
||||
|
||||
namespace FFMpegCore.Test
|
||||
{
|
||||
|
|
|
@ -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)}\"";
|
||||
|
|
|
@ -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}\"";
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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}\"";
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace FFMpegCore.Pipes
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FFMpegCore
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue