Media Type Functions


The Mtype.h header file in the DirectShow base classes provides helper functions for handling media types. These general-purpose functions copy and delete a task-allocated AM_MEDIA_TYPE structure. This is useful when using the IEnumMediaTypes interface, because the implementation allocates the structures that must be deleted later.

The functions are paired as follows:

Function Description
AreEqualVideoTypes Compares the format, height, and width of two video sources.
CopyMediaType Copies a task-allocated AM_MEDIA_TYPE structure.
CreateMediaType Allocates and initializes an AM_MEDIA_TYPE structure.
DeleteMediaType Deletes a task-allocated AM_MEDIA_TYPE structure.
FreeMediaType Frees a task-allocated AM_MEDIA_TYPE structure from memory.


AreEqualVideoTypes

Media Type Functions

Determines if two media types have the same video format, width, and height.

BOOL WINAPI AreEqualVideoTypes (
  CMediaType *pmt1,
  CMediaType *pmt2
  );

Parameters
pmt1
First media type to compare.
pmt2
Second media type to compare.
Return Values

Returns TRUE if pmt1 and pmt2 have the same video format, width, and height or FALSE otherwise.


CopyMediaType

Media Type Functions

Copies a task-allocated AM_MEDIA_TYPE structure.

void WINAPI CopyMediaType(
  AM_MEDIA_TYPE *pmtTarget,
  const AM_MEDIA_TYPE *pmtSource
  );

Parameters
pmtTarget
Pointer to an area of memory in which to place the new copy of the structure.
pmtSource
Pointer to a source structure to copy.
Return Values

No return value.

Remarks

Free the resources in the pmtTarget structure by calling FreeMediaType when your code is done with the structure.


CreateMediaType

Media Type Functions

Creates a task-allocated AM_MEDIA_TYPE structure.

AM_MEDIA_TYPE * WINAPI CreateMediaType(
  AM_MEDIA_TYPE const *pSrc
  );

Parameters
pSrc
Pointer to an AM_MEDIA_TYPE source structure.
Return Values

Returns a new AM_MEDIA_TYPE structure, or NULL if there is an error.

Remarks

Free the structure and resources allocated by this routine by calling DeleteMediaType when your code is done with the structure.


DeleteMediaType

Media Type Functions

Deletes a task-allocated AM_MEDIA_TYPE structure.

void WINAPI DeleteMediaType(
  AM_MEDIA_TYPE *pmt
  );

Parameters
pmt
Pointer to an AM_MEDIA_TYPE structure.
Return Values

No return value.

Remarks

The structure should have been created by a call to CreateMediaType.


FreeMediaType

Media Type Functions

Frees a task-allocated AM_MEDIA_TYPE structure from memory.

void WINAPI FreeMediaType(
  AM_MEDIA_TYPE& mt
  );

Parameters
mt
Address of the structure.
Return Values

No return value.

Remarks

The structure should have been initialized by a call to CopyMediaType.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.