Esempio n. 1
0
        private void getStaticInfo(Dictionary <string, CCTVStaticInfo> staticDict, VideoParser.Front front, VideoParser.Video video, int channel)
        {
            CCTVStaticInfo info = new CCTVStaticInfo()
            {
                VideoId      = getNodeId(video.Id),
                Name         = video.Name,
                IP           = front.Host,
                HighDef      = video.HighDef,
                PanTilt      = video.PanTiltUnit != null && (video.PanTiltUnit.EightDirections || video.PanTiltUnit.FourDirections),
                Zoom         = video.PanTiltUnit != null && video.PanTiltUnit.Zoom,
                AuxSwitch    = getAuxSwitch(video.PanTiltUnit),
                VideoAnalyze = video.VideoAnalyze,
                TargetTrack  = video.PanTiltUnit != null && video.PanTiltUnit.Trackable,
                Streams      = getStreamInfos(video),
            };

            info.ImageTrackHost = ImageTrackInfoProvider.Instance.GetImageTrackHost(video.Id);
            info.ImageTrack     = !string.IsNullOrEmpty(info.ImageTrackHost);
            if (video.DvrChannel > 0)
            {
                channel = video.DvrChannel;
            }
            info.DvrChannelInfo = getDvrChannelInfo(front, channel);

            if (info.TargetTrack && video.PanTiltUnit != null)
            {
                var ptz = video.PanTiltUnit;
                info.Latitude  = ptz.Latitude;
                info.Longitude = ptz.Longitude;
                info.Altitude  = ptz.Altitude;
                info.TrackInfo = new TrackVideoInfo()
                {
                    UpLimit     = ptz.UpLimit,
                    DownLimit   = ptz.DownLimit,
                    LeftLimit   = ptz.LeftLimit,
                    RightLimit  = ptz.RightLimit,
                    MaxViewPort = ptz.WideView,
                    MinViewPort = ptz.TeleView,
                };
            }
            else
            {
                VideoPosition videoPosition;
                if (_videoPosSync.TryGetValue(info.VideoId, out videoPosition))
                {
                    info.Latitude  = videoPosition.Latitude;
                    info.Longitude = videoPosition.Longitude;
                    info.Altitude  = videoPosition.Altitude;
                    info.Heading   = videoPosition.Heading;
                    info.ViewPort  = videoPosition.ViewPort;
                }
            }

            staticDict[info.VideoId] = info;
        }
Esempio n. 2
0
        private void onUpdate(StaticInfoSynchronizer <ThumbnailInfo> synchronizer, IEnumerable <string> keysUpdated)
        {
            string        key = keysUpdated.FirstOrDefault();
            ThumbnailInfo info;

            if (key != null && synchronizer.TryGetValue(key, out info))
            {
                _info = info;
                fireUpdateEvent(info);
            }
        }
Esempio n. 3
0
        CCTVDynamicInfo getCameraInfo(VideoParser.Camera camera)
        {
            if (camera != null)
            {
                CCTVDynamicInfo dynamicInfo = getDynamicInfo(getNodeId(camera.Id));
                dynamicInfo.Heading = camera.Pointing.Pan;
                CCTVStaticInfo staticInfo;
                if (_staticSync.TryGetValue(dynamicInfo.VideoId, out staticInfo) && staticInfo.TrackInfo != null)
                {
                    double zoom = Math.Min(1, Math.Max(0, camera.Zoom));
                    dynamicInfo.ViewPort = (1 - zoom) * (staticInfo.TrackInfo.MaxViewPort - staticInfo.TrackInfo.MinViewPort) + staticInfo.TrackInfo.MinViewPort;
                }
                return(dynamicInfo);
            }

            return(null);
        }
