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 *)