bool play(string videoId, int streamIndex = -1) { if (!_disposed) { CCTVStaticInfo videoInfo = CCTVInfoManager.Instance.GetStaticInfo(videoId); if (videoInfo != null && videoInfo.Streams != null && videoInfo.Streams.Length > 0) { if (streamIndex < 0) { streamIndex = videoInfo.Streams[0].Index; } StreamInfo streamInfo = videoInfo.Streams.First(x => x.Index == streamIndex); if (streamInfo != null) { lock (_videoSourceLockObj) { _videoData = VideoDataManager.Instance.GetVideoData(videoId, streamInfo.Url); _videoData.VideoSource.Hikm4StreamReceived += VideoSource_Hikm4StreamReceived; _videoData.VideoSource.FfmpegStreamReceived += VideoSource_FfmpegStreamReceived; _videoData.VideoSource.UniviewStreamReceived += VideoSource_UniviewStreamReceived; _videoData.VideoSource.VideoFrameReceived += VideoSource_VideoFrameReceived; } return(true); } } } return(false); }
bool play(string videoId, int streamIndex = -1) { LastImageTime = DateTime.Now; if (videoId == VideoId) { //同一个VideoID,初始缩略图只需刷新一次,因为这是一个相当耗时的操作。 //即使play操作失败时,也无需重复设置缩略图。 if (_thumbnail == null) { _thumbnail = ThumbnailsPack.Instance.GetThumbnail(videoId); if (_thumbnail != null) { ImageSource imgSrc = imageBytesToImageSource(_thumbnail.ImageBytes); updateImageSource(imgSrc); } } //var thumbnail = ThumbnailManager.Default.GetThumbnail(videoId); //if (thumbnail != null) //{ // ImageSource imgSrc = imageBytesToImageSource(thumbnail.ImageBytes); // updateImageSource(imgSrc); //} CCTVStaticInfo videoInfo = CCTVInfoManager.Instance.GetStaticInfo(videoId); if (videoInfo != null && videoInfo.Streams != null && videoInfo.Streams.Length > 0) { VideoName = CCTVInfoManager.Instance.GetVideoReadableName(VideoId); //Console.WriteLine(VideoId + "___" + VideoName); StreamInfoArray = videoInfo.Streams; if (streamIndex < 0) { streamIndex = videoInfo.Streams[0].Index; } StreamInfo streamInfo = videoInfo.Streams.First(x => x.Index == streamIndex); if (streamInfo != null) { StreamName = streamInfo.Name; lock (_videoSourceLockObj) { _videoData = VideoDataManager.Instance.GetVideoData(videoId, streamInfo.Url); _videoData.VideoSource.Hikm4StreamReceived += VideoSource_Hikm4StreamReceived; _videoData.VideoSource.FfmpegStreamReceived += VideoSource_FfmpegStreamReceived; _videoData.VideoSource.UniviewStreamReceived += VideoSource_UniviewStreamReceived; _videoData.VideoSource.StreamTypeChanged += VideoSource_StreamTypeChanged; _videoData.VideoSource.VideoFrameReceived += VideoSource_VideoFrameReceived; } return(true); } } } return(false); }
internal VirtualDevice(CCTVStaticInfo real, Gateway gw, string sipNum, SIP_Registrar _reg) { _realInfo = real; _sipNum = sipNum; _gateway = gw; _registrar = _reg; string localIP = IPAddressHelper.GetLocalIp(); _localAOR = $"{sipNum}@{localIP}"; }
public VideoSource GetVideoSource(string videoId) { _clientHub.UpdateDefault(CCTVInfoType.StaticInfo); CCTVStaticInfo info = _clientHub.GetStaticInfo(videoId); var streamInfo = info.Streams.OrderBy(x => x.Index).First(); if (streamInfo != null) { return(GetVideoSource(videoId, streamInfo.Url)); } return(null); }
public VideoSource GetVideoSource(string videoId, int streamId) { _clientHub.UpdateDefault(CCTVInfoType.StaticInfo); CCTVStaticInfo info = _clientHub.GetStaticInfo(videoId); var streamInfo = info.Streams.FirstOrDefault(_ => _.Index == streamId); if (streamInfo != null) { return(GetVideoSource(videoId, streamInfo.Url)); } return(null); }
// POST: api/Static public IHttpActionResult Post([FromBody] CCTVStaticInfo info) { if (info == null) { throw new HttpRequestException("视频节点静态信息内容为空。"); } if (string.IsNullOrWhiteSpace(info.VideoId)) { info.VideoId = Guid.NewGuid().ToString(); } StaticPersistence.Instance.Put(info.VideoId, info); return(Ok("添加静态信息成功")); }
// GET: api/VideoInfo/5 public IHttpActionResult Get(string id) { CCTVStaticInfo si = StaticPersistence.Instance.GetInfo(id); if (si != null) { CCTVVideoInfoWrap video = new CCTVVideoInfoWrap(); video.StaticInfo = si; video.Control = ControlPersistence.Instance.GetInfo(id); video.CameraLimits = CameraPersistence.Instance.GetInfo(id); video.TargetTrack = TargetTrackPersistence.Instance.GetInfo(id); video.VideoTrack = VideoTrackPersistence.Instance.GetInfo(id); video.VideoAnalyze = AnalyzePersistence.Instance.GetInfo(id); video.DeviceInfo = DevicePersistence.Instance.GetInfo(id); return(Ok(video)); } return(BadRequest("无效的VideoId")); }
//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("修改视频设备信息成功")); }
private StreamInfo findStreamInfo(string videoId, int actualStream) { CCTVStaticInfo staticInfo = _clientHub.GetStaticInfo(videoId); if (staticInfo != null) { foreach (StreamInfo streamInfo in staticInfo.Streams) { ulong id = 0; int stream = 1; if (getCctv1UrlInfo(streamInfo.Url, out id, out stream)) { if (stream == actualStream) { return(streamInfo); } } } } return(null); }
//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 PutStaticInfo(CCTVStaticInfo info, bool isDeleted) { PutDefaultInfo(CCTVInfoType.StaticInfo, 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; }