Example #1
0
 //Put:api/Camera/5
 public IHttpActionResult Put(string id, [FromBody] CCTVCameraLimits camera)
 {
     if (id == null)
     {
         return(BadRequest("无效的VideoId标识"));
     }
     if (camera == null)
     {
         return(BadRequest("提交的数据是空值"));
     }
     CameraPersistence.Instance.Put(id, camera);
     return(Ok("修改摄像机相位信息成功"));
 }
Example #2
0
 // POST: api/Camera
 public IHttpActionResult Post([FromBody] CCTVCameraLimits camera)
 {
     if (camera == null)
     {
         return(BadRequest("提交的数据是空值"));
     }
     if (string.IsNullOrWhiteSpace(camera.VideoId))
     {
         return(BadRequest("无效的VideoId标识"));
     }
     CameraPersistence.Instance.Put(camera.VideoId, camera);
     return(Ok("添加摄像机相位信息成功"));
 }
 public void PutCameraLimitsInfo(CCTVCameraLimits info, bool isDeleted)
 {
     PutDefaultInfo(CCTVInfoType.CameraLimitsInfo, info.VideoId, info, isDeleted);
 }
        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;
        }