DirectShow Animated Header -- CSource Class DirectShow Animated Header -- CSource Class* Microsoft DirectShow SDK
*Index  *Topic Contents
*Previous Topic: CRendererPosPassThru Class
*Next Topic: CSourcePosition Class

CSource Class


CSource class hierarchy

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.


CSource::AddPin

CSource Class

Adds a pin to the source filter.

HRESULT AddPin(
  CSourceStream * pStream
  );

Parameters
pStream
Pointer to the CSourceStream object associated with the pin.
Return Values

Returns S_OK if successful, or E_OUTOFMEMORY if no memory is available.


CSource::CSource

CSource Class

Initializes the CSource object.

CSource(
  TCHAR *pName,
  LPUNKNOWN lpunk,
  CLSID clsid
  );

Parameters
pName
Debugging name of this object.
lpunk
Controlling IUnknown passed to the derived class's CreateInstance function.
clsid
Class identifier of the filters.
Return Values

No return value.

Remarks

The derived class could create the pins here, unless it provides a means for the developer to do this.


CSource::FindPinNumber

CSource Class

Retrieves the number of the pin supporting a given IPin interface.

int FindPinNumber(
  IPin *iPin
  );

Parameters
iPin
IPin interface of the pin to retrieve.
Return Values

Returns the pin number or –1 if no matching pin number is found.


CSource::GetPin

CSource Class

Returns a pointer to the specified pin.

CBasePin *GetPin(
  int n
  );

Parameters
n
Pin number of the requested pin.
Return Values

Returns the pointer to the pin or NULL if the index is out of range.

Remarks

This member function is specified in CBaseFilter and is implemented here. Note that this pin interface will not have been reference counted when obtained.


CSource::GetPinCount

CSource Class

Retrieves the number of pins contained by the filter.

int GetPinCount(void);

Return Values

Returns the pin count.

Remarks

This member function is specified in CBaseFilter and is implemented here.


CSource::pStateLock

CSource Class

Retrieves a pointer to the filter-critical section.

CCritSec* pStateLock(void);

Return Values

Returns the critical section.

Remarks

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.


CSource::RemovePin

CSource Class

Removes a pin from the source filter.

HRESULT RemovePin(
  CSourceStream * pStream
  );

Parameters
pStream
CSourceStream object associated with the pin.
Return Values

Returns S_OK if successful or S_FALSE if unsuccessful.

Remarks

The pStream parameter is not deleted. This member function adjusts pin locations in the m_paStreams array.

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.

*Top of Page