MFCreateMediaBufferWrapper function (mfapi.h)

Creates a media buffer that wraps an existing media buffer. The new media buffer points to the same memory as the original media buffer, or to an offset from the start of the memory.


HRESULT MFCreateMediaBufferWrapper(
  [in]  IMFMediaBuffer *pBuffer,
  [in]  DWORD          cbOffset,
  [in]  DWORD          dwLength,
  [out] IMFMediaBuffer **ppBuffer


[in] pBuffer

A pointer to the IMFMediaBuffer interface of the original media buffer.

[in] cbOffset

The start of the new buffer, as an offset in bytes from the start of the original buffer.

[in] dwLength

The size of the new buffer. The value of cbOffset + dwLength must be less than or equal to the size of valid data the original buffer. (The size of the valid data is returned by the IMFMediaBuffer::GetCurrentLength method.)

[out] ppBuffer

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

Return value

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return code Description
The function succeeded.
The requested offset or the requested length is not valid.


The maximum size of the wrapper buffer is limited to the size of the valid data in the original buffer. This might be less than the allocated size of the original buffer. To set the size of the valid data, call IMFMediaBuffer::SetCurrentLength.

This function is available on the following platforms if the Windows Media Format 11 SDK redistributable components are installed:

  • Windows XP with Service Pack 2 (SP2) and later.
  • Windows XP Media Center Edition 2005 with KB900325 (Windows XP Media Center Edition 2005) and KB925766 (October 2006 Update Rollup for Windows XP Media Center Edition) installed.


Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header mfapi.h
Library Mfplat.lib
DLL Mfplat.dll

See also

Media Buffers

Media Foundation Functions