Problems getting custom filter interface to work with application

From: Rylan Hilman (sabremau_at_yahoo.com)
Date: 10/25/04

  • Next message: The March Hare [MVP]: "Re: Problems getting custom filter interface to work with application"
    Date: 24 Oct 2004 22:50:14 -0700
    
    

    I seem to be stuck in my attempts to add a custom interface to a
    custom DirectShow filter. The filter works, I can compile it and
    register it and get it to display just fine, but if I try to add an
    interface to it, the application, for some reason, can't see it. I'm
    fairly new to DirectShow/COM programming, but have been Googling and
    reading documentation for a while and don't seem to be any closer to
    solving this one.

      I've modified the ball project from the DirectX SDK to act as a
    custom source filter(at the moment, just displaying a solid rectangle
    of varying colors), and the playwnd project from the SDK to load the
    filter and render it to a window. This far, everything's fine; the
    application loads the filter, renders it, and plays no problem.

      However, I implemented(or tried to implement) a custom interface,
    following steps found in
    http://groups.google.com/groups?selm=3cda37d5%241_3%40news.nntpserver.com&output=gplain
    , but trying to QueryInterface on the IID returns a failure.

    Here is the IDL file:

    [
         uuid(AE0D4042-DCD3-49EF-ADFF-F3E90AFA8D82),
         version(1.0),
         helpstring("MI Filter Library")
    ]
    library MIFilterLib
    {
         importlib("stdole32.tlb");
         importlib("stdole2.tlb");
         [
              object,
              uuid(9DF89119-74D0-4DA4-BA76-2953346FFDAE),
              helpstring("IMIFilter Interface"),
              pointer_default(unique)
         ]
         interface IMIFilter: IUnknown
         {
              HRESULT Test();
         };
    }

    Excerpt from the header file:

    class CMIStream : public CSourceStream, public IMIFilter
    {

    public:

       [various other functions]

       DECLARE_IUNKNOWN
       STDMETHODIMP NonDelegatingQueryInterface(REFIID iid, void **ppv);
       STDMETHODIMP Test();

       [various other functions]

    }; // CMIStream

    Implementation of NonDelegatingQueryInterface:

    STDMETHODIMP CMIStream::NonDelegatingQueryInterface(REFIID riid, void
    **ppv)
    {
        if (riid == IID_IMIFilter)
        {
            flag = -1;
            return (HRESULT) GetInterface((IMIFilter *) this, ppv);
        }
        else
        {
            if( flag >= 0 )
                flag++;
            return CSourceStream::NonDelegatingQueryInterface(riid, ppv);
        }
    }

      Flag, in here, is a test value that changes the color of the
    displayed video filter output. Basically, if flag is being constantly
    changed, the color displayed smoothly changes, but if it is -1, then
    it's locked into a specified color. I can see that IID_IMIFilter is
    defined in the idl-generated header file, but if I try to do:

      pGB->QueryInterface(IID_IMIFilter, (void **)&pMI)

      in the modified playwnd project, it returns E_NOINTERFACE, and the
    debugging flag never reaches -1. I know it's getting called, because
    flag is getting incremented all the time, but it goes through the else
    every time.

      The only thing I can think of offhand is that the IID is not getting
    registered somewhere, even though the project that generates the
    filter's .ax file contains both the filter and the interface
    definition. The filter's getting registered just fine, but is there
    something I'm missing to make sure the interface is also visible?


  • Next message: The March Hare [MVP]: "Re: Problems getting custom filter interface to work with application"

    Relevant Pages