Ejemplo n.º 1
0
        /// <summary>
        /// Preview archive fragments
        /// </summary>
        /// <param name="camera">Selected camera</param>
        /// <returns></returns>
        /// <remarks>
        /// TODO: Improve performance. Solve freeze behavior.
        /// </remarks>
        private async Task InitFragmentsAsync(CameraViewModel camera)
        {
            try
            {
                _fragments.Clear();
                camera.Model.Fragments.Clear();

                DateTime dateEnd   = DateTime.Now.ToUniversalTime();
                DateTime dateStart = new DateTime(year: dateEnd.Year - 1,
                                                  month: dateEnd.Month,
                                                  day: dateEnd.Day,
                                                  hour: dateEnd.Hour,
                                                  minute: dateEnd.Minute,
                                                  second: dateEnd.Second);

                string      url = _spec.GetArchiveUrl(camera.Model, dateStart, dateEnd);
                XmlDocument doc = await SpecificationModel.GetXmlDocAsync(url);

                await camera.Model.InitFragments(doc);

                foreach (ArchiveFragment f in camera.Model.Fragments)
                {
                    _fragments.Add(new ArchiveFragmentViewModel(f.FromTime, f.ToTime));
                }
            }
            catch (InvalidOperationException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        private void DummyInitCamera(string text = "None")
        {
            _cameras.Clear();
            CameraViewModel empty = new CameraViewModel(new Camera(name: text, id: null));

            _cameras.Add(empty);
        }
Ejemplo n.º 3
0
        public async void ChangeStream(CameraViewModel camera, DateTime?time)
        {
            CloseStream();

            if (camera.Id == null)      // Dummy camera
            {
                Timestamp = "";
                _fragments.Clear();
                SetStartScreen();
                return;
            }

            CancellationToken token = _cts.Token;

            InitFragmentsAsync(camera);

            string url = _spec.GetStreamRequestUrl(camera.Model, time);

            try
            {
                await _stream.StartAsync(url, token);
            }
            catch (OperationCanceledException)
            {
                System.Diagnostics.Debug.WriteLine("User cancel stream.");
            }
        }