Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have added a source filter to graph ,now i need to conect filters individually.
at first , i need to retrive the source filter output pins .

i used this funtion to enumerate the pin but at the pEnum->Next(1, &pPin, NULL)
the pEnum return S_FALSE.
but HRESULT hr = pFilter->EnumPins(&pEnum); the hr =S_OK.
i have no idea about this .may i have lose any thing before call this funtion
and i have tried another source filter (AVI/WAV File Source)in GetUnconnectedPin funtion but it fails again.

C++
HRESULT GetUnconnectedPin(
    IBaseFilter *pFilter,   // Pointer to the filter.
    PIN_DIRECTION PinDir,   // Direction of the pin to find.
    IPin **ppPin)           // Receives a pointer to the pin.
{
    *ppPin = 0;
    IEnumPins *pEnum = 0;
    IPin *pPin = 0;
    HRESULT hr = pFilter->EnumPins(&pEnum);
    if (FAILED(hr))
    {
        return hr;
    }
   //it works very good untill here
    while (pEnum->Next(1, &pPin, NULL) == S_OK)//here ,pEnum return S_FALSE
    {
        PIN_DIRECTION ThisPinDir;
        pPin->QueryDirection(&ThisPinDir);
        if (ThisPinDir == PinDir)
        {
            IPin *pTmp = 0;
            hr = pPin->ConnectedTo(&pTmp);
            if (SUCCEEDED(hr))  // Already connected, not the pin we want.
            {
                pTmp->Release();
            }
            else  // Unconnected, this is the pin we want.
            {
                pEnum->Release();
                *ppPin = pPin;
                return S_OK;
            }
        }
        pPin->Release();
    }
    pEnum->Release();
    // Did not find a matching pin.
    return E_FAIL;
}


[EDIT] Added pre tags for better readability - Code-o-mat [/EDIT]
Posted
Updated 8-May-12 0:59am
v2

1 solution

I wanted to add this as a comment, but since that function seems to be gone (and i can't seem to be able to figure out how to send a "private message")...
Did you specify the input for the filter? If not, try specifying the input (e.g. the URL or file name or whatever) and do the enumerating after that, it's possible that without an input the filter won't expose any output pins.
 
Share this answer
 
Comments
lanhxg 8-May-12 10:51am    
i will try it!thanks in advance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900