How to add a custom interface and filter custom interface to a filter?

Source: Internet
Author: User

How to add a custom interface and filter custom interface to a filter?
To add an interface to a filter, follow these steps:

1. Create an Interface header file "Interface. h", which contains the guid(use guidgen.exe) of the Interface and the declaration of the Interface function.

Remember to add the include of initguid. h. Otherwise, the "unresolvable external symbol _ IID _" error will occur during use.

2. Add # include "Interface. h" at the beginning of the header file filter. h of the Cfilter class ".

3. inherit the Cfilter: public Interface from the CFilter class declaration.

4. Add the Interface function declaration in the Cfilter class declaration:

// -------- Interface methods ----------
STDMETHODIMP SetServerAddr (char * inIP, int inPort );

5. Define the functions that implement the Interface in the definition of the Cfilter class:

// ----------------------- Interface methods -----------------------------
STDMETHODIMP CFilter: SetServerAddr (char * inIP, int inPort)
{

......
Return S_ OK;
}

6. Do not forget to add two lines of code to the CFilter: NonDelegatingQueryInterface function to expose the interface to the outside world:

// Basic COM-used here to reveal our own interfaces

STDMETHODIMP CFilter: NonDelegatingQueryInterface (REFIID riid, void ** GMM)

{
......

If (riid = IID_Interface)
Return GetInterface (Interface *) this, GMM );
......
}

So far, the filter interface has been added. If other applications want to use this interface, it is like using other com components. 1. Add Interface. h to the project. 2. Add # include "Interface. h" before use ". 3. After the filter is successfully added, use the QueryInterface function to obtain the interface pointer.


In VS2010 MFC, how does DirectShow call a custom filter? Detailed steps? What do you mean? Please hurry up.

0. After the filter is registered on the computer, declare an IBaseFilter in the code,
1. Use the cocreateinstance function to obtain the filter. The CLSID must be the CLSID of your custom filter, and the IID must be the BaseFilter. If you just add this filter to graph, you don't need to proceed.
2. If you want to perform further operations through the interface, use the queryinterface function to obtain the interface. The IID is used to write the IID of your custom interface, and the class is used to write your custom filter interface class. Of course, declare your interface class in the current project, or directly include the header file.

Java, implements the Filter interface, how to let the process into the doFilter Method

Configure the following information in your web. xml file:
<Filter>
<Filter-name> EncodingFilter </filter-name>
<Filter-class> com. struts. filter. EncodingFilter </filter-class>
</Filter>
<Filter-mapping>
<Filter-name> EncodingFilter </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>

Name. You can change the path based on your own settings.

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.