This class provides the mechanism for enumerating the pin's preferred media types. Its constructor must be passed to an object from a class derived from CBasePin. It uses the virtual member function GetMediaType to retrieve each of the media types in turn. It also uses the pin's CBasePin::GetMediaTypeVersion member function to determine if the number or type of media types has changed.
The base pin class does not support dynamic media type changes. CBaseFilter::GetPinVersion always returns the same value, for example.
The media type enumerator must fill in a list of pointers to media type structures. The memory for those media type structures must be released by the callers when they have finished with it. However, the memory must not be allocated from any language-specific heap; otherwise, problems might occur between a filter written in C and another written in C++. For this reason, the base classes provide generic functions (not member functions of a class) to create and delete media types: CreateMediaType and DeleteMediaType. These manage memory allocation from the task allocator.
All member functions in this class that return HRESULT and accept a pointer as a parameter return E_POINTER when passed a null pointer.
Member Functions
Name | Description |
CEnumMediaTypes | Constructs a CEnumMediaTypes object. |
Implemented IUnknown Methods
Name | Description |
QueryInterface | Returns pointers to supported interfaces. |
AddRef | Increments the reference count. |
Release | Decrements the reference count. |
Implemented IEnumMediaTypes Methods
Name | Description |
Clone | Creates a duplicate CEnumMediaTypes object with the same state. |
Next | Returns the next media type after the current position. |
Reset | Sets the current position back to the beginning. |
Skip | Skips over one or more entries in the enumerator. |
Increments the reference count for the calling interface on an object. It should be called for every new copy of a pointer to an interface on a given object.
ULONG AddRef(void);
Returns an integer from 1 to n, the value of the new reference count. This information is meant to be used for diagnostic/testing purposes only, because, in certain situations, the value might be unstable.
This member function implements the IUnknown::AddRef method.
Constructs a CEnumMediaTypes object.
CEnumMediaTypes(
CBasePin *pPin,
CEnumMediaTypes *pEnumMediaTypes
);
No return value.
This is a standard class constructor.
Retrieves another enumerator containing the same enumeration state as the current one.
HRESULT Clone(
IEnumMediaTypes ** ppEnum
);
Returns an HRESULT value.
This member function implements the IEnumMediaTypes::Clone method.
Retrieves the specified number of items in the enumeration sequence.
HRESULT Next(
ULONG cMediaTypes,
AM_MEDIA_TYPE** ppMediaTypes,
ULONG * pcFetched
);
Returns an HRESULT value.
This member function implements the IEnumMediaTypes::Next method. To call this method, pass a pointer's address to a media type. The base class implementation relies on the existence of an overridden CBasePin::GetMediaType member function in the derived class that will provide the next media type.
Free each media type acquired by calling DeleteMediaType, which will free the format block and the media type itself.
Retrieves a pointer to a specified interface on a component to which a client currently holds an interface pointer.
HRESULT QueryInterface(
REFIID iid,
void ** ppvObject
);
Returns S_OK if the interface is supported, S_FALSE if not.
This member function implements the IUnknown::QueryInterface method and passes out references to the IEnumMediaTypes interface. Override this class to return other interfaces on the object in the derived class.
Decrements the reference count for the calling interface on an object. If the reference count on the object falls to zero, the object is freed from memory.
ULONG Release(void);
Returns the resulting value of the reference count, which is used for diagnostic/testing purposes only. If you need to know that resources have been freed, use an interface with higher-level semantics.
This member function implements the IUnknown::Release method.
Resets the enumerator to the beginning so that the next call to the IEnumMediaTypes::Next method will return, at a minimum, the first media type in the enumeration.
HRESULT Reset(void);
Returns S_OK if successful; otherwise, returns S_FALSE.
This member function implements the IEnumMediaTypes::Reset method.
Skips a specified number of elements in the enumeration sequence.
HRESULT Skip(
ULONG cMediaTypes
);
Returns an HRESULT value.
This member function implements the IEnumMediaTypes::Skip method.
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.