Microsoft DirectX 8.1 (C++)

AM_MEDIA_TYPE Structure

The AM_MEDIA_TYPE structure describes the format of a media sample.

Syntax

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

Members

majortype

Globally unique identifier (GUID) that specifies the major type of the media sample. For a list of possible major types, see Media Types.

subtype

GUID that specifies the subtype of the media sample. For a list of possible subtypes, see Media Types.

bFixedSizeSamples

If TRUE, samples are of a fixed size. This field is informational only. For audio, it is generally set to TRUE. For video, it is usually TRUE for uncompressed video and FALSE for compressed video.

bTemporalCompression

If TRUE, samples are compressed using temporal (interframe) compression. A value of TRUE indicates that not all frames are key frames. This field is informational only.

lSampleSize

Size of the sample in bytes. For compressed data, the value can be zero.

formattype

GUID that specifies the structure used for the format block. The pbFormat member points to the corresponding format structure. Format types include the following:

Format type Format structure
FORMAT_None or GUID_NULL None.
FORMAT_DvInfo DVINFO
FORMAT_MPEGVideo MPEG1VIDEOINFO
FORMAT_MPEG2Video MPEG2VIDEOINFO
FORMAT_VideoInfo VIDEOINFOHEADER
FORMAT_VideoInfo2 VIDEOINFOHEADER2
FORMAT_WaveFormatEx WAVEFORMATEX

pUnk

Not used.

cbFormat

Size of the format block, in bytes.

pbFormat

Pointer to the format block. The structure type is specified by the formattype member. The format structure must be present, unless formattype is GUID_NULL or FORMAT_None.

Remarks

When two pins connect, they negotiate a media type, which is defined by an AM_MEDIA_TYPE structure. The media type describes the format of the data that the filters will exchange. If the filters do not agree on a media type, they cannot connect.

The stream type is specified by two GUIDs, called the major type and the subtype. The major type defines the general category, such as video, audio, or byte stream. The subtype defines a narrower category within the major type. For example, video subtypes include 8-bit, 16-bit, 24-bit, and 32-bit RGB.

The AM_MEDIA_TYPE structure is followed by a variable-length block of data that contains format-specific information. The pbFormat member points to this block, called the format block. The layout of the format block depends on the type of data in the stream, and is specified by the formattype member. The format block might be NULL. Check the cbFormat member to determine the size. Cast the pbFormat member to access the format block. For example:

if (pmt->formattype == FORMAT_VideoInfo)
{
    VIDEOINFOHEADER *pVih = 
        reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
    /* Access VIDEOINFOHEADER members through pVih. */
}

In some situations, you can set the format block to NULL and the format type to GUID_NULL, resulting in a partial media type. This enables you to specify a range of possible formats. For example, you can specify 24-bit RGB (MEDIASUBTYPE_RGB24) without giving an exact width or height.

See Also