IAMStreamConfig::GetFormat method (strmif.h)

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The GetFormat method retrieves the current or preferred output format.

Syntax

HRESULT GetFormat(
  [out] AM_MEDIA_TYPE **ppmt
);

Parameters

[out] ppmt

Address of a pointer to an AM_MEDIA_TYPE structure.

Return value

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_NOT_CONNECTED
The input pin is not connected.

Remarks

If the pin is connected, this method returns the format that the pin is currently using. Otherwise, the method returns the pin's preferred format for the next pin connection. If you have already called the IAMStreamConfig::SetFormat method to set the format, GetFormat returns the same format. If not, it returns the first format in the pin's list of preferred formats, as determined by the IPin::EnumMediaTypes method.

The method allocates the memory for the AM_MEDIA_TYPE structure, fills in the structure, and returns it in the pmt parameter. The caller must release the memory, including the format block. You can use the DeleteMediaType helper function in the base class library.

On some compression filters, the method fails if the filter's input pin is not connected.

Examples

C++
IAMStreamConfig *pConfig = NULL;
// Query the output pin for IAMStreamConfig (not shown).
AM_MEDIA_TYPE *pmt = NULL;
hr = pConfig->GetFormat(&pmt);
if (SUCCEEDED(hr))
{
    /* Examine the media type for any information you need. */
    DeleteMediaType(pmt);
}
pConfig->Release();

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header strmif.h (include Dshow.h)
Library Strmiids.lib

See also

Error and Success Codes

IAMStreamConfig Interface