Microsoft DirectX 9.0


The GetMediaType method retrieves a preferred media type.


virtual HRESULT GetMediaType(
    int iPosition,
    CMediaType *pMediaType

virtual HRESULT GetMediaType(
    CMediaType *pMediaType



Zero-based index value.


Pointer to a CMediaType object that receives the media type.

Return Value

Returns one of the HRESULT values shown in the following table.

Value Description
S_OK Success.
VFW_S_NO_MORE_ITEMS Index out of range.
E_INVALIDARG Index less than zero.
E_UNEXPECTED Unexpected error.


There are two versions of this method. One version overrides the CBasePin::GetMediaType method and takes an index value as a parameter. The other version is designed to retrieve a single media type, so it lacks the index parameter.

The single-parameter method returns E_UNEXPECTED. The two-parameter method verifies that the iPosition parameter is zero and then calls the single-parameter version. Depending on the number of media types the pin supports, you must override one of these methods:

See Also