次の方法で共有


AM_MEDIA_TYPE (Compact 2013)

3/26/2014

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

Library

Strmiids.lib

See Also

Reference

DirectShow Structures