private void WriteFilterchain(FFmpegCommand command, Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } var context = FilterBindingContext.Create(filterchain.InputCount, filterchain.OutputCount); WriteFilterchainIn(command, filterchain); var shouldIncludeDelimitor = false; filterchain.Filters.ToList().ForEach(filter => { if (shouldIncludeDelimitor) { BuilderBase.Append(","); } else { BuilderBase.Append(" "); shouldIncludeDelimitor = true; } WriteFilter(filter, context); }); WriteFilterchainOut(filterchain); }
private void WriteFilterchain(FFmpegCommand command, Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } WriteFilterchainIn(command, filterchain); var shouldIncludeDelimitor = false; filterchain.Filters.List.ForEach(filter => { if (shouldIncludeDelimitor) { _builderBase.Append(","); } else { _builderBase.Append(" "); shouldIncludeDelimitor = true; } filter.Setup(command, filterchain); WriteFilter(filter); }); WriteFilterchainOut(filterchain); }
public static bool ValidateFiltersMaxMin(Filterchain filterchain, List <StreamIdentifier> resources) { var maximumAllowed = GetFilterInputMax(filterchain); var minimumAllowed = GetFilterInputMin(filterchain); return(resources.Count >= minimumAllowed); }
public override List <StreamIdentifier> SetupTemplate(FFmpegCommand command, List <StreamIdentifier> streamIdList) { if (streamIdList.Count != 2) { throw new InvalidOperationException("Crossfade Concatenate requires two input video streams."); } var streamTo = streamIdList[1]; var streamFrom = streamIdList[0]; //grab the current length of the streamId specified var streamFromMetadata = MetadataHelpers.GetMetadataInfo(command, streamFrom); //from == // - split // - 1: start -> (end - durationOf) // - 2: (end - durationOf) -> end //to == // - split // - 1: start -> (start + durationOf) // - 2: (start + durationOf) -> end //blend == // - from:2 / to:1 //output == // - (from:1, blend, to:2) var endMinusDuration = streamFromMetadata.VideoStream.Duration - Duration; var fromSplit = command.Select(streamFrom) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var fromMain = fromSplit.Take(0) .Filter(new TrimVideo(null, endMinusDuration.TotalSeconds, VideoUnitType.Seconds)); var fromBlend = fromSplit.Take(1) .Filter(new TrimVideo(endMinusDuration.TotalSeconds, null, VideoUnitType.Seconds)); var toSplit = command.Select(streamTo) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var toBlend = toSplit.Take(0) .Filter(new TrimVideo(null, Duration.TotalSeconds, VideoUnitType.Seconds)); var toMain = toSplit.Take(1) .Filter(new TrimVideo(Duration.TotalSeconds, null, VideoUnitType.Seconds)); var blendOut = command.Select(toBlend.StreamIdentifiers) .Select(fromBlend.StreamIdentifiers) .Filter(Filterchain.FilterTo <VideoStream>(new Blend(string.Format(CrossfadeAlgorithm, Duration.TotalSeconds)))); var result = command.Select(fromMain.StreamIdentifiers) .Select(blendOut.StreamIdentifiers) .Select(toMain.StreamIdentifiers) .Filter(Filterchain.FilterTo <VideoStream>(new Concat())); return(result.StreamIdentifiers); }
public void FilterchainIAudio_Add_Restriction() { var filterchain = Filterchain.FilterTo <AudioStream>(); Assert.DoesNotThrow(() => filterchain.Filters.Add(new Concat())); Assert.Throws <ForStreamInvalidException>(() => filterchain.Filters.Add(new Fade())); }
public static Filtergraph FilterTo <TStreamType>(this Filtergraph filtergraph, int count, params IFilter[] filters) where TStreamType : class, IStream, new() { var filterchain = Filterchain.FilterTo <TStreamType>(count, filters); return(filtergraph.Add(filterchain)); }
public void Command_FilterchainManager_Verify() { var command = CommandHelper.CreateCommand(); command.AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetVideoFile()); var streamId1 = command.StreamIdentifier(0); var streamId2 = command.StreamIdentifier(1); var streamId3 = command.StreamIdentifier(2); var streamId4 = command.StreamIdentifier(3); var filterchain = Filterchain.FilterTo <VideoStream>(new Trim(1, 2, VideoUnitType.Seconds)); var filterchain2 = Filterchain.FilterTo <AudioStream>(new AEvalSrc()); Assert.Throws <ArgumentNullException>(() => command.FilterchainManager.Add(null)); Assert.Throws <InvalidOperationException>(() => command.FilterchainManager.Add(filterchain, null)); Assert.Throws <ArgumentNullException>(() => command.FilterchainManager.AddToEach(null)); Assert.Throws <ArgumentException>(() => command.FilterchainManager.AddToEach(filterchain, null)); Assert.DoesNotThrow(() => command.FilterchainManager.Add(filterchain2, null)); Assert.DoesNotThrow(() => command.FilterchainManager.Add(filterchain, streamId1)); Assert.DoesNotThrow(() => command.FilterchainManager.AddToEach(filterchain, streamId2, streamId3, streamId4)); Assert.True(command.Filtergraph.Count == 5); }
public void FilterchainIVideo_Add_Restriction() { var filterchain = Filterchain.FilterTo <VideoStream>(); filterchain.Filters.Add(new Concat()); Assert.Throws <ForStreamInvalidException>(() => filterchain.Filters.Add(new AMix())); }
public void InputToFilterToOutput_Verify() { var baseline = Resource.From(Utilities.GetVideoFile()) .LoadMetadata() .Streams .OfType <VideoStream>() .First(); var calculatedSeconds = (baseline.Info.VideoMetadata.Duration.TotalSeconds * 3d) - 2d; var calculatedDuration = TimeSpan.FromSeconds(calculatedSeconds); var filterchain = Filterchain.FilterTo <VideoStream>(new Split(3)); var split = CommandFactory.Create() .CreateOutputCommand() .WithInput <VideoStream>(Utilities.GetVideoFile()) .Filter(filterchain); var concat1 = split.Command .Select(split.StreamIdentifiers[1]) .Select(split.StreamIdentifiers[1]) .Filter(new Dissolve(1d)); var concat2 = concat1.Select(split.StreamIdentifiers[2]) .Filter(new Dissolve(1d)); var output = concat2.MapTo <Mp4>().First(); var metadataInfo1 = MetadataHelpers.GetMetadataInfo(concat2.Command, concat2.StreamIdentifiers.FirstOrDefault()); var metadataInfo2 = MetadataHelpers.GetMetadataInfo(output.Owner, output.GetStreamIdentifier()); Assert.True(metadataInfo1.VideoStream.VideoMetadata.Duration == calculatedDuration); Assert.True(metadataInfo2.VideoStream.VideoMetadata.Duration == calculatedDuration); }
public void Filterchain_Add_Duplicate() { var filterchain = Filterchain.FilterTo <VideoStream>(); Assert.DoesNotThrow(() => filterchain.Filters.Add(new Overlay())); Assert.Throws <InvalidOperationException>(() => filterchain.Filters.Add(new Overlay())); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a two audio and video files var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetAudioFile()) .AddInput(Assets.Utilities.GetAudioFile()); //select the first two video streams and run concat filter var videoConcat = command.Select(command.Take(0), command.Take(1)) .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat())); //select the first two audio streams and run concat filter var audioConcat = command.Select(command.Take(2), command.Take(3)) .Filter(Filterchain.FilterTo <VideoStream>(new Filters.Concat(1, 0))); command.Select(audioConcat, videoConcat) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a video and audio file var command = factory.CreateOutputCommand() .AddInput(Assets.Utilities.GetVideoFile()) .AddInput(Assets.Utilities.GetAudioFile()); //select the first two streams from the input command var splitVideo = command.Take(0) .Filter(Filterchain.FilterTo <VideoStream>(new Split(2))); var splitAudio = command.Take(1) .Filter(Filterchain.FilterTo <AudioStream>(new ASplit(2))); //map the first audio and video stream to the output command.Select(splitVideo.Take(0), splitAudio.Take(0)) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\foo.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); command.Select(splitVideo.Take(1), splitAudio.Take(1)) .MapTo <Mp4>(@"c:\source\ffmpeg\bin\temp\bar.mp4", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
public static MetadataInfoTreeGroup Create(FFmpegCommand command, Filterchain filterchain) { var metadataInfoTreeGroup = new MetadataInfoTreeGroup(filterchain); metadataInfoTreeGroup.Fill(command, filterchain); return metadataInfoTreeGroup; }
public static MetadataInfoTreeGroup Create(FFmpegCommand command, Filterchain filterchain) { var metadataInfoTreeGroup = new MetadataInfoTreeGroup(filterchain); metadataInfoTreeGroup.Fill(command, filterchain); return(metadataInfoTreeGroup); }
private void WriteFilterchainOut(Filterchain filterchain) { var filterchainOutputs = filterchain.GetStreamIdentifiers(); filterchainOutputs.ForEach(streamId => { BuilderBase.Append(" "); BuilderBase.Append(FormattingUtility.Map(streamId.Map)); }); }
public void FilterchainIVideo_RemoveType() { var filterchain = Filterchain.FilterTo <VideoStream>( new Fade(), new ColorBalance()); Assert.True(filterchain.Filters.Contains <Fade>()); filterchain.Filters.Remove <Fade>(); Assert.False(filterchain.Filters.Contains <Fade>()); }
public void FilterchainIVideo_RemoveAll() { var filterchain = Filterchain.FilterTo <VideoStream>( new Fade(), new ColorBalance()); Assert.True(filterchain.Filters.Count == 2); filterchain.Filters.RemoveAll(filter => true); Assert.True(filterchain.Filters.Count == 0); }
public static void ValidateFilter(FFmpegCommand command, Filterchain filterchain) { if (command.Owner == null) { throw new ArgumentException("Command must contain an owner before sugar is allowed.", "command"); } if (filterchain == null) { throw new ArgumentNullException("filterchain"); } }
private Filterchain BuilChain() { chain = new Filterchain(); List <Filter> filters = new List <Filter>(); KeepALiveFilter keepAliveFilter = new KeepALiveFilter(); SendTimeOutFilter sendTimeOutFilter = new SendTimeOutFilter(); filters.Add(keepAliveFilter); filters.Add(sendTimeOutFilter); chain.setFilters(filters); chain.init(); return(chain); }
/// <summary> /// Method, called during [Render] to bring forward all the necessary resources, necessary action for maximum abstraction from the user. /// </summary> /// <param name="command">The command chain the current filter belongs to.</param> /// <param name="filterchain">The filterchain that the filter belongs to</param> public void Setup(FFmpegCommand command, Filterchain filterchain) { InputCount = filterchain.Resources.Count; if (InputCount == 0) { throw new InvalidOperationException("Cannot setup filter with a resource count of zero."); } if (InputCount > MaxInputs) { throw new InvalidOperationException("The filter has exceeded the maximum allowed number of inputs."); } }
public void Filtergraph_Add() { var filtergraph = Filtergraph.Create(CommandHelper.CreateCommand()); var filterchain1 = Filterchain.FilterTo <AudioStream>(); var filterchain2 = Filterchain.FilterTo <VideoStream>(); filtergraph.Add(filterchain1); Assert.True(filtergraph.Count == 1); filtergraph.Add(filterchain2); Assert.True(filtergraph.Count == 2); }
public static int GetFilterInputMax(Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } return(filterchain.Filters.Min(f => { var filterAttribute = AttributeRetrieval.GetAttribute <FilterAttribute>(f.GetType()); return filterAttribute.MaxInputs; })); }
public void Command_FilterWithNoStream() { var command = CommandHelper.CreateCommand(); var filterchain = Filterchain.FilterTo <AudioStream>(new AEvalSrc { Expression = "0" }); CommandStage stage = null; Assert.DoesNotThrow(() => stage = command.Filter(filterchain)); Assert.True(stage.StreamIdentifiers.Count == 1); }
public List <StreamIdentifier> AddToEach(Filterchain filterchain, params StreamIdentifier[] streamIds) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } if (streamIds == null || streamIds.Length == 0) { throw new ArgumentException("Cannot apply filters to null or empty objects.", "streamIds"); } var resourceList = new List <StreamIdentifier>(streamIds); return(resourceList.SelectMany(r => Add(filterchain, r)).ToList()); }
internal FilterchainOutput(Filterchain owner, IStream resource) { if (owner == null) { throw new ArgumentNullException("owner"); } if (resource == null) { throw new ArgumentNullException("resource"); } Owner = owner; Stream = resource; Id = Guid.NewGuid().ToString(); }
public override List <StreamIdentifier> SetupTemplate(FFmpegCommand command, List <StreamIdentifier> streamIdList) { if (streamIdList.Count != 1) { throw new InvalidOperationException("Crossfade Concatenate requires two input video streams."); } //trim == // - trim filter // - reset PTS filter var result = command.Select(streamIdList) .Filter(Filterchain.FilterTo <VideoStream>(TrimFilter, new SetPts(SetPtsExpressionType.ResetTimestamp))); return(result.StreamIdentifiers); }
public static int GetFilterOutputMax(Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } return(filterchain.Filters.List.Max(f => { if (!(f is IFilterMultiOutput)) { return 1; } return (f as IFilterMultiOutput).OutputCount(); })); }
public static bool ValidateFilters(FFmpegCommand command, Filterchain filterchain, List <StreamIdentifier> streamIds) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } return(filterchain.Filters.List.TrueForAll(f => { if (!(f is IFilterValidator)) { return true; } return (f as IFilterValidator).Validate(command, filterchain, streamIds); })); }
public static int GetFilterOutputMax(Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } return filterchain.Filters.List.Max(f => { if (!(f is IFilterMultiOutput)) { return 1; } return (f as IFilterMultiOutput).OutputCount(); }); }
public static bool ValidateFilters(FFmpegCommand command, Filterchain filterchain, List<StreamIdentifier> streamIds) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } return filterchain.Filters.List.TrueForAll(f => { if (!(f is IFilterValidator)) { return true; } return (f as IFilterValidator).Validate(command, filterchain, streamIds); }); }
private void Fill(FFmpegCommand command, Filterchain filterchain) { filterchain.ReceiptList.ForEach(streamId => { var resourceIndexOf = CommandHelperUtility.IndexOfResource(command, streamId); if (resourceIndexOf > -1) { DependecyTree.Add(MetadataInfoTreeSource.Create(command.Inputs[resourceIndexOf])); } var filterchainIndexOf = CommandHelperUtility.IndexOfFilterchain(command, streamId); if (filterchainIndexOf > -1) { DependecyTree.Add(Create(command, command.Filtergraph[filterchainIndexOf])); } }); }
public static void ProcessFilters(FFmpegCommand command, Filterchain filterchain) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } filterchain.Filters.List.ForEach(filter => { if (!(filter is IFilterProcessor)) { return; } (filter as IFilterProcessor).PrepCommands(command, filterchain); }); }
private void Fill(FFmpegCommand command, Filterchain filterchain) { filterchain.ReceiptList.ForEach(streamId => { var resourceIndexOf = CommandHelper.IndexOfResource(command, streamId); if (resourceIndexOf > -1) { DependecyTree.Add(MetadataInfoTreeSource.Create(command.Inputs[resourceIndexOf])); } var filterchainIndexOf = CommandHelper.IndexOfFilterchain(command, streamId); if (filterchainIndexOf > -1) { DependecyTree.Add(Create(command, command.Filtergraph[filterchainIndexOf])); } }); }
private void WriteFilterchainIn(FFmpegCommand command, Filterchain filterchain) { filterchain.ReceiptList.ForEach(streamId => { BuilderBase.Append(" "); var indexOfResource = command.Objects.Inputs.FindIndex(inputs => inputs.GetStreamIdentifiers().Any(s => s.Map == streamId.Map)); if (indexOfResource >= 0) { var commandResource = command.Objects.Inputs[indexOfResource]; var commandStream = commandResource.Resource.Streams.First(s => s.Map == streamId.Map); BuilderBase.Append(FormattingUtility.Map(commandStream, indexOfResource)); } else { BuilderBase.Append(FormattingUtility.Map(streamId.Map)); } }); }
public void CommandFilterchainManager_Verify() { var factory = CommandFactory.Create(); var command = factory.CreateOutputCommand() .WithInput <VideoStream>(Assets.Utilities.GetVideoFile()) .WithInput <VideoStream>(Assets.Utilities.GetVideoFile()); var commandFilterchainManager = FiltergraphManager.Create(command.Command); var filterchain = Filterchain.FilterTo <VideoStream>(new Fps()); var filterchain2 = Filterchain.FilterTo <VideoStream>(new Concat()); var streamIds = new List <StreamIdentifier>(); Assert.DoesNotThrow(() => streamIds = commandFilterchainManager.AddToEach(filterchain, command.StreamIdentifiers.ToArray())); Assert.True(streamIds.Count == 2); Assert.DoesNotThrow(() => streamIds = commandFilterchainManager.Add(filterchain2, streamIds.ToArray())); Assert.True(streamIds.Count == 1); }
public static void Run() { //set up ffmpeg command configuration with locations of default output folders, ffmpeg, and ffprobe. ResourceManagement.CommandConfiguration = CommandConfiguration.Create( @"c:\source\ffmpeg\bin\temp", @"c:\source\ffmpeg\bin\ffmpeg.exe", @"c:\source\ffmpeg\bin\ffprobe.exe"); //create a factory var factory = CommandFactory.Create(); //create a command adding a two audio files factory.CreateOutputCommand() .WithInput <AudioStream>(Assets.Utilities.GetAudioFile()) .WithInput <AudioStream>(Assets.Utilities.GetAudioFile()) .Filter(Filterchain.FilterTo <AudioStream>(new Filters.Concat(1, 0))) .MapTo <M4A>(@"c:\source\ffmpeg\bin\temp\foo.m4a", SettingsCollection.ForOutput(new OverwriteOutput())); //render the output factory.Render(); }
public void PrepCommands(FFmpegCommand command, Filterchain filterchain) { if (filterchain.OutputList.Count == 0) { throw new InvalidOperationException("A split cannot happen without a demo output to split on."); } if (filterchain.OutputList.Count > NumberOfStreams) { throw new InvalidOperationException("A split cannot happen when the supplied filterchain has to many demo outputs."); } if (filterchain.OutputList.Count == NumberOfStreams) { return; } for (var i = filterchain.OutputList.Count; i < NumberOfStreams; i++) { filterchain.OutputList.Add(filterchain.OutputList .First() .Copy()); } }
public static MetadataInfoStreamCalculator Create(FFmpegCommand command, Filterchain filterchain) { var infoStreamItem = MetadataInfoTreeGroup.Create(command, filterchain); return new MetadataInfoStreamCalculator(infoStreamItem); }
public bool Validate(FFmpegCommand command, Filterchain filterchain, List<StreamIdentifier> streamIds) { //concat filters should be used independently of other filters return filterchain.Filters.Count == 1; }
/// <summary> /// adds the given Filterchain to the Filtergraph /// </summary> /// <param name="filterchain">the filterchain to be added to the filtergraph</param> public Filtergraph Add(Filterchain filterchain) { filterchain.Owner = this; FilterchainList.Add(filterchain); return this; }
public bool Contains(Filterchain filterchain) { return FilterchainList.Any(f => f.Id == filterchain.Id); }
public int IndexOf(Filterchain filterchain) { return FilterchainList.FindIndex(f => f.Id == filterchain.Id); }
private MetadataInfoTreeGroup(Filterchain filterchain) { Filterchain = filterchain; DependecyTree = new List<MetadataInfoTreeItem>(); }
/// <summary> /// merges the given Filterchain to the Filtergraph /// </summary> /// <param name="filterchain">the filterchain to be added to the filtergraph</param> /// <param name="optionType">the option specifying how the merge should declare a winner</param> public Filtergraph Merge(Filterchain filterchain, FFmpegMergeOptionType optionType) { var indexOfItem = IndexOf(filterchain); if (indexOfItem != -1 && optionType == FFmpegMergeOptionType.NewWins) { FilterchainList.RemoveAt(indexOfItem); filterchain.Owner = this; FilterchainList.Insert(indexOfItem, filterchain); } else if (indexOfItem == -1) { Add(filterchain); } return this; }
public bool Validate(FFmpegCommand command, Filterchain filterchain, List<StreamIdentifier> streamIds) { return filterchain.Filters.Count == 1; }
internal static FilterchainOutput Create(Filterchain owner, IStream resource) { return new FilterchainOutput(owner, resource); }
public List<StreamIdentifier> AddToEach(Filterchain filterchain, params StreamIdentifier[] streamIds) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } if (streamIds == null || streamIds.Length == 0) { throw new ArgumentException("Cannot apply filters to null or empty objects.", "streamIds"); } var resourceList = new List<StreamIdentifier>(streamIds); return resourceList.SelectMany(r => Add(filterchain, r)).ToList(); }
public List<StreamIdentifier> Add(Filterchain filterchain, params StreamIdentifier[] streamIds) { if (filterchain == null) { throw new ArgumentNullException("filterchain"); } var streamIdList = new List<StreamIdentifier>(); var hasStreams = (streamIds != null && streamIds.Length > 0); if (hasStreams) { streamIdList.AddRange(streamIds); if (!streamIdList.TrueForAll(streamId => Owner.Objects.ContainsInput(streamId) || Owner.Objects.ContainsStream(streamId))) { throw new ArgumentException("Cannot apply filters to inputs or streams that do not exist in the command.", "streamIds"); } } var finalFilter = filterchain.Filters.LastOrDefault(); if (finalFilter == null) { throw new ArgumentException("Filterchain must contain at least one filter.", "filterchain"); } if (!Utilities.ValidateFiltersMaxMin(filterchain, streamIdList)) { throw new InvalidOperationException( "Filterchain is invalid, not withing range of calculated allowable resources."); } if (!Utilities.ValidateFilters(Owner, filterchain, streamIdList)) { throw new InvalidOperationException( "Filterchain is invalid, failed to comply with child filter requirements."); } var maximumInputs = Utilities.GetFilterInputMax(filterchain); Filterchain finalFilterchain = null; if (hasStreams) { var segmentsList = Helpers.BreakStreamIdentifiers(maximumInputs, streamIds); segmentsList.ForEach(segment => { var segmentList = new List<StreamIdentifier>(segment); if (finalFilterchain != null) { finalFilterchain.GetStreamIdentifiers().ForEach(r => segmentList.Insert(0, r)); } finalFilterchain = filterchain.Copy(); finalFilterchain.Owner = Owner.Objects.Filtergraph; finalFilterchain.SetResources(segmentList); Utilities.ProcessFilters(Owner, finalFilterchain); Owner.Objects.Filtergraph.Add(finalFilterchain); }); } else { finalFilterchain = filterchain.Copy(); finalFilterchain.Owner = Owner.Objects.Filtergraph; Utilities.ProcessFilters(Owner, finalFilterchain); Owner.Objects.Filtergraph.Add(finalFilterchain); } if (finalFilterchain == null) { throw new InvalidOperationException( "Filterchain is invalid, segemented filters caused an unrecoverable issue."); } return finalFilterchain.GetStreamIdentifiers(); }
public static int GetFilterInputMax(Filterchain filterchain) { return filterchain.Filters.List.Min(f => f.MaxInputs); }
public static bool ValidateFiltersMax(Filterchain filterchain, List<StreamIdentifier> resources) { var maximumAllowedMinimum = GetFilterInputMax(filterchain); return maximumAllowedMinimum > 1 || (maximumAllowedMinimum == 1 && resources.Count == 1); }