Пример #1
0
        public VideoChunk Next(VideoEvent @event)
        {
            StopTimestamp = @event.Timestamp;

            switch (@event.Type)
            {
            case VideoEventType.Add:
                return(new VideoChunk
                {
                    Segments = Segments.Concat(new[] { @event.Segment }).ToArray(),
                    StartTimestamp = @event.Timestamp
                });

            case VideoEventType.Remove:
                var segments = Segments.Where(x => x != @event.LastSegment).ToArray();
                if (segments.Length == 0)
                {
                    return(null);
                }
                return(new VideoChunk
                {
                    Segments = segments,
                    StartTimestamp = @event.Timestamp
                });

            case VideoEventType.Update:
                return(new VideoChunk
                {
                    Segments = Segments.Where(x => x != @event.LastSegment).Concat(new[] { @event.Segment }).ToArray(),
                    StartTimestamp = @event.Timestamp
                });

            default:
                throw new InvalidOperationException($"Unexpected video event type '{@event.Type}'.");
            }
        }
Пример #2
0
        public new GlobalPath Combine(params string[] segments)
        {
            var parsedSegments = segments.SelectMany((segment) => GetSegmentsFromString(segment));

            return(new GlobalPath(VolumeId, Segments.Concat(parsedSegments)));
        }