CopyMediaType function

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

The CopyMediaType function copies an AM_MEDIA_TYPE structure into another structure, including the format block

Syntax

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

Parameters

pmtTarget

Pointer to an AM_MEDIA_TYPE structure. The method copies the media type into this structure.

pmtSource

Pointer to a source AM_MEDIA_TYPE structure to copy.

Return value

Returns S_OK or E_OUTOFMEMORY.

Remarks

This function allocates the memory for the format block. If the pmtTarget parameter already contains an allocated format block, a memory leak will occur. To avoid a memory leak, call FreeMediaType before calling this function.

After the method returns, call FreeMediaType on pmtTarget to free the format block.

Requirements

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

See also

Media Type Functions