コード例 #1
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();
        }
コード例 #2
0
        public static CommandStage Select(this CommandStage stage, StreamIdentifier streamId)
        {
            var streamIdList = new List <StreamIdentifier> {
                streamId
            };

            return(stage.Select(streamIdList));
        }
コード例 #3
0
 public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId)
 {
     if (this.eventStreams.ContainsKey(streamId.Value))
     {
         return(this.eventStreams[streamId.Value].ToEvents());
     }
     throw new Exception("Stream not found");
 }
コード例 #4
0
        public T GetById <T>(Guid id) where T : EventStream
        {
            var streamId   = new StreamIdentifier(typeof(T).Name, id);
            var history    = this.eventStore.GetByStreamId(streamId);
            T   streamItem = processor.RebuildAggregate <T>(history);

            return(streamItem);
        }
コード例 #5
0
 public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId)
 {
     if (store.ContainsKey(streamId.Value))
     {
         return(store[streamId.Value].AsReadOnly());
     }
     throw new EventStreamNotFoundException(streamId);
 }
コード例 #6
0
        public static CommandStage Select(this FFmpegCommand command, StreamIdentifier streamId)
        {
            var streamIdList = new List <StreamIdentifier>()
            {
                streamId
            };

            return(command.Select(streamIdList));
        }
コード例 #7
0
        public Task <IEnumerable <Event> > GetByStreamIdAsync(StreamIdentifier streamId)
        {
            if (_store.TryGetValue(streamId.Value, out var value))
            {
                return(Task.FromResult(value));
            }

            throw new EventStreamNotFoundException(streamId);
        }
コード例 #8
0
ファイル: Repository.cs プロジェクト: chorton2227/ESF
        public T GetById <T>(Guid id) where T : EventStream, new()
        {
            var eventStream = new T();
            var streamId    = new StreamIdentifier(eventStream.Name, id);
            var events      = _eventStore.GetByStreamId(streamId);

            eventStream.Load(events);
            return(eventStream);
        }
コード例 #9
0
        public T GetById <T>(Guid id) where T : EventStream, new()
        {
            var streamItem = new T();
            var streamId   = new StreamIdentifier(streamItem.Name, id);
            var history    = this.eventStore.GetByStreamId(streamId);

            streamItem.LoadFromHistory(history);
            return(streamItem);
        }
コード例 #10
0
        public async Task <T> GetById <T>(Guid id) where T : AggregateRoot, new()
        {
            var streamItem = new T();
            var streamId   = new StreamIdentifier(streamItem.GetType().Name, id);
            var history    = await _eventStore.GetByStreamId(streamId);

            streamItem.LoadFromHistory(history);
            return(streamItem);
        }
コード例 #11
0
        public static int IndexOfFilterchain(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingFilterchain = FilterchainFromStreamIdentifier(command, streamId);

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

            return(command.Filtergraph.IndexOf(matchingFilterchain));
        }
コード例 #12
0
        public static int IndexOfResource(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingResource = CommandInputFromStreamIdentifier(command, streamId);

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

            return(command.Inputs.IndexOf(matchingResource));
        }
コード例 #13
0
        public static int IndexOfOutput(FFmpegCommand command, StreamIdentifier streamId)
        {
            var matchingOutput = CommandOutputFromStreamIdentifier(command, streamId);

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

            return(command.Outputs.IndexOf(matchingOutput));
        }
コード例 #14
0
        public async Task <T> GetByIdAsync <T>(Guid id)
            where T : EventStream, new()
        {
            var streamItem = new T();
            var streamId   = new StreamIdentifier(streamItem.Name, id);
            var history    = await _eventStore.GetByStreamIdAsync(streamId);

            streamItem.LoadFromHistory(history);

            return(streamItem);
        }
コード例 #15
0
        static void UploadFileToDataBase()
        {
            //your default folder to save files

            StreamIdentifier.DefaultFolderPath = "J:\\Test\\";

            //test file path to save in database
            string filePath = "D:\\SignalGo-Sample.rar";
            //file id from your sql etc id
            int fileId = 456;
            //your file password to access get stream
            string password = "******";

            using (StreamIdentifier streamIdentifier = new StreamIdentifier())
            {
                var info     = new System.IO.FileInfo(filePath);
                var checkSum = FileChecksumMaker.GetFileCheckSum(filePath);
                //save your information of file
                FileInfo fileInfo = new FileInfo()
                {
                    Id = fileId,
                    CreatedDateTime    = DateTime.Now,
                    FileChecksumInfo   = checkSum,
                    FileName           = Path.GetFileName(filePath),
                    DataType           = "application/x-rar-compressed",
                    FileSize           = info.Length,
                    LastUpdateDateTime = DateTime.Now,
                    Password           = password
                };

                //start upload your file or stream
                var result = streamIdentifier.StartUpload(fileInfo, filePath, 0, info.Length, (position) =>
                {
                    Console.WriteLine($"Position Wrote : {position} From Length: {info.Length}");
                });

                Console.WriteLine("Upload Result: " + result);
            }

            var fileToDownload = StreamIdentifier.GetFileInfo(fileId, password);

            if (fileToDownload != null)
            {
                //get stream to read
                var stream = StreamIdentifier.GetFileStream(fileId, 0);
                Console.WriteLine("get file to download success!");
            }
            else
            {
                Console.WriteLine("file not found or password is wrong!");
            }
        }
