Share via


Enumerator Base Classes (Compact 2013)

3/26/2014

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:

One other DirectShow enumerator interface, IEnumFilters, is not represented by a base classe because it is implemented only by the filter graph manager.

The following illustration shows the interfaces for the enumerators.

Ee493964.5a2e4004-a2df-4bf3-afe4-0419087775f1(en-us,WinEmbedded.80).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.

See Also

Reference

Base Classes that Implement Interfaces