Compare commits

...

4 commits

Author SHA1 Message Date
OmriGoldberger
0d7bed9d13
Merge 36d778a3a2 into 1c4333ee4c 2024-12-06 16:43:15 +01:00
Malte Rosenbjerg
1c4333ee4c
Merge pull request #552 from rosenbjerg/bump-dependencies--instances
Some checks failed
CI / ci (macos-13) (push) Has been cancelled
CI / ci (ubuntu-latest) (push) Has been cancelled
CI / ci (windows-latest) (push) Has been cancelled
Bump Instances
2024-12-05 10:05:06 +01:00
Malte Rosenbjerg
855e6ece30 Bump Instances 2024-12-05 10:59:59 +02:00
Omri Goldberger
36d778a3a2 Added a support for pre-exsiting pipe 2024-01-01 10:47:26 +02:00
3 changed files with 49 additions and 3 deletions

View file

@ -0,0 +1,46 @@
using System.Diagnostics;
using FFMpegCore.Pipes;
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents input parameter for a specific name pipe
/// </summary>
public class InputExistingPipeArgument : IInputArgument
{
public string PipeName { get; }
public string PipePath => PipeHelpers.GetPipePath(PipeName);
public string Text => $"-i \"{PipePath}\"";
public InputExistingPipeArgument(string pipeName)
{
PipeName = pipeName;
}
public void Pre()
{
if (string.IsNullOrEmpty(PipeName))
{
throw new InvalidOperationException("Pipe name cannot be null or empty");
}
}
public async Task During(CancellationToken cancellationToken = default)
{
try
{
var tcs = new TaskCompletionSource<bool>();
cancellationToken.Register(() => tcs.TrySetCanceled());
await tcs.Task;
}
catch(OperationCanceledException)
{
Debug.WriteLine($"{GetType().Name} cancelled");
}
}
public void Post()
{
}
}
}

View file

@ -26,6 +26,7 @@ private string GetText()
public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments); public static FFMpegArguments FromUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments); public static FFMpegArguments FromDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputDeviceArgument(device), addArguments);
public static FFMpegArguments FromPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputPipeArgument(sourcePipe), addArguments); public static FFMpegArguments FromPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputPipeArgument(sourcePipe), addArguments);
public static FFMpegArguments FromPipeInput(string pipeName, Action<FFMpegArgumentOptions>? addArguments = null) => new FFMpegArguments().WithInput(new InputExistingPipeArgument(pipeName), addArguments);
public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configureOptions) public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configureOptions)
{ {
@ -41,6 +42,7 @@ public FFMpegArguments WithGlobalOptions(Action<FFMpegGlobalArguments> configure
public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments); public FFMpegArguments AddUrlInput(Uri uri, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputArgument(uri.AbsoluteUri, false), addArguments);
public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments); public FFMpegArguments AddDeviceInput(string device, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputDeviceArgument(device), addArguments);
public FFMpegArguments AddPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputPipeArgument(sourcePipe), addArguments); public FFMpegArguments AddPipeInput(IPipeSource sourcePipe, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputPipeArgument(sourcePipe), addArguments);
public FFMpegArguments AddPipeInput(string pipeName, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new InputExistingPipeArgument(pipeName), addArguments);
public FFMpegArguments AddMetaData(string content, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(content), addArguments); public FFMpegArguments AddMetaData(string content, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(content), addArguments);
public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments); public FFMpegArguments AddMetaData(IReadOnlyMetaData metaData, Action<FFMpegArgumentOptions>? addArguments = null) => WithInput(new MetaDataArgument(MetaDataSerializer.Instance.Serialize(metaData)), addArguments);

View file

@ -17,10 +17,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Instances" Version="3.0.0" /> <PackageReference Include="Instances" Version="3.0.1" />
<PackageReference Include="System.Text.Json" Version="9.0.0" /> <PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>