Microsoft DirectX 9.0

ISampleGrabber::SetMediaType

The SetMediaType method specifies the media type for the connection on the Sample Grabber's input pin.

Syntax

HRESULT SetMediaType(
  const AM_MEDIA_TYPE *pType
);

Parameters

pType

Pointer to an AM_MEDIA_TYPE structure specifies the required media type. It is not necessary to set all the structure members; see Remarks for details.

Return Value

Returns S_OK.

Remarks

By default, the Sample Grabber has no preferred media type. To ensure that the Sample Grabber connects to the correct filter, call this method before building the filter graph.

This method restricts the range of media types that the filter will accept. When the filter connects, it tries to match the media type given in pType. To do so, it compares the major type, subtype, and format type GUIDs, in that order. For each of these GUIDs, if pType has the value GUID_NULL, the Sample Grabber accepts the media type without any further checks. If pType has any other value, the Sample Grabber compares it to the GUID in the connection type. Unless the two GUIDs match exactly, the Sample Grabber rejects the connection.

Example 1:

The Sample Grabber will accept any video type where the major type equals MEDIATYPE_Video. It will not check the subtype.

Example 2:

Now the Sample Grabber will check the subtype, and accept only RGB 24 video.

Limitations: Regardless of what type you set, the Sample Grabber Filter rejects any video types with top-down orientation (negative biHeight), or with a format type of FORMAT_VideoInfo2. In this case, although the SetMediaType method succeeds, the filter will not connect.

See Also