public static void Write(VideoCaptureDevice device, CameraProperty property) { if (!property.Supported) { return; } switch (property.Specific) { case "CameraControl": { CameraControlProperty p = (CameraControlProperty)Enum.Parse(typeof(CameraControlProperty), property.Identifier, true); WriteProperty(device, p, property); break; } case "VideoProcAmp": { VideoProcAmpProperty p = (VideoProcAmpProperty)Enum.Parse(typeof(VideoProcAmpProperty), property.Identifier, true); WriteProperty(device, p, property); break; } case "Logitech": { WriteLogitechProperty(device, property); break; } } }
public CameraPropertySettings GetVideoPropertySettings(VideoProcAmpProperty property) { int filterHandle; IBaseFilter captureFilter = null; filterHandle = filterGraph.FindFilterByName("Video input", out captureFilter); if (captureFilter != null) { int min = 0; int max = 0; int stepDelta = 1; int defaultValue = 0; VideoProcAmpFlags videoFlags; IAMCameraControl iC = captureFilter as IAMCameraControl; ((IAMVideoProcAmp)iC).GetRange(property, out min, out max, out stepDelta, out defaultValue, out videoFlags); CameraPropertySettings videoPropertySettings = new CameraPropertySettings(); videoPropertySettings.Minimum = min; videoPropertySettings.Maximum = max; videoPropertySettings.Step = stepDelta; videoPropertySettings.DefaultValue = defaultValue; return(videoPropertySettings); } else { return(null); } }
private void PropertyChanged(VideoProcAmpProperty videoProcAmpProperty, int value) { if (OnVideoProcAmpPropertyChanged != null) { OnVideoProcAmpPropertyChanged(videoProcAmpProperty, value); } }
public void SetVideoProcAmpPropertyAuto(VideoProcAmpProperty videoProcAmpProperty, int iVal) { VideoCapturePlayer.Dispatcher.BeginInvoke((Action) delegate { int hr1 = VideoCapturePlayer.VideoAProcAmp.Set(videoProcAmpProperty, iVal, VideoProcAmpFlags.Auto); }); }
private static void WriteProperty(VideoCaptureDevice device, VideoProcAmpProperty property, CameraProperty value) { if (!value.Supported) { return; } try { VideoProcAmpFlags flags = value.Automatic ? VideoProcAmpFlags.Auto : VideoProcAmpFlags.Manual; int v; bool parsed = int.TryParse(value.CurrentValue, NumberStyles.Any, CultureInfo.InvariantCulture, out v); if (parsed) { device.SetVideoProperty(property, v, flags); } else { log.ErrorFormat("Could not parse property {0}, value: {1}.", value.Identifier, value.CurrentValue); } } catch (Exception e) { log.ErrorFormat("Could not write property {0}. {1}.", value.Identifier, e.Message); } }
private static void WriteProperty(VideoCaptureDevice device, VideoProcAmpProperty property, CameraProperty value) { VideoProcAmpFlags flags = value.Automatic ? VideoProcAmpFlags.Auto : VideoProcAmpFlags.Manual; int v = int.Parse(value.CurrentValue, CultureInfo.InvariantCulture); device.SetVideoProperty(property, v, flags); }
/// <summary> /// The event handler for the <see cref="OnCameraControlPropertyChanged"/> event. /// Updates the video capture device with new brightness, contrast, etc. /// </summary> /// <param name="property">The <see cref="VideoProcAmpProperty"/> to be changed</param> /// <param name="value">The new value for the property</param> public void OnVideoProcAmpPropertyChanged(VideoProcAmpProperty property, int value) { if (videoProcAmp == null) { return; } int min, max, steppingDelta, defaultValue; VideoProcAmpFlags flags; try { Console.WriteLine("//ERV ---------- OnVideoProcAmpPropertyChanged(" + property + "," + value); videoProcAmp.GetRange(property, out min, out max, out steppingDelta, out defaultValue, out flags); if (value >= min && value <= max) { videoProcAmp.Set(property, value, flags); } } catch (Exception ex) { //ErrorLogger.ProcessException(ex, false); Console.WriteLine("ERROR! " + ex.ToString()); MessageBox.Show(ex.Message); } }
internal WebcamProperty GetProcAmpProperties(VideoProcAmpProperty property) { HResult result = HResult.ERROR_NOT_READY; WebcamProperty settings = new WebcamProperty { _name = property.ToString(), _procAmpProp = property, _isProcAmp = true }; if (_base._webcamMode) { IAMVideoProcAmp control = _base.mf_MediaSource as IAMVideoProcAmp; result = control.GetRange(property, out settings._min, out settings._max, out settings._step, out settings._default, out VideoProcAmpFlags flags); if (result == Player.NO_ERROR) { settings._supported = (flags & VideoProcAmpFlags.Manual) != 0; settings._autoSupport = (flags & VideoProcAmpFlags.Auto) != 0; control.Get(property, out settings._value, out flags); settings._auto = (flags & VideoProcAmpFlags.Auto) != 0; } } _base._lastError = result; return(settings); }
/// <summary> /// /// </summary> /// <param name="dsDevice"></param> /// <param name="prop"></param> /// <returns></returns> public int GetVideoControl(DsDevice dsDevice, VideoProcAmpProperty prop) { IFilterGraph2 filterGraph = new FilterGraph() as IFilterGraph2; IBaseFilter capFilter = null; int retVal = 0; try { // add the video input device int hr = filterGraph.AddSourceFilterForMoniker(dsDevice.Mon, null, "Source Filter", out capFilter); DsError.ThrowExceptionForHR(hr); IAMVideoProcAmp videoControl = capFilter as IAMVideoProcAmp; int min, max, step, default_val; VideoProcAmpFlags flag = 0; videoControl.GetRange(prop, out min, out max, out step, out default_val, out flag); videoControl.Get(prop, out retVal, out flag); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(retVal); }
/// <summary> /// 设置Manual属性值 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <param name="propertyValue"></param> public void SetVideoProcAmpManualParameterValue(VideoProcAmpProperty videoProcAmpProperty, int propertyValue) { VideoCapturePlayer.Dispatcher.BeginInvoke((Action) delegate { VideoCapturePlayer.VideoProcAmpSetter?.SetManualParameterValue(videoProcAmpProperty, propertyValue); }); }
public VideoProcAmpCameraProperty(CameraPropertyDescriptor descriptor, IAMVideoProcAmp videoAmpControl, VideoProcAmpProperty videoAmpProperty) { Descriptor = descriptor; _videoAmpControl = videoAmpControl; _videoAmpProperty = videoAmpProperty; UpdateRange(); }
public int GetParameterValue(VideoProcAmpProperty property) { int iRet; VideoProcAmpFlags cameraControlFlags; iAMVideoProcAmp.Get(property, out iRet, out cameraControlFlags); return(iRet); }
/// <summary> /// 获取<see cref="VideoProcAmpProperty"/>的设置范围为作<paramref name="callBack"/>的参数 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <param name="callBack"></param> public void GetVideoProcAmpRangeParameterAsnyc(VideoProcAmpProperty videoProcAmpProperty, Action <VideoProcAmpRangeParameter> callBack) { VideoCapturePlayer.Dispatcher.BeginInvoke((Action) delegate { callBack?.Invoke( VideoCapturePlayer.VideoProcAmpSetter?.GetRangeParameterValue(videoProcAmpProperty)); }); }
public VideoSetting(IAMVideoProcAmp filter, VideoProcAmpProperty property) { _CamFilter = filter; _CamProperty = property; _Name = property.ToString(); // Update all defaults min max, etc... Read(); }
/// <summary> /// 设置VideoProcAmpProperty的Mannual值 /// 有做有效值判断 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <param name="perpertyValue"></param> public void SetManualParameterValue(VideoProcAmpProperty videoProcAmpProperty, int perpertyValue) { if (_propertyToRangeParameter.ContainsKey(videoProcAmpProperty) || this.GetRangeParameterValue(videoProcAmpProperty) != null) { VideoProcAmpRangeParameter videoProcAmpRangeParameter = _propertyToRangeParameter[videoProcAmpProperty]; int ensureValue = perpertyValue; int hr = this._videoProcAmp.Set(videoProcAmpProperty, ensureValue, VideoProcAmpFlags.Manual); } }
/// <summary> /// 设置VideoProcAmpProperty的值 /// 有做有效值判断 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <param name="perpertyValue"></param> public void SetParameterValue(VideoProcAmpProperty videoProcAmpProperty, int perpertyValue) { if (_propertyToRangeParameter.ContainsKey(videoProcAmpProperty) || this.GetRangeParameterValue(videoProcAmpProperty) != null) { VideoProcAmpRangeParameter videoProcAmpRangeParameter = _propertyToRangeParameter[videoProcAmpProperty]; int ensureValue = Math.Min(Math.Max(videoProcAmpRangeParameter.MinValue, perpertyValue), videoProcAmpRangeParameter.MaxValue); this._videoProcAmp.Set(videoProcAmpProperty, ensureValue, VideoProcAmpFlags.Manual); } }
/// <summary> /// 获取<see cref="VideoProcAmpProperty"/>的单值作为回调CALLBACK的参数 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <param name="callBack"></param> public void GetVideoProcAmpParameterAsnyc(VideoProcAmpProperty videoProcAmpProperty, Action <int> callBack) { VideoCapturePlayer.Dispatcher.BeginInvoke((Action) delegate { int?getValue = VideoCapturePlayer.VideoProcAmpSetter?.GetParameterValue(videoProcAmpProperty); if (getValue != null) { callBack?.Invoke((int)getValue); } }); }
public void SetVideoProperty(VideoProcAmpProperty property, int propertyValue) { int filterHandle; IBaseFilter captureFilter = null; filterHandle = filterGraph.FindFilterByName("Video input", out captureFilter); if (captureFilter != null) { IAMCameraControl iC = captureFilter as IAMCameraControl; ((IAMVideoProcAmp)iC).Set(property, propertyValue, VideoProcAmpFlags.Manual); } }
private static CameraProperty ReadProperty(VideoCaptureDevice device, VideoProcAmpProperty property) { CameraProperty p = new CameraProperty(); p.Identifier = property.ToString(); p.Specific = "VideoProcAmp"; p.ReadOnly = false; p.Type = CameraPropertyType.Integer; p.Representation = CameraPropertyRepresentation.LinearSlider; p.CanBeAutomatic = true; try { int min; int max; int step; int defaultValue; VideoProcAmpFlags flags; bool success = device.GetVideoPropertyRange(property, out min, out max, out step, out defaultValue, out flags); if (!success) { p.Supported = false; } else { p.Supported = true; p.Minimum = min.ToString(CultureInfo.InvariantCulture); p.Maximum = max.ToString(CultureInfo.InvariantCulture); int currentValue; success = device.GetVideoProperty(property, out currentValue, out flags); if (!success) { p.Supported = false; } else { p.CurrentValue = currentValue.ToString(CultureInfo.InvariantCulture); p.Automatic = flags == VideoProcAmpFlags.Auto; } } } catch { p.Supported = false; } return(p); }
/// <summary> /// 获取属性单值 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <returns></returns> public int GetParameterValue(VideoProcAmpProperty videoProcAmpProperty) { int iret = 0; try { int hr = this._videoProcAmp.Get(videoProcAmpProperty, out int getValue, out VideoProcAmpFlags videoProcAmpFlags); string s = DsError.GetErrorText(hr); iret = getValue; } catch (Exception) { } return(iret); }
public int GetVideoProperty(VideoProcAmpProperty property) { int filterHandle; IBaseFilter captureFilter = null; filterHandle = filterGraph.FindFilterByName("Video input", out captureFilter); int propertyValue = 0; VideoProcAmpFlags videoProcAmpFlags; if (captureFilter != null) { IAMCameraControl iC = captureFilter as IAMCameraControl; ((IAMVideoProcAmp)iC).Get(property, out propertyValue, out videoProcAmpFlags); } return(propertyValue); }
public VideoProcAmpRangeParameter GetRangeParameterValue(VideoProcAmpProperty property) { VideoProcAmpRangeParameter _model = new VideoProcAmpRangeParameter(); int Min, Max, Step, Default; VideoProcAmpFlags _flgs; int hr2 = iAMVideoProcAmp.GetRange(property, out Min, out Max, out Step, out Default, out _flgs); DsError.ThrowExceptionForHR(hr2); _model.MinValue = Min; _model.MaxValue = Max; _model.SetpValue = Step; _model.DefaultValue = Default; _model.VideoProcAmpFlags = _flgs; return(_model); }
/// <summary> /// /// </summary> /// <param name="dsDevice"></param> /// <param name="prop"></param> /// <param name="value"></param> /// <param name="flag"></param> public void SetVideoControl(DsDevice dsDevice, VideoProcAmpProperty prop, int value = 0, VideoProcAmpFlags flag = VideoProcAmpFlags.Auto) { IFilterGraph2 filterGraph = new FilterGraph() as IFilterGraph2; IBaseFilter capFilter = null; try { // add the video input device int hr = filterGraph.AddSourceFilterForMoniker(dsDevice.Mon, null, "Source Filter", out capFilter); DsError.ThrowExceptionForHR(hr); IAMVideoProcAmp videoControl = capFilter as IAMVideoProcAmp; videoControl.Set(prop, value, flag); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 获取可设置范围值 /// </summary> /// <param name="videoProcAmpProperty"></param> /// <returns></returns> public VideoProcAmpRangeParameter GetRangeParameterValue(VideoProcAmpProperty videoProcAmpProperty) { VideoProcAmpRangeParameter videoProcAmpRangeParameter = null; try { int hr = this._videoProcAmp.GetRange(videoProcAmpProperty, out int min, out int max, out int step, out int defaultValue, out VideoProcAmpFlags videoProcAmpFlags); string sss = DsError.GetErrorText(hr); if (hr == 0) { videoProcAmpRangeParameter = new VideoProcAmpRangeParameter { VideoProcAmpProperty = videoProcAmpProperty, MinValue = min, MaxValue = max, StepValue = step, DefaultValue = defaultValue, Flags = videoProcAmpFlags }; //加入字典 if (_propertyToRangeParameter.ContainsKey(videoProcAmpProperty)) { _propertyToRangeParameter[videoProcAmpProperty] = videoProcAmpRangeParameter; } else { _propertyToRangeParameter.Add(videoProcAmpProperty, videoProcAmpRangeParameter); } } } catch (Exception) { } return(videoProcAmpRangeParameter); }
public void TestAllInOne() { int hr = 0; int minValue, maxValue, defaultValue; int stepping; VideoProcAmpFlags caps; int newValue; VideoProcAmpFlags newCaps; //This test is very hardware dependent. Video ProcAmp Property tested can be changed here. VideoProcAmpProperty propertyToCheck = VideoProcAmpProperty.Saturation; // Get values for this property hr = this.videoProcAmp.GetRange(propertyToCheck, out minValue, out maxValue, out stepping, out defaultValue, out caps); DsError.ThrowExceptionForHR(hr); // try to increment this value hr = this.videoProcAmp.Set(propertyToCheck, defaultValue + stepping, VideoProcAmpFlags.Manual); DsError.ThrowExceptionForHR(hr); // Read this new value hr = this.videoProcAmp.Get(propertyToCheck, out newValue, out newCaps); DsError.ThrowExceptionForHR(hr); Debug.Assert(newValue == defaultValue + stepping, "IAMVideoProcAmp.Get / Set"); Debug.Assert(newCaps == VideoProcAmpFlags.Manual, "IAMVideoProcAmp.Get / Set"); // try to set it as Auto hr = this.videoProcAmp.Set(propertyToCheck, defaultValue, VideoProcAmpFlags.Auto); DsError.ThrowExceptionForHR(hr); // Read this value hr = this.videoProcAmp.Get(propertyToCheck, out newValue, out newCaps); DsError.ThrowExceptionForHR(hr); // With my hardware, Contrast & Gamma can't be set to Auto // But Saturation works Debug.Assert(newCaps == VideoProcAmpFlags.Auto, "IAMVideoProcAmp.Get / Set"); }
/// <summary> /// Gets the range and default value of a specified camera property. /// </summary> /// /// <param name="property">Specifies the property to query.</param> /// <param name="minValue">Receives the minimum value of the property.</param> /// <param name="maxValue">Receives the maximum value of the property.</param> /// <param name="stepSize">Receives the step size for the property.</param> /// <param name="defaultValue">Receives the default value of the property.</param> /// <param name="controlFlags">Receives a member of the <see cref="CameraControlFlags"/> enumeration, indicating whether the property is controlled automatically or manually.</param> /// /// <returns>Returns true on success or false otherwise.</returns> /// /// <exception cref="ArgumentException">Video source is not specified - device moniker is not set.</exception> /// <exception cref="ApplicationException">Failed creating device object for moniker.</exception> /// <exception cref="NotSupportedException">The video source does not support camera control.</exception> /// public bool GetVideoPropertyRange(VideoProcAmpProperty property, out int minValue, out int maxValue, out int stepSize, out int defaultValue, out VideoProcAmpFlags controlFlags) { bool ret = true; // check if source was set if ((deviceMoniker == null) || (string.IsNullOrEmpty(deviceMoniker))) { throw new ArgumentException("Video source is not specified."); } lock (sync) { object tempSourceObject = null; // create source device's object try { tempSourceObject = FilterInfo.CreateFilter(deviceMoniker); } catch { throw new ApplicationException("Failed creating device object for moniker."); } if (!(tempSourceObject is IAMVideoProcAmp)) { throw new NotSupportedException("The video source does not support camera control."); } IAMVideoProcAmp pCamControl = (IAMVideoProcAmp)tempSourceObject; int hr = pCamControl.GetRange(property, out minValue, out maxValue, out stepSize, out defaultValue, out controlFlags); ret = (hr >= 0); Marshal.ReleaseComObject(tempSourceObject); } return(ret); }
internal void SetProcAmpProperties(VideoProcAmpProperty property, WebcamProperty value) { HResult result = HResult.ERROR_NOT_READY; if (_base._webcamMode) { if (value == null || !value._isProcAmp || value._procAmpProp != property) { result = HResult.E_INVALIDARG; } else { WebcamProperty props = GetProcAmpProperties(property); if (!props._supported) { result = HResult.MF_E_NOT_AVAILABLE; } else if (value._auto && props._auto) { result = Player.NO_ERROR; } else if (!value._auto && (value._value < props._min || value._value > props._max)) { result = HResult.MF_E_OUT_OF_RANGE; } if (result == HResult.ERROR_NOT_READY) { try { result = ((IAMVideoProcAmp)_base.mf_MediaSource).Set(property, value._value, value._auto ? VideoProcAmpFlags.Auto : VideoProcAmpFlags.Manual); } catch (Exception e) { result = (HResult)Marshal.GetHRForException(e); } } } } _base._lastError = result; }
/////////////////////////////////////////////////////////////////////////////// // Inherited methods // /////////////////////////////////////////////////////////////////////////////// #region OVERRIDES #endregion //OVERRIDES /////////////////////////////////////////////////////////////////////////////// // Eventhandler // /////////////////////////////////////////////////////////////////////////////// #region EVENTHANDLER /// <summary> /// The event handler for the <see cref="OnCameraControlPropertyChanged"/> event. /// Updates the video capture device with new brightness, contrast, etc. /// </summary> /// <param name="property">The <see cref="VideoProcAmpProperty"/> to be changed</param> /// <param name="value">The new value for the property</param> private void OnVideoProcAmpPropertyChanged(VideoProcAmpProperty property, int value) { if (this.videoProcAmp == null) { return; } int min, max, steppingDelta, defaultValue; VideoProcAmpFlags flags; try { this.videoProcAmp.GetRange(property, out min, out max, out steppingDelta, out defaultValue, out flags); if (value >= min && value <= max) { this.videoProcAmp.Set(property, value, flags); } } catch (Exception ex) { ErrorLogger.ProcessException(ex, false); } }
public DeviceParaInfo(VideoProcAmpProperty videoProperty, string value, string deviceName) { VideoProperty = videoProperty; Value = value; DeviceName = deviceName; }
private void SetVideoSourceProperty(VideoCaptureDevice device, VideoProcAmpProperty prop, string n) { try { int v; if (Int32.TryParse(Nv(Camobject.settings.procAmpConfig, n), out v)) { if (v > Int32.MinValue) { int fv; if (Int32.TryParse(Nv(Camobject.settings.procAmpConfig, "f" + n), out fv)) { device.SetProperty(prop, v, (VideoProcAmpFlags)fv); } } } } catch (Exception ex) { ErrorHandler?.Invoke(ex.Message); } }
/// <summary> /// Sets a specified property on the camera. /// </summary> /// /// <param name="property">Specifies the property to set.</param> /// <param name="value">Specifies the new value of the property.</param> /// <param name="controlFlags">Specifies the desired control setting.</param> /// /// <returns>Returns true on success or false otherwise.</returns> /// /// <exception cref="ArgumentException">Video source is not specified - device moniker is not set.</exception> /// <exception cref="ApplicationException">Failed creating device object for moniker.</exception> /// <exception cref="NotSupportedException">The video source does not support camera control.</exception> /// public bool SetVideoProperty(VideoProcAmpProperty property, int value, VideoProcAmpFlags controlFlags) { bool ret = true; // check if source was set if ((deviceMoniker == null) || (string.IsNullOrEmpty(deviceMoniker))) { throw new ArgumentException("Video source is not specified."); } lock (sync) { object tempSourceObject = null; // create source device's object try { tempSourceObject = FilterInfo.CreateFilter(deviceMoniker); } catch { throw new ApplicationException("Failed creating device object for moniker."); } if (!(tempSourceObject is IAMVideoProcAmp)) { throw new NotSupportedException("The video source does not support camera control."); } IAMVideoProcAmp pCamControl = (IAMVideoProcAmp)tempSourceObject; int hr = pCamControl.Set(property, value, controlFlags); ret = (hr >= 0); Marshal.ReleaseComObject(tempSourceObject); } return ret; }
/// <summary> /// コンストラクタ /// </summary> /// <param name="graph">フィルタグラフ</param> /// <param name="property">プロパティの種別</param> public CxAMVideoProcAmp(IxDSGraphBuilderProvider graph, VideoProcAmpProperty property) { Graph = graph; Property = property; }
/// <summary> /// Returns property of camera (brightness/gamma etc) /// </summary> /// <param name="prop"></param> /// <param name="setting"></param> /// <param name="flags"></param> /// <returns></returns> /// <exception cref="ArgumentException"></exception> /// <exception cref="ApplicationException"></exception> /// <exception cref="NotSupportedException"></exception> public bool GetProperty(VideoProcAmpProperty prop, out int setting, out VideoProcAmpFlags flags) { setting = Int32.MinValue; flags = VideoProcAmpFlags.None; bool ret = false; // check if source was set if (string.IsNullOrEmpty(_deviceMoniker)) { return false; } lock (_sync) { object tempSourceObject; // create source device's object try { tempSourceObject = FilterInfo.CreateFilter(_deviceMoniker); } catch { return false; } if (!(tempSourceObject is IAMVideoProcAmp)) { return false; } var pCamControl = (IAMVideoProcAmp)tempSourceObject; try { int hr = pCamControl.Get(prop, out setting, out flags); ret = (hr >= 0); } catch { // ignored } Marshal.FinalReleaseComObject(tempSourceObject); } return ret; }
/// <summary> /// Returns possible range of values for given property /// </summary> /// <param name="prop"></param> /// <param name="min"></param> /// <param name="max"></param> /// <param name="steppingData"></param> /// <param name="defaultValue"></param> /// <param name="flags"></param> /// <returns></returns> /// <exception cref="ArgumentException"></exception> /// <exception cref="ApplicationException"></exception> /// <exception cref="NotSupportedException"></exception> public bool GetPropertyRange(VideoProcAmpProperty prop, out int min, out int max, out int steppingData, out int defaultValue, out VideoProcAmpFlags flags) { min = Int32.MinValue; max = Int32.MinValue; steppingData = Int32.MinValue; defaultValue = Int32.MinValue; flags = VideoProcAmpFlags.None; bool ret; // check if source was set if (string.IsNullOrEmpty(_deviceMoniker)) { throw new ArgumentException("Video source is not specified."); } lock (_sync) { object tempSourceObject; // create source device's object try { tempSourceObject = FilterInfo.CreateFilter(_deviceMoniker); } catch { throw new ApplicationException("Failed creating device object for moniker."); } if (!(tempSourceObject is IAMVideoProcAmp)) { throw new NotSupportedException("The video source does not support properties."); } var pCamControl = (IAMVideoProcAmp)tempSourceObject; int hr = pCamControl.GetRange(prop, out min, out max, out steppingData, out defaultValue, out flags); ret = (hr >= 0); Marshal.FinalReleaseComObject(tempSourceObject); } return ret; }
private void SetParameterValue(VideoProcAmpProperty i_prop, int value) { DsDevice[] capDevices; // Get the collection of video devices capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); DsDevice dev = capDevices[0]; // TODO: Almacenar en la clase el ID del dispositivo (no usar este 0) object o; Guid IID_IBaseFilter = new Guid("56a86895-0ad4-11ce-b03a-0020af0ba770"); dev.Mon.BindToObject(null, null, ref IID_IBaseFilter, out o); IAMVideoProcAmp vProps = (IAMVideoProcAmp)o; VideoProcAmpFlags pFlags = new VideoProcAmpFlags(); vProps.Set(i_prop, value, pFlags); }
/// <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); }
/// <summary> /// The event handler for the <see cref="OnCameraControlPropertyChanged"/> event. /// Updates the video capture device with new brightness, contrast, etc. /// </summary> /// <param name="property">The <see cref="VideoProcAmpProperty"/> to be changed</param> /// <param name="value">The new value for the property</param> public void OnVideoProcAmpPropertyChanged(VideoProcAmpProperty property, int value) { if (videoProcAmp == null) return; int min, max, steppingDelta, defaultValue; VideoProcAmpFlags flags; try { videoProcAmp.GetRange(property, out min, out max, out steppingDelta, out defaultValue, out flags); if (value >= min && value <= max) videoProcAmp.Set(property, value, flags); } catch (Exception) { //ErrorLogger.ProcessException(ex, false); } }