Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to add a pin in directshow transform filter? (Read 5116 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to add a pin in directshow transform filter?

Hi all, I am currently trying to build a new directshow transform filter.
I need this filter to take in 2 input pins. How should I go about doing this?

I have try to modify the code from the SDK but failed, this is my attempt, any help would be greatly appreciated, Thanks.

Amended from Null in place from directx SDK.:
//setup data
const AMOVIESETUP_PIN
psudPins[] = { { L"InputA"            // strName
              , FALSE              // bRendered
              , FALSE              // bOutput
              , FALSE              // bZero
              , TRUE              // bMany
              , &CLSID_NULL        // clsConnectsToFilter
              , L"Output"          // strConnectsToPin
              , 1                  // nTypes
              , &sudPinTypes }      // lpTypes
           
//My mod Start
         , { L"InputB"          // strName
              , FALSE              // bRendered
              , FALSE                // bOutput
              , FALSE              // bZero
              , TRUE              // bMany
              , &CLSID_NULL        // clsConnectsToFilter
              , L"Output"            // strConnectsToPin
              , 1                  // nTypes
              , &sudPinTypes }   
//My mod End   

, { L"OutputA"          // strName
              , FALSE              // bRendered
              , TRUE                // bOutput
              , FALSE              // bZero
              , FALSE              // bMany
              , &CLSID_NULL        // clsConnectsToFilter
              , L"Input"            // strConnectsToPin
              , 1                  // nTypes
              , &sudPinTypes }
                        
                           };  // lpTypes


//the following code is also amended under GetPin
CBasePin *CNullInPlace::GetPin(int n)
{
    // Create the single input pin and the single output pin
    // If anything fails, fail the whole lot and clean up.

    if (m_pInput == NULL || m_pOutput == NULL)
    {
        HRESULT hr = S_OK;

        m_pInput = new CNullInPlaceInputPin1(NAME("Null input pin1"),
                                          this,              // Owner filter
                                          &hr,              // Result code
                                          L"InputA");        // Pin name

        // a failed return code should delete the object

    //    if (FAILED(hr) || m_pInput == NULL)
    //    {
  //        delete m_pInput;
  //        m_pInput = NULL;
  //          return NULL;
  //    }


      
//My Mod Start
m_pInput = new CNullInPlaceInputPin2(NAME("Null input pin2"),
                                          this,              // Owner filter
                                          &hr,              // Result code
                                          L"InputB");        // Pin name

        // a failed return code should delete the object

        if (FAILED(hr) || m_pInput == NULL)
        {
            delete m_pInput;
            m_pInput = NULL;
            return NULL;
        }

//My Mod End

        m_pOutput = new CNullInPlaceOutputPin(NAME("Null output pin"),
                                            this,            // Owner filter
                                            &hr,            // Result code
                                            L"OutputA");      // Pin name

        // failed return codes cause both objects to be deleted

        if (FAILED(hr) || m_pOutput == NULL)
        {
            delete m_pInput;
            m_pInput = NULL;

            delete m_pOutput;
            m_pOutput = NULL;
            return NULL;
        }


}

I have done the above modification but it does not seems to work. In graph edit, I see only one input pin and one output pin, Being Input B and Output A.
My guess is that m_pInput is being assigned 2 times thus the first pin: InputA is being overwritten.

I did other modificiation also which include:
// ----------------------------------------------------------------------------
// Class definitions of input pin, output pin and filter
// ----------------------------------------------------------------------------


class CNullInPlaceInputPin1 : public CTransInPlaceInputPin
{
    public:
        CNullInPlaceInputPin1( TCHAR *pObjectName
                            , CTransInPlaceFilter *pTransInPlaceFilter
                            , HRESULT * phr
                            , LPCWSTR pName
                            )
                              : CTransInPlaceInputPin( pObjectName
                                                    , pTransInPlaceFilter
                                                    , phr
                                                    , pName
                                                    )
        {
        }

        HRESULT CheckMediaType(const CMediaType* pmt);
};

//My Mod start
class CNullInPlaceInputPin2 : public CTransInPlaceInputPin
{
    public:
        CNullInPlaceInputPin2( TCHAR *pObjectName
                            , CTransInPlaceFilter *pTransInPlaceFilter
                            , HRESULT * phr
                            , LPCWSTR pName
                            )
                              : CTransInPlaceInputPin( pObjectName
                                                    , pTransInPlaceFilter
                                                    , phr
                                                    , pName
                                                    )
        {
        }

      // HRESULT CheckMediaType(const CMediaType* pmt);
};

//My Mod End
class CNullInPlaceOutputPin : public CTransInPlaceOutputPin
{
    public:
        CNullInPlaceOutputPin( TCHAR *pObjectName
                            , CTransInPlaceFilter *pTransInPlaceFilter
                            , HRESULT * phr
                            , LPCWSTR pName
                            )
                              : CTransInPlaceOutputPin( pObjectName
                                                      , pTransInPlaceFilter
                                                      , phr
                                                      , pName
                                                      )
        {
        }

        HRESULT CheckMediaType(const CMediaType* pmt);
};


btw, what is class CNullInPlaceOutputPin  and m_pInput. Do we need to add in a new class and pointer if we need an additional pins.
And what did I do wrong and what is need to add in an extra input pin…

Thanks for all the attention.