DirectShow principle analysis of the filter to filter connection

Source: Internet
Author: User

Filter is the most basic concept in DirectShow. DirectShow uses filter graph to manage the filter. The filter graph is the container for the filter.

Filter is usually made up of one or several pins. The filter is connected by a pin to form a chain.

A PIN is also a COM component that implements the Ipin interface for each pin.

The two pins you are trying to link must be in a filter graph.


The connection process is as follows:

1.Filter Graph manager ipin::connect on output pin

2. If the output pin accepts a connection, call Ipin::receiveconnection

3. If the input pin also accepts this connection, the two parties are connected successfully

The first is to analyze the connect implementation of the base class function Cbasepin:

Cbasepin inherited the Ipin.

[cpp]  View plain  copy <pre name= "code"  class= "CPP" >HRESULT __stdcall  Cbasepin::connect (ipin * preceivepin, __in_opt const am_media_type *pmt    // optional media type)    {        Checkpointer (Preceivepin,e_pointer);       validatereadptr (pReceivePin,sizeof ( Ipin));       cautolock cobjectlock (m_plock);        displaypininfo (preceivepin);          /*  Check to see if the pin is already connected  */        if  (m_connected)  {            dbglog ((Log_trace, connect_trace_level, text ("already connected"));            return VFW_E_ALREADY_CONNECTED;        } &nbSp        /* General Filter only accepts connections in the stopped state */       if  (! IsStopped ()  && !m_bcanreconnectwhenactive)  {            return VFW_E_NOT_STOPPED;       }          /* Start Media type Check to find a type */   supported by both sides     const cmediatype  * ptype =  (cmediatype*) pmt;       hresult hr =  agreemediatype (Preceivepin, ptype);       if  (FAILED (HR))  {            dbglog (log_trace, connect_trace_level,  TEXT ("Failed to agree type"));               // Since the procedure is already returning an error  Code, there           // is nothing else this  function can do to report the error.            execute_assert ( succeeded ( breakconnect ()  )  );       #ifdef  DXMPERF           perflog_connect (  ( ipin *)  this, pReceivePin, hr, pmt );   #endif  // dxmperf               return hr;        }          dbglog (log_trace, connect_trace_level ,  text ("connection succeeded"));      #ifdef  DXMPERF        perflog_connect (  (ipin *)  

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.