public static void BuildStreamUrl(StreamInfo[] sis, CCTVDeviceInfo device) { if (sis == null || device == null) { return; } switch (device.DeviceType) { case DeviceType.HikIP: { foreach (StreamInfo si in sis) { si.Url = string.Format(HikvUrl, device.User, device.Password, device.Ip, device.Port, si.Channel, si.StreamType.ToString()); } } break; case DeviceType.Axis: { foreach (StreamInfo si in sis) { si.Url = string.Format(RtspUrl, device.User, device.Password, device.Ip, si.StreamType == StreamType.Main ? "Quality" : "Mobile"); } } break; case DeviceType.HikAnalog: case DeviceType.Unknown: default: break; } }
private CCTVServerInfo getPreferServer(string videoId) { CCTVServerInfo preferServer = _currentServer; CCTVDeviceInfo di = _clientHub.GetDeviceInfo(videoId); if (di != null && !string.IsNullOrWhiteSpace(di.PreferredServerId)) { CCTVServerInfo temp = _clientHub.GetServerInfo(di.PreferredServerId); if (temp != null && !string.IsNullOrWhiteSpace(temp.StreamServerIp)) { preferServer = temp; } } return(preferServer); }
//Put:api/DeviceInfo/5 public IHttpActionResult Put(string id, [FromBody] CCTVDeviceInfo device) { if (id == null) { return(BadRequest("无效的VideoId标识")); } if (device == null) { return(BadRequest("提交的数据是空值")); } //更新码流Url CCTVStaticInfo si = StaticPersistence.Instance.GetInfo(id); if (si != null && si.Platform == CCTVPlatformType.CCTV2) { StreamUrlGenner.BuildStreamUrl(si.Streams, device); StaticPersistence.Instance.Put(id, si); } DevicePersistence.Instance.Put(id, device); return(Ok("修改视频设备信息成功")); }
//Put: api/static/5 public IHttpActionResult Put(string id, [FromBody] CCTVStaticInfo info) { if (id == null) { return(BadRequest("无效的VideoId标识")); } if (info == null) { return(BadRequest("请求的静态信息对象为空")); } //更新码流Url if (info.Platform == CCTVPlatformType.CCTV2) { CCTVDeviceInfo di = DevicePersistence.Instance.GetInfo(info.VideoId); if (di != null) { StreamUrlGenner.BuildStreamUrl(info.Streams, di); } } StaticPersistence.Instance.Put(id, info); return(Ok("修改静态信息成功")); }
public void PutDeviceInfo(CCTVDeviceInfo info, bool isDeleted) { PutDefaultInfo(CCTVInfoType.DeviceInfo, 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; }