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> /// Updates the values in the specified (previously obtained) property data of the playing webcam. /// </summary> /// <param name="property">Specifies the webcam property data to update, previously obtained with for example myPlayer.Webcam.Brightness.</param> public void UpdatePropertyData(WebcamProperty property) { if (_base._webcamMode) { if (property != null) { WebcamProperty currentProperty; if (property._isProcAmp) { currentProperty = GetProcAmpProperties(property._procAmpProp); } else { currentProperty = GetControlProperties(property._controlProp); } property._value = currentProperty._value; property._auto = currentProperty._auto; _base._lastError = Player.NO_ERROR; } else { _base._lastError = HResult.E_INVALIDARG; } } else { _base._lastError = HResult.MF_E_NOT_AVAILABLE; } }
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; }
/// <summary> /// Sets the specified property of the playing webcam to the default value or (if available) to automatic control, for example myPlayer.Webcam.ResetProperty(myPlayer.Webcam.Brightness). /// </summary> /// <param name="property">Specifies the webcam property, obtained with for example myPlayer.Webcam.Brightness.</param> public void ResetProperty(WebcamProperty property) { SetProperty(property, property._default, property._autoSupport); }
/// <summary> /// Sets the specified property of the playing webcam to the specified value or to automatic control, for example myPlayer.Webcam.SetProperty(myPlayer.Webcam.Brightness, 100, false). /// </summary> /// <param name="property">Specifies the webcam property, obtained with for example myPlayer.Webcam.Brightness.</param> /// <param name="value">The value to be set.</param> /// <param name="auto">If set to true, the value parameter is ignored and the automatic control of the property is enabled (if available).</param> public void SetProperty(WebcamProperty property, int value, bool auto) { if (_base._webcamMode) { if (property != null) { WebcamProperty currentProp; if (property._isProcAmp) { currentProp = GetProcAmpProperties(property._procAmpProp); } else { currentProp = GetControlProperties(property._controlProp); } if (currentProp.Supported) { if (auto || (value >= currentProp._min && value <= currentProp._max)) { bool setProperty = true; if (auto) { if (currentProp._auto) { setProperty = false; } } else if (value == currentProp._value && !currentProp.AutoEnabled) { setProperty = false; } if (setProperty) { try { if (property._isProcAmp) { _base._lastError = ((IAMVideoProcAmp)_base.mf_MediaSource).Set(property._procAmpProp, value, auto ? VideoProcAmpFlags.Auto : VideoProcAmpFlags.Manual); } else { _base._lastError = ((IAMCameraControl)_base.mf_MediaSource).Set(property._controlProp, value, auto ? CameraControlFlags.Auto : CameraControlFlags.Manual); } if (_base._lastError == Player.NO_ERROR) { if (auto) { property._auto = true; } else { property._value = value; } } } catch (Exception e) { _base._lastError = (HResult)Marshal.GetHRForException(e); } } else { _base._lastError = Player.NO_ERROR; } } else { _base._lastError = HResult.MF_E_OUT_OF_RANGE; } } else { _base._lastError = HResult.MF_E_NOT_AVAILABLE; } } else { _base._lastError = HResult.E_INVALIDARG; } } else { _base._lastError = HResult.MF_E_NOT_AVAILABLE; } }