About displaying the filter graph of an application in graphedit

Source: Internet
Author: User

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:

  1. Compile your application with code that adds a rot entry for the filter graph.
  2. Run graphedit.
  3. Run your application.
  4. InFileMenu, clickConnect to remote graph....
  5. InSelect a remote filter graph to view...Dialog box, select the process ident
  6. Ifier (PID) of the second application.
  7. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.