2011-12-01 79 views
2

我有直接显示过滤器,它接受输入并对其进行处理并将结果提供给输出引脚。如何从directshow滤波器输出引脚获取数据?

我想写这个过滤器输出数据到一个文件...我想在它的过滤器class.So我想获得输出引脚缓冲区数据。

很快如何达到其滤波器输出引脚的最终数据?我该怎么做?

不:输出引脚从CBaseOutputPin.This导出是一个开源的过滤它“神奇” :-)把赖特数据到其输出引脚,我无法弄清楚如何尚未...

更新:

这里是siutuation:GFilter的

Media Source ----> GFilter ----> FileWriter 

我的源代码...我的FileWriter没有源代码......我想什么做的是使GFilter编写它自己的数据...我调试GFilter得到一些洞察如何其转换数据,但我试图写这个数据结果与错误的数据...所以我现在欺骗如何简单地在其输出引脚获取数据...

更新[2]

在筛选outputpin somwhere滤波器作家通过文件写入器销IStreamPtr可变...寄托都似乎写入到可变m_pIStream其是[IStreamPtr]

GFilterOutput::CompleteConnect(IPin *pReceivePin) 
{ 


    // make sure that this is the file writer, supporting 
    // IStream, or we will not be able to write out the metadata 
    // at stop time 
    // m_pIStream is IStreamPtr type 
    m_pIStream = pReceivePin; 
    if (m_pIStream == NULL) 
    { 
     return E_NOINTERFACE; 
    } 
    return CBaseOutputPin::CompleteConnect(pReceivePin); 
} 
类型

...

GFilterOutput::Replace(LONGLONG pos, const BYTE* pBuffer, long cBytes) 
{ 
    //OutputDebugStringA("DEBUG: Now at MuxOutput Replace"); 

    // all media content is written when the graph is running, 
    // using IMemInputPin. On stop (during our stop, but after the 
    // file writer has stopped), we switch to IStream for the metadata. 
    // The in-memory index is updated after a successful call to this function, so 
    // any data not written on completion of Stop will not be in the index. 
    CAutoLock lock(&m_csWrite); 

    HRESULT hr = S_OK; 
    if (m_bUseIStream) 
    { 


     IStreamPtr pStream = GetConnected(); 
     if (m_pIStream == NULL) 
     { 
      hr = E_NOINTERFACE; 
     } else { 
      LARGE_INTEGER liTo; 
      liTo.QuadPart = pos; 
      ULARGE_INTEGER uliUnused; 
      hr = m_pIStream->Seek(liTo, STREAM_SEEK_SET, &uliUnused); 
      if (SUCCEEDED(hr)) 
      { 
       ULONG cActual; 
       hr = m_pIStream->Write(pBuffer, cBytes, &cActual); 
       if (SUCCEEDED(hr) && ((long)cActual != cBytes)) 
       { 
        hr = E_FAIL; 
       } 
      } 
     } 
    } else { 
     // where the buffer boundaries lie is not important in this 
     // case, so break writes up into the buffers. 
     while (cBytes && (hr == S_OK)) 
     { 
      IMediaSamplePtr pSample; 
      hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0); 
      if (SUCCEEDED(hr)) 
      { 
       long cThis = min(pSample->GetSize(), cBytes); 
       BYTE* pDest; 
       pSample->GetPointer(&pDest); 
       CopyMemory(pDest, pBuffer, cThis); 
       pSample->SetActualDataLength(cThis); 

       // time stamps indicate file position in bytes 
       LONGLONG tStart = pos; 
       LONGLONG tEnd = pos + cThis; 
       pSample->SetTime(&tStart, &tEnd); 
       hr = Deliver(pSample); 
       if (SUCCEEDED(hr)) 
       { 
        pBuffer += cThis; 
        cBytes -= cThis; 
        pos += cThis; 
       } 
      } 
     } 
    } 
    return hr; 
} 

回答

0

你有完整的源代码,直接通过调试器直到你的过滤器调用对端下游过滤器的IPin::Receive,在那里更新/覆盖代码,并且你有完全控制将数据写入文件等。

+0

更新我的信息..它似乎这是无效的在我的情况下... GFilter类InputPin有接收方法,但GFilter输出pi没有..而我无法调试第三方过滤器可能是调用接收我的过滤。我想要在GFilter中访问这个... – Novalis

+0

“我有GFilter的源代码”,所以你有代码。您不需要FileWriter的代码,只需在FileWriter的'IPin :: Receive'被调用之前在GFilter中尽可能晚地转储数据。 –

+0

那么,过滤器与文件编写器通​​过IStream接口说话...我只是无法弄清楚它在哪里调用FireWriter IPin ::接收...我甚至在源代码中搜索接收关键字... :-) – Novalis