How can I reverse engineer a DirectShow graph?
Asked Answered
F

7

15

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

Foreside answered 26/8, 2008 at 12:2 Comment(0)
P
14

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

Potvaliant answered 26/8, 2008 at 12:15 Comment(0)
P
10

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.

Pavla answered 1/7, 2009 at 17:21 Comment(0)
A
5

IGraphBuilder::SetLogFile (see http://msdn.microsoft.com/en-us/library/dd390091(v=vs.85).aspx) will give you lots of useful diagnostic information about what happens during graph building. Pass in a file handle (e.g. opened by CreateFile) and cast it to a DWORD_PTR. Call again with NULL to finish logging before you close the file handle.

The code in the following blog post for dumping a graph will give you some extra information to interpret the numbers in the log file.

http://rxwen.blogspot.com/2010/04/directshow-debugging-tips.html

Alphanumeric answered 1/4, 2011 at 15:29 Comment(1)
Great! I learn a new very useful information about DirectShow :-)Grettagreuze
S
1

There is a detailed MSDN entry on this. http://msdn.microsoft.com/en-us/library/windows/desktop/dd390650(v=vs.85).aspx

Stretto answered 2/10, 2011 at 8:58 Comment(0)
M
1

You need to:

  1. Register you filter graph to the "Running Objects Table" - ROT - Using the code below
  2. Connect to your filter graph using GraphEdit (File->Connect to Remote Graph) or even better - With GraphEditPlus

To register your filter graph as a "connectable" graph, call this with your filter graph:

void AddToROT( IUnknown *pUnkGraph, DWORD *pdwRegister ) 
{
    IMoniker * pMoniker;
    IRunningObjectTable *pROT;
    WCHAR wsz[128];
    HRESULT hr;

    if (FAILED(GetRunningObjectTable(0, &pROT)))
        return;

    wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId());

    hr = CreateItemMoniker(L"!", wsz, &pMoniker);
    if (SUCCEEDED(hr)) 
    {
        hr = pROT->Register(0, pUnkGraph, pMoniker, pdwRegister);
        pMoniker->Release();
    }

    pROT->Release();
}

And call this before you release the graph:

void RemoveFromROT(DWORD pdwRegister)
{
    IRunningObjectTable *pROT;

    if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) 
    {
        pROT->Revoke(pdwRegister);
        pROT->Release();
    }
}

`

Matelot answered 6/11, 2014 at 17:50 Comment(0)
A
0

Older versions of DirectX, I belive 9a, but not 9b had a "debug mode" for dshow. It would output logs of debug info into the debug console.

So download an older version, set it to debug. then open up debugview or load graphedt.exe in visual studio to see the debug info.

Armil answered 15/9, 2008 at 20:42 Comment(0)
M
0

You could "save" the graph (serialize it) to a .grf graphedit file, possibly: https://mcmap.net/q/822943/-is-there-any-helper-tool-for-creating-graphedit-files-quot-on-the-fly-quot-programmatically

Also it appears that graphedit can "remote attach" to a running graph? http://rxwen.blogspot.com/2010/04/directshow-debugging-tips.html

Maeganmaelstrom answered 2/8, 2012 at 15:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.