CMediaType class

[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.]

cmediatype class hierarchy

The CMediaType class manages media types. This class inherits the AM_MEDIA_TYPE structure. It can be cast to a variable of type AM_MEDIA_TYPE.

Public Methods Description
CMediaType Constructor method.
~CMediaType Destructor method.
Set Sets the media type from another media type.
IsValid Determines whether a major type has been assigned to this object.
Type Retrieves the major type.
SetType Specifies the major type.
Subtype Retrieves the subtype.
SetSubtype Specifies the subtype.
IsFixedSize Determines if the samples have a fixed size or a variable size.
IsTemporalCompressed Determines if the stream uses temporal compression.
GetSampleSize Retrieves the sample size.
SetSampleSize Specifies a fixed sample size, or specifies that samples have a variable size.
SetVariableSize Specifies that samples do not have a fixed size.
SetTemporalCompression Specifies whether samples are compressed using temporal compression.
Format Retrieves a pointer to the format block.
FormatLength Retrieves the length of the format block.
SetFormatType Specifies the format type.
FormatType Retrieves the format type.
SetFormat Specifies the format block.
ResetFormatBuffer Deletes the format block.
AllocFormatBuffer Allocates memory for the format block.
ReallocFormatBuffer Reallocates the format block to a new size.
InitMediaType Initializes the media type.
MatchesPartial Determines if this media type matches a partially specified media type.
IsPartiallySpecified Determines if the media type is partially defined.
Operators Description
operator = Overloads the assignment operator to copy a media type.
operator == Tests for equality between CMediaType objects.
operator != Tests for inequality between CMediaType objects.

Requirements

Requirement Value
Header
Mtype.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)