async void OnFrameAvailable(object sender, FrameReadyEventArgs e)
        {
            lastFrameTime = Environment.TickCount;

            var img = e.BitmapSource;

            CameraImage.Source = e.BitmapSource;

            if (img != null)
            {
                device.CameraInfo.LastFrame = img;
            }

            if (lastCheckTime + 1000 < lastFrameTime)
            {
                lastCheckTime = Environment.TickCount;
                var properties = await device.GetStatus();

                if (properties.ContainsKey("alarm_status"))
                {
                    // device current alarm status,0=no alarm;1=motion detection alarm;2=input alarm;3=voice detection alarm
                    double alarm = (double)properties["alarm_status"];
                    if (alarm == 1)
                    {
                        SaveFrame(e.BitmapSource);
                    }
                }
            }
        }
示例#2
0
        private async void SetupNewCamera(FoscamDevice device)
        {
            var newCam = store.MergeNewCamera(device.CameraInfo);

            if (newCam.IsNew || newCam.LastPingTime + 10000 < Environment.TickCount)
            {
                // get the device properties
                device = new FoscamDevice()
                {
                    CameraInfo = newCam
                };
                var properties = await device.GetStatus();

                if (properties.HasValue("Error"))
                {
                    device.CameraInfo.StaticError = properties.GetValue <string>("Error");
                }
                else
                {
                    var realName = properties.GetValue <string>("alias");
                    if (!string.IsNullOrEmpty(realName))
                    {
                        newCam.Name = realName;
                    }

                    var sysver = properties.GetValue <string>("sys_ver");
                    if (!string.IsNullOrEmpty(sysver))
                    {
                        newCam.SystemVersion = sysver;
                    }

                    var webver = properties.GetValue <string>("app_ver");
                    if (!string.IsNullOrEmpty(webver))
                    {
                        newCam.WebUiVersion = webver;
                    }

                    CheckFirmwareVersion(device);
                    newCam.IsNew = false;
                }
            }

            Prompt.Text             = "";
            newCam.LastPingTime     = Environment.TickCount;
            newCam.Rebooting        = false;
            newCam.UpdatingFirmware = false;
            newCam.PropertyChanged -= OnCameraPropertyChanged;
            newCam.PropertyChanged += OnCameraPropertyChanged;

            if (store.Cameras.Count > 1 && noCamera != null && store.Cameras.Contains(noCamera))
            {
                this.RemoveNoCameraMessage();
            }
        }