Microsoft DirectX 8.0 |
Class for managing media types. This class inherits the AM_MEDIA_TYPE structure. It can be cast to a variable of type AM_MEDIA_TYPE.
Declaration: Mtype.h
Public Methods | |
---|---|
CMediaType | Constructor method. |
~CMediaType | Destructor method. |
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 | |
operator = | Overloads the assignment operator to copy a media type. |
operator == | Tests for equality between CMediaType objects. |
operator != | Tests for inequality between CMediaType objects. |
Allocates memory for the format block.
Syntax
BYTE* AllocFormatBuffer( ULONG length );
Parameters
- length
- Size required for the format block, in bytes.
Return Value
Returns a pointer to the new block if successful. Otherwise, returns NULL.
Remarks
If the method successfully allocates a new format block, it frees the existing format block. If the allocation fails, the method leaves the existing format block.
Constructor method.
Syntax
CMediaType(void); CMediaType( const GUID *majortype ); CMediaType( const AM_MEDIA_TYPE& mtype ); CMediaType( const CMediaType& cmtype );
Parameters
- majortype
- Pointer to a major type GUID.
- mtype
- Reference to an AM_MEDIA_TYPE structure.
- cmtype
- Reference to a CMediaType object.
Remarks
The constructor calls the InitMediaType function to initialize the media type. If the majortype parameter is specified, the constructor initializes the major type GUID. If the mtype or cmtype parameter is specified, the constructor copies the media type information (including the format block) into the new object.
Destructor method.
Syntax
~CMediaType(void);
Remarks
The destructor calls the FreeMediaType function on itself.
Retrieves a pointer to the format block.
Syntax
BYTE* Format(void) const;
Return Value
Returns the pbFormat member.
Retrieves the length of the format block.
Syntax
ULONG FormatLength(void) const;
Return Value
Returns the cbFormat member.
Retrieves the format type.
Syntax
const GUID *FormatType(void) const;
Return Value
Returns a pointer to the formattype member.
Retrieves the sample size.
Syntax
ULONG GetSampleSize(void) const;
Return Value
If the sample size is fixed, returns the sample size in bytes. Otherwise, returns zero.
Initializes the media type.
Syntax
void InitMediaType(void);
Remarks
This method zeroes the object's memory, sets the fixed-sample-size property to TRUE, and sets the sample size to 1.
Determines if the samples have a fixed size or a variable size.
Syntax
BOOL IsFixedSize(void) const;
Return Value
Returns the value of the bFixedSizeSamples member.
Determines if the media type is partially defined. A media type is partial if the major type, subtype, or format type is GUID_NULL.
Syntax
BOOL IsPartiallySpecified(void) const;
Return Value
Returns TRUE if the media type is partially specified. Otherwise, returns FALSE.
Remarks
The IPin::Connect method can accept partial media types.
The implementation does not actually test the subtype. If there is a specified format type, the media type is not considered partial, even if the subtype is GUID_NULL.
Determines if the stream uses temporal compression.
Syntax
BOOL IsTemporalCompressed(void) const;
Return Value
Returns the value of the bTemporalCompression member.
Determines whether a major type has been assigned to this object.
Syntax
BOOL IsValid(void) const;
Return Value
Returns TRUE if a major type has been assigned to this object. Otherwise, returns FALSE.
Remarks
By default, CMediaType objects are initialized with a major type of GUID_NULL. Call this method to determine whether the object has been correctly initialized.
Determines if this media type matches a partially specified media type.
Syntax
BOOL MatchesPartial( const CMediaType *ppartial ) const;
Parameters
- ppartial
- Pointer to the media type to match.
Return Value
Returns TRUE if the media types match. Otherwise, returns FALSE.
Remarks
The media type specified by ppartial can have a value of GUID_NULL for the major type, subtype, or format type. Any members with GUID_NULL values are not tested. (In effect, GUID_NULL acts as a wildcard.) Members with values other than GUID_NULL must match for the media type to match.
Reallocates the format block to a new size.
Syntax
BYTE* ReallocFormatBuffer( ULONG length );
Parameters
- length
- New size required for the format block, in bytes. Must be greater than zero.
Return Value
Returns a pointer to the new block if successful. Otherwise, returns either a pointer to the old format block, or NULL.
Remarks
This method allocates a new format block. It copies as much of the existing format block as possible into the new format block. If the new block is smaller than the existing block, the existing format block is truncated. If the new block is larger, the contents of the additional space are undefined. They are not explicitly set to zero.
Deletes the format block.
Syntax
void ResetFormatBuffer(void);
Specifies the format block.
Syntax
BOOL SetFormat( BYTE *pFormat, ULONG length );
Parameters
- pFormat
- Pointer to a block of memory that contains the format block.
- length
- Length of the format block, in bytes.
Return Value
Returns TRUE if successful, or FALSE if an error occurred.
Remarks
This method copies the format block specified by pFormat. To set the format type, call the SetFormatType method.
Specifies the format type.
Syntax
void SetFormatType( const GUID *pformattype );
Parameters
- pformattype
- Pointer to a GUID that specifies the format type.
Remarks
This method sets the formattype member. The format type defines the layout of the format block. For example, if the format type is FORMAT_VideoInfo, the format block should contain a VIDEOINFOHEADER structure. To set the format block, call the SetFormat method. The caller is responsible for making sure that the format block matches the format type.
Specifies a fixed sample size, or specifies that samples have a variable size.
Syntax
void SetSampleSize( ULONG sz );
Parameters
- sz
- Sample size, in bytes, or zero.
Remarks
If value of sz is zero, the media type uses variable sample sizes. Otherwise, the sample size is fixed at sz bytes.
Specifies the subtype.
Syntax
void SetSubtype( const GUID *psubtype );
Parameters
- psubtype
- Pointer to a GUID that specifies the subtype.
Specifies whether samples are compressed using temporal (interframe) compression.
Syntax
void SetTemporalCompression( BOOL bCompressed );
Parameters
- bCompressed
- Boolean value that specifies whether the stream uses temporal compression. If the stream uses temporal compression, set the value to TRUE.
Remarks
This method sets the bTemporalCompression member.
Specifies the major type.
Syntax
void SetType( const GUID *ptype );
Parameters
- ptype
- Pointer to a GUID that specifies the major type.
Specifies that samples do not have a fixed size.
Syntax
void SetVariableSize(void);
Remarks
This method sets the bFixedSizeSamples member to FALSE. Subsequent calls to the CMediaType::GetSampleSize method return zero.
Retrieves the subtype.
Syntax
const GUID *Type(void) const;
Return Value
Returns a pointer to the subtype member.
Retrieves the major type.
Syntax
const GUID *Type(void) const;
Return Value
Returns a pointer to the majortype member.
Overloads the assignment operator to copy a media type.
Syntax
CMediaType& operator=( const CMediaType& cmtype ); CMediaType& operator=( const AM_MEDIA_TYPE& mtype );
Parameters
- cmtype
- Reference to a CMediaType object.
- mtype
- Reference to an AM_MEDIA_TYPE structure.
Return Value
Returns a reference to the object.
Tests for equality between CMediaType objects.
Syntax
inline BOOL operator==( const CMediaType& rt ) const;
Parameters
- rt
- Reference to the CMediaType object to compare.
Return Value
Returns TRUE if rt is equal to this object. Otherwise, returns FALSE.
Tests for inequality between CMediaType objects.
Syntax
BOOL operator!=( const CMediaType& rt ) const;
Parameters
- rt
- Reference to the CMediaType object to compare.
Return Value
Returns TRUE if rt is not equal to this object. Otherwise, returns FALSE.