protected virtual void SetStructure(Guid guidPropSet, int propId, System.Type structureType, object structValue) { Guid propertyGuid = guidPropSet; IKsPropertySet propertySet = _captureFilter as IKsPropertySet; KSPropertySupport IsTypeSupported = 0; if (propertySet == null) { AppLogger.Message("SetStructure() properySet=null"); return; } int hr = propertySet.QuerySupported(propertyGuid, propId, out IsTypeSupported); if (hr != 0 || (IsTypeSupported & KSPropertySupport.Set) == 0) { AppLogger.Message("GetString() GetStructure is not supported"); return; } int iSize = Marshal.SizeOf(structureType); IntPtr pDataReturned = Marshal.AllocCoTaskMem(iSize); Marshal.StructureToPtr(structValue, pDataReturned, true); hr = propertySet.Set(propertyGuid, propId, pDataReturned, (int)iSize, pDataReturned, (int)iSize); if (hr != 0) { AppLogger.Message(String.Format("SetStructure() failed 0x{0:X}", hr)); } Marshal.FreeCoTaskMem(pDataReturned); }
public object GetStructure(Guid guidPropSet, int propId, System.Type structureType) { Guid propertyGuid = guidPropSet; IKsPropertySet propertySet = _captureFilter as IKsPropertySet; KSPropertySupport IsTypeSupported = 0; int uiSize; if (propertySet == null) { AppLogger.Message("GetStructure() properySet=null"); return(null); } int hr = propertySet.QuerySupported(propertyGuid, propId, out IsTypeSupported); if (hr != 0 || (IsTypeSupported & KSPropertySupport.Get) == 0) { AppLogger.Message("GetString() GetStructure is not supported"); return(null); } object objReturned = null; IntPtr pDataReturned = Marshal.AllocCoTaskMem(1000); hr = propertySet.Get(propertyGuid, propId, IntPtr.Zero, 0, pDataReturned, 1000, out uiSize); if (hr == 0) { objReturned = Marshal.PtrToStructure(pDataReturned, structureType); } else { AppLogger.Message(String.Format("GetStructure() failed 0x{0:X}", hr)); } Marshal.FreeCoTaskMem(pDataReturned); return(objReturned); }
private bool SupportFor(KSProperties.CameraControlFeature feature) { KSPropertySupport supported = new KSPropertySupport(); _ksPropertySet.QuerySupported(PROPSETID_VIDCAP_CAMERACONTROL, (int)feature, out supported); return(supported.HasFlag(KSPropertySupport.Set) && supported.HasFlag(KSPropertySupport.Get)); }
public int QuerySupported(Guid guidPropSet, int dwPropID, out KSPropertySupport pTypeSupport) { pTypeSupport = KSPropertySupport.Get; if (guidPropSet != PropSetID.Pin) { return(E_PROP_SET_UNSUPPORTED); } if (dwPropID != (int)AMPropertyPin.Category) { return(E_PROP_ID_UNSUPPORTED); } return(S_OK); }
public int QuerySupported(Guid guidPropSet, int dwPropID, out KSPropertySupport pTypeSupport) { #if HAMED_LOG_METHOD_INFO MethodBase method = new StackTrace().GetFrame(0).GetMethod(); Console.WriteLine(this.GetType().FullName + " - " + method.Name + " - " + method.ToString()); #endif pTypeSupport = KSPropertySupport.Get; if (guidPropSet != PropSetID.Pin) { return(E_PROP_SET_UNSUPPORTED); } if (dwPropID != (int)AMPropertyPin.Category) { return(E_PROP_ID_UNSUPPORTED); } return(S_OK); }
/// <summary> /// Set broadcast frequency using the IKsProperySet interface. /// </summary> /// <param name="Freq"></param> /// <returns></returns> public int SetFrequency(int Freq) { int hr; IKsPropertySet pKs = _tvTuner as IKsPropertySet; DirectShowLib.KSPropertySupport dwSupported = new KSPropertySupport(); DshowError errorCode = DshowError.VFW_NO_ERROR; // Use IKsProperySet interface (interface for Vfw like property // window) for getting/setting tuner specific information. // Check first if the Property is supported. if (pKs == null) { errorCode = DshowError.VFW_E_NO_INTERFACE; return((int)errorCode); } // Use IKsProperySet interface (interface for Vfw like propery // window) for getting and setting tuner specific information // like the real broadcast frequency. hr = pKs.QuerySupported( PROPSETID_TUNER, (int)KSPROPERTY_TUNER.TUNER_FREQUENCY, out dwSupported); if (hr == 0) { if (((dwSupported & DirectShowLib.KSPropertySupport.Get) == DirectShowLib.KSPropertySupport.Get) && ((dwSupported & DirectShowLib.KSPropertySupport.Set) == DirectShowLib.KSPropertySupport.Set) & (Freq >= this.minFrequency && Freq <= this.maxFrequency)) { // Create and prepare data structures KSPROPERTY_TUNER_FREQUENCY_S Frequency = new KSPROPERTY_TUNER_FREQUENCY_S(); IntPtr freqData = Marshal.AllocCoTaskMem(Marshal.SizeOf(Frequency)); IntPtr instData = Marshal.AllocCoTaskMem(Marshal.SizeOf(Frequency.Instance)); int cbBytes = 0; // Convert the data Marshal.StructureToPtr(Frequency, freqData, true); Marshal.StructureToPtr(Frequency.Instance, instData, true); hr = pKs.Get( PROPSETID_TUNER, (int)KSPROPERTY_TUNER.TUNER_FREQUENCY, instData, Marshal.SizeOf(Frequency.Instance), freqData, Marshal.SizeOf(Frequency), out cbBytes); if (hr == 0) { // Specify the TV broadcast frequency and tuning flag Frequency.Instance.Frequency = Freq; Frequency.Instance.TuningFlags = (int)KS_TUNER_TUNING_FLAGS.TUNING_EXACT; // Convert the data Marshal.StructureToPtr(Frequency, freqData, true); Marshal.StructureToPtr(Frequency.Instance, instData, true); // Now change the broadcast frequency hr = pKs.Set( PROPSETID_TUNER, (int)KSPROPERTY_TUNER.TUNER_FREQUENCY, instData, Marshal.SizeOf(Frequency.Instance), freqData, Marshal.SizeOf(Frequency)); if (hr < 0) { errorCode = (DshowError)hr; } } else { errorCode = (DshowError)hr; } if (freqData != IntPtr.Zero) { Marshal.FreeCoTaskMem(freqData); } if (instData != IntPtr.Zero) { Marshal.FreeCoTaskMem(instData); } } } else { // QuerySupported errorCode = (DshowError)hr; } return((int)errorCode); }
public int QuerySupported(Guid guidPropSet, int dwPropId, out KSPropertySupport pTypeSupport) { pTypeSupport = KSPropertySupport.Get; if (guidPropSet != PropSetID.Pin) { return EPropSetUnsupported; } if (dwPropId != (int)AMPropertyPin.Category) { return EPropIdUnsupported; } return S_OK; }
public int QuerySupported(Guid guidPropSet, int dwPropID, out KSPropertySupport pTypeSupport) { pTypeSupport = KSPropertySupport.Get; if (guidPropSet != PropSetID.Pin) { return E_PROP_SET_UNSUPPORTED; } if (dwPropID != (int)AMPropertyPin.Category) { return E_PROP_ID_UNSUPPORTED; } return S_OK; }
private bool SupportFor(KSProperties.CameraControlFeature feature) { KSPropertySupport supported = new KSPropertySupport(); _ksPropertySet.QuerySupported(PROPSETID_VIDCAP_CAMERACONTROL,(int)feature, out supported); return (supported.HasFlag(KSPropertySupport.Set) && supported.HasFlag(KSPropertySupport.Get)); }