简体   繁体   中英

QueryInterface on Filter in DirectShow.NET

I use filters from Video Processing Project and want to set settings of the filters. In c++ it works via ISettingsInterface.

ISettingsInterface * pSettingsInterface = NULL;
pRotateFilter->QueryInterface ( IID_ISettingsInterface, ( void ** ) &pSettingsInterface );
hr = pSettingsInterface->SetParameter ( "rotationmode", "3" );
hr = g_pGraph->AddFilter ( pRotateFilter, L"RotateFilter" );

In the DirectShowlib c# wrappers there is no such interface? There is also no QueryInterface function on the filter.

I solved it by declaring the interface:

 [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
            );
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM