public static CommandOutput SetupCommandOutputMaps <TOutputType>(CommandStage stage, SettingsCollection settings, string fileName) where TOutputType : class, IContainer, new() { var settingsCopy = settings.Copy(); var commandOutput = CommandOutput.Create(Resource.CreateOutput <TOutputType>(), settingsCopy); stage.StreamIdentifiers.ForEach(streamId => { var theStream = StreamFromStreamIdentifier(stage.Command, streamId); var theResource = CommandInputFromStreamIdentifier(stage.Command, streamId); if (theResource == null) { commandOutput.Settings.Merge(new Map(streamId), FFmpegMergeOptionType.NewWins); } else { var resourceIndex = IndexOfResource(stage.Command, streamId); commandOutput.Settings.Merge(new Map(string.Format("{0}:{1}", resourceIndex, theStream.ResourceIndicator)), FFmpegMergeOptionType.NewWins); } commandOutput.Resource.Streams.Add(theStream.Copy()); }); if (!string.IsNullOrWhiteSpace(fileName)) { commandOutput.Resource.Name = fileName; } return(commandOutput); }
public void Command_WithInputVsAddInput_Verify() { var command = CommandHelper.CreateCommand(); Assert.Throws<ArgumentException>(() => command.AddInput(string.Empty)); Assert.Throws<ArgumentException>(() => command.WithInput<VideoStream>(string.Empty)); var stage = new CommandStage(command); Assert.DoesNotThrow(() => { stage = command.AddInput(Assets.Utilities.GetVideoFile()) .WithInput<VideoStream>(Assets.Utilities.GetVideoFile()); }); Assert.True(command.Inputs.Count == 2); Assert.True(stage.StreamIdentifiers.Count == 1); }