private void NewVolumeStream()
        {
            CurrentStream++;
            string newVolumeName = null;
            int    p             = _archiveName.LastIndexOf(".");

            if (p >= 0 && _altNames && (p + 1) == _archiveName.Length - 3)
            {
                if (CurrentStream == 0)
                {
                    newVolumeName = _archiveName;
                }
                else
                {
                    newVolumeName = _archiveName.Substring(0, p + 1) + (CurrentStream > 9 ? (CurrentStream > 99 ? CurrentStream.ToString() : "0" + CurrentStream) : "00" + CurrentStream);
                }
            }
            else
            {
                newVolumeName = _archiveName + VolumeNumber(CurrentStream + 1);
            }
            Streams.Add(File.Create(newVolumeName));
            Streams[CurrentStream].SetLength(_volumeSize);
            StreamOffsets.Add(CurrentStream, new KeyValuePair <long, long>(0, _volumeSize - 1));
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public AudioStream()
        {
            if (!AudioManager.IsInit)
            {
                Trace.WriteLine("[AudioStream] AudioStream() : No audio context available.");
                return;
            }

            // Add to the known list of audio streams
            if (Streams == null)
            {
                Streams = new List <AudioStream>();
            }
            Streams.Add(this);

            Buffers = OpenAL.AL.GenBuffers(2);
            AudioManager.Check();

            Source = OpenAL.AL.GenSource();
            AudioManager.Check();

            // Stream buffers
            BufferData             = new Dictionary <int, byte[]>();
            BufferData[Buffers[0]] = new byte[44100];
            BufferData[Buffers[1]] = new byte[44100];
        }
        public Task <Stream> GetReadWriteStream()
        {
            FileStream stream = null;

            try
            {
                Debug.WriteLine("OPENING READ/WRITE STREAM");
                stream = new FileStream(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
                if (!stream.CanRead)
                {
                    throw new IOException("Stream must readable");
                }
                if (!stream.CanWrite)
                {
                    throw new IOException("Stream must be writable");
                }
                if (!stream.CanSeek)
                {
                    throw new IOException("Stream must be seekable");
                }
                Streams.Add(stream);
                return(Task.FromResult((Stream)stream));
            }
            catch (Exception ex)
            {
                stream?.Close();
                return(Task.FromException <Stream>(ex));
            }
        }
Example #4
0
 private void NewVolumeStream()
 {
     CurrentStream++;
     Streams.Add(File.Create(_archiveName + VolumeNumber(CurrentStream + 1)));
     Streams[CurrentStream].SetLength(_volumeSize);
     StreamOffsets.Add(CurrentStream, new KeyValuePair <long, long>(0, _volumeSize - 1));
 }
Example #5
0
        public M3U8File(string rawData)
        {
            RawData = rawData;

            if (string.IsNullOrEmpty(rawData))
            {
                return;
            }

            var subs =
                rawData
                .Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
                .FirstOrDefault(e => e.StartsWith("#EXT-X-MEDIA:TYPE=SUBTITLES"));

            if (!string.IsNullOrEmpty(subs))
            {
                SubtitlesUri = new Uri(CsvParser.Parse(subs).FirstOrDefault(e => e.StartsWith("URI="))?.Substring(4) ?? "");
            }

            var lines =
                rawData.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)
                .Where(e => e.StartsWith("#EXT-X-STREAM-INF") || e.StartsWith("http"))
                .ToList();

            var i = 0;

            while (i < lines.Count)
            {
                Streams.Add(new StreamInformation(lines[i++], lines[i++]));
            }

            Streams.Sort();
        }
 /// Add an animation to a specific stream
 public void Add(TStream stream, IAnimation animation, IAnimationCurve curve, IAnimationTarget target)
 {
     Validate();
     animation.AnimationCurve  = curve;
     animation.AnimationTarget = target;
     Streams.Add(stream, animation);
 }
 /// Add an animation to a specific stream
 public void Add(TStream stream, IAnimation animation, IAnimationCurve curve, GameObject target)
 {
     Validate();
     animation.AnimationCurve  = curve;
     animation.AnimationTarget = new TargetSingle(target);
     Streams.Add(stream, animation);
 }
Example #8
0
        public async Task <Stream> GetReadWriteStream()
        {
            Stream stream = null;

            try
            {
                stream = await File.OpenStreamForWriteAsync();

                if (!stream.CanRead)
                {
                    throw new IOException("Stream must readable");
                }
                if (!stream.CanWrite)
                {
                    throw new IOException("Stream must be writable");
                }
                if (!stream.CanSeek)
                {
                    throw new IOException("Stream must be seekable");
                }
                Streams.Add(stream);
                return(stream);
            }
            catch (Exception)
            {
                stream?.Close();
                throw;
            }
        }
Example #9
0
        private void ParseStreams(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            var lines = new List <string>(data.Trim().Split('\n'));

            lines.RemoveAt(0);
            lines.RemoveAt(0);

            for (int i = 0; i < lines.Count / 2; i++)
            {
                string line1 = lines[i * 2];
                string line2 = lines[i * 2 + 1];

                var matchLine1 = Regex.Match(line1, "RESOLUTION=([0-9x]+),BANDWIDTH=([0-9]+)");

                if (matchLine1.Success)
                {
                    var bandwidth = int.Parse(matchLine1.Groups[2].Value);
                    var info      = new StreamInfo()
                    {
                        Url        = UrlHelper.GetBaseMasterUrl(masterUrl) + line2,
                        Bandwidth  = bandwidth,
                        Resolution = matchLine1.Groups[1].Value,
                        ApproxSize = (Duration * (bandwidth / 1024) / 1024 / 8)
                    };
                    Streams.Add(info);
                }
            }
        }
        public MainWindowViewModel()
        {
            AddLocalStreamCommand =
                new RelayCommand(p => Streams.Add(new LocalStreamViewModel()));

            AddUriStreamCommand =
                new RelayCommand(p => Streams.Add(new UriStreamViewModel()));
        }
Example #11
0
 public StreamTableElement(string name, params MaterialStream[] streams)
 {
     Name          = name;
     Icon.IconType = IconTypes.StreamTable;
     SetColors("Silver", "GhostWhite");
     foreach (MaterialStream stream in streams)
     {
         Streams.Add(stream);
     }
 }
Example #12
0
        void ProgramMapTableReceived(object sender, TsStreamEventArgs eventArgs)
        {
            var e = eventArgs as TsStreamEventArgs <TsTable>;

            if (e == null)
            {
                return;
            }

            lock (_syncObject)
            {
                var pmt = e.DecodedUnit.TableIdentifier == TableIdentifier.ProgramMap ? (ProgramMapTable)e.DecodedUnit : null;
                if (pmt == null)
                {
                    return;
                }

                Debug.WriteLine("Program Map Received");
                Debug.WriteLine("Program Number: " + pmt.ProgramNumber + " Program Clock Reference PID: " +
                                pmt.ProgramClockReferencePid);

                Info = pmt.ProgramInfo;
                foreach (var pm in pmt.Rows)
                {
                    Debug.WriteLine("******** " + pm.StreamType + " on PID " + pm.PacketIdentifier);
#if DEBUG
                    foreach (var descriptor in pm.StreamInfo)
                    {
                        Debug.WriteLine("\tHas " + descriptor.Tag + " descriptor.");
                    }
#endif
                    var stream =
                        (from s in Streams where s.PacketIdentifier == pm.PacketIdentifier select s).FirstOrDefault();
                    if (stream == null)
                    {
                        try
                        {
                            stream = (TsStream)Activator.CreateInstance(TsStream.StreamTypes[pm.StreamType]);
                            stream.PacketIdentifier = pm.PacketIdentifier;
                        }
                        catch (Exception)
                        {
                            stream = new ByteStream()
                            {
                                PacketIdentifier = pm.PacketIdentifier
                            };
                        }
                        Streams.Add(stream);
                        OnStreamAdded(stream);
                    }
                    stream.Type = pm.StreamType;
                    stream.Info = pm.StreamInfo;
                }
            }
        }
Example #13
0
 public StreamTableElement AddMaterialStream(MaterialStream stream)
 {
     if (!Streams.Contains(stream))
     {
         Streams.Add(stream);
     }
     else
     {
         throw new InvalidOperationException("Stream " + stream.Name + " already included in streamtable");
     }
     return(this);
 }
Example #14
0
        public async Task AddReleaseIfExists(string branchName)
        {
            string remoteName = branchName;

            //Handle "special names"
            switch (branchName)
            {
            case "Nightly":
                remoteName = "master";
                break;

            default:
                break;
            }

            string fullpath = $"refs/heads/{remoteName}";

            /*BlobContainerClient client =
             *  new BlobContainerClient(new Uri($"https://jppcdnstorage.blob.core.windows.net/{ProductFamily}"));*/
            string path = $"https://jppcdnstorage.blob.core.windows.net/{ProductFamily}";

            BlobContainerClient client = new BlobContainerClient(new Uri(path));

            var result = client.GetBlobsAsync(prefix: $"{fullpath}/{HostVerison}");

            long          buildId = 0;
            ReleaseStream rs      = new ReleaseStream()
            {
                Name  = branchName,
                Class = ReleaseClass.Alpha
            };

            await foreach (BlobItem blob in result)
            {
                if (blob.Name.EndsWith(".zip") && !blob.Deleted)
                {
                    string blobId  = Path.GetFileNameWithoutExtension(blob.Name);
                    long   foundId = long.Parse(blobId);

                    if (foundId > buildId)
                    {
                        buildId      = foundId;
                        rs.BaseUrl   = new Uri(client.Uri.AbsoluteUri + "/" + blob.Name);
                        rs.ReleaseId = buildId;
                    }
                }
            }

            if (buildId > 0)
            {
                Streams.Add(rs);
            }
        }
Example #15
0
        internal async ReusableTask <RentedStream> GetStreamAsync(ITorrentFileInfo file, FileAccess access)
        {
            if (!Streams.TryGetValue(file, out ITorrentFileStream s))
            {
                s = null;
            }

            if (s != null)
            {
                // If we are requesting write access and the current stream does not have it
                if (((access & FileAccess.Write) == FileAccess.Write) && !s.CanWrite)
                {
                    logger.InfoFormatted("Didn't have write permission for {0} - reopening", file.Path);
                    CloseAndRemove(file, s);
                    s = null;
                }
                else
                {
                    // Place the filestream at the end so we know it's been recently used
                    Streams.Remove(file);
                    Streams.Add(file, s);
                }
            }

            if (s == null)
            {
                if (!File.Exists(file.FullPath))
                {
                    if (!string.IsNullOrEmpty(Path.GetDirectoryName(file.FullPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(file.FullPath));
                    }
                    NtfsSparseFile.CreateSparse(file.FullPath, file.Length);
                }
                s = StreamCreator(file, access);

                // Ensure that we truncate existing files which are too large
                if (s.Length > file.Length)
                {
                    if (!s.CanWrite)
                    {
                        s.Dispose();
                        s = StreamCreator(file, FileAccess.ReadWrite);
                    }
                    await s.SetLengthAsync(file.Length);
                }

                Add(file, s);
            }

            return(new RentedStream(s));
        }
Example #16
0
        /// <summary>
        /// Initializes a new instance of the InMultiStreamWrapper class.
        /// </summary>
        /// <param name="fileName">The archive file name.</param>
        /// <param name="dispose">Perform Dispose() if requested to.</param>
        public InMultiStreamWrapper(string fileName, bool dispose) :
            base(dispose)
        {
            string baseName = fileName.Substring(0, fileName.Length - 4);
            int    i        = 0;

            while (File.Exists(fileName))
            {
                Streams.Add(new FileStream(fileName, FileMode.Open));
                long length = Streams[i].Length;
                StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length));
                StreamLength += length;
                fileName      = baseName + VolumeNumber(i + 1);
            }
        }
        /// <summary>   Initializes a new instance of the InMultiStreamWrapper class.</summary>
        /// <param name="fileName">         The archive file name.</param>
        /// <param name="altVolumeNaming">  true to alternate volume naming.</param>
        /// <param name="zipMultiVolume">   true to zip multi volume.</param>
        /// <param name="dispose">          Perform Dispose() if requested to.</param>
        public InMultiStreamWrapper(string fileName, bool altVolumeNaming, bool zipMultiVolume, bool dispose) :
            base(dispose, zipMultiVolume)
        {
            string baseName;
            string originalName = fileName;
            long   length       = 0;
            int    i            = 0;

            zipFormat = zipMultiVolume;
            if (zipMultiVolume)
            {
                baseName = fileName.Substring(0, fileName.Length - 2);

                while (true)
                {
                    int j = i + 1;
                    fileName = baseName + (j > 9 ? j.ToString() : "0" + j);
                    if (!File.Exists(fileName))
                    {
                        break;
                    }
                    Streams.Add(new FileStream(fileName, FileMode.Open, FileAccess.Read));
                    length = Streams[i].Length;
                    StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length));
                    StreamLength += length;
                }

                Streams.Add(new FileStream(originalName, FileMode.Open, FileAccess.Read));
                length = Streams[i].Length;
                StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length));
                StreamLength += length;
            }
            else
            {
                baseName = fileName.Substring(0, fileName.Length - 4);

                while (File.Exists(fileName))
                {
                    Streams.Add(new FileStream(fileName, FileMode.Open, FileAccess.Read));
                    length = Streams[i].Length;
                    StreamOffsets.Add(i++, new KeyValuePair <long, long>(StreamLength, StreamLength + length));
                    StreamLength += length;
                    fileName      = baseName + VolumeNumber(i + (altVolumeNaming ? 0 : 1));
                }
            }
        }
