private TreeViewItem updateNode(VideoParser.Node node)
        {
            TreeViewItem item = new TreeViewItem();

            item.Header     = node.Name;
            item.Tag        = node;
            item.IsExpanded = true;
            VideoParser.Server server = node as CCTVClient.VideoParser.Server;
            if (server != null)
            {
                foreach (VideoParser.Node child in server.Childs)
                {
                    item.Items.Add(updateNode(child));
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    foreach (VideoParser.Video child in front.Childs)
                    {
                        item.Items.Add(getVideoNode(child, front.Online));
                    }
                }
            }
            return(item);
        }
        private void Info_NodeTreeEvent(VideoParser.Node tree, string xml)
        {
            HashSet <ulong> videoIdSet = new HashSet <ulong>();

            collectVideoId(videoIdSet, tree);
            _videoIdArray = videoIdSet.ToArray();
        }
Beispiel #3
0
        private void getOnlineStatus(Dictionary <string, OnlineStatus> onlineDict, VideoParser.Node node)
        {
            string nodeId = getNodeId(node.Id);

            onlineDict[nodeId] = new OnlineStatus()
            {
                NodeId = nodeId, Online = node.Online
            };

            VideoParser.Server server = node as VideoParser.Server;
            if (server != null)
            {
                if (server.Childs != null)
                {
                    foreach (VideoParser.Node child in server.Childs)
                    {
                        getOnlineStatus(onlineDict, child);
                    }
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    if (front.Childs != null)
                    {
                        foreach (VideoParser.Video child in front.Childs)
                        {
                            getOnlineStatus(onlineDict, child);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void _info_NodeTreeEvent(VideoParser.Node tree, string xml)
        {
            Console.WriteLine("Update once!");
            var allKeys = getAllCCTV1Id();

            updateHierarchy(tree, allKeys);
            updateStatic(tree, allKeys);
        }
Beispiel #5
0
 public void UpdateTree(VideoParser.Node node)
 {
     lock (_trackVideos)
     {
         _trackVideos.Clear();
         AddTrackVideo(node);
     }
 }
Beispiel #6
0
 private void updateHierarchy(VideoParser.Node tree)
 {
     if (tree != null)
     {
         Dictionary <string, HierarchyInfo> hierarchyDict = new Dictionary <string, HierarchyInfo>();
         getHierarchyInfo(hierarchyDict, null, tree);
         _hierarchySync.ReplaceAll(hierarchyDict);
     }
 }
Beispiel #7
0
 private void updateHierarchy(VideoParser.Node tree, List <string> allKeys)
 {
     if (tree != null)
     {
         HierarchyClassifier classifier = new HierarchyClassifier();
         classifier.Classify(tree);
         deleteAndUpdate(_hierarchySync, allKeys, classifier.Hierarchies, x => x.Id);
     }
 }
Beispiel #8
0
 private void updateStatic(VideoParser.Node tree)
 {
     if (tree != null)
     {
         Dictionary <string, CCTVStaticInfo> staticDict = new Dictionary <string, CCTVStaticInfo>();
         getStaticInfo(staticDict, tree);
         _staticSync.ReplaceAll(staticDict);
     }
 }
Beispiel #9
0
 private void updateOnline(VideoParser.Node tree)
 {
     if (tree != null)
     {
         Dictionary <string, OnlineStatus> onlineDict = new Dictionary <string, OnlineStatus>();
         getOnlineStatus(onlineDict, tree);
         _onlineSync.ReplaceAll(onlineDict);
     }
 }
        private void classifyInfo(VideoParser.Node node, string serverId)
        {
            //在线标识。
            var nodeId = getNodeId(node.Id);

            _onlineStatus[nodeId] = new CCTVOnlineStatus()
            {
                VideoId = nodeId, Online = node.Online
            };

            VideoParser.Server server = node as VideoParser.Server;
            if (server != null)
            {
                CCTVServerInfo si = new CCTVServerInfo()
                {
                    ServerId          = getNodeId(node.Id),
                    Name              = node.Name,
                    InfoServiceIp     = node.Host,
                    InfoServicePort   = 27010,
                    StreamServerIp    = node.Host,
                    StreamServerPort  = 37010,
                    ControlServerIp   = node.Host,
                    ControlServerPort = 47010
                };
                _servers[si.ServerId] = si;
                if (server.Childs != null)
                {
                    foreach (VideoParser.Node child in server.Childs)
                    {
                        classifyInfo(child, si.ServerId);
                    }
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    if (front.Childs != null)
                    {
                        int channel = 1;
                        foreach (VideoParser.Video child in front.Childs)
                        {
                            classifyInfo(front, child, channel, serverId);
                            if (front.Type == 1 || front.Type == 11)
                            {
                                channel += 4;
                            }
                            else
                            {
                                channel++;
                            }
                        }
                    }
                }
            }
        }
Beispiel #11
0
 static string getNodeType(VideoParser.Node node)
 {
     if (node is VideoParser.Server)
     {
         return("Server");
     }
     else if (node is VideoParser.Front)
     {
         return("Front");
     }
     else
     {
         return("Node");
     }
 }
Beispiel #12
0
 static NodeType getNodeType(VideoParser.Node node)
 {
     if (node is VideoParser.Server)
     {
         return(NodeType.Server);
     }
     else if (node is VideoParser.Front)
     {
         return(NodeType.Server);
     }
     else
     {
         return(NodeType.Video);
     }
 }
Beispiel #13
0
 private void updateStatic(VideoParser.Node tree, List <string> allKeys)
 {
     if (tree != null)
     {
         StaticInfoClassifier classifier = new StaticInfoClassifier(_globalInfo, _videoPosSync);
         classifier.Classify(tree);
         //_staticSync.ReplaceAll(staticDict);
         deleteAndUpdate(_staticSync, allKeys, classifier.StaticInfos, x => x.VideoId);
         deleteAndUpdate(_onlineSync, allKeys, classifier.OnlineStatus, x => x.VideoId);
         deleteAndUpdate(_serverSync, allKeys, classifier.Servers, x => x.ServerId);
         deleteAndUpdate(_cameraSync, allKeys, classifier.Cameras, x => x.VideoId);
         deleteAndUpdate(_controlSync, allKeys, classifier.Controls, x => x.VideoId);
         deleteAndUpdate(_deviceSync, allKeys, classifier.Devices, x => x.VideoId);
         deleteAndUpdate(_videoTrackSync, allKeys, classifier.VideoTracks, x => x.VideoId);
     }
 }
Beispiel #14
0
 private void _cctvInfo_NodeTreeEvent(VideoParser.Node tree, string xml)
 {
     lock (_nodeTree)
     {
         bool isSameNode = _nodeTree.IsSameNode(tree);
         _nodeTree.UpdateTree(tree);
         _videoNode = tree;
         if (isSameNode)
         {
             updateNodesData();
         }
         else
         {
             addCCTVsShow();
         }
     }
 }
Beispiel #15
0
 public bool IsSameNode(VideoParser.Node node)
 {
     lock (_trackVideos)
     {
         if (_trackVideos.Count == 0)
         {
             return(false);
         }
         CCTVNodeTree newNode = new CCTVNodeTree();
         newNode.AddTrackVideo(node);
         if (isSameVideos(newNode.GetAllTrackVideos()))
         {
             return(true);
         }
         return(false);
     }
 }
Beispiel #16
0
        private void getHierarchyInfo(string parentId, VideoParser.Node node)
        {
            string nodeId = getNodeId(node.Id);

            _dictHier[nodeId] = new CCTVHierarchyInfo()
            {
                Id        = nodeId,
                Name      = node.Name,
                Type      = getNodeType(node),
                ParentId  = parentId,
                ElementId = nodeId
            };

            VideoParser.Server server = node as VideoParser.Server;
            if (server != null)
            {
                if (server.Childs != null)
                {
                    foreach (VideoParser.Node child in server.Childs)
                    {
                        getHierarchyInfo(nodeId, child);
                    }
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    if (front.Childs != null)
                    {
                        foreach (VideoParser.Video child in front.Childs)
                        {
                            getHierarchyInfo(nodeId, child);
                        }
                    }
                }
            }
        }
Beispiel #17
0
 public void AddTrackVideo(VideoParser.Node node)
 {
     VideoParser.Server server = node as VideoParser.Server;
     if (server != null)
     {
         foreach (VideoParser.Node child in server.Childs)
         {
             AddTrackVideo(child);
         }
     }
     else
     {
         VideoParser.Front front = node as VideoParser.Front;
         if (front != null)
         {
             foreach (VideoParser.Video child in front.Childs)
             {
                 addTrackVideo(child);
             }
         }
     }
 }
 private static void collectVideoId(HashSet <ulong> videoIdSet, VideoParser.Node node)
 {
     VideoParser.Server server = node as VideoParser.Server;
     if (server != null)
     {
         foreach (VideoParser.Node child in server.Childs)
         {
             collectVideoId(videoIdSet, child);
         }
     }
     else
     {
         VideoParser.Front front = node as VideoParser.Front;
         if (front != null)
         {
             foreach (VideoParser.Video video in front.Childs)
             {
                 videoIdSet.Add(video.Id);
             }
         }
     }
 }
Beispiel #19
0
 private void getStaticInfo(Dictionary <string, CCTVStaticInfo> staticDict, VideoParser.Node node)
 {
     VideoParser.Server server = node as VideoParser.Server;
     if (server != null)
     {
         if (server.Childs != null)
         {
             foreach (VideoParser.Node child in server.Childs)
             {
                 getStaticInfo(staticDict, child);
             }
         }
     }
     else
     {
         VideoParser.Front front = node as VideoParser.Front;
         if (front != null)
         {
             if (front.Childs != null)
             {
                 int channel = 1;
                 foreach (VideoParser.Video child in front.Childs)
                 {
                     getStaticInfo(staticDict, front, child, channel);
                     if (front.Type == 1 || front.Type == 11)
                     {
                         channel += 4;
                     }
                     else
                     {
                         channel++;
                     }
                 }
             }
         }
     }
 }
Beispiel #20
0
        private void getHierarchyInfo(Dictionary <string, HierarchyInfo> hierarchyDict, string parentId, VideoParser.Node node)
        {
            string nodeId = getNodeId(node.Id);

            hierarchyDict[nodeId] = new HierarchyInfo()
            {
                NodeId   = nodeId,
                Name     = node.Name,
                Type     = getNodeType(node),
                ParentId = parentId,
            };

            VideoParser.Server server = node as VideoParser.Server;
            if (server != null)
            {
                if (server.Childs != null)
                {
                    foreach (VideoParser.Node child in server.Childs)
                    {
                        getHierarchyInfo(hierarchyDict, nodeId, child);
                    }
                }
            }
            else
            {
                VideoParser.Front front = node as VideoParser.Front;
                if (front != null)
                {
                    if (front.Childs != null)
                    {
                        foreach (VideoParser.Video child in front.Childs)
                        {
                            getHierarchyInfo(hierarchyDict, nodeId, child);
                        }
                    }
                }
            }
        }
Beispiel #21
0
 private void _info_NodeTreeEvent(VideoParser.Node tree, string xml)
 {
     updateHierarchy(tree);
     updateStatic(tree);
     updateOnline(tree);
 }
 public void Classify(VideoParser.Node node)
 {
     classifyInfo(node, null);
 }
Beispiel #23
0
 public void Classify(VideoParser.Node node)
 {
     getHierarchyInfo(null, node);
 }