This class and its corresponding class, CSourceStream, simplify the construction of source filters that produce continuous streams of data comparable to the way the CTransformFilter class assists in the creation of transform filters.
The CSource class provides a wrapper for the CBaseFilter class that performs the pin management and works with the CSourceStream class to provide the pins.
To use the CSource class to build a filter:
For an example of using the CSource class, see the Ball sample in the \Samples\DS\Ball directory of the Microsoft® DirectShow™ SDK Software Development Kit (SDK).
This class does not help build an asynchronous file reader source filter, which requires support of an IAsyncReader interface and a downstream parser filter that supports the CPullPin class.
Protected Data Members
Name | Description |
m_cStateLock | Locks this data member to serialize access to the filter state. |
m_iPins | Number of pins on this filter; updated by the CSource::AddPin and CSource::RemovePin member functions. |
m_paStreams | Array of streams associated with this filter. |
Member Functions
Name | Description |
AddPin | Adds a pin to the source filter. |
CSource | Constructs a CSource object. |
FindPinNumber | Retrieves the number of the pin through the IPin parameter. |
GetPin | Returns a pointer to a specified pin. |
GetPinCount | Gets the number of pins contained by the filter. |
pStateLock | Returns a pointer to the filter-critical section. |
RemovePin | Removes a pin from the source filter. |
Implemented IBaseFilter Methods
Name | Description |
FindPin | Retrieves a pointer to the pin with the specified identifier. |
Initializes the CSource object.
CSource(
TCHAR *pName,
LPUNKNOWN lpunk,
CLSID clsid
);
No return value.
The derived class could create the pins here, unless it provides a means for the developer to do this.
Adds a pin to the source filter.
HRESULT AddPin(
CSourceStream * pStream
);
Returns S_OK if successful, or E_OUTOFMEMORY if no memory is available.
Retrieves the number of the pin supporting a given IPin interface.
int FindPinNumber(
IPin *iPin
);
Returns the pin number or –1 if no matching pin number is found.
Returns a pointer to the specified pin.
CBasePin *GetPin(
int n
);
Returns the pointer to the pin or NULL if the index is out of range.
This member function is specified in CBaseFilter and is implemented here. Note that this pin interface will not have been reference counted when obtained.
Retrieves the number of pins contained by the filter.
int GetPinCount(void);
Returns the pin count.
This member function is specified in CBaseFilter and is implemented here.
Retrieves a pointer to the filter-critical section.
CCritSec* pStateLock(void);
Returns the critical section.
Locking consists of holding the filter-critical section by calling the pStateLock member function and using the returned object to serialize access to functions. Typically, this lock can be held by a function when the worker thread might want to hold it. Therefore, to access a shared state from the worker thread, add another critical-section object. The exception occurs during the processing loop of the thread when it is safe to retrieve the filter-critical section from within CSourceStream::FillBuffer.
Removes a pin from the source filter.
HRESULT RemovePin(
CSourceStream * pStream
);
Returns S_OK if successful or S_FALSE if unsuccessful.
The pStream parameter is not deleted. This member function adjusts pin locations in the m_paStreams array.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.