Example #18
0
 public Stream ExtractEager()
 {
     lock (this)
     {
         if (!_disposed)
         {
             var fi = (FsItem as FileInfo).AssertNotNull();
             var fs = fi.OpenRead();
             Streams.Add(fs);
             return(fs);
         }
         else
         {
             throw new ObjectDisposedException(this.ToString());
         }
     }
 }
Example #19
0
        void Add(ITorrentFileInfo file, ITorrentFileStream stream)
        {
            logger.InfoFormatted("Opening filestream: {0}", file.FullPath);

            if (MaxStreams != 0 && Streams.Count >= MaxStreams)
            {
                for (int i = 0; i < UsageOrder.Count; i++)
                {
                    if (!Streams[UsageOrder[i]].Rented)
                    {
                        CloseAndRemove(UsageOrder[i], Streams[UsageOrder[i]]);
                        break;
                    }
                }
            }
            Streams.Add(file, stream);
            UsageOrder.Add(file);
        }
Example #20
0
 public void Connect(T stream)
 {
     if (Streams.Count < Multiplicity || Multiplicity == -1)
     {
         if (!Streams.Contains(stream))
         {
             IsConnected = true;
             Streams.Add(stream);
         }
         else
         {
             throw new InvalidOperationException("Stream " + stream.Name + " already connected to port " + Name);
         }
     }
     else
     {
         throw new InvalidOperationException("No more streams allowed for port " + Name);
     }
 }
