DirectShow.NET中筛选器的QueryInterface
本文关键字:QueryInterface 筛选 NET DirectShow | 更新日期: 2023-09-27 18:00:03
我使用视频处理项目中的过滤器,并希望设置过滤器的设置。在c++中,它通过ISettingsInterface工作。
ISettingsInterface * pSettingsInterface = NULL;
pRotateFilter->QueryInterface ( IID_ISettingsInterface, ( void ** ) &pSettingsInterface );
hr = pSettingsInterface->SetParameter ( "rotationmode", "3" );
hr = g_pGraph->AddFilter ( pRotateFilter, L"RotateFilter" );
在DirectShowlib c#包装器中没有这样的接口?过滤器上也没有QueryInterface
函数。
我通过声明接口解决了这个问题:
[ComImport, System.Security.SuppressUnmanagedCodeSecurity,Guid("388EEF20-40CC-4752-A0FF-66AA5C4AF8FA"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ISettingsInterface
{
[PreserveSig]
int GetParameter(
[MarshalAs(UnmanagedType.LPStr)] String type,
[MarshalAs(UnmanagedType.I4)] int buffersize,
[In, Out, MarshalAs(UnmanagedType.LPStr)] String value,
[In, Out, MarshalAs(UnmanagedType.I4)] ref int length
);
[PreserveSig]
int SetParameter(
[MarshalAs(UnmanagedType.LPStr)] String type,
[MarshalAs(UnmanagedType.LPStr)] String value
);
[PreserveSig]
int GetParameterSettings(
[MarshalAs(UnmanagedType.LPStr)] ref String szResult,
[In] int nSize
);
}