|
@@ -13,6 +13,8 @@ CCaptureVideo::CCaptureVideo()
|
|
m_pVW = NULL;
|
|
m_pVW = NULL;
|
|
m_pMC = NULL;
|
|
m_pMC = NULL;
|
|
m_pGB = NULL;
|
|
m_pGB = NULL;
|
|
|
|
+ m_pBF = NULL;
|
|
|
|
+ m_pGrabber = NULL;
|
|
m_pCapture = NULL;
|
|
m_pCapture = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,10 +109,12 @@ HRESULT CCaptureVideo::Init(int iDeviceID, HWND hWnd)
|
|
//hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber );
|
|
//hr = m_pGrabber.CoCreateInstance( CLSID_SampleGrabber );
|
|
hr = CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_ISampleGrabber, (void**)&m_pGrabber );
|
|
hr = CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_ISampleGrabber, (void**)&m_pGrabber );
|
|
|
|
|
|
- if( !m_pGrabber ){
|
|
|
|
|
|
+ if( !m_pGrabber )
|
|
|
|
+ {
|
|
AfxMessageBox("Fail to create SampleGrabber, maybe qedit.dll is not registered?");
|
|
AfxMessageBox("Fail to create SampleGrabber, maybe qedit.dll is not registered?");
|
|
return hr;
|
|
return hr;
|
|
}
|
|
}
|
|
|
|
+
|
|
CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );
|
|
CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabBase( m_pGrabber );
|
|
//ÉèÖÃÊÓÆµ¸ñʽ
|
|
//ÉèÖÃÊÓÆµ¸ñʽ
|
|
AM_MEDIA_TYPE mt;
|
|
AM_MEDIA_TYPE mt;
|
|
@@ -118,26 +122,33 @@ HRESULT CCaptureVideo::Init(int iDeviceID, HWND hWnd)
|
|
mt.majortype = MEDIATYPE_Video;
|
|
mt.majortype = MEDIATYPE_Video;
|
|
mt.subtype = MEDIASUBTYPE_RGB24;
|
|
mt.subtype = MEDIASUBTYPE_RGB24;
|
|
hr = m_pGrabber->SetMediaType(&mt);
|
|
hr = m_pGrabber->SetMediaType(&mt);
|
|
- if( FAILED( hr ) ){
|
|
|
|
|
|
+ if( FAILED( hr ) )
|
|
|
|
+ {
|
|
AfxMessageBox("Fail to set media type!");
|
|
AfxMessageBox("Fail to set media type!");
|
|
return hr;
|
|
return hr;
|
|
}
|
|
}
|
|
|
|
+
|
|
hr = m_pGB->AddFilter( pGrabBase, L"Grabber" );
|
|
hr = m_pGB->AddFilter( pGrabBase, L"Grabber" );
|
|
- if( FAILED( hr ) ){
|
|
|
|
|
|
+ if( FAILED( hr ) )
|
|
|
|
+ {
|
|
AfxMessageBox("Fail to put sample grabber in graph");
|
|
AfxMessageBox("Fail to put sample grabber in graph");
|
|
return hr;
|
|
return hr;
|
|
}
|
|
}
|
|
|
|
+
|
|
// try to render preview/capture pin
|
|
// try to render preview/capture pin
|
|
hr = m_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
|
hr = m_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
|
if( FAILED( hr ) )
|
|
if( FAILED( hr ) )
|
|
hr = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
|
hr = m_pCapture->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,m_pBF,pGrabBase,NULL);
|
|
- if( FAILED( hr ) ){
|
|
|
|
|
|
+
|
|
|
|
+ if( FAILED( hr ) )
|
|
|
|
+ {
|
|
AfxMessageBox("Can¡¯t build the graph");
|
|
AfxMessageBox("Can¡¯t build the graph");
|
|
return hr;
|
|
return hr;
|
|
}
|
|
}
|
|
|
|
|
|
hr = m_pGrabber->GetConnectedMediaType( &mt );
|
|
hr = m_pGrabber->GetConnectedMediaType( &mt );
|
|
- if ( FAILED( hr) ){
|
|
|
|
|
|
+ if ( FAILED( hr) )
|
|
|
|
+ {
|
|
AfxMessageBox("Failt to read the connected media type");
|
|
AfxMessageBox("Failt to read the connected media type");
|
|
return hr;
|
|
return hr;
|
|
}
|
|
}
|