示例#1
0
        /// <summary>
        /// Creates a TreeNode for the given group info
        /// </summary>
        /// <param name="Group">group info to create a tree-node for.</param>
        /// <returns>a TreeNode with this group's info, and all of its sources under it as nodes</returns>
        private TreeNode CreateGroupNode(SourceDiscoveryGroup group)
        {
            TreeNode result = new TreeNode();

            result.Text        = group.Name;
            result.ToolTipText = group.Name;
            if (group.ServerInfo != null)
            {
                result.Tag = group.ServerInfo;
            }
            else
            {
                result.Tag = group;
            }

            if (group.Sources.Count > 0)
            {
                foreach (StreamSourceInfo source in group.Sources)
                {
                    TreeNode sourceNode = new TreeNode();
                    sourceNode.Text = source.Description;
//                    sourceNode.ToolTipText = source.ClientURL;
                    sourceNode.Tag = source;
                    result.Nodes.Add(sourceNode);
                }
            }
            return(result);
        }
 private void CheckForNewOrChangedGroups(List <SourceDiscoveryGroup> newGroups)
 {
     foreach (SourceDiscoveryGroup newGroup in newGroups)
     {
         String name = newGroup.Name;
         if (name != null)
         {
             if (_groups.ContainsKey(name))
             {
                 SourceDiscoveryGroup existingGroup = _groups[name];
                 if (newGroup.Version > existingGroup.Version)
                 {
                     _groups.Remove(name);
                     _groups.Add(name, newGroup);
                     FireGroupChanged(newGroup);
                 }
             }
             else
             {
                 _groups.Add(name, newGroup);
                 FireGroupOnline(newGroup);
             }
         }
     }
 }
示例#3
0
 private void queryDaemon_ServerNowUnavailable(object sender, QueryMediaServers.ServerEventArgs e)
 {
     if (_groups.ContainsKey(e.ServerAddress))
     {
         SourceDiscoveryGroup group = _groups[e.ServerAddress];
         FireGroupOffline(group);
         _groups.Remove(e.ServerAddress);
     }
 }
示例#4
0
        private void queryDaemon_ServerNowAvailable(object sender, QueryMediaServers.ServerEventArgs e)
        {
            SourceDiscoveryGroup group      = new SourceDiscoveryGroup();
            ServerInfo           serverInfo = _queryMediaServers.MediaServers[e.ServerAddress];

            group.ServerInfo = serverInfo;
            group.Name       = serverInfo.ServerName;
            foreach (StreamSourceInfo streamSourceInfo in serverInfo.StreamSources.Items)
            {
                group.Sources.Add(streamSourceInfo);
            }
            _groups.Add(e.ServerAddress, group);
            FireGroupOnline(group);
        }
示例#5
0
 /// <summary>
 /// Updates a server in the TreeView if its ServerInfo has changed
 /// </summary>
 void queryDaemon_ServerInfoChanged(object sender, QueryMediaServers.ServerEventArgs e)
 {
     if (_groups.ContainsKey(e.ServerAddress))
     {
         SourceDiscoveryGroup group      = _groups[e.ServerAddress];
         ServerInfo           serverInfo = _queryMediaServers.MediaServers[e.ServerAddress];
         group.Name = serverInfo.ServerName;
         group.Sources.Clear();
         foreach (StreamSourceInfo streamSourceInfo in serverInfo.StreamSources.Items)
         {
             group.Sources.Add(streamSourceInfo);
         }
         FireGroupChanged(group);
     }
 }
示例#6
0
 private void BuildServerPath(List <ServerInfo> path, TreeNode tn)
 {
     if (tn.Tag is ServerInfo)
     {
         path.Insert(0, tn.Tag as ServerInfo);
     }
     else if (tn.Tag is SourceDiscoveryGroup)
     {
         SourceDiscoveryGroup group = tn.Tag as SourceDiscoveryGroup;
         path.Insert(0, group.ServerInfo);
     }
     if (tn.Parent != null)
     {
         BuildServerPath(path, tn.Parent);
     }
 }
示例#7
0
        /// <summary>
        /// Connects to given address and parses xml to extract all IP addresses
        /// of all nodes advertising given service type
        /// </summary>
        /// <param name="type">Type of service to retrieve.</param>
        /// <param name="address">IP address to get xml from - Note that the file /xml/services is added onto this IP.</param>
        /// <param name="exc">If an exception was thrown while retrieving services, it is returned here.</param>
        /// <returns>list of Advertised Service Objects</returns>
        public static SourceDiscoveryGroup QueryWowza(String hostAddress, String username, String password)
        {
            SourceDiscoveryGroup result = new SourceDiscoveryGroup();
            string page = "";
            String url  = String.Format(@"http://{0}/serverinfo", hostAddress);

            try
            {
                page = GetResponseString(url, username, password);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
                return(result);
            }
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(page);
            XmlNodeList appNodes = xmldoc.SelectNodes("/WowzaMediaServerPro/VHost/Application");

            foreach (XmlNode appNode in appNodes)
            {
                XmlNode appNameNode = appNode.SelectSingleNode("Name");
                if (appNameNode.InnerText == "live" || appNameNode.InnerText == "axbro")
                {
                    XmlNode appInstanceNode = appNode.SelectSingleNode("ApplicationInstance");
                    if (appInstanceNode != null)
                    {
                        XmlNodeList rtpSessions = appInstanceNode.SelectNodes("RTPSession");
                        foreach (XmlNode rtpSession in rtpSessions)
                        {
                            XmlNode          uriNode = rtpSession.SelectSingleNode("URI");
                            String           uri     = uriNode.InnerText;
                            StreamSourceInfo source  = new StreamSourceInfo();
//                            source.ClientURL = uri;
                            source.Description = uri;
                            result.Sources.Add(source);
                        }
                    }
                }
            }
            return(result);
        }
