Pin Base Classes (Windows Embedded CE 6.0)
1/6/2010
A pin must expose methods so that the filter graph manager can connect the pin with a pin on another filter.
Pins also expose methods so that connected pins can negotiate what media type they will pass between them, and which pin will provide the shared memory allocator for transporting the media sample.
Additionally, the output pin is responsible for passing each media sample to its connected input pin; the input pin is responsible for receiving it.
Finally, pins must support interfaces so that quality-control messages and position information can be passed through the stream from pin to pin.
The following illustration shows the pin classes. All pin classes are derived from CBasePin, a base class derived from CUnknown.
CBasePin implements the IPin interface. The IPin interface specifies methods for connecting to other pins, negotiating the media type to be used with the connected pin, querying internal connections on the pin, and informing the pin of stream activity.
In addition to implementing the IPin methods, CBasePin also implements IQualityControl methods so that quality-control messages can be passed through the filter graph from one pin to the next.
Quality-control messages allow a filter, such as a renderer, to request another filter to adjust its sample rate.
Typically, quality-control messages travel upstream from renderer to source filter. However, in cases such as a video capture filter, the source filter (for example, a VCR reader) can send quality-control messages downstream to the renderer filter to adjust its rate.
The CBasePin class provides several virtual member functions that can be overridden to provide handling of the connection, media type negotiation, and disconnection processes.
The following base classes derive from CBasePin to provide default handling for many of these tasks:
- CBaseOutputPin implements an output pin.
- CBaseInputPin implements an input pin.
CBaseOutputPin is the base class for the CTransformOutputPin and CSourceStream classes. Likewise, CBaseInputPin is the base class for the CTransformInputPin class.
The basic model that the CBaseInputPin and CBaseOutputPin classes use clarifies these derived pin classes.
In the connection and transport model used by two pins, the input pin supports the IMemInputPin interface so it can receive a media sample. The CBaseInputPin class implements the IMemInputPin interface.
Also, one of the two pins must supply a shared memory allocator object, which is an object that contains the IMemAllocator interface that generates media sample objects passed between pins.
An IMemInputPin method, implemented by the CBaseInputPin class, supplies this allocator object, implemented by the CMemAllocator class. The connected output pin also has the option of supplying its own allocator; if this is the case, it notifies the input pin (through another IMemInputPin method) of the final decision of which allocator is used.
The CBaseOutputPin class provides extra member functions to set the size and count of samples in the allocator, retrieve a media sample from the allocator, deliver that media sample to the connected input pin, and deliver end-of-stream and end-flush messages downstream. It also implements many of the IPin methods.
CPullPin is a class that is used on the input pin of a parser filter. It is derived from the CAMThread class as is shown in the following illustration.
A parser filter pulls information from the disk, using the asynchronous file reader filter, or from the Internet, using the URL moniker filter. CPullPin works with the IAsyncReader interface, which is implemented on the source reader filter upstream.
CPullPin starts the thread, pulls data from the upstream filter, and then pushes the data downstream. CPullPin can call its own IMemInputPin::Receive method after pulling the sample from the source. It can also perform the equivalent routines elsewhere.