Freigeben über


IAMStreamConfig::GetFormat

 
Microsoft DirectShow 9.0

IAMStreamConfig::GetFormat

The GetFormat method retrieves the current or preferred output format.

Syntax

  HRESULT GetFormat(
  AM_MEDIA_TYPE **pmt
);

Parameters

pmt

[out] Address of a pointer to an AM_MEDIA_TYPE structure.

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_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.

Example Code

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

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

Library: Use Strmiids.lib.

See Also