Search code examples
videodirectxdirectshowmpeg

How can I reverse engineer a DirectShow graph?


I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine.

Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing.

Is there any way to see debug output from GraphBuilder when it assembles a graph?

Is there a way to dump a working graph to see how it was put together?

Any other ideas for unraveling the mystery that lives in the DirectShow box?

Thanks! -Z


Solution

  • You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to remote Graph...

    In order to find your graph in the list, you have to register it in the running object table:

    void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister ) 
    {
        IMoniker* pMoniker;
        IRunningObjectTable* pROT;
        GetRunningObjectTable( 0, &pROT );
    
        WCHAR wsz[256];     
        swprintf_s( wsz, L"FilterGraph %08p pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId() );
        CreateItemMoniker( L"!", wsz, &pMoniker );
    
        pROT->Register( 0, pUnkGraph, pMoniker, pdwRegister );
    
        // Clean up any COM stuff here ...
    }
    

    After destroying your graph, you should remove it from the ROT by calling IRunningObjectTable::Revoke