Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 735
ZebZiggle Avatar asked Aug 26 '08 12:08

ZebZiggle


2 Answers

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

like image 195
Timbo Avatar answered Oct 21 '22 14:10

Timbo


Roman Ryltsov has created a DirectShow Filter Graph Spy tool (http://alax.info/blog/777), a wrapper COM dll over the FilterGraph interface, which logs all the calls to FilterGraph methods.

Also it will add all the created graphs into Running Object Table (ROT) which you can then visualize using tools like GraphEdit or GraphStudio. Very useful when you need to see how a Windows Media Player graph looks like.

like image 25
Cristian Adam Avatar answered Oct 21 '22 14:10

Cristian Adam