How to add custom interfaces and call Filters

Source: Internet
Author: User

In this example, a custom interface added based on virtualcamera is used to control OSD display by exe.

1. Interface Section

# Ifndef _ h_myfilter __
# DEFINE _ h_myfilter __

# Ifdef _ cplusplus
Extern "C "{
# Endif
// # Include <initguid. h>
// Extern_guid
Extern_guid (iid_imyfilter,
0xef31f705, 0x32a7, 0x477a, 0x90, 0xc9, 0x2c, 0x7e, 0x81, 0xeb, 0x2, 0x5d );

Declare_interface _ (imyfilter, iunknown)
{
Stdmethod (setosd) (This _ int osd_en) pure;
};
# Ifdef _ cplusplus
}
# Endif


# Endif

2. Filter inheritance Interface


# Include "myfilter. H"
Class cvcam: Public csource, public imyfilter
{
Public:


Static cunknown * winapi createinstance (lpunknown lpunk, hresult * phr );
Stdmethodimp nondelegatingqueryinterface (refiid riid, void ** GMM );//????
Declare_iunknown;
Stdmethodimp setosd (INT osd_en );
Ifiltergraph * getgraph () {return m_pgraph ;}
Int osd_enable;
PRIVATE:
Cvcam (lpunknown lpunk, hresult * phr );
Cvcampin * m_ppin;

Public:

};

/////////////////////////////////////

Stdmethodimp cvcam: setosd (INT osd_en)
{
Osd_enable = osd_en;
Return s_ OK;
}


Stdmethodimp cvcam: nondelegatingqueryinterface (refiid riid, void ** GMM)
{
If (riid = _ uuidof (iamstreamconfig) | riid = _ uuidof (ikspropertyset ))
{
// M_pastreams [0]-> QueryInterface (riid, GMM );
Return m_pastreams [0]-> QueryInterface (riid, GMM );
}
Else if (riid = iid_imyfilter)
{
Return getinterface (imyfilter *) This, GMM );
}
Else
Return cbasefilter: nondelegatingqueryinterface (riid, GMM); // modify
}

3. Application call

 //Search for Filter Based on guid

HR = cocreateinstance (clsid_myfilter, 0, clsctx_inproc_server, iid_ibasefilter, reinterpret_cast <void **> (& psrcfilter ));

Imyfilter * pinterface = NULL;

HR = psrcfilter-> QueryInterface (iid_imyfilter, (void **) & pinterface );// Query the interface from the filter

Pinterface-> setosd (0 );// Use interface functions



How to add custom interfaces and call Filters

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.