Graphedit can load a filter graph created by an external process. With this feature, you can see exactly what filter graph your application builds, with only a minimal amount of additional code in your application.
The application must register the filter graph instance in the running object table (ROT ). the rot is a globally accessible look-up table that keeps track of running objects. for information about how your application can add its filter graph to the rot, see the topic loading a graph from an external process in the Microsoft DirectShow documentation.
To use this feature, perform the following steps:
- Compile your application with code that adds a rot entry for the filter graph.
- Run graphedit.
- Run your application.
- InFileMenu, clickConnect to remote graph....
- InSelect a remote filter graph to view...Dialog box, select the process ident
- Ifier (PID) of the second application.
- ClickOK.
To refresh the list of process identifiers, clickRefreshIn the dialog box.
Note that this can only be used in 2000 and XP.
The following code adds the filter graph in the application to the rot,
Hresult augraph: addtorot (iunknown * punkgraph, DWORD * pdwregister)
{
Hresult hR = noerror;
Imoniker * pmoniker = NULL;
Irunningobjecttable * prot = NULL;
If (failed (getrunningobjecttable (0, & prot )))
{
Return e_fail;
}
Wchar wsz [256];
: Memset (wsz, 0,256 );
// WsprintfW (wsz, l "PID: % 08x igraphfilter = % 08x", (dword_ptr) punkgraph, getcurrentprocessid ());
HR = stringcchprintfw (wsz, numelms (wsz), L "filtergraph % 08x PID % 08x ",
(Dword_ptr) punkgraph, getcurrentprocessid ());
HR = createitemmoniker (L "! ", Wsz, & pmoniker );
If (succeeded (HR ))
{
HR = prot-> Register (rotflags_registrationkeepsalive, punkgraph, pmoniker, pdwregister );
Pmoniker-> release ();
}
Prot-> release ();
Return hr;
}
Below is the Code to remove it after we use it:
Void augraph: removefromrot (DWORD pdwregister)
{
Irunningobjecttable * prot = NULL;
If (succeeded (getrunningobjecttable (0, & prot )))
{
Prot-> revoke (pdwregister );
Prot-> release ();
}
}
The code structure in our entire application is as follows:
HR = cocreateinstance (clsid_filtergraph, null, clsctx_inproc_server,
Iid_igraphbuilder, (void **) & m_pgb );
If (failed (HR ))
{
Return hr;
}
# Ifdef _ debug
HR = addtorot (m_pgb, & dwregister );
# Endif
........... Application
# Ifdef _ debug
Removefromrot (dwregister );
# Endif
If (m_pgb)
M_pgb = NULL;
View my running results
Of course, sometimes we may have errors, but we have to be patient and try again. You can see it.