CBasePin.Connect 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 Connect method connects the pin to another pin. This method implements the IPin::Connect method.

Syntax

HRESULT Connect(
         IPin          *pReceivePin,
   const AM_MEDIA_TYPE *pmt
);

Parameters

pReceivePin

Pointer to the receiving pin's IPin interface.

pmt

Pointer to an AM_MEDIA_TYPE structure that specifies the media type for the connection.

Return value

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

Return code Description
S_OK
Success.
VFW_E_ALREADY_CONNECTED
The pin is already connected.
VFW_E_NO_ACCEPTABLE_TYPES
Could not find an acceptable media type.
VFW_E_NOT_STOPPED
The filter is active and the pin does not support dynamic reconnection.
VFW_E_TYPE_NOT_ACCEPTED
The specified media type is not acceptable.

Remarks

The pmt parameter can be NULL. It can also specify a partial media type, with a value of GUID_NULL for the major type, subtype, or format.

In the base class, this method tests whether the pin is already connected and whether the filter is stopped. It delegates the rest of the connection process to the CBasePin::AgreeMediaType method.

Requirements

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

See also

CBasePin Class