Example #1
0
        public static MetadataInfoTreeContainer GetMetadataInfo(FFmpegCommand command, StreamIdentifier streamId)
        {
            //first validate that the streamId does in fact belong to the command.
            if (!CommandHelperUtility.ReceiptBelongsToCommand(command, streamId))
            {
                throw new ArgumentException("The provided streamId is not part of the provided ffmpeg command.",
                    "streamId");
            }

            var resourceIndex = CommandHelperUtility.IndexOfResource(command, streamId);
            if (resourceIndex > -1)
            {
                return ResourceMetadataInfo(command, resourceIndex);
            }

            var filterchainIndex = CommandHelperUtility.IndexOfFilterchain(command, streamId);
            if (filterchainIndex > -1)
            {
                return FilterchainMetadataInfo(command, filterchainIndex);
            }

            var outputIndex = CommandHelperUtility.IndexOfOutput(command, streamId);
            if (outputIndex > -1)
            {
                return OutputMetadataInfo(command, outputIndex);
            }

            return null;
        }
Example #2
0
        public static IStream StreamFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
        {
            var commandInput = CommandInputFromStreamIdentifier(command, streamId);

            if (commandInput != null)
            {
                return(commandInput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map));
            }

            var commandOutput = CommandOutputFromStreamIdentifier(command, streamId);

            if (commandOutput != null)
            {
                return(commandOutput.Resource.Streams.FirstOrDefault(si => si.Map == streamId.Map));
            }

            var filterchain = FilterchainFromStreamIdentifier(command, streamId);

            if (filterchain != null)
            {
                var filterchainOutput = filterchain.OutputList.First(si => si.Stream.Map == streamId.Map);

                return(filterchainOutput.Stream);
            }

            throw new StreamNotFoundException();
        }
Example #3
0
        public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId);

            if (matchingOutput == null)
            {
                return(-1);
            }

            return(command.Outputs.IndexOf(matchingOutput));
        }
Example #4
0
        public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingResource = CommandInputFromStreamIdentifier(command, streamId);

            if (matchingResource == null)
            {
                return(-1);
            }

            return(command.Inputs.IndexOf(matchingResource));
        }
Example #5
0
        public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId);

            if (matchingFilterchain == null)
            {
                return(-1);
            }

            return(command.Filtergraph.IndexOf(matchingFilterchain));
        }
Example #6
0
        public StreamIdentifier GetStreamIdentifier <TStreamType>()
            where TStreamType : class, IStream
        {
            var streamInReference = Resource.Streams.OfType <TStreamType>().FirstOrDefault();

            if (streamInReference == null)
            {
                throw new StreamNotFoundException(typeof(TStreamType));
            }

            return(StreamIdentifier.Create(Owner.Owner.Id, Owner.Id, streamInReference.Map));
        }
Example #7
0
 public bool ContainsStream(StreamIdentifier streamId)
 {
     return Filtergraph.FilterchainList.Any(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)));
 }
Example #8
0
 public bool ContainsInput(StreamIdentifier streamId)
 {
     return Inputs.Any(input => input.GetStreamIdentifiers().Any(s => s.Equals(streamId)));
 }
Example #9
0
 public bool ContainsStream(StreamIdentifier streamId)
 {
     return(Filtergraph.FilterchainList.Any(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId))));
 }
Example #10
0
 public bool ContainsInput(StreamIdentifier streamId)
 {
     return(Inputs.Any(input => input.GetStreamIdentifiers().Any(s => s.Equals(streamId))));
 }
Example #11
0
 public Map(StreamIdentifier streamId)
 {
     Stream = streamId.Map;
 }
Example #12
0
        public static Filterchain FilterchainFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
        {
            if (streamId == null)
            {
                throw new ArgumentNullException("streamId");
            }

            return(command.Objects.Filtergraph.FilterchainList.FirstOrDefault(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId))));
        }
Example #13
0
        public static CommandOutput CommandOutputFromStreamIdentifier(FFmpegCommand command, StreamIdentifier streamId)
        {
            if (streamId == null)
            {
                throw new ArgumentNullException("streamId");
            }

            return(command.Objects.Outputs.FirstOrDefault(i => i.GetStreamIdentifiers().Any(si => si.Map == streamId.Map)));
        }
Example #14
0
 public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId)
 {
     return(command.Owner.Id == streamId.FactoryId &&
            command.Id == streamId.CommandId);
 }
Example #15
0
 public bool Equals(StreamIdentifier streamId)
 {
     return(Map == streamId.Map &&
            CommandId == streamId.CommandId &&
            FactoryId == streamId.FactoryId);
 }
Example #16
0
 public List <StreamIdentifier> GetStreamIdentifiers()
 {
     return(Resource.Streams
            .Select(s => StreamIdentifier.Create(Owner.Owner.Id, Owner.Id, s.Map))
            .ToList());
 }
Example #17
0
 public Map(StreamIdentifier streamId)
     : base(SettingType)
 {
     Stream = streamId.Map;
 }