Exemplo n.º 1
0
        public IPipeResult Transform(IPipeSource source)
        {
            var transforms = _pack.Transforms.ToList();
            var destinations = _pack.Destinations.ToList();
            var nameTransform = _pack.NameTransform ?? (Func<string, string>)(s => s);

            var result = new PipeResult() { Success = true };

            try
            {
                var workDoc = source.GetDocument();
                foreach (var transform in transforms)
                {
                    if (workDoc == null) break;
                    var tmpDoc = transform.Process(workDoc);
                    workDoc = tmpDoc;
                }

                // transforming failed
                if (workDoc == null)
                {
                    result.Success = false;
                    return result;
                }

                result.Document = workDoc;

                foreach (var destination in destinations)
                {
                    var name = nameTransform(source.Name);

                    var streamDestination = destination as IPipeStreamDestination;
                    if (streamDestination != null)
                    {
                        var tmpStream = new MemoryStream();
                        workDoc.Save(tmpStream);
                        tmpStream.Position = 0;

                        streamDestination.Save(tmpStream, name);

                        tmpStream.Position = 0;
                        result.Stream = tmpStream;
                    }

                    var customDestination = destination as IPipeCustomDestination;
                    if (customDestination != null)
                    {
                        customDestination.Save(workDoc, name);
                    }
                }
            }
            catch (Exception ex)
            {
                result.Exception = ex;
                result.Success = false;
            }

            return result;
        }
Exemplo n.º 2
0
 public InputPipeArgument(IPipeSource writer) : base(PipeDirection.Out)
 {
     Writer = writer;
 }
Exemplo n.º 3
0
        public IPipeResult Transform(IPipeSource source)
        {
            var transforms    = _pack.Transforms.ToList();
            var destinations  = _pack.Destinations.ToList();
            var nameTransform = _pack.NameTransform ?? (s => s);

            var result = new PipeResult {
                Success = true
            };

            try
            {
                var workDoc = source.GetDocument();
                foreach (var transform in transforms)
                {
                    if (workDoc == null)
                    {
                        break;
                    }
                    var tmpDoc = transform.Process(workDoc);
                    workDoc = tmpDoc;
                }

                // transforming failed
                if (workDoc == null)
                {
                    result.Success = false;
                    return(result);
                }

                result.Document = workDoc;

                foreach (var destination in destinations)
                {
                    var name = nameTransform(source.Name);

                    if (destination is IPipeStreamDestination streamDestination)
                    {
                        var tmpStream = new MemoryStream();
                        workDoc.Save(tmpStream);
                        tmpStream.Position = 0;

                        streamDestination.Save(tmpStream, name);

                        tmpStream.Position = 0;
                        result.Stream      = tmpStream;
                    }

                    if (destination is IPipeCustomDestination customDestination)
                    {
                        customDestination.Save(workDoc, name);
                    }
                }
            }
            catch (Exception ex)
            {
                result.Exception = ex;
                result.Success   = false;
            }

            return(result);
        }
Exemplo n.º 4
0
 public static FFMpegArguments FromPipe(IPipeSource writer) => new FFMpegArguments(new InputPipeArgument(writer));
Exemplo n.º 5
0
 public FFMpegArguments AddPipeInput(IPipeSource sourcePipe, Action <FFMpegArgumentOptions>?addArguments = null) => WithInput(new InputPipeArgument(sourcePipe), addArguments);
Exemplo n.º 6
0
 public static FFMpegArguments FromPipeInput(IPipeSource sourcePipe, Action <FFMpegArgumentOptions>?addArguments = null) => new FFMpegArguments().WithInput(new InputPipeArgument(sourcePipe), addArguments);
Exemplo n.º 7
0
 public PipeManager(IPipeSource[] pipeSources)
 {
     _pipeSources = pipeSources;
 }