示例#8
0
        private void SourceDiscoveryPlugin_GroupChanged(object sender, GroupEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler <GroupEventArgs>(SourceDiscoveryPlugin_GroupChanged), new object[] { sender, e });
                return;
            }
            Debug.WriteLine("SourceDiscoveryPlugin_GroupInfoChanged");
            try
            {
                tvServerList.BeginUpdate();
                SourceDiscoveryGroup group = e.Group;
                if (group != null)
                {
                    String name = group.Name;
                    if (name != null)
                    {
                        TreeNode node = FindTreeNode(name);
                        if (node != null)
                        {
                            expandedState.Clear();
                            CacheExpansion(node);

                            TreeNode newNode = CreateGroupNode(group);
                            RemoveNode(node);
                            InsertNode(newNode, node.Index);
                            ApplyCachedExpansion(newNode);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                ErrorLogger.DumpToDebug(exc);
            }
            finally
            {
                tvServerList.EndUpdate();
            }
        }
示例#9
0
        /// <summary>
        /// Connects to given address and parses xml to extract all IP addresses
        /// of all nodes advertising given service type
        /// </summary>
        /// <param name="type">Type of service to retrieve.</param>
        /// <param name="address">IP address to get xml from - Note that the file /xml/services is added onto this IP.</param>
        /// <param name="exc">If an exception was thrown while retrieving services, it is returned here.</param>
        /// <returns>list of Advertised Service Objects</returns>
        public static List <SourceDiscoveryGroup> Query(String url, String username, String password)
        {
            List <SourceDiscoveryGroup> result = new List <SourceDiscoveryGroup>();
            XDocument doc = XDocument.Load(url);
            IEnumerable <XElement> groups = doc.Element("SourceGroups").Elements("SourceGroup");

            foreach (XElement group in groups)
            {
                SourceDiscoveryGroup sourceGroup = new SourceDiscoveryGroup();
                sourceGroup.Version = Int32.Parse(group.Attribute("Version").Value);
                sourceGroup.Name    = group.Attribute("Name").Value;
                IEnumerable <XElement> sources = group.Elements("StreamSourceInfo");
                foreach (XElement xmlSource in sources)
                {
                    try
                    {
                        StreamSourceInfo source = new StreamSourceInfo();
                        source.SourceName  = xmlSource.Attribute("SourceName").Value;
                        source.Description = xmlSource.Attribute("Description").Value;
                        if (xmlSource.Attribute("ClientURL") != null)
                        {
                            source.SinkAddress = xmlSource.Attribute("ClientURL").Value;
                        }
                        else if (xmlSource.Attribute("SinkAddress") != null)
                        {
                            source.SinkAddress = xmlSource.Attribute("SinkAddress").Value;
                        }
                        if (xmlSource.Attribute("HasAudio") != null)
                        {
                            if (xmlSource.Attribute("HasAudio").Value == "1")
                            {
                                source.HasAudio = true;
                            }
                        }
                        XElement xmlCameraControl = xmlSource.Element("CameraControl");
                        if (xmlCameraControl != null)
                        {
                            CameraControlInfo info = new CameraControlInfo();
                            info.PTZType = (PTZType)Enum.Parse(typeof(PTZType), xmlCameraControl.Attribute("PTZType").Value);
                            XElement xmlCaps = xmlCameraControl.Element("Capabilities");
                            if (xmlCaps != null)
                            {
                                info.Capabilities = CameraCapabilitiesAndLimits.CreateFromXml(xmlCaps);
                            }
                            XElement xmlAddress = xmlCameraControl.Element("Address");
                            if (xmlAddress != null)
                            {
                                info.Address = xmlAddress.Value;
                            }
                            source.CameraControl = info;
                        }
                        sourceGroup.Sources.Add(source);
                    }
                    catch (Exception e)
                    {
                        ErrorLogger.DumpToDebug(e);
                    }
                }
                result.Add(sourceGroup);
            }
            return(result);
        }
示例#10
0
        /// <summary>
        /// Connects to given address and parses xml to extract all IP addresses
        /// of all nodes advertising given service type
        /// </summary>
        /// <param name="type">Type of service to retrieve.</param>
        /// <param name="address">IP address to get xml from - Note that the file /xml/services is added onto this IP.</param>
        /// <param name="exc">If an exception was thrown while retrieving services, it is returned here.</param>
        /// <returns>list of Advertised Service Objects</returns>
        public static List <SourceDiscoveryGroup> ReadFile(String path)
        {
            List <SourceDiscoveryGroup> result = new List <SourceDiscoveryGroup>();
            XDocument doc = XDocument.Load(path);
            IEnumerable <XElement> groups = doc.Element("SourceGroups").Elements("SourceGroup");

            foreach (XElement group in groups)
            {
                SourceDiscoveryGroup sourceGroup = new SourceDiscoveryGroup();
                ServerInfo           serverInfo  = new ServerInfo();
                serverInfo.ServerName    = "Local";
                serverInfo.ServerAddress = "127.0.0.1";
                sourceGroup.ServerInfo   = serverInfo;
                sourceGroup.Version      = Int32.Parse(group.Attribute("Version").Value);
                sourceGroup.Name         = group.Attribute("Name").Value;
                IEnumerable <XElement> sources = group.Elements("StreamSourceInfo");
                foreach (XElement xmlSource in sources)
                {
                    StreamSourceInfo source = new StreamSourceInfo();
                    source.SourceName = xmlSource.Attribute("Name").Value;
                    XAttribute sourceTypeAttribute = xmlSource.Attribute("SourceType");
                    if (sourceTypeAttribute != null)
                    {
                        source.SourceType = (SourceType)Enum.Parse(typeof(SourceType), sourceTypeAttribute.Value);
                    }
                    else
                    {
                        source.SourceType = SourceType.RTSP;
                    }
                    source.Description = xmlSource.Attribute("Description").Value;
                    if (xmlSource.Attribute("SinkAddress") != null)
                    {
                        source.SinkAddress = xmlSource.Attribute("SinkAddress").Value;
                    }
                    else if (xmlSource.Attribute("ClientURL") != null)
                    {
                        source.SinkAddress = xmlSource.Attribute("ClientURL").Value;
                    }
                    if (source.SinkAddress.StartsWith(@"rtsp://"))
                    {
                        if ((xmlSource.Attribute("SourceType") != null) && xmlSource.Attribute("SourceType").Value == "RTSP_Elecard")
                        {
                            source.SourceType = SourceType.RTSP_Elecard;
                        }
                        else
                        {
                            source.SourceType = SourceType.RTSP;
                        }
                    }
                    if (xmlSource.Element("CameraControl") != null)
                    {
                        XElement          xmlCameraControl = xmlSource.Element("CameraControl");
                        CameraControlInfo info             = new CameraControlInfo();
                        info.PTZType = (PTZType)Enum.Parse(typeof(PTZType), xmlCameraControl.Attribute("PTZType").Value);
                        XElement xmlCaps = xmlCameraControl.Element("Capabilities");
                        if (xmlCaps != null)
                        {
                            info.Capabilities = CameraCapabilitiesAndLimits.CreateFromXml(xmlCaps);
                        }
                        XElement xmlAddress = xmlCameraControl.Element("Address");
                        if (xmlAddress != null)
                        {
                            info.Address = xmlAddress.Value;
                        }
                        source.CameraControl = info;
                    }
                    sourceGroup.Sources.Add(source);
                }
                result.Add(sourceGroup);
            }
            return(result);
        }
示例#11
0
        private void DoWowzaQuery(IPAddress ipAddress)
        {
            Boolean fireOnline         = false;
            Boolean fireChanged        = false;
            String  hostAddress        = ipAddress.ToString() + ":" + HostPort;
            SourceDiscoveryGroup group = Wowza.QueryWowza(hostAddress, Username, Password);

            if (_group == null)
            {
                _group     = group;
                fireOnline = true;
            }
            else
            {
                if (_group.Sources.Count > 0)
                {
                    foreach (StreamSourceInfo source in _group.Sources)
                    {
                        try
                        {
                            StreamSourceInfo newSourceInfo = group.FindSource(source.SourceName);
                        }
                        catch (Exception e)
                        {
                            _group.Sources.Remove(source);
                            fireChanged = true;
                        }
                    }
                }
                else
                {
                    fireChanged = true;
                }
                foreach (StreamSourceInfo source in group.Sources)
                {
                    try
                    {
                        StreamSourceInfo previousSource = _group.FindSource(source.SourceName);
//                        if (source.ClientURL == previousSource.ClientURL == false)
                        if (true)
                        {
                            _group.Sources.Remove(previousSource);
                            _group.Sources.Add(source);
                            fireChanged = true;
                        }
                    }
                    catch (Exception e)
                    {
                        _group.Sources.Add(source);
                        fireChanged = true;
                    }
                }
            }
            if (fireOnline)
            {
                FireGroupOnline(_group);
            }
            else if (fireChanged)
            {
                FireGroupChanged(_group);
            }
        }