Question

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

Was it helpful?

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

OTHER TIPS

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.

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

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();
    }
}

`

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.

You could "save" the graph (serialize it) to a .grf graphedit file, possibly: https://stackoverflow.com/a/10612735/32453

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top