如何将EZrgb24过滤器连接到我的图形

本文关键字:我的 图形 连接 过滤器 EZrgb24 | 更新日期: 2023-09-27 18:21:37

上下文

我成功地加载了一个32位ezrgb24 COM(从示例中编译)

这个视频在directshow.net和c#上播放得很好。

然而,我不知道如何将我创建的ezrgb24过滤器连接到我的图形。

在我的课开始时添加

[ComImport,
System.Security.SuppressUnmanagedCodeSecurity,
Guid("fd5010a3-8ebe-11ce-8183-00aa00577da1"), 
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IIPEffect
{
    [PreserveSig]
    void get_IPEffect([Out] out int effectNum, [Out] out double StartTime, [Out] out double Length);
    [PreserveSig]
    void put_IPEffect([In] int effectNum, [In] double StartTime, [In] double Length);
}
internal enum CLSCTX
{
    Inproc = 0x03,
    Server = 0x15,
    All = 0x17,
}

[ComImport]
[Guid("8B498501-1218-11CF-ADC4-00A0D100041B")]
public class EZRGB24
{
}

相关代码

        IBaseFilter ibfRenderer = null;
        ISampleGrabber sampGrabber = null;
        IBaseFilter capFilter = null;
        IPin iPinInFilter = null;
        IPin iPinOutFilter = null;
        IPin iPinInDest = null;

        Type comType = null;
        object comObj = null;
        m_FilterGraph = new FilterGraph() as IFilterGraph2;
        try
        {
            // Get the SampleGrabber interface
            sampGrabber = new SampleGrabber() as ISampleGrabber;
            // Add the video source
            hr = m_FilterGraph.AddSourceFilter(_videoPath, "Ds.NET FileFilter", out capFilter);
            DsError.ThrowExceptionForHR(hr);
            // Hopefully this will be the video pin
            IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
            IBaseFilter baseGrabFlt = sampGrabber as IBaseFilter;
            ConfigureSampleGrabber(sampGrabber);
            iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
            iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);
            // Add the frame grabber to the graph
            hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
            DsError.ThrowExceptionForHR(hr);
            hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);
            DsError.ThrowExceptionForHR(hr);
            // Get the default video renderer
            ibfRenderer = (IBaseFilter)new VideoRendererDefault();
            // Add it to the graph
            hr = m_FilterGraph.AddFilter(ibfRenderer, "Ds.NET VideoRendererDefault");
            DsError.ThrowExceptionForHR(hr);
            iPinInDest = DsFindPin.ByDirection(ibfRenderer, PinDirection.Input, 0);
            // Connect the graph.  Many other filters automatically get added here
            hr = m_FilterGraph.Connect(iPinOutFilter, iPinInDest);
            DsError.ThrowExceptionForHR(hr);

            SaveSizeInfo(sampGrabber);

            ----- everything works fine up to here.
            IIPEffect myClass = (IIPEffect)(new EZRGB24());

            myClass.put_IPEffect(1008, 0, 100000);

            hr = m_FilterGraph.AddFilter((IBaseFilter)myClass, "EZRGB24");
            IPin inPinx = DsFindPin.ByDirection((IBaseFilter)myClass, PinDirection.Input, 0);
            m_FilterGraph.Connect(iPinOutSource, inPinx);
            DsError.ThrowExceptionForHR(hr);

当我把鼠标移到myClass上时,我可以看到它不是null。

此外,我试着用图形编辑插入我的图形,但我的程序没有列出。此外,该行之后的hr为0hr=m_FilterGraph.AddFilter((IBaseFilter)myClass,"EZRGB24");

我使用的是directshow.net,然而,这也被标记为directshow,因为我觉得这个解决方案适用于c#或c++。

这是我之前问题的后续内容如何使用EZrgb24过滤器

如何将EZrgb24过滤器连接到我的图形

您正在使用iPinOutSource进行两次连接。首先执行:

// Hopefully this will be the video pin
IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);

以及后来的

m_FilterGraph.Connect(iPinOutSource, inPinx);

引脚只能有一个连接。