Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 7
0
 public bool ContainsStream(StreamIdentifier streamId)
 {
     return Filtergraph.FilterchainList.Any(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId)));
 }
Esempio n. 8
0
 public bool ContainsInput(StreamIdentifier streamId)
 {
     return Inputs.Any(input => input.GetStreamIdentifiers().Any(s => s.Equals(streamId)));
 }
Esempio n. 9
0
 public bool ContainsStream(StreamIdentifier streamId)
 {
     return(Filtergraph.FilterchainList.Any(f => f.GetStreamIdentifiers().Any(r => r.Equals(streamId))));
 }
Esempio n. 10
0
 public bool ContainsInput(StreamIdentifier streamId)
 {
     return(Inputs.Any(input => input.GetStreamIdentifiers().Any(s => s.Equals(streamId))));
 }
Esempio n. 11
0
 public Map(StreamIdentifier streamId)
 {
     Stream = streamId.Map;
 }
Esempio n. 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))));
        }
Esempio n. 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)));
        }
Esempio n. 14
0
 public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId)
 {
     return(command.Owner.Id == streamId.FactoryId &&
            command.Id == streamId.CommandId);
 }
Esempio n. 15
0
 public bool Equals(StreamIdentifier streamId)
 {
     return(Map == streamId.Map &&
            CommandId == streamId.CommandId &&
            FactoryId == streamId.FactoryId);
 }
Esempio n. 16
0
 public List <StreamIdentifier> GetStreamIdentifiers()
 {
     return(Resource.Streams
            .Select(s => StreamIdentifier.Create(Owner.Owner.Id, Owner.Id, s.Map))
            .ToList());
 }
Esempio n. 17
0
 public Map(StreamIdentifier streamId)
     : base(SettingType)
 {
     Stream = streamId.Map;
 }