CBasePin Class (Windows CE 5.0)

Send Feedback


This is an abstract base class from which all pins are derived.

CBasePin supports the IPin interface. If your pin does not supply or use the IMemInputPin interface, derive from this; otherwise, derive from the CBaseInputPin class or the CBaseOutputPin class.

The connection process is crucial to the success of creating filter graphs. The filter graph finds two filters (and subsequently two pins) to connect.

It calls the IPin::Connect method on the output pin (and it can call Connect on the input pin at the same time). The output pin then calls the virtual pin member function CBasePin::CheckConnect.

Derived classes should override this member function to use QueryInterface to return any interfaces required.

The base class implementation of CheckConnect queries the IMemInputPin interface to establish the default transport protocol.

After calling CheckConnect, the output pin calls CBasePin::AgreeMediaType; this is a worker member function not intended for overriding in derived classes. This gets the input pin's enumerator and calls CBasePin::TryMediaTypes with it.

TryMediaTypes is another base pin worker member function that is not intended for derivation. It cycles through each media type provided by an enumerator to determine if a connection can be made with that type.

If that process fails, AgreeMediaType retrieves the output pin's media type enumerator and calls CBasePin::GetMediaType, which cycles through the media types to agree on a connection type. If there is agreement, a media type with the input and output pins becomes the type used in the connection.

If no media type can be agreed on, the connection between the pins cannot be made. The base pin calls CBasePin::SetMediaType to broadcast the format. The m_mt base pin variable is set during this process.

The IPin interface provides a method called QueryAccept. This method allows a connected filter to query whether the pin will accept a specified media type.

The method is asynchronous so that a filter can call it at any time — even when another filter is calling it. For this reason, its implementation in any override of the base class should not lock the filter.

The base class implementation of IPin::QueryAccept calls the overridden CBasePin::CheckMediaType member function on the derived pin class.

All member functions in this class that return HRESULT and accept a pointer as a parameter return E_POINTER when passed a null pointer.

Protected Data Members

Member Description
m_bRunTimeError Run-time error generated.
m_Connected Pin that this pin is connected to.
m_dir Direction of this pin.
m_dRate Rate from the CBasePin::NewSegment call.
m_mt Media type that this pin is using.

This is established during the connection process.

m_pFilter Filter that created the pin.
m_pLock Object used for locking.
m_pQSink Target for quality messages.
m_pName Name of the pin.
m_tStart Start time from the CBasePin::NewSegment call.
m_tStop Stop time from the CBasePin::NewSegment call.
m_TypeVersion Current media type version (see CBasePin::GetMediaTypeVersion).

Member Functions

Member function Description
AttemptConnection Attempts to make a connection to another pin using a specified media type.
CBasePin Constructs a CBasePin object.
CurrentRate Returns the segment rate set by the CBasePin::NewSegment member function.
CurrentStartTime Returns the segment start time set by the CBasePin::NewSegment member function.
CurrentStopTime Returns the segment stop time set by the CBasePin::NewSegment member function.
DisplayPinInfo Displays pin information on the debugging monitor.
DisplayTypeInfo Displays media type information on the debugging monitor.
GetConnected Returns the pin that is connected to this pin.
IncrementTypeVersion Adds 1 to the current media type version.
IsConnected Determines whether the pin is connected.
IsStopped Determines whether the filter owning this pin is in the State_Stopped state.
Name Returns the m_pName name of the pin.

Overrideable Member Functions

Member function Description
Active Switches the pin to the active (running) mode.
AgreeMediaType Agrees on the media type to be used by the pin.
BreakConnect Adds custom code when the connection quits.

This is also called when a stage in the connection process fails, so this member function should also clean up partial connection states.

CheckConnect Adds custom code when the connection is being made.

This is called at the start of the connection process.

CheckMediaType Checks if the pin can support a specific media type.
CompleteConnect Completes the connection.
GetMediaType Returns the media type used by the pin.
GetMediaTypeVersion Returns the version of the pins that were created dynamically.
Inactive Switches the pin to the inactive (stopped) mode.
SetMediaType Sets the m_mt data member to the established media type.
TryMediaTypes Tries to find an acceptable media type for a connection from the list returned by a media type enumerator.

Implemented IPin Methods

Method Description
Connect Initiates a connection to another pin.
ConnectedTo Returns a pointer to the connecting pin.
ConnectionMediaType Returns the media type of this pin's connection.
Disconnect Breaks a connection.
EndOfStream Informs the input pin that no additional data is expected until a new run command is issued.

(By default, returns S_FALSE.)

EnumMediaTypes Returns an enumerator for this pin's preferred media types.
NewSegment Specifies that samples following this call are grouped as a segment with a given start time, stop time, and rate.
QueryAccept Determines whether this pin accepts the media type.
QueryDirection Retrieves the pin direction of the pin.
QueryId Retrieves an identifier for the pin.
QueryInternalConnections Returns an array of the pins that this pin connects to internally.
QueryPinInfo Retrieves information about the pin (name, owning filter, or direction).
ReceiveConnection Called by a connecting pin to make a connection to this pin.

Usually this does not need to be overridden, because the default implementation calls CBasePin::CheckConnect, CBasePin::CheckMediaType, and CBasePin::BreakConnect.

Run Notifies the pin that the filter has changed state from paused to running.

Implemented IQualityControl Methods

Method Description
Notify Notifies the recipient that a quality change is requested.
SetSink Sets the IQualityControl object that will receive quality messages.

Implemented INonDelegatingUnknown Methods

Method Description
NonDelegatingAddRef Increments the owning filter's reference count.
NonDelegatingQueryInterface Retrieves CBasePin interfaces.

To pass out pointers to interfaces added by the derived pin class, override this member function.

NonDelegatingRelease Decrements the owning filter's reference count.


DirectShow applications and DirectShow filters have different include file and link library requirements.

For more information, see Setting Up the Build Environment.

OS Versions: Windows CE 2.12 and later. Version 2.12 requires DXPAK 1.0 or later.

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.