Microsoft DirectX 8.1 (C++) |
Filters support the IBaseFilter::EnumPins method, which enumerates the pins available on the filter. It returns a pointer to the IEnumPins interface. The IEnumPins::Next method retrieves IPin interface pointers.
The following example shows a function that locates a pin with a given direction (input or output) on a given filter. It uses the PIN_DIRECTION enumeration to specify the pin direction, and the IPin::QueryDirection method to find the direction of each enumerated pin. If this function finds a matching pin, it returns an IPin interface pointer with an outstanding reference count. The caller is responsible for releasing the interface.
IPin *GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir)
{
BOOL bFound = FALSE;
IEnumPins *pEnum;
IPin *pPin;
pFilter->EnumPins(&pEnum);
while(pEnum->Next(1, &pPin, 0) == S_OK)
{
PIN_DIRECTION PinDirThis;
pPin->QueryDirection(&PinDirThis);
if (bFound = (PinDir == PinDirThis))
break;
pPin->Release();
}
pEnum->Release();
return (bFound ? pPin : 0);
}
This function could easily be modified to return the nth pin with the specified direction.