MFCreateMediaBufferFromMediaType function (mfapi.h)

Allocates a system-memory buffer that is optimal for a specified media type.

Syntax

HRESULT MFCreateMediaBufferFromMediaType(
  [in]  IMFMediaType   *pMediaType,
  [in]  LONGLONG       llDuration,
  [in]  DWORD          dwMinLength,
  [in]  DWORD          dwMinAlignment,
  [out] IMFMediaBuffer **ppBuffer
);

Parameters

[in] pMediaType

A pointer to the IMFMediaType interface of the media type.

[in] llDuration

The sample duration. This value is required for audio formats.

[in] dwMinLength

The minimum size of the buffer, in bytes. The actual buffer size might be larger. Specify zero to allocate the default buffer size for the media type.

[in] dwMinAlignment

The minimum memory alignment for the buffer. Specify zero to use the default memory alignment.

[out] ppBuffer

Receives a pointer to the IMFMediaBuffer interface. The caller must release the interface.

Return value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

For video formats, if the format is recognized, the function creates a 2-D buffer that implements the IMF2DBuffer2 interface. Otherwise it creates a linear buffer. To get the IMF2DBuffer2 interface, call QueryInterface on the pointer returned in ppBuffer. If the QueryInterface method fails, use the IMFMediaBuffer interface to access the buffer memory.

For audio formats, the function allocates a buffer that is large enough to contain llDuration audio samples, or dwMinLength, whichever is larger.

This function always allocates system memory. For Direct3D surfaces, use the MFCreateDXGISurfaceBuffer or MFCreateDXSurfaceBuffer function.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header mfapi.h
Library Mfplat.lib
DLL Mfplat.dll

See also

Media Foundation Functions