Example #21
0
        private void ParseStreams(string data, string streamBaseUrl, string extra)
        {
            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            var lines = new List <string>(data.Trim().Split('\n'));

            if (lines.Count < 4)
            {
                return;
            }

            lines.RemoveRange(0, 2);

            for (int i = 0; i < lines.Count / 2; i++)
            {
                string line1 = lines[i * 2];
                string line2 = lines[i * 2 + 1];

                var matchLine1 = Regex.Match(line1, "BANDWIDTH=([0-9]+),CODECS=\"(.+)\",RESOLUTION=([0-9x]+)");
                var matchLine2 = Regex.Match(line2, "(.+)\\?");

                if (matchLine1.Success && matchLine2.Success)
                {
                    var bandwidth = int.Parse(matchLine1.Groups[1].Value);
                    var info      = new StreamInfo()
                    {
                        Url        = _urBaseurl + streamBaseUrl + matchLine2.Groups[1].Value,
                        Bandwidth  = bandwidth,
                        Resolution = matchLine1.Groups[3].Value,
                        Codec      = matchLine1.Groups[2].Value,
                        ApproxSize = (Duration * (bandwidth / 1024) / 1024 / 8),
                        Extra      = extra
                    };
                    Streams.Add(info);
                }
            }
        }
        StreamItem AddStreamItem(string streamName)
        {
            var stream = new StreamItem()
            {
                Enabled = true,
                Name    = streamName,
                Color   = _colors[(_currentColor++)]
            };

            stream.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "Enabled")
                {
                    var streamItem = (StreamItem)sender;
                    var e          = new StreamChangedEventArgs(streamItem.Name, streamItem.Enabled);
                    OnStreamChanged(e);
                }
            };

            Streams.Add(stream);

            return(stream);
        }
