The CSource class is a base class for implementing source filters. A filter derived from CSource contains one or more output pins derived from the CSourceStream class. Each output pin creates a worker thread that pushes media samples downstream.
Note The CSource class is designed to support the push model for data flow. This class is not recommended for creating file-reader filters. File readers should support the pull model, through the IAsyncReader interface. For more information, see Data Flow for Filter Developers.
|Protected Member Variables||Description|
|m_iPins||Number of pins on the filter.|
|m_paStreams||Array of pins.|
|m_cStateLock||Critical section object that protects the filter state.|
|GetPinCount||Retrieves the number of pins on the filter.|
|GetPin||Retrieves a pin.|
|pStateLock||Retrieves a pointer to the filter's critical section object.|
|AddPin||Adds a new output pin to the filter.|
|RemovePin||Removes a specified pin from the filter.|
|FindPinNumber||Retrieves the number of a specified pin on the filter.|
|FindPin||Retrieves the pin with the specified identifier.|
To implement an output pin, do the following:
- Derive a class from CSourceStream.
- Override the CSourceStream::GetMediaType method and possibly the CSourceStream::CheckMediaType method, which validate media types for the pin.
- Implement the CBaseOutputPin::DecideBufferSize method, which returns the pin's buffer requirements.
- Implement the CSourceStream::FillBuffer method, which fills a media sample buffer with data.
To implement the filter, do the following:
- Derive a class from CSource.
- In the constructor, create one or more output pins derived from CSourceStream. The pins automatically add themselves to the filter in their constructor methods, and remove themselves in their destructor methods.
To synchronize the filter state among multiple threads, call the CSource::pStateLock method. This method returns a pointer to the filter-state critical section. Use the CAutoLock class to hold the critical section. From a pin, you can access pStateLock from the pin's CBasePin::m_pFilter member variable, as follows:
Build date: 11/16/2013