Microsoft DirectX 8.0

IMediaBuffer Interface

This interface provides methods for manipulating a data buffer. Any buffer passed to a Microsoft® DirectX® Media Object (DMO) must implement this interface.

Methods in Vtable Order

IUnknown methodsDescription
QueryInterfaceRetrieves pointers to supported interfaces.
AddRefIncrements the reference count.
ReleaseDecrements the reference count.
IMediaBuffer methodsDescription
SetLengthSpecifies the length of the data currently in the buffer.
GetMaxLengthRetrieves the maximum number of bytes this buffer can hold.
GetBufferAndLengthRetrieves the buffer and the size of the valid data in the buffer.

IMediaBuffer::SetLength

IMediaBuffer Interface

Specifies the length of the data currently in the buffer.

Syntax

HRESULT SetLength(
   DWORD cbLength
);

Parameters

cbLength
Size of the data, in bytes. The value must not exceed the buffer's maximum size. Call the GetMaxLength method to obtain the maximum size.

Return Value

Returns S_OK if successful. Otherwise, returns an HRESULT value indicating the cause of the error.

Remarks

This method sets the size of the valid data currently in the buffer, not the buffer's allocated size.

IMediaBuffer::GetMaxLength

IMediaBuffer Interface

Retrieves the maximum number of bytes this buffer can hold.

Syntax

HRESULT GetMaxLength(
    DWORD *pcbMaxLength
);

Parameters

pcbMaxLength
[out] Pointer to a variable that receives the buffer's maximum size, in bytes.

Return Value

Returns S_OK if successful. Otherwise, returns an HRESULT value indicating the cause of the error.

IMediaBuffer::GetBufferAndLength

IMediaBuffer Interface

Retrieves the buffer and the size of the valid data in the buffer.

Syntax

HRESULT GetBufferAndLength(
    BYTE **ppBuffer,  
    DWORD *pcbLength
);

Parameters

ppBuffer
[out] Address of a pointer that receives the buffer array. Can be NULL if pcbLength is not NULL.
pcbLength
[out] Pointer to a variable that receives the size of the valid data, in bytes. Can be NULL if ppBuffer is not NULL.

Return Value

Returns an HRESULT value. Possible values include the following.

S_OKSuccess
E_POINTERNULL pointer argument

Remarks

Either parameter can be NULL, in which case it does not receive a value. At least one parameter must be non-NULL. If both parameters are NULL, the method returns E_POINTER.

The value returned in the pcbLength parameter is the size of the valid data in the buffer, not the buffer's allocated size. To obtain the buffer's allocated size, call the GetMaxLength method.