Share via


IAMStreamConfig::SetFormat

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This method sets the audio or video stream's format.

Syntax

HRESULT SetFormat(
  AM_MEDIA_TYPE* pmt
);

Parameters

Return Value

Returns an HRESULT value that depends on the implementation of the interface.

Remarks

A call to this method will fail if the pin is streaming.

If your output pin is not connected and you can connect it with this media type, return S_OK from this method and start enumerating the specified media type as follows. Specify this format as format number zero in the CTransformOutputPin::GetMediaType function's iPosition parameter. You can offer and accept only this type to ensure that the pins will use this format for the connection when it occurs.

If your output pin is already connected and you can provide this type, then reconnect your pin. If the other pin cannot accept the media type, fail this call and leave your connection alone.

Passing in NULL as a parameter value can cause some filters to set their default format and forget a previous format you have given it with this method.

The frame rate at which your filter should produce data is determined by the AvgTimePerFrame field of VIDEOINFOHEADER of the media type your output pin is connected with. You may not be able to capture at any arbitrary frame rate, but only certain rates. If your pin is connected with a media type that asks for a frame rate you cannot provide, you should provide frames at the next lowest frame rate possible. For example, if your media type has AvgTimePerFrame=333333 (approximately 1/30 of a second, meaning 30 frames per second) and you can only capture 29.97 or 35 frames per second, you should provide frames at 29.97 frames per second, because that is the closest value lower than 30 that you can provide. You can provide a higher frame rate than asked if the frame rate you provide does not create frame durations more than 1 microsecond shorter than requested, because AvgTimePerFrame may simply have rounding errors. If the AvgTimePerFrame field is 0, you can supply frames at any default frame rate that you want.

Requirements

Windows Embedded CE Windows CE 2.12 and later
Windows Mobile Pocket PC for Windows Mobile Version 5.0 and later, Smartphone for Windows Mobile Version 5.0 and later
Note Microsoft DirectShow applications and DirectShow filters have different include file and Library requirements
For more information, see Setting Up the Build Environment, Version 2.12 requires DXPAK 1.0 or later

See Also

Reference

CTransformOutputPin::GetMediaType
AM_MEDIA_TYPE
VIDEOINFOHEADER