Exemplo n.º 1
0
        public static XMLConfigInfo Load()
        {
            if (!File.Exists( CONFIG_FILE_NAME ))
            {
                return GetDefaultConfigInfo();
            }

            XMLConfigInfo config = new XMLConfigInfo();
            config.Decoders = new List<DecoderConfigInfo>();

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(CONFIG_FILE_NAME);
                XmlNodeList channels = doc.SelectNodes(DECODER_XPATH);
                foreach (XmlNode channel in channels)
                {
                    DecoderConfigInfo channelInfo = new DecoderConfigInfo();
                    foreach (XmlAttribute attribute in channel.Attributes)
                    {
                        if (attribute.Name == "Id")
                        {
                            channelInfo.Id = int.Parse(attribute.Value);
                        }
                        else if (attribute.Name == "BiteRate")
                        {
                            channelInfo.BitRate = int.Parse(attribute.Value);
                        }
                        else if (attribute.Name == "FrameRate")
                        {
                            channelInfo.FrameRate = int.Parse(attribute.Value);
                        }
                    }

                    config.Decoders.Add(channelInfo);
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.Message);
                return GetDefaultConfigInfo();
            }

            return config;
        }
Exemplo n.º 2
0
        private static XMLConfigInfo GetDefaultConfigInfo()
        {
            XMLConfigInfo config = new XMLConfigInfo();
            config.Decoders = new List<DecoderConfigInfo>();
            for (int i = 0; i < CHANNEL_COUNT; i++)
            {
                DecoderConfigInfo channel = new DecoderConfigInfo();
                channel.Id = i;
                channel.BitRate = BITE_RATE;
                channel.FrameRate = FRAME_RATE;
                config.Decoders.Add( channel );
            }

            Save( config );

            return config;
        }