Microsoft DirectX 8.1 (C++)

CBaseInputPin::Receive

The Receive method receives the next media sample in the stream. This method implements the IMemInputPin::Receive method.

Syntax

HRESULT Receive(
    IMediaSample *pSample
);

Parameters

pSample

Pointer to the sample's IMediaSample interface.

Return Value

Returns an HRESULT value. Possible values include those listed in the following table.

Value Description
S_OK Success.
S_FALSE Pin is currently flushing; sample was rejected.
E_POINTER NULL pointer argument.
VFW_E_INVALIDMEDIATYPE Invalid media type.
VFW_E_RUNTIME_ERROR A run-time error occurred.
VFW_E_WRONG_STATE The pin is stopped.

Remarks

The upstream output pin calls this method to deliver a sample to the input pin. The input pin must do one of the following:

If the pin uses a worker thread to process the sample, add a reference count to the sample inside this method. After the method returns, the upstream pin releases the sample. When the sample's reference count reaches zero, the sample returns to the allocator for re-use.

This method is synchronous and can block. If the method might block, the pin's CBaseInputPin::ReceiveCanBlock method should return S_OK.

In the base class, this method performs the following steps:

  1. Calls the CBaseInputPin::CheckStreaming method to verify that the pin can process samples now. If it cannot—for example, if the pin is stopped—the method fails.
  2. Retrieves the sample properties and checks whether the format has changed (see below).
  3. If the format has changed, the method calls the CBasePin::CheckMediaType method to determine whether the new format is acceptable.
  4. If the new format is not acceptable, the method calls the CBasePin::EndOfStream method, posts an EC_ERRORABORT event, and returns an error code.
  5. Assuming there were no errors, the method returns S_OK.

Test for a format change as follows:

In the base class, this method does not process the sample. The derived class must override this method to perform the processing. (What this entails depends entirely on the filter.) The derived class should call the base-class method, to check for the errors described previously.

See Also