Share via


Enumerator Base Classes

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

An enumerator is an interface that provides methods for traversing a list of elements. Enumerators are used in COM programming, and the DirectShow model follows the COM model in enumerating objects. The following enumerator classes are provided in the class library:

The DirectShow enumerator interface IEnumFilters Interface and ** IEnumRegFilters Interface are not represented by base classes because they are implemented only by the filter graph manager.

The following illustration shows the interfaces for the enumerators.

Aa924857.5a2e4004-a2df-4bf3-afe4-0419087775f1(en-us,MSDN.10).gif

The CEnumPins class creates an enumerator when the IBaseFilter::EnumPins method is called. The enumerator returned by this method is a pointer to the IEnumPins interface, which is implemented by the CEnumPins class.

The CEnumPins member functions can then be called to retrieve pointers to each of the pins on the filter. This enumerator accomplishes this by calling the CBaseFilter::GetPin member function on the filter.

The filter must override the base class CBaseFilter::GetPin member function to supply the enumerator with the next pin in the list each time it is called.

The CEnumMediaTypes class creates an enumerator when the IPin::EnumMediaTypes method is called. Pins store a list of the media types that they support. During negotiation of the media type, one pin typically calls the EnumMediaTypes method on its connected pin, retrieves the enumerator, and uses it to select a media type.

Both of these enumerator classes support the Next, Skip, Reset, and Clone methods familiar to COM programmers.

The media type enumerators call the CBasePin::GetMediaType member function, which must be overridden by the derived pin class, to return the next media type in a list of media types accepted by the pin.

Enumerators operate as threads, and must have synchronized access to the pin media type list. For this reason, the classes that implement enumerators inherit, through multiple inheritance, from the CCritSec class, which provides critical section management.

For more information about the CCritSec class, see Win32 Classes.