title: Get continuous frames from camera filter when source filter stops sending?
body: <p><img src="https://i.stack.imgur.com/vweHs.jpg" alt="enter image description here" /></p>
  <p>Hi All,</p>
  <p>I have a transform filter which takes two inputs, one from camera and other from a file source. Inside my transform filter I am blending the inputs from two sources.</p>
  <p>Transform filter is derived from CTransformFilter</p>
  <pre><code>class CWMTransformFilter : public CTransformFilter
  </code></pre>
  <p>and extra pin is derived from: CTransformInputPin(which inturn derives from CBaseInputPin)</p>
  <pre><code>class CFileInputPin : public CTransformInputPin
  </code></pre>
  <p>In my case what is happening is, if the file source is small (assume 10 secs), I get input from camera also for 10 secs, later camera stops sending frames to the input pin.</p>
  <p>So what i now need is :<br />
  <strong>1. How to inform camera to send frames even when source filter stops sending ?<br />
  2. How to restart the source filter when the playing of the source file is stopped?</strong>   (something like playing file in loop)</p>
  <p>Update:</p>
  <pre><code>STDMETHODIMP CFileInputPin::EndOfStream()
  {
      //return CTransformInputPin::EndOfStream();
      return S_OK;
  }
  
  STDMETHODIMP CFileInputPin::Receive(IMediaSample* pSample)
  {
      HRESULT hr;
      BYTE* pBufferIn;
      long lBufferLength, lBufferSize;
      hr = CBaseInputPin::Receive(pSample);
      if (FAILED(hr))
      {
          printf(&quot;Error !!\n&quot;);
          return hr;
      }
      hr = pSample-&gt;GetPointer(&amp;pBufferIn);
      DWORD stat = WaitForSingleObject(m_pFil-&gt;m_QSem,0L);
      BOOL bSem = FALSE;
      if( WAIT_OBJECT_0 == stat )
      {
          BYTE *pBuf = (BYTE *) malloc( Wsize*2 );
          memcpy(pBuf,pBufferIn,Wsize); //lBufferLength);
          sEncodedFrame CurFrame={pBuf,Wsize};
          m_pFil-&gt;m_Q.push(CurFrame); //push it onto the queue
  
          bSem = ReleaseSemaphore(m_pFil-&gt;m_QSem,1,NULL);
          if(!bSem)
          {
              printf(&quot;ReleaseSemaphore error: %d \n&quot;, GetLastError());
          }
  
          return S_OK;
      }
      else
      {
          printf(&quot;Cant Receive frame 0x%x \n&quot;,stat);
          return E_FAIL;
      }
      return S_OK;
  }
  
  HRESULT CWMTransformFilter::Transform(IMediaSample *pSource, IMediaSample *pDest)
  {
      unsigned char r,g,b;
      unsigned char y,u,v;
  
      BYTE *pBufferIn, *pBufferOut, *pBuf;
      HRESULT hr = pSource-&gt;GetPointer(&amp;pBufferIn);
      hr = pDest-&gt;GetPointer(&amp;pBufferOut);
      if (FAILED(hr))
      {
          return hr;
      }
      long srclen = pSource-&gt;GetActualDataLength();
      long dstlen = pDest-&gt;GetActualDataLength();
  
      LONG pLastCnt;
      BOOL bSem = FALSE;
      //printf(&quot;Waiting to fill buffer %d\n&quot;,pSource);
      //return S_OK;
      //try
      //{
      while(1)
      {
          //if(1)
          DWORD ret = WaitForSingleObject(m_QSem,0L);
          if(ret != WAIT_OBJECT_0)
          {
              printf(&quot;Get error %d \n&quot;,GetLastError());
          }
          if( WAIT_OBJECT_0 == ret )
          {
              
              sEncodedFrame Frame;
              if( m_Q.empty() == false )
              {
                  Frame = m_Q.front();
                  m_Q.pop();
                  pBuf = (BYTE*) malloc(dstlen*2);
                  pLastCnt = Frame.iValidSize;
                  printf(&quot;Copy onto queue \n&quot;);
                  memcpy(pBuf,Frame.pFrame,pLastCnt); //Frame.iValidSize);
                  free(Frame.pFrame);
                  //delete &amp;Frame;
                  bSem = ReleaseSemaphore(m_QSem,1,NULL);
                  if(!bSem)
                  {
                      printf(&quot;ReleaseSemaphore error: %d \n&quot;, GetLastError());
                  }
                  hr = S_OK;
                  break;
              }
              else
              {
                  bSem = ReleaseSemaphore(m_QSem,1,NULL);
                  if(!bSem)
                  {
                      printf(&quot;ReleaseSemaphore error: %d \n&quot;, GetLastError());
                  }
                  //return S_OK;
                  hr = E_FAIL;
              }
          }
          else
          {
              //return S_OK;
              hr = E_FAIL;
          }
      }
  
      for(i = 0; i &lt; windowWidth*2*windowHeight ; i+=4)
      {
       y = pBufferIn[i];
       u = pBufferIn[i+1];
       v = pBufferIn[i+3];
       r = y + 1.4075 * (v - 128);
       g = y - 0.3455 * (u - 128) - (0.7169 * (v - 128));
       b = y + 1.7790 * (u - 128);
  
      if(((r &gt; b) &amp;&amp;(g &gt; b)) &amp;&amp; (g &lt;= 200) )
      {
          pBufferIn[i] = pBuf[i];
          pBufferIn[i+1] = pBuf[i+1];
          pBufferIn[i+2] = pBuf[i+2];
          pBufferIn[i+3] = pBuf[i+3];
      }
  }
  
      // Process the data.
      memcpy(pBufferOut,pBufferIn,pSource-&gt;GetSize()); //after blend
  
      pDest-&gt;SetActualDataLength(pDest-&gt;GetSize());
      pDest-&gt;SetSyncPoint(TRUE);
      return S_OK;
  }
  </code></pre>
  <p>CFileInputPin::Receive is where I receive samples from file input pin,<br />
  CFileInputPin::EndOfStream(), notifies that samples are completed.<br />
  CWMTransformFilter::Transform(), is where the samples are given out to the outpin to renderer.</p>
  <p>Thanks,<br />
  Shyam</p>