Esempio n. 4
0
        CCTVDynamicInfo getCameraInfo(VideoParser.Camera camera)
        {
            if (camera != null)
            {
                CCTVDynamicInfo dynamicInfo = getDynamicInfo(getNodeId(camera.Id));
                dynamicInfo.Heading = camera.Pointing.Pan;
                dynamicInfo.Tilt    = camera.Pointing.Tilt;
                CCTVStaticInfo   staticInfo;
                CCTVCameraLimits cLimits;
                if (_staticSync.TryGetValue(dynamicInfo.VideoId, out staticInfo) && _cameraSync.TryGetValue(dynamicInfo.VideoId, out cLimits))
                {
                    double zoom = Math.Min(1, Math.Max(0, camera.Zoom));
                    dynamicInfo.ViewPort = (1 - zoom) * (cLimits.MaxViewPort - cLimits.MinViewPort) + cLimits.MinViewPort;
                }
                return(dynamicInfo);
            }

            return(null);
        }
        private void classifyInfo(VideoParser.Front front, VideoParser.Video video, int channel, string serverId)
        {
            //在线标识。
            var videoId = getNodeId(video.Id);

            if (video.DvrChannel > 0)
            {
                channel = video.DvrChannel;
            }

            _onlineStatus[videoId] = new CCTVOnlineStatus()
            {
                VideoId = videoId, Online = video.Online
            };

            CCTVStaticInfo info = new CCTVStaticInfo()
            {
                VideoId   = videoId,
                Name      = video.Name,
                ImageType = video.HighDef ? ImageType.HighDef : ImageType.Unknow,
                Platform  = CCTVPlatformType.CCTV1,
                Streams   = getStreamInfos(video, channel),
            };

            if (video.PanTiltUnit != null && video.PanTiltUnit.Trackable)
            {
                var ptz = video.PanTiltUnit;
                info.Latitude  = ptz.Latitude;
                info.Longitude = ptz.Longitude;
                info.Altitude  = ptz.Altitude;
                //生成摄像机象限信息
                CCTVCameraLimits camera = new CCTVCameraLimits()
                {
                    VideoId     = info.VideoId,
                    UpLimit     = ptz.UpLimit,
                    DownLimit   = ptz.DownLimit,
                    LeftLimit   = ptz.LeftLimit,
                    RightLimit  = ptz.RightLimit,
                    MaxViewPort = ptz.WideView,
                    MinViewPort = ptz.TeleView
                };
                _cameras[camera.VideoId] = camera;
            }
            else
            {
                VideoPosition videoPosition;
                if (_vpSync.TryGetValue(info.VideoId, out videoPosition))
                {
                    info.Latitude  = videoPosition.Latitude;
                    info.Longitude = videoPosition.Longitude;
                    info.Altitude  = videoPosition.Altitude;
                    info.Heading   = videoPosition.Heading;
                    info.ViewPort  = videoPosition.ViewPort;
                }
            }
            _statics[info.VideoId] = info;

            //视频跟踪
            var vTrackHost = ImageTrackInfoProvider.Instance.GetImageTrackHost(video.Id);

            if (!string.IsNullOrWhiteSpace(vTrackHost))
            {
                var vTrack = new CCTVVideoTrack()
                {
                    Ip      = vTrackHost,
                    RpcPort = 8068,
                    SubPort = 8061,
                    VideoId = info.VideoId
                };
                _videoTracks[vTrack.VideoId] = vTrack;
            }


            //生成设备信息。
            CCTVDeviceInfo di = new CCTVDeviceInfo()
            {
                VideoId           = info.VideoId,
                DeviceType        = DeviceType.HikIP,
                PreferredServerId = serverId,
                User     = front.User,
                Password = front.Pass,
                Port     = front.Port
            };

            //大于33的认为是IP直连。
            if (channel >= 33)
            {
                di.Ip = video.Host;
            }
            else
            {
                di.Ip = front.Host;
            }
            _devices[di.VideoId] = di;

            //TODO:生成控制信息。徐测试以此方法生成是否可行。
            CCTVControlConfig cc = new CCTVControlConfig()
            {
                VideoId   = info.VideoId,
                Type      = getControlType(video.PanTiltUnit),
                Ip        = di.Ip,
                Port      = di.Port,
                Channel   = channel,
                AuxSwitch = getAuxSwitch(video.PanTiltUnit)
            };

            _controls[cc.VideoId] = cc;
        }