Example #23
0
        public override void DownloadAndParseData()
        {
            string info          = streamDownloader.Download(DataUrl);
            var    infoColletion = HttpUtility.ParseQueryString(info);

            Title = infoColletion["title"];
            if (string.IsNullOrEmpty(Title))
            {
                Title = HttpUtility.ParseQueryString(new Uri(BaseUrl).Query)["v"];
            }

            Duration = string.IsNullOrEmpty(infoColletion["length_seconds"]) ? 0 : int.Parse(infoColletion["length_seconds"]);

            var availableFormats = infoColletion["url_encoded_fmt_stream_map"];

            if (availableFormats == string.Empty)
            {
                return;
            }

            var formatList = new List <string>(Regex.Split(availableFormats, VideoUrlsSeparator));

            //formatList.ForEach(format =>
            //{
            //    if (string.IsNullOrEmpty(format.Trim()))
            //        return;

            //    var formatInfoCollection = HttpUtility.ParseQueryString(format);
            //    var urlEncoded = formatInfoCollection["url"];
            //    var itag = formatInfoCollection["itag"];
            //    var quality = formatInfoCollection["quality"];
            //    var signature = formatInfoCollection["sig"];
            //    var fallbackHost = formatInfoCollection["fallback_host"];
            //    var formatCode = int.Parse(itag);

            //    urlEncoded = string.Format("{0}&fallback_host={1}&signature={2}", urlEncoded, fallbackHost, signature);
            //    var url = new Uri(HttpUtility.UrlDecode(HttpUtility.UrlDecode(urlEncoded)));
            //    Streams.Add(new YouTubeStreamInfo(url.ToString(), quality, formatCode));
            //});

            var hdFormats = infoColletion["adaptive_fmts"];

            formatList = new List <string>(Regex.Split(hdFormats, VideoUrlsSeparator));
            formatList.ForEach(format =>
            {
                if (string.IsNullOrEmpty(format.Trim()))
                {
                    return;
                }

                var formatInfoCollection = HttpUtility.ParseQueryString(format);
                var urlEncoded           = formatInfoCollection["url"];
                var itag         = formatInfoCollection["itag"];
                var quality      = formatInfoCollection["quality_label"];
                var signature    = formatInfoCollection["sig"];
                var bitrate      = formatInfoCollection["bitrate"];
                var bandwidth    = string.IsNullOrEmpty(bitrate) ? 0 : int.Parse(bitrate);
                var fallbackHost = formatInfoCollection["fallback_host"];
                var formatCode   = int.Parse(itag);

                urlEncoded = $"{urlEncoded}&fallback_host={fallbackHost}&signature={signature}";
                var url    = new Uri(HttpUtility.UrlDecode(HttpUtility.UrlDecode(urlEncoded)));
                var stream = new YouTubeStreamInfo(url.ToString(), quality, formatCode)
                {
                    Bandwidth  = bandwidth,
                    ApproxSize = (Duration * (bandwidth / 1024) / 1024 / 8)
                };

                Streams.Add(stream);
                Debug.WriteLine("Found stream id={0} quality={1}", stream.FormatCode, stream.Quality);
            });

            var bestMpaAudio = Streams.Cast <YouTubeStreamInfo>()
                               .Where(s => s.FormatCode >= 139 && s.FormatCode <= 141)
                               .OrderByDescending(s => s.FormatCode).FirstOrDefault();
            var bestWebMAudio = Streams.Cast <YouTubeStreamInfo>()
                                .Where(s => s.FormatCode >= 170 && s.FormatCode <= 171)
                                .OrderByDescending(s => s.FormatCode).FirstOrDefault();

            //If we have separate audio streams then select the best for later muxing.
            //If not then hope there is audio in the stream..
            //WebM & Mp4 Video only
            Streams.Cast <YouTubeStreamInfo>().Where(s => s.FileEnding == ".mp4")
            .ToList().ForEach(s =>
            {
                if (bestMpaAudio != null)
                {
                    s.AudioUrl   = bestMpaAudio.AudioUrl;
                    s.StreamType = StreamType.VideoSeparateAudio;
                }
            });
            Streams.Cast <YouTubeStreamInfo>().Where(s => s.FileEnding == ".webm")
            .ToList().ForEach(s =>
            {
                if (bestWebMAudio != null)
                {
                    s.AudioUrl   = bestWebMAudio.AudioUrl;
                    s.StreamType = StreamType.VideoSeparateAudio;
                }
            });

            Streams.Reverse();
            Streams.RemoveAll(s => s.Resolution.Contains("Unknown"));

            PosterUrl = infoColletion["thumbnail_url"];
            if (!string.IsNullOrEmpty(PosterUrl))
            {
                PosterImage = streamDownloader.DownloadImage(PosterUrl);
            }
        }
