locked
How do I find Filter type and name RRS feed

  • Question

  • I added an unknown source filter to my filter graph (Direct Show) with

    hr = pGraph->AddSourceFilter(wFileName, wFileName, &pSourceFilter);

    How do I acquire the name and type of the added filter? I think I should use QueryFilterInfo but how do I implement it? (I am a beginner).
    Tuesday, June 23, 2009 5:24 PM

Answers

  • CComPtr<IBaseFilter> pSourceFilter;
    // your AddSourceFilter call
    FILTER_INFO FilterInformation;
    ZeroMemory(&FilterInformation, sizeof FilterInformation);
    HRESULT nResult = pSourceFilter->QueryFilterInfo(&FilterInformation);

    http://alax.info/blog/tag/directshow
    • Proposed as answer by Chris P_ Friday, June 26, 2009 2:37 PM
    • Marked as answer by The March Hare Sunday, July 12, 2009 7:04 PM
    Tuesday, June 23, 2009 5:31 PM
  • Please note that you are at the very beginning ow the way to get the thing done. In particular, just replacing CComPtr<IBaseFilter> with IBaseFilter* is not safe. I suggest that you check Windows SDK samples that cover basic DirectShow tasks:

    Windows SDK: http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en
    Path: \Samples\Multimedia\DirectShow
    http://alax.info/blog/tag/directshow
    Tuesday, June 23, 2009 7:58 PM
  • The video type of the file is not necessarily known to the source filter.  The standard source filter for most file types (ASync source) doesn't know anything about file formats at all, it leaves that up to the parser filter.  Once the parser filter is in the graph and connected to the source, then you will be able to see the video type on the output pin.

    If you aren't doing deterministic graph building then you might be able to get the information you need from IMediaDet instead.


    [MVP] http://www.chrisnet.net/code.htm microsoft.public.win32.programmer.directx.audio
    Friday, June 26, 2009 2:36 PM

All replies

  • CComPtr<IBaseFilter> pSourceFilter;
    // your AddSourceFilter call
    FILTER_INFO FilterInformation;
    ZeroMemory(&FilterInformation, sizeof FilterInformation);
    HRESULT nResult = pSourceFilter->QueryFilterInfo(&FilterInformation);

    http://alax.info/blog/tag/directshow
    • Proposed as answer by Chris P_ Friday, June 26, 2009 2:37 PM
    • Marked as answer by The March Hare Sunday, July 12, 2009 7:04 PM
    Tuesday, June 23, 2009 5:31 PM
  • Your code gave me 4 errors;

        CComPtr<IBaseFilter>    pSourceFilter;
        hr = pGraph->AddSourceFilter(wFileName, wFileName, &pSourceFilter);
        FILTER_INFO    FilterInformation;
        ZeroMemory(&FilterInformation, sizeof FilterInformation);
        HRESULT nResult  =  pSourceFilter->QueryFilterInfo(&FilterInformation);

    the errors are:

    Error    1    error C2065: 'CComPtr' : undeclared identifier    c:\Documents and Settings\Will\My Documents\My Projects\Digital Wind Chime\Rendertest.cpp    228   
    Error    2    error C2275: 'IBaseFilter' : illegal use of this type as an expression    c:\Documents and Settings\Will\My Documents\My Projects\Digital Wind Chime\Rendertest.cpp    228   
    Error    3    error C2065: 'pSourceFilter' : undeclared identifier    c:\Documents and Settings\Will\My Documents\My Projects\Digital Wind Chime\Rendertest.cpp    228   
    Error    4    error C2227: left of '->QueryFilterInfo' must point to class/struct/union/generic type    c:\Documents and Settings\Will\My Documents\My Projects\Digital Wind Chime\Rendertest.cpp    232   

    so I replaced the line CComPtr<IBaseFilter>  pSourceFilter;
    with  
    IBaseFilter   *pSourceFilter
    The build succeeded  but the debug data only told me what I already know, namely, the name of the input file and the extension.
    I need to know the format of the input file so I thought that, if I know the filter name and type, I can determine the file format, is it UYVY or  YUY2 or RGB etc.
    So my new question is this , is there a method that will return the format type of the input video file?

    Thanks.
    Tuesday, June 23, 2009 7:47 PM
  • Please note that you are at the very beginning ow the way to get the thing done. In particular, just replacing CComPtr<IBaseFilter> with IBaseFilter* is not safe. I suggest that you check Windows SDK samples that cover basic DirectShow tasks:

    Windows SDK: http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en
    Path: \Samples\Multimedia\DirectShow
    http://alax.info/blog/tag/directshow
    Tuesday, June 23, 2009 7:58 PM
  • The video type of the file is not necessarily known to the source filter.  The standard source filter for most file types (ASync source) doesn't know anything about file formats at all, it leaves that up to the parser filter.  Once the parser filter is in the graph and connected to the source, then you will be able to see the video type on the output pin.

    If you aren't doing deterministic graph building then you might be able to get the information you need from IMediaDet instead.


    [MVP] http://www.chrisnet.net/code.htm microsoft.public.win32.programmer.directx.audio
    Friday, June 26, 2009 2:36 PM