How to connect EZrgb24 filter to my graph

谁都会走 提交于 2019-12-25 02:39:06

问题


Context

I successfully loaded a 32 bit ezrgb24 COM (compiled it from the samples)

The video is playing just fine with directshow.net and c#.

However, I dont know how to connect the ezrgb24 filter I created to my graph.

Added in the beggining of my class

[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
{

}

Relevant code

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

When I mouse over myClass, I can see it's not null.

Also, I tryed to plug onto my graph with graph edit, but my program isn't listed. Also, hr is 0 after that line hr = m_FilterGraph.AddFilter((IBaseFilter)myClass, "EZRGB24");

I am using directshow.net, however, this is also tagged both directshow as I feel the solution will work for either c# or c++.

This is a follow up of my previous question How to use EZrgb24 filter


回答1:


You are using iPinOutSource twice to connect. First you execute:

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

hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);

and later

m_FilterGraph.Connect(iPinOutSource, inPinx);

A pin can only have one connection.



来源:https://stackoverflow.com/questions/25813060/how-to-connect-ezrgb24-filter-to-my-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!