예제 #1
0
        static bool Pull(Options opt)
        {
            bool result = false;

            opt.Status            = Options.TheadStatus.Running;
            opt.ThreadStartTime   = DateTime.Now;
            opt.ThreadCounterTime = DateTime.Now;
            opt.LogInformation("\r\nPull " + opt.Name + "\r\n Pulling from : " + opt.InputUri + "\r\n Storing in   : " + opt.OutputUri);


            DiskCache d = new DiskCache();

            d.Initialize(opt.OutputUri);
            ManifestManager mc = ManifestManager.CreateManifestCache(new Uri(opt.InputUri), (ulong)opt.MinBitrate, (ulong)opt.MaxBitrate, opt.AudioTrackName, opt.TextTrackName, opt.MaxDuration, (ulong)opt.BufferSize, opt.LiveOffset);

            mc.SetManifestOutput(d);
            var t = d.RemoveAsset(mc);

            t.Wait();
            t = mc.DownloadManifest();
            t.Wait();
            result = t.Result;
            if (result == true)
            {
                var tt = mc.StartDownloadChunks();
                tt.Wait();
                result = tt.Result;
                while (mc.GetAssetStatus() != AssetStatus.ChunksDownloaded)
                {
                    if (opt.CounterPeriod > 0)
                    {
                        System.Threading.Tasks.Task.Delay(opt.CounterPeriod * 1000 / 10).Wait();
                        if ((opt.ListCounters == null) || (opt.ListCounters.Count == 0))
                        {
                            CreatePullCounters(opt, mc);
                        }
                        else
                        {
                            UpdatePullCounters(opt, mc);
                        }
                    }
                    else
                    {
                        System.Threading.Tasks.Task.Delay(1000).Wait();
                    }
                }
            }

            opt.LogInformation("Pull " + opt.Name + " done");
            opt.Status = Options.TheadStatus.Stopped;
            return(result);
        }
예제 #2
0
파일: Pull.cs 프로젝트: fvneerden/ASTool
        static public async Task <bool> Pull(Options opt)
        {
            bool result = false;

            opt.Status          = Options.TheadStatus.Running;
            opt.ThreadStartTime = DateTime.Now;
            opt.LogInformation("\r\nPull " + opt.Name + "\r\n Pulling from : " + opt.InputUri + "\r\n Storing in   : " + opt.OutputUri);


            DiskCache d = new DiskCache();

            d.Initialize(opt.OutputUri);
            ManifestManager mc = ManifestManager.CreateManifestCache(new Uri(opt.InputUri), (ulong)opt.MinBitrate, (ulong)opt.MaxBitrate, opt.AudioTrackName, opt.TextTrackName, opt.MaxDuration, (ulong)opt.BufferSize, opt.LiveOffset);

            mc.SetManifestOutput(d);
            await d.RemoveAsset(mc);

            result = await mc.DownloadManifest();

            if (result == true)
            {
                result = await mc.StartDownloadChunks();

                while (mc.GetAssetStatus() != AssetStatus.ChunksDownloaded)
                {
                    await Task.Delay(5000);

                    if ((opt.ListCounters == null) || (opt.ListCounters.Count == 0))
                    {
                        CreatePullCounters(opt, mc);
                    }
                    else
                    {
                        UpdatePullCounters(opt, mc);
                    }
                }
            }

            opt.LogInformation("Pull " + opt.Name + " done");
            opt.Status = Options.TheadStatus.Stopped;
            return(result);
        }