示例#1
0
        /// <summary>
        /// Creates the instance by parsing the Capture node in the configuration file
        /// </summary>
        /// <param name="xmlNode">The TvAudio xml node</param>
        /// <returns>TvAudio instance</returns>
        public static Capture CreateInstance(XmlNode xmlNode)
        {
            Capture capture = new Capture();
            Dictionary <VideoProcAmpProperty, VideoQuality> videoProcAmpValues =
                new Dictionary <VideoProcAmpProperty, VideoQuality>();

            capture.VideoProcAmpValues = videoProcAmpValues;
            if (xmlNode != null)
            {
                XmlNode viceoCaptureNode           = xmlNode.SelectSingleNode("videoCapture");
                XmlNode nameNode                   = viceoCaptureNode.SelectSingleNode("name");
                XmlNode videoInNode                = viceoCaptureNode.SelectSingleNode("videoIn");
                XmlNode audioInNode                = viceoCaptureNode.SelectSingleNode("audioIn");
                XmlNode teletextPinNode            = viceoCaptureNode.SelectSingleNode("teletextPin");
                XmlNode frameRateNode              = viceoCaptureNode.SelectSingleNode("frameRate");
                XmlNode imageResolutionNode        = viceoCaptureNode.SelectSingleNode("imageResolution");
                XmlNode availableVideoStandardNode = viceoCaptureNode.SelectSingleNode("videoStandard/available");
                XmlNode currentVideoStandardNode   = viceoCaptureNode.SelectSingleNode("videoStandard/selected");
                string  resolution                 = imageResolutionNode.InnerText;
                try
                {
                    capture.TeletextPin = Int32.Parse(teletextPinNode.InnerText);
                    capture.FrameRate   = Double.Parse(frameRateNode.InnerText, CultureInfo.GetCultureInfo("en-GB").NumberFormat);
                    capture.VideoIn     = Int32.Parse(videoInNode.InnerText);
                    if (audioInNode != null)
                    {
                        capture.AudioCaptureName = nameNode.InnerText;
                    }
                    else
                    {
                        XmlNode audioCaptureNode     = xmlNode.SelectSingleNode("audioCapture");
                        XmlNode audioCaptureNameNode = audioCaptureNode.SelectSingleNode("audioIn");
                        audioInNode = audioCaptureNameNode.SelectSingleNode("audioIn");
                        capture.AudioCaptureName = audioCaptureNameNode.InnerText;
                    }
                    capture.AudioIn = Int32.Parse(audioInNode.InnerText);
                    if (resolution != null)
                    {
                        string[] imageResolutions = resolution.Split('x');
                        capture.ImageWidth  = Int32.Parse(imageResolutions[0]);
                        capture.ImageHeight = Int32.Parse(imageResolutions[1]);
                    }
                    capture.CurrentVideoStandard   = (AnalogVideoStandard)Int32.Parse(currentVideoStandardNode.InnerText);
                    capture.AvailableVideoStandard = (AnalogVideoStandard)Int32.Parse(availableVideoStandardNode.InnerText);
                    XmlNodeList videoQualityList = viceoCaptureNode.SelectSingleNode("videoProcAmp").SelectNodes("videoQuality");
                    if (videoQualityList != null)
                    {
                        foreach (XmlNode pin in videoQualityList)
                        {
                            int minValue                  = Int32.Parse(pin.Attributes["minValue"].Value);
                            int maxValue                  = Int32.Parse(pin.Attributes["maxValue"].Value);
                            int defaultValue              = Int32.Parse(pin.Attributes["defaultValue"].Value);
                            int delta                     = Int32.Parse(pin.Attributes["delta"].Value);
                            VideoProcAmpFlags flags       = (VideoProcAmpFlags)Int32.Parse(pin.Attributes["flags"].Value);
                            int value                     = Int32.Parse(pin.Attributes["value"].Value);
                            VideoProcAmpProperty property = (VideoProcAmpProperty)Int32.Parse(pin.InnerText);
                            VideoQuality         quality  = new VideoQuality(minValue, maxValue, delta, defaultValue,
                                                                             flags == VideoProcAmpFlags.Manual, value);
                            videoProcAmpValues.Add(property, quality);
                        }
                    }
                }
                catch
                {
                    return(capture);
                }
                capture.Name = nameNode.InnerText;
            }
            return(capture);
        }
