|
//mpeg2dmx.ax
WCHAR szMPegTS[]=L"@device:sw:{083863F1-70DE-11D0-BD40-00A0C911CE86}\\{731B8592-4001-46D4-B1A5-33EC792B4501}";
// construct source filter
if (m_bInit)
{
CMediaType mt;
mt.majortype = MEDIATYPE_Stream;
mt.subtype = MEDIASUBTYPE_MPEG2_TRANSPORT;
mt.formattype =FORMAT_MPEGStreams;
m_pSourceStream = new CMemStream(m_pDataList);
m_pSourceStream->bStopFlag=0;
m_pSourceReader = new CMemReader(m_pSourceStream,&mt,&hr);
m_pSourceReader->AddRef();
// Add our source filter
hr = m_pGB->AddFilter(m_pSourceReader, NULL);
// find mpeg2 filter
hr=GetFilterByMoniker(szMPegTS, (IBaseFilter **)&m_pMpeg2tsFilter);
//add mpeg2 filter
hr=m_pMpeg2tsFilter->AddRef();
hr = m_pGB->AddFilter(m_pMpeg2tsFilter, NULL);
hr=m_pMpeg2VideoFilter->AddRef();
hr = m_pGB->AddFilter(m_pMpeg2VideoFilter, NULL);
if (FAILED(hr))
{
m_bInit = false;
}
//This is where the connection fails
hr=ConnectFilters(m_pGB,m_pSourceReader,m_pMpeg2tsFilter);
The ConnectFilters function finds an INPIN and an OUTPIN in two filters and calls: hr = pGraph->Connect(pOut, pIn) to connect, and finding two PINs separately is successful.
HRESULT CFilterGraph::ConnectFilters(
IGraphBuilder *pGraph,
IBaseFilter *pSrc,
IBaseFilter *pDest)
{
if ((pGraph == NULL) || (pSrc == NULL) || (pDest == NULL))
{
return E_POINTER;
}
// Find an output pin on the first filter.
IPin *pOut = 0;
HRESULT hr = GetUnconnectedPin(pSrc, PINDIR_OUTPUT,&pOut);
if (FAILED(hr))
{
return hr;
}
hr = ConnectFilters(pGraph, pOut, pDest);
pOut->Release();
return hr;
}
HRESULT CFilterGraph::ConnectFilters(
IGraphBuilder *pGraph, // Filter Graph Manager.
IPin *pOut, // Output pin on the upstream filter.
IBaseFilter *pDest) // Downstream filter.
{
if ((pGraph == NULL) || (pOut == NULL) || (pDest == NULL))
{
return E_POINTER;
}
// Find an input pin on the downstream filter.
IPin *pIn = 0;
HRESULT hr = GetUnconnectedPin(pDest, PINDIR_INPUT,&pIn);
if (FAILED(hr))
{
return hr;
}
// Try to connect them.
hr = pGraph->Connect(pOut, pIn); //The place where the real connection fails is here
pIn->Release();
return hr;
} |
|