Пример #1
0
 // PUT: api/VideoInfo/5
 public IHttpActionResult Put(string id, [FromBody] CCTVVideoInfoWrap viw)
 {
     if (string.IsNullOrWhiteSpace(id))
     {
         return(BadRequest("视频ID不能为空"));
     }
     if (viw == null)
     {
         return(BadRequest("数据不能为空"));
     }
     //更新基本信息
     if (viw.StaticInfo != null)
     {
         viw.StaticInfo.VideoId = id;
         //生成码流的URL
         if (viw.StaticInfo.Platform == CCTVPlatformType.CCTV2)
         {
             StreamUrlGenner.BuildStreamUrl(viw.StaticInfo.Streams, viw.DeviceInfo);
         }
         StaticPersistence.Instance.Put(id, viw.StaticInfo);
     }
     //更新基本信息以外的其他信息。
     if (viw.Control != null)
     {
         viw.Control.VideoId = id;
         ControlPersistence.Instance.Put(id, viw.Control);
     }
     if (viw.CameraLimits != null)
     {
         viw.CameraLimits.VideoId = id;
         CameraPersistence.Instance.Put(id, viw.CameraLimits);
     }
     if (viw.TargetTrack != null)
     {
         viw.TargetTrack.VideoId = id;
         TargetTrackPersistence.Instance.Put(id, viw.TargetTrack);
     }
     if (viw.VideoTrack != null)
     {
         viw.VideoTrack.VideoId = id;
         VideoTrackPersistence.Instance.Put(id, viw.VideoTrack);
     }
     if (viw.VideoAnalyze != null)
     {
         viw.VideoAnalyze.VideoId = id;
         AnalyzePersistence.Instance.Put(id, viw.VideoAnalyze);
     }
     if (viw.DeviceInfo != null)
     {
         viw.DeviceInfo.VideoId = id;
         DevicePersistence.Instance.Put(id, viw.DeviceInfo);
     }
     return(Ok("修改视频信息成功"));
 }
Пример #2
0
        // POST: api/VideoInfo
        public IHttpActionResult Post([FromBody] CCTVVideoInfoWrap viw)
        {
            if (viw == null || viw.StaticInfo == null)
            {
                return(BadRequest("视频基本信息不能为空"));
            }
            if (string.IsNullOrWhiteSpace(viw.StaticInfo.VideoId))
            {
                viw.StaticInfo.VideoId = Guid.NewGuid().ToString();
            }

            string videoId = viw.StaticInfo.VideoId;

            //生成码流的URL
            if (viw.StaticInfo.Platform == CCTVPlatformType.CCTV2)
            {
                StreamUrlGenner.BuildStreamUrl(viw.StaticInfo.Streams, viw.DeviceInfo);
            }
            StaticPersistence.Instance.Put(videoId, viw.StaticInfo);
            if (viw.Control != null)
            {
                viw.Control.VideoId = videoId;
                ControlPersistence.Instance.Put(videoId, viw.Control);
            }
            if (viw.CameraLimits != null)
            {
                viw.CameraLimits.VideoId = videoId;
                CameraPersistence.Instance.Put(videoId, viw.CameraLimits);
            }
            if (viw.TargetTrack != null)
            {
                viw.TargetTrack.VideoId = videoId;
                TargetTrackPersistence.Instance.Put(videoId, viw.TargetTrack);
            }
            if (viw.VideoTrack != null)
            {
                viw.VideoTrack.VideoId = videoId;
                VideoTrackPersistence.Instance.Put(videoId, viw.VideoTrack);
            }
            if (viw.VideoAnalyze != null)
            {
                viw.VideoAnalyze.VideoId = videoId;
                AnalyzePersistence.Instance.Put(videoId, viw.VideoAnalyze);
            }
            if (viw.DeviceInfo != null)
            {
                viw.DeviceInfo.VideoId = videoId;
                DevicePersistence.Instance.Put(videoId, viw.DeviceInfo);
            }
            return(Ok("添加视频信息成功"));
        }
Пример #3
0
        //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("修改视频设备信息成功"));
        }
Пример #4
0
 //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("修改静态信息成功"));
 }
Пример #5
0
        // PUT: api/VideoInfoNode/5
        public IHttpActionResult Put(string id, [FromBody] VideoInfoNodeViewModel vinvm)
        {
            CCTVVideoInfoWrap viw = vinvm.VideoInfo;

            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest("视频ID不能为空"));
            }
            if (viw == null)
            {
                return(BadRequest("数据不能为空"));
            }

            //更新基本信息
            if (viw.StaticInfo != null)
            {
                viw.StaticInfo.VideoId = id;
                //生成码流的URL
                if (viw.StaticInfo.Platform == CCTVPlatformType.CCTV2)
                {
                    StreamUrlGenner.BuildStreamUrl(viw.StaticInfo.Streams, viw.DeviceInfo);
                }
                StaticPersistence.Instance.Put(id, viw.StaticInfo);
            }
            //更新基本信息以外的其他信息。
            if (viw.Control != null)
            {
                viw.Control.VideoId = id;
                ControlPersistence.Instance.Put(id, viw.Control);
            }
            if (viw.CameraLimits != null)
            {
                viw.CameraLimits.VideoId = id;
                CameraPersistence.Instance.Put(id, viw.CameraLimits);
            }
            if (viw.TargetTrack != null)
            {
                viw.TargetTrack.VideoId = id;
                TargetTrackPersistence.Instance.Put(id, viw.TargetTrack);
            }
            if (viw.VideoTrack != null)
            {
                viw.VideoTrack.VideoId = id;
                VideoTrackPersistence.Instance.Put(id, viw.VideoTrack);
            }
            if (viw.VideoAnalyze != null)
            {
                viw.VideoAnalyze.VideoId = id;
                AnalyzePersistence.Instance.Put(id, viw.VideoAnalyze);
            }
            if (viw.DeviceInfo != null)
            {
                viw.DeviceInfo.VideoId = id;
                DevicePersistence.Instance.Put(id, viw.DeviceInfo);
            }

            CCTVHierarchyInfo hi = new CCTVHierarchyInfo();

            hi.Id        = vinvm.NodeId;
            hi.ParentId  = vinvm.ParentId;
            hi.Type      = NodeType.Video;
            hi.Name      = viw.StaticInfo.Name;
            hi.ElementId = viw.StaticInfo.VideoId;
            if (string.IsNullOrWhiteSpace(hi.Id))
            {
                hi.Id = Guid.NewGuid().ToString();
            }
            HierarchyPersistence.Instance.Put(CCTVLogicalTree.DefaultName, hi);
            return(Ok("修改视频信息成功"));
        }