Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Audio and Video
DirectShow
Interfaces
IAMStreamConfig
 IAMStreamConfig::SetFormat method
IAMStreamConfig::SetFormat method

Applies to: desktop apps only

The SetFormat method sets the output format on the pin.

Syntax

HRESULT SetFormat(
  [in]  AM_MEDIA_TYPE *pmt
);

Parameters

pmt [in]

Pointer to an AM_MEDIA_TYPE structure that specifies the new format.

Return value

Returns an HRESULT value. Possible values include the following.

Return codeDescription
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

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Strmif.h (include Dshow.h)

Library

Strmiids.lib

See also

Error and Success Codes
IAMStreamConfig Interface

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
flow      rogerdpack   |   Edit   |   Show History
Ok I think I've figured out how this is supposed to work. If a graph creator calls SetFormat(NULL) on your filter, it should "reset" its state, and allow IEnumMediaTypes (which internally calls out to your GetStreamCaps et al) to return the full list. IEnumMediaTypes should also still return them the full list even if they have already called CBasePin.SetMediaType. However, if they once call SetFormat at any point, then subsequent calls to IEnumMediaTypes should only return that type. So I guess SetMediaType is like SetFormat but less binding somehow, since it doesn't affect future calls to IEnumMediaTypes, but SetFormat does. This allows for some "setup phase" to call SetFormat, then to render the pin's default later (straight or via Enumerating and only being able to use the first type) and it will use the type specified.
Tags What's this?: Add a tag
Flag as ContentBug
sets fps      rogerdpack   |   Edit   |   Show History
NB that this "should" allow callers to specify the fps, see http://msdn.microsoft.com/en-us/library/aa928940.aspx Also note that basically the convention is, if they pass in "NULL" to reset to the default format/settings. Some users (Flash Player, for instance) call this with NULL before doing any enumeration, just to reset it to ground zero.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker