首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > 多媒体 >

Mobile上 Directshow開發Camera問題,该怎么解决

2012-03-03 
Mobile上 Directshow開發Camera問題我們利用DirectShow開發Camera平常都能正常開啟關閉但連續開啟關閉數十

Mobile上 Directshow開發Camera問題
我們利用DirectShow開發Camera

平常都能正常開啟關閉

但連續開啟關閉數十次後,Camera會開始出現全黑畫面,

發現問題在於Transform filter 跟Render filter連接時失敗

ConnectFilters( pGraphBuilder, m_pTransformFilter, m_pRender );

C/C++ code
HRESULT ConnectFilters(IGraphBuilder *pGraph,IBaseFilter *pSrc,IBaseFilter *pDest){    if(( !pGraph ) || ( !pSrc ) || ( !pDest )) return E_POINTER;     // Find an output pin on the first filter.    HRESULT hr = E_FAIL;     CComPtr<IPin> pOut = NULL;     CHK( GetUnconnectedPin( pSrc, PINDIR_OUTPUT, &pOut ));     CHK( ConnectFilters( pGraph, pOut, pDest )); Cleanup:    if( FAILED( hr ))        RETAILMSG( 1, ( L"CAMERA >>> Connect Filters Failed...\r\n" ));     if( pOut )        pOut.Release();     return hr;}//=============================================================================HRESULT ConnectFilters(IGraphBuilder *pGraph, IPin *pOut, IBaseFilter *pDest){    if( (!pGraph) || (!pOut) || (!pDest) ) return E_POINTER;     // Find an input pin on the downstream filter.    HRESULT hr = E_FAIL;     CComPtr<IPin> pIn = NULL;     CHK( GetUnconnectedPin( pDest, PINDIR_INPUT, &pIn ));     PIN_INFO pinInfo_OUT, pinInfo_IN;     memset( &pinInfo_OUT, 0, sizeof( PIN_INFO ));     memset( &pinInfo_IN, 0, sizeof( PIN_INFO ));     hr = pOut->QueryPinInfo( &pinInfo_OUT );     hr = pIn->QueryPinInfo( &pinInfo_IN );     // Try to connect them.    CHK( pGraph->Connect( pOut, pIn )); Cleanup:    if( FAILED( hr ))        RETAILMSG( 1, ( L"CAMERA >>> Connect Pins Failed...\r\n" ));     if( pIn )        pIn.Release();     return hr;}//=============================================================================HRESULT GetUnconnectedPin(IBaseFilter *pFilter,PIN_DIRECTION PinDir,IPin **ppPin){    HRESULT hr = E_FAIL;     *ppPin = 0;    CComPtr<IEnumPins> pEnum = NULL;     IPin *pPin = 0;         CHK( pFilter->EnumPins( &pEnum ));     while( pEnum->Next(1, &pPin, NULL) == S_OK )    {        PIN_DIRECTION ThisPinDir;         hr = pPin->QueryDirection( &ThisPinDir );         if( ThisPinDir == PinDir )        {            CComPtr<IPin> pTmp = NULL;             hr = pPin->ConnectedTo(&pTmp);             if( SUCCEEDED( hr ))  // Already connected, not the pin we want.            {                pTmp.Release();             }            else  // Unconnected, this is the pin we want.            {                *ppPin = pPin;                 hr = S_OK;                 break;             }        }        pPin->Release();     }Cleanup:    if( FAILED( hr ))        RETAILMSG( 1, ( L"CAMERA >>> Get Unconnected Pin Failed...\r\n" ));     if( pEnum )        pEnum.Release();     return hr; }


檢驗此function後,發現有正確找出Transform filter的output pin及Render filter的Input pin

卻在連接兩個Pin時失敗,

hr = pOut->QueryPinInfo( &pinInfo_OUT ); <====S_Ok
hr = pIn->QueryPinInfo( &pinInfo_IN ); <====S_Ok

// Try to connect them.
hr = pGraph->Connect( pOut, pIn ); <====出現Error code為0x80040217

請問有可能是什麼原因照成這樣的情況發生呢??


[解决办法]
0x80040217 
VFW_E_CANNOT_CONNECT 
No combination of intermediate filters could be found to make the connection. 

应该是上游Filter能接受的媒体类型发生改变造成的,查查Video Capture Filter?

热点排行