Example #24
0
        /// <summary>
        /// Creates and adds a few ItemViewModel objects into the Items collection.
        /// </summary>
        public void LoadData()
        {
            Statuses.Add(new ItemViewModel {
                Operation = "tweet", PageUri = "/StatusDemos/TweetDemo.xaml"
            });
            Statuses.Add(new ItemViewModel {
                Operation = "home timeline", PageUri = "/StatusDemos/HomeTimelineDemo.xaml"
            });

            Streams.Add(new ItemViewModel {
                Operation = "filter stream", PageUri = "/StreamingDemos/FilterStreamDemo.xaml"
            });
            Streams.Add(new ItemViewModel {
                Operation = "sample stream", PageUri = "/StreamingDemos/SampleStreamDemo.xaml"
            });
            Streams.Add(new ItemViewModel {
                Operation = "user stream", PageUri = "/StreamingDemos/UserStreamDemo.xaml"
            });

            // Sample data; replace with real data
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime one", PageUri = "Maecenas praesent accumsan bibendum"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime two", PageUri = "Dictumst eleifend facilisi faucibus"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime three", PageUri = "Habitant inceptos interdum lobortis"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime four", PageUri = "Nascetur pharetra placerat pulvinar"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime five", PageUri = "Maecenas praesent accumsan bibendum"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime six", PageUri = "Dictumst eleifend facilisi faucibus"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime seven", PageUri = "Habitant inceptos interdum lobortis"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime eight", PageUri = "Nascetur pharetra placerat pulvinar"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime nine", PageUri = "Maecenas praesent accumsan bibendum"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime ten", PageUri = "Dictumst eleifend facilisi faucibus"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime eleven", PageUri = "Habitant inceptos interdum lobortis"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime twelve", PageUri = "Nascetur pharetra placerat pulvinar"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime thirteen", PageUri = "Maecenas praesent accumsan bibendum"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime fourteen", PageUri = "Dictumst eleifend facilisi faucibus"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime fifteen", PageUri = "Habitant inceptos interdum lobortis"
            });
            this.Items.Add(new ItemViewModel()
            {
                Operation = "runtime sixteen", PageUri = "Nascetur pharetra placerat pulvinar"
            });

            this.IsDataLoaded = true;
        }