コード例 #16
0
        protected void Given <TEventStream, TEvent>(Guid id, TEvent evt)
            where TEvent : IEvent
            where TEventStream : EventStream
        {
            var streamIdentifier = new StreamIdentifier(typeof(TEventStream).Name, id);
            var eventStoreStream = new EventStoreStream(streamIdentifier, new List <IEvent> {
                evt
            });

            this.eventStore.Save(new List <EventStoreStream> {
                eventStoreStream
            });
            this.eventStore.CommitInitialEvents();
        }
コード例 #17
0
        public byte[] Serialize()
        {
            List <byte> ser = new List <byte>();

            //Put in guid
            ser.AddRange(StreamIdentifier.ToByteArray());

            //Put in Stream Package count
            ser.AddRange(BitConverter.GetBytes(StreamPackageCount));

            //Put in my package number
            ser.AddRange(BitConverter.GetBytes(PackageNumber));

            //Put in the content
            ser.AddRange(Content);

            return(ser.ToArray());
        }
コード例 #18
0
        public async Task <IEnumerable <IEvent> > GetByStreamId(StreamIdentifier streamId)
        {
            if (streamId == null || string.IsNullOrWhiteSpace(streamId.Value))
            {
                throw new InvalidOperationException("stream Id is required");
            }
            var result = await _connection.ReadStreamEventsForwardAsync(streamId.Value, StreamPosition.Start, 1000, false);

            if (result != null && result.Status == SliceReadStatus.Success)
            {
                List <IEvent> res = GetEvents(result);
                return(res);
            }
            else
            {
                throw new InvalidOperationException(string.Format("There no events with Stream identifer : {0}", streamId.Value));
            }
        }
コード例 #19
0
        private void Fill(FFmpegCommand command, CommandOutput commandOutput)
        {
            //find the command output map setting, if the command output has map settings
            //then they make up its dependecy tree.
            var allSettingMaps = commandOutput.Settings.OfType <Map>();

            if (allSettingMaps.Any())
            {
                var streamIdListFromMaps = allSettingMaps.Select(map => StreamIdentifier.Create(command.Owner.Id, command.Id, map.Stream)).ToList();

                Fill(command, streamIdListFromMaps);

                return;
            }

            //if the command output does not contain map settings then the dependency tree
            //is made up of all the input streams.
            command.Objects.Inputs.ForEach(commandResource => DependecyTree.Add(MetadataInfoTreeSource.Create(commandResource)));
        }
コード例 #20
0
 public static Options Create(StreamIdentifier streamIdentifier,
                              StreamRevision expectedStreamRevision, TimeSpan?timeoutAfter) => new()
コード例 #21
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)));
        }
コード例 #22
0
 public bool Equals(StreamIdentifier streamId)
 {
     return Map == streamId.Map
            && CommandId == streamId.CommandId
            && FactoryId == streamId.FactoryId;
 }
コード例 #23
0
 public IEnumerable <IEvent> GetByStreamId(StreamIdentifier streamId, params Type[] types)
 {
     // TODO fix
     throw new NotImplementedException();
 }
コード例 #24
0
 public StreamIdentifier GetStreamIdentifier()
 {
     return(StreamIdentifier.Create(Owner.Owner.Owner.Id, Owner.Id, Stream.Map));
 }
コード例 #25
0
 public static bool ReceiptBelongsToCommand(FFmpegCommand command, StreamIdentifier streamId)
 {
     return(command.Owner.Id == streamId.FactoryId &&
            command.Id == streamId.CommandId);
 }
コード例 #26
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))));
        }
コード例 #27
0
        public static MetadataInfoTreeContainer GetMetadataInfo(FFmpegCommand command, StreamIdentifier streamId)
        {
            //first validate that the streamId does in fact belong to the command.
            if (!CommandHelper.ReceiptBelongsToCommand(command, streamId))
            {
                throw new ArgumentException("The provided streamId is not part of the provided ffmpeg command.",
                                            "streamId");
            }

            var resourceIndex = CommandHelper.IndexOfResource(command, streamId);

            if (resourceIndex > -1)
            {
                return(ResourceMetadataInfo(command, resourceIndex));
            }

            var filterchainIndex = CommandHelper.IndexOfFilterchain(command, streamId);

            if (filterchainIndex > -1)
            {
                return(FilterchainMetadataInfo(command, filterchainIndex));
            }

            var outputIndex = CommandHelper.IndexOfOutput(command, streamId);

            if (outputIndex > -1)
            {
                return(OutputMetadataInfo(command, outputIndex));
            }

            return(null);
        }
コード例 #28
0
ファイル: EQPacket.cs プロジェクト: Vaion/Server
 public void SetVersionIdentifierMethod(StreamIdentifier Identifier)
 {
     this.Identifier = Identifier;
 }
コード例 #29
0
 public void SetVersionIdentifierMethod(StreamIdentifier Identifier)
 {
     this.Identifier = Identifier;
 }
コード例 #30
0
 public EventStreamNotFoundException(StreamIdentifier identifier)
     : base(string.Format("Stream Not Found Id: {0}", identifier.Value))
 {
 }
コード例 #31
0
 public EventStoreStream(StreamIdentifier identifier, IEnumerable <IEvent> events)
 {
     this.Id     = identifier.Value;
     this.Events = events.ToList();
 }
コード例 #32
0
 public bool Equals(StreamIdentifier streamId)
 {
     return(Map == streamId.Map &&
            CommandId == streamId.CommandId &&
            FactoryId == streamId.FactoryId);
 }