共用方式為


IAMStreamConfig::SetFormat

 
Microsoft DirectShow 9.0

IAMStreamConfig::SetFormat

The SetFormat method sets the output format on the pin.

Syntax

  HRESULT SetFormat(
  AM_MEDIA_TYPE *pmt
);

Parameters

pmt

[in] Pointer to an AM_MEDIA_TYPE structure that specifies the new format.

Return Values

Returns an HRESULT value. Possible values include the following.

Return code Description
S_OK Success.
E_OUTOFMEMORY Insufficient memory.
E_POINTER NULL pointer value.
VFW_E_INVALIDMEDIATYPE This media type is not valid.
VFW_E_NOT_CONNECTED The input pin is not connected.
VFW_E_NOT_STOPPED Cannot set the type; the filter is not stopped.
VFW_E_WRONG_STATE Cannot set the type; the filter is not stopped.

Remarks

This method specifies the format for the output pin. If the pin is not connected, it will use this format for its next connection. If the pin is already connected, it will attempt to reconnect with this format. The method might fail if the other pin rejects the new type.

If this method succeeds, subsequent calls to the IPin::EnumMediaTypes method will return the new type, and no others.

On most filters, this method fails if the filter is paused or running. On some compression filters, the method fails if the filter's input pin is not connected.

With some filters, you can call this method with the value NULL to reset the pin to its default format.

Filter Developers: The following remarks describe how to implement this method:

If the output pin is not connected, and the pin supports the specified media type, return S_OK. Store the media type and offer it as format number zero in the CBasePin::GetMediaType method. Do not offer other formats, and reject other formats in the CBasePin::CheckMediaType method.

If the pin is already connected, and the pin supports the media type, reconnect the pin with that type. If the other pin rejects the new type, return VFW_E_INVALIDMEDIATYPE and restore the original connection.

Requirements

Header: Declared in Strmif.h; include Dshow.h.

Library: Use Strmiids.lib.

See Also