Exemplo n.º 1
0
 // POST: api/Control
 public IHttpActionResult Post([FromBody] CCTVControlConfig control)
 {
     if (control == null)
     {
         return(BadRequest("提交的数据是空值"));
     }
     if (string.IsNullOrWhiteSpace(control.VideoId))
     {
         return(BadRequest("无效的VideoId标识"));
     }
     ControlPersistence.Instance.Put(control.VideoId, control);
     return(Ok("添加视频控制信息成功"));
 }
Exemplo n.º 2
0
 //Put:api/Control/5
 public IHttpActionResult Put(string id, [FromBody] CCTVControlConfig control)
 {
     if (id == null)
     {
         return(BadRequest("无效的VideoId标识"));
     }
     if (control == null)
     {
         return(BadRequest("提交的数据是空值"));
     }
     ControlPersistence.Instance.Put(id, control);
     return(Ok("修改视频控制信息成功"));
 }
Exemplo n.º 3
0
 public void PutControlConfig(CCTVControlConfig info, bool isDeleted)
 {
     PutDefaultInfo(CCTVInfoType.ControlConfig, info.VideoId, info, isDeleted);
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        private DeviceItemsCollection buildDeviceItems(string parentId, Platform plat)
        {
            //过滤出仅平台鉴权用户可用的视频列表。
            List <string> acIds = getUserDeviceId(plat);
            IEnumerable <CCTVStaticInfo> infos = InfoService.Instance.GetAllStaticInfo();

            if (infos != null)
            {
                Dictionary <string, string> dictIdPairs = new Dictionary <string, string>();
                IEnumerable <SipIdMap>      dids        = InfoService.Instance.GetAllSipIdMap();
                if (dids != null)
                {
                    foreach (SipIdMap sp in dids)
                    {
                        dictIdPairs[sp.StaticId] = sp.SipNumber;
                    }
                }
                DeviceItemsCollection items = new DeviceItemsCollection();
                foreach (CCTVStaticInfo si in infos)
                {
                    CCTVControlConfig cc  = InfoService.Instance.GetControlConfig(si.VideoId);
                    string            sip = null;
                    if (dictIdPairs.ContainsKey(si.VideoId))
                    {
                        sip = dictIdPairs[si.VideoId];
                    }
                    else
                    {
                        sip = SipIdGenner.GenDeviceID();
                        InfoService.Instance.PutSipIdMap(si.VideoId, new SipIdMap(si.VideoId, sip), false);
                    }
                    ItemType it = new ItemType()
                    {
                        DeviceID     = sip,
                        ParentID     = parentId,
                        Event        = StatusEvent.ADD,
                        Name         = si.Name,
                        Manufacturer = "Seecool",
                        Model        = "Seecool",
                        Owner        = "Seecool",
                        CivilCode    = sip,
                        Block        = "",
                        Address      = "1",
                        Parental     = 0,
                        SafetyWay    = 0,
                        RegisterWay  = 1,
                        CertNum      = "1",
                        Certifiable  = 1,
                        ErrCode      = 400,
                        EndTime      = DateTime.Now,
                        Secrecy      = 0,
                        IPAddress    = cc?.Ip,
                        Port         = cc == null ? 8000 : cc.Port,
                        Password     = cc?.Password,
                        Status       = StatusType.ON,
                        Longitude    = si.Longitude,
                        Latitude     = si.Latitude
                    };
                    items.Add(it);
                }
                return(items);
            }
            else
            {
                return(null);
            }
        }