mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2025-01-19 04:56:43 +00:00
10a646e37e
Former-commit-id: 4f38eed753
31 lines
926 B
C#
31 lines
926 B
C#
using System;
|
|
using System.IO.Pipes;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using FFMpegCore.Pipes;
|
|
|
|
namespace FFMpegCore.Arguments
|
|
{
|
|
/// <summary>
|
|
/// Represents input parameter for a named pipe
|
|
/// </summary>
|
|
public class InputPipeArgument : PipeArgument, IInputArgument
|
|
{
|
|
public readonly IPipeSource Writer;
|
|
|
|
public InputPipeArgument(IPipeSource writer) : base(PipeDirection.Out)
|
|
{
|
|
Writer = writer;
|
|
}
|
|
|
|
public override string Text => $"{Writer.GetStreamArguments()} -i \"{PipePath}\"";
|
|
|
|
protected override async Task ProcessDataAsync(CancellationToken token)
|
|
{
|
|
await Pipe.WaitForConnectionAsync(token).ConfigureAwait(false);
|
|
if (!Pipe.IsConnected)
|
|
throw new OperationCanceledException();
|
|
await Writer.WriteAsync(Pipe, token).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|