示例#2
0
 /// <summary>
 /// Creates the instance by parsing the Capture node in the configuration file
 /// </summary>
 /// <param name="xmlNode">The TvAudio xml node</param>
 /// <returns>TvAudio instance</returns>
 public static Capture CreateInstance(XmlNode xmlNode)
 {
   Capture capture = new Capture();
   Dictionary<VideoProcAmpProperty, VideoQuality> videoProcAmpValues =
     new Dictionary<VideoProcAmpProperty, VideoQuality>();
   capture.VideoProcAmpValues = videoProcAmpValues;
   if (xmlNode != null)
   {
     XmlNode viceoCaptureNode = xmlNode.SelectSingleNode("videoCapture");
     XmlNode nameNode = viceoCaptureNode.SelectSingleNode("name");
     XmlNode videoInNode = viceoCaptureNode.SelectSingleNode("videoIn");
     XmlNode audioInNode = viceoCaptureNode.SelectSingleNode("audioIn");
     XmlNode teletextPinNode = viceoCaptureNode.SelectSingleNode("teletextPin");
     XmlNode frameRateNode = viceoCaptureNode.SelectSingleNode("frameRate");
     XmlNode imageResolutionNode = viceoCaptureNode.SelectSingleNode("imageResolution");
     XmlNode availableVideoStandardNode = viceoCaptureNode.SelectSingleNode("videoStandard/available");
     XmlNode currentVideoStandardNode = viceoCaptureNode.SelectSingleNode("videoStandard/selected");
     string resolution = imageResolutionNode.InnerText;
     try
     {
       capture.TeletextPin = Int32.Parse(teletextPinNode.InnerText);
       capture.FrameRate = Double.Parse(frameRateNode.InnerText, CultureInfo.GetCultureInfo("en-GB").NumberFormat);
       capture.VideoIn = Int32.Parse(videoInNode.InnerText);
       if (audioInNode != null)
       {
         capture.AudioCaptureName = nameNode.InnerText;
       }
       else
       {
         XmlNode audioCaptureNode = xmlNode.SelectSingleNode("audioCapture");
         XmlNode audioCaptureNameNode = audioCaptureNode.SelectSingleNode("audioIn");
         audioInNode = audioCaptureNameNode.SelectSingleNode("audioIn");
         capture.AudioCaptureName = audioCaptureNameNode.InnerText;
       }
       capture.AudioIn = Int32.Parse(audioInNode.InnerText);
       if (resolution != null)
       {
         string[] imageResolutions = resolution.Split('x');
         capture.ImageWidth = Int32.Parse(imageResolutions[0]);
         capture.ImageHeight = Int32.Parse(imageResolutions[1]);
       }
       capture.CurrentVideoStandard = (AnalogVideoStandard)Int32.Parse(currentVideoStandardNode.InnerText);
       capture.AvailableVideoStandard = (AnalogVideoStandard)Int32.Parse(availableVideoStandardNode.InnerText);
       XmlNodeList videoQualityList = viceoCaptureNode.SelectSingleNode("videoProcAmp").SelectNodes("videoQuality");
       if (videoQualityList != null)
       {
         foreach (XmlNode pin in videoQualityList)
         {
           int minValue = Int32.Parse(pin.Attributes["minValue"].Value);
           int maxValue = Int32.Parse(pin.Attributes["maxValue"].Value);
           int defaultValue = Int32.Parse(pin.Attributes["defaultValue"].Value);
           int delta = Int32.Parse(pin.Attributes["delta"].Value);
           VideoProcAmpFlags flags = (VideoProcAmpFlags)Int32.Parse(pin.Attributes["flags"].Value);
           int value = Int32.Parse(pin.Attributes["value"].Value);
           VideoProcAmpProperty property = (VideoProcAmpProperty)Int32.Parse(pin.InnerText);
           VideoQuality quality = new VideoQuality(minValue, maxValue, delta, defaultValue,
                                                   flags == VideoProcAmpFlags.Manual, value);
           videoProcAmpValues.Add(property, quality);
         }
       }
     }
     catch
     {
       return capture;
     }
     capture.Name = nameNode.InnerText;
   }
   return capture;
 }