Example #25
0
 public void AddReleaseStream(ReleaseStream stream)
 {
     Streams.Add(stream.Name, stream);
 }
Example #26
0
            public bool AddStream(Stream stream)
            {
                // if the stream clashes with another stream
                if (!Fits(stream))
                {
                    return(false);
                }

                // add to list of streams
                Streams.Add(stream);

                // run through list of classes
                foreach (Session session in stream.Classes)
                {
                    // increase total time spent in classes
                    TimeInClasses += session.Length;

                    // if we're adding the class to an empty day
                    if (_classesByDay[session.Day].Count == 0)
                    {
                        // increment day count
                        Days++;
                        // add start and ending times to totals
                        _totalStart += new TimeLength(session.StartTime.DayMinutes);
                        _totalEnd   += new TimeLength(session.EndTime.DayMinutes);

                        // add length to total time at uni
                        TimeAtUni += session.Length;
                    }
                    else
                    {
                        // if it's earlier than the earliest class of that day
                        if (session.StartTime < _classesByDay[session.Day][0].StartTime)
                        {
                            TimeLength difference = _classesByDay[session.Day][0].StartTime - session.StartTime;
                            // remove the difference for total start
                            _totalStart -= difference;
                            // add the difference for total time at uni
                            TimeAtUni += difference;
                        }
                        // if it's later than the latest class
                        if (session.EndTime > _classesByDay[session.Day][_classesByDay[session.Day].Count - 1].EndTime)
                        {
                            TimeLength difference = session.EndTime -
                                                    _classesByDay[session.Day][_classesByDay[session.Day].Count - 1]
                                                    .EndTime;
                            // add the difference for total end
                            _totalEnd += difference;
                            // add the difference for total time at uni
                            TimeAtUni += difference;
                        }
                    }
                    // update average day length
                    AverageDayLength = TimeAtUni / Days;

                    // add new classes to day-indexed list
                    _classesByDay[session.Day].Add(session);
                    //ClassesByDay_[session.Day].Sort();

                    // check class start/end times against maxima/minima
                    if (session.StartTime < EarlyStart)
                    {
                        EarlyStart = session.StartTime;
                    }
                    if (session.StartTime > LateStart)
                    {
                        LateStart = session.StartTime;
                    }
                    if (session.EndTime < EarlyEnd)
                    {
                        EarlyEnd = session.EndTime;
                    }
                    if (session.EndTime > LateEnd)
                    {
                        LateEnd = session.EndTime;
                    }

                    // check day length
                    TimeLength dayLength = _classesByDay[session.Day][_classesByDay[session.Day].Count - 1].EndTime -
                                           _classesByDay[session.Day][0].StartTime;
                    if (dayLength < MinDayLength)
                    {
                        MinDayLength = dayLength;
                    }
                    if (dayLength > MaxDayLength)
                    {
                        MaxDayLength = dayLength;
                    }
                }

                // clear break data
                NumberBreaks = 0;
                AverageBreak = new TimeLength(0, 0);
                ShortBreak   = new TimeLength(24, 0);
                LongBreak    = new TimeLength(0, 0);
                TimeInBreaks = new TimeLength(0, 0);
                // clear block data
                NumberBlocks = 0;
                AverageBlock = new TimeLength(0, 0);
                ShortBlock   = new TimeLength(24, 0);
                LongBlock    = new TimeLength(0, 0);
                // TODO: rewrite to avoid full sweep?
                // do a fresh sweep of all days to rebuild break/block data
                foreach (List <Session> daySessions in _classesByDay)
                {
                    // empty day - skip
                    if (daySessions.Count == 0)
                    {
                        continue;
                    }

                    int i;
                    CompareAdjacent(daySessions, out i);
                }

                if (NumberBreaks > 0)
                {
                    // divide the sum of breaks to find the mean
                    AverageBreak = TimeInBreaks / NumberBreaks;
                }

                // divide the sum of blocks to find the mean
                AverageBlock /= NumberBlocks;

                AverageStart = new TimeOfDay(_totalStart.TotalMinutes / Days);
                AverageEnd   = new TimeOfDay(_totalEnd.TotalMinutes / Days);

                return(true);
            }
