Share via


ISampleGrabber::GetCurrentBuffer

 
Microsoft DirectShow 9.0

ISampleGrabber::GetCurrentBuffer

The GetCurrentBuffer method retrieves a copy of the buffer associated with the most recent sample.

Syntax

  HRESULT GetCurrentBuffer(
  long *pBufferSize,
  long *pBuffer
);

Parameters

pBufferSize

[in, out]  Pointer to the size of the buffer. If pBuffer is NULL, this parameter receives the required buffer size, in bytes. If pBuffer is not NULL, you should set this parameter equal to the size of the buffer, in bytes. On output, the parameter receives the number of bytes that were copied into the buffer. This value might be smaller than the size of the buffer.

pBuffer

[out]  Pointer to an array of bytes of size pBufferSize, or NULL.  If this parameter is NULL, the current buffer is copied into the array. If this parameter is NULL, the pBufferSize parameter receives the required buffer size.

Return Value

Returns one of the following values.

Return code Description
E_INVALIDARG Samples are not being buffered. Call SetBufferSamples.
E_OUTOFMEMORY The specified buffer is not large enough.
E_POINTER NULL pointer argument.
S_OK Success.
VFW_E_NOT_CONNECTED The filter is not connected.
VFW_E_WRONG_STATE The filter has not received any samples yet. To deliver a sample, run or pause the graph.

Remarks

To activate buffering, call ISampleGrabber::SetBufferSamples with a value of TRUE.

Call this method twice. On the first call, set pBuffer to NULL. The size of the buffer is returned in pBufferSize. Then allocate an array and call the method again. On the second call, pass the size of the array in pBufferSize, and pass the address of the array in pBuffer. If the array is not large enough, the method returns E_OUTOFMEMORY.

The pBuffer parameter is typed as a long pointer, but the contents of the buffer depend on the format of the data. Call ISampleGrabber::GetConnectedMediaType to get the media type of the format.

The filter does not buffer preroll samples, or samples in which the dwStreamId member of the AM_SAMPLE2_PROPERTIES structure is anything other than AM_STREAM_MEDIA.

Requirements

Header: Include Qedit.h. This header file is not compatible with Microsoft® Direct3D® headers later than version 7.

Library: Use strmiids.lib.

See Also