共用方式為


AM_MEDIA_TYPE

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This structure describes a media sample type.

Syntax

typedef struct  _MediaType{
  GUID majortype;
  GUID subtype;
  BOOL bFixedSizeSamples;
  BOOL bTemporalCompression;
  ULONG lSampleSize;
  GUID formattype;
  IUnknown* pUnk;
  ULONG cbFormat;
  /* [size_is] */ BYTE __RPC_FAR* pbFormat;
} AM_MEDIA_TYPE;

Members

  • majortype
    Major type of the media sample.
  • subtype
    Subtype of the media sample.
  • bFixedSizeSamples
    If TRUE, samples are of a fixed size.
  • bTemporalCompression
    If TRUE, samples are compressed.
  • lSampleSize
    Size of the sample in bytes.
  • formattype
    Registered (GUID) format type.
  • pUnk
    Pointer to the IUnknown interface.
  • cbFormat
    Size of the format section of the media type.

Remarks

Media Types

In any function that receives an AM_MEDIA_TYPE parameter, always validate the values of cbFormat and formattype before dereferencing the pbFormat member.

The following code is incorrect:

if (pmt->formattype == FORMAT_VideoInfo)
{
    VIDEOINFOHEADER *pVIH = (VIDEOINFOHEADER*)pmt->pbFormat;
    // **** Wrong! ****
}

The following code is correct:

if ((pmt->formattype == FORMAT_VideoInfo) && 
    (pmt->cbFormat > sizeof(VIDEOINFOHEADER) &&
    (pbFormat != NULL))
{
    VIDEOINFOHEADER *pVIH = (VIDEOINFOHEADER*)pmt->pbFormat;
    // Now you can use pVIH.
}

Requirements

Header dshow.h
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

DirectShow Structures