Example #27
0
 /// <summary>Adds a stream. <para /> Use <seealso cref="FilterStream" /> to add filter-based streams. </summary>
 /// <param name="stream">to add</param>
 /// <returns>from clause</returns>
 public FromClause Add(Stream stream)
 {
     Streams.Add(stream);
     return(this);
 }
Example #28
0
 internal void OnStreamAdded(QuicStream stream)
 {
     Streams.Add(stream);
 }
        /// <summary>
        /// Aktiviert den Empfang einer Quelle.
        /// </summary>
        /// <param name="sources">Informationen zu den zu aktivierenden Quellen.</param>
        protected override void OnAddSources(ReceiveInformation[] sources)
        {
            // Prepare operation
            Start(device =>
            {
                // Check mode
                if (EPGProgress.HasValue)
                {
                    CardServerException.Throw(new EPGActiveFault());
                }
                if (m_ScanProgress >= 0)
                {
                    CardServerException.Throw(new SourceUpdateActiveFault());
                }

                // Force reload of group information to be current
                device.ResetInformationReaders();

                // Create optimizer
                var optimizer = new StreamSelectionOptimizer();

                // Source backmap
                var infos = new Dictionary <SourceIdenfierWithKey, ReceiveInformation>();

                // Pre-Test
                foreach (var info in sources)
                {
                    // It's not allowed to activate a source twice
                    var key = new SourceIdenfierWithKey(info.UniqueIdentifier, info.Selection.Source);
                    if (FindSource(key) != null)
                    {
                        CardServerException.Throw(new SourceInUseFault(info.Selection.Source));
                    }

                    // Remember
                    infos.Add(key, info);

                    // Prepare to optimize
                    optimizer.Add(info.Selection, info.Streams);
                }

                // See how many we are allowed to start
                var allowed = optimizer.Optimize();

                // Streams to activate
                var newStreams = new List <ActiveStream>();
                try
                {
                    // Process all
                    for (int i = 0; i < allowed; ++i)
                    {
                        // Attach to the source
                        var current = sources[i];
                        var source  = current.Selection;
                        var key     = new SourceIdenfierWithKey(current.UniqueIdentifier, source.Source);

                        // Create the stream manager
                        var manager = source.Open(optimizer.GetStreams(i));

                        // Attach file size mapper
                        manager.FileBufferSizeChooser = infos[key].GetFileBufferSize;

                        // Create
                        var stream = new ActiveStream(key.UniqueIdentifier, manager, current.Streams, current.RecordingPath);

                        // Remember
                        newStreams.Add(stream);

                        // See if we have to connect an optimizer for restarts
                        if (device.HasConsumerRestriction)
                        {
                            stream.EnableOptimizer(source);
                        }

                        // Try to start
                        stream.Refresh(m_RetestWatchDogInterval);
                    }

                    // Loaded all
                    newStreams.ForEach(stream => Streams.Add(stream.SourceKey, stream));

                    // Generate response
                    try
                    {
                        // Create all
                        return(newStreams.Select(stream => stream.CreateInformation()).ToArray());
                    }
                    finally
                    {
                        // No need to clean up
                        newStreams.Clear();
                    }
                }
                finally
                {
                    // Cleanup
                    newStreams.ForEach(stream => stream.Dispose());
                }
            });
        }
        /// <summary>
        /// Aktiviert eine einzelne Quelle für den <i>Zapping Modus</i>.
        /// </summary>
        /// <param name="source">Die gewünschte Quelle.</param>
        /// <param name="target">Die Netzwerkadresse, an die alle Daten versendet werden sollen.</param>
        protected override void OnSetZappingSource(SourceSelection source, string target)
        {
            // Prepare operation
            Start(device =>
            {
                // The next stream identifier to use
                short nextStreamIdentifier = 0;
                if (Streams.Count > 0)
                {
                    nextStreamIdentifier = Streams.Values.First().Manager.NextStreamIdentifier;
                }

                // Activate the source group - will terminate all active streams
                SelectGroup(device, source);

                // Create optimizer and stream selector
                var optimizer = new StreamSelectionOptimizer();
                var streams   =
                    new StreamSelection
                {
                    AC3Tracks    = { LanguageMode = LanguageModes.All },
                    MP2Tracks    = { LanguageMode = LanguageModes.All },
                    SubTitles    = { LanguageMode = LanguageModes.All },
                    ProgramGuide = true,
                    Videotext    = true,
                };

                // Prepare to optimize
                optimizer.Add(source, streams);

                // See how many we are allowed to start
                optimizer.Optimize();

                // Create
                var stream = new ActiveStream(Guid.Empty, source.Open(optimizer.GetStreams(0)), streams, null);
                try
                {
                    // Configure streaming target
                    stream.Manager.StreamingTarget = target;

                    // Attach next stream identifier
                    stream.Manager.NextStreamIdentifier = nextStreamIdentifier;

                    // See if we have to connect an optimizer for restarts
                    if (device.HasConsumerRestriction)
                    {
                        stream.EnableOptimizer(source);
                    }

                    // Try to start
                    stream.Refresh(m_RetestWatchDogInterval);

                    // Load
                    Streams.Add(stream.SourceKey, stream);
                }
                catch
                {
                    // Cleanup
                    stream.Dispose();

                    // Forward
                    throw;
                }

                // Report state
                return(CreateState(device));
            });
        }