## IEnumMediaTypes Interface

The IEnumMediaTypes interface enumerates the preferred formats for a pin.

When to Implement

This interface must be implemented and made available by the IPin::EnumMediaTypes method. The CBasePin::EnumMediaTypes member function automatically does this in the DirectShow™ class library and uses the CEnumMediaTypes class to create the enumerator object.

When to Use

This interface is normally used by a connecting pin to determine the media type when negotiating a connection. It can also be passed through to other pins, either upstream or downstream of the filter, when intervening filters do not have a list of preferred media types. For example, a transform-inplace filter might pass the IEnumMediaTypes interface of a downstream input pin to the connecting output pin of the upstream filter, instead of providing its own IEnumMediaTypes interface.

Methods in Vtable Order

IUnknown methods | Description
QueryInterface | Returns pointers to supported interfaces.
AddRef | Increments the reference count.
Release | Decrements the reference count.

IEnumMediaTypes methods | Description
Next | Retrieves the specified number of items in the enumeration sequence.
Skip | Skips a specified number of elements in the enumeration sequence.
Reset | Resets the enumeration sequence to the beginning.
Clone | Returns another enumerator containing the same enumeration state as the current one.

###

IEnumMediaTypes::Clone

IEnumMediaTypes Interface

Returns another enumerator containing the same enumeration state as the current one.

HRESULT Clone(
IEnumMediaTypes ** ppEnum
);

##### Parameters

ppEnum
  [out] New copy of the enumerator.

##### Return Values

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:

Value | Meaning
E_FAIL | Failure.
E_POINTER | Null pointer argument.
E_INVALIDARG | Invalid argument.
E_NOTIMPL | Method isn't supported.
S_OK or NOERROR | Success.

###

IEnumMediaTypes::Next

IEnumMediaTypes Interface

Retrieves the specified number of items in the enumeration sequence.

HRESULT Next(
ULONG cMediaTypes,
AM_MEDIA_TYPE ** ppMediaTypes,
ULONG * pcFetched
);

##### Parameters

cMediaTypes
  [in] Number of media types to place.
ppMediaTypes
  [out] Array in which to place the pointers to the next media type.
pcFetched
  [out] Actual count passed.

##### Return Values

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:

Value | Meaning
E_FAIL | Failure.
E_POINTER | Null pointer argument.
E_INVALIDARG | Invalid argument.
E_NOTIMPL | Method isn't supported.
S_OK or NOERROR | Success.

##### Remarks

To use this method, pass an array of pointers to media types. (If you want only a single media type, you can pass a pointer to a media type pointer in place of an array of media type pointers.) The interface allocates the necessary AM_MEDIA_TYPE structures and initializes them with the variable format block. Free each media type by calling DeleteMediaType, which will free the format block and the media type itself.

###

IEnumMediaTypes::Reset

IEnumMediaTypes Interface

Resets the enumerator to the beginning so that the next call to the IEnumMediaTypes::Next method returns, at a minimum, the first media type (if any) in the enumeration.

HRESULT Reset(void);

##### Return Values

Returns S_OK if successful; otherwise, returns S_FALSE.

###

IEnumMediaTypes::Skip

IEnumMediaTypes Interface

Skips a specified number of elements in the enumeration sequence.

HRESULT Skip(
ULONG cMediaTypes
);

##### Parameters

cMediaTypes
  [in] Number of media type elements to skip.

##### Return Values

Returns an HRESULT value that depends on the implementation. HRESULT can be one of the following standard constants, or other values not listed:

Value | Meaning
E_FAIL | Failure.
E_POINTER | Null pointer argument.
E_INVALIDARG | Invalid argument.
E_NOTIMPL | Method isn't supported.
S_OK or NOERROR | Success.

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