CVideoTransformFilter.Receive method

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The Receive method receives a media sample, processes it, and delivers an output sample to the downstream filter. This method overrides the CTransformFilter::Receive method.

Syntax

HRESULT Receive(
   IMediaSample *pSample
);

Parameters

pSample

Pointer to the IMediaSample interface on the input sample.

Return value

Returns an HRESULT value. Possible values include the following:

Return code Description
S_FALSE
The upstream filter should stop sending samples.
S_OK
Success.

Remarks

This method calls CVideoTransformFilter::ShouldSkipFrame to determine whether it should deliver this sample or simply discard it. If ShouldSkipFrame returns FALSE (indicating the sample should be delivered), the method does the following:

  1. Calls CTransformFilter::InitializeOutputSample to prepare the output sample
  2. Calls CTransformFilter::Transform to process the input sample. This method is pure virtual, and must be implemented in the derived class.
  3. Calls CBaseOutputPin::Deliver to deliver the output sample.

Also, this method checks for format changes on the input or output sample, by calling IMediaSample::GetMediaType. If there is a format change, the method sets the connection type on the corresponding pin. Before it sets the new type, it calls StopStreaming. After it sets the new type, it calls StartStreaming. The derived class can use these methods to update its internal state. The derived class might also need to check for the new format in its Transform method.

Requirements

Requirement Value
Header
Vtrans.h (include Streams.h)
Library
Strmbase.lib (retail builds);
Strmbasd.lib (debug builds)

See also

CVideoTransformFilter Class