HRESULT CVideoSource::RenderStream( )
{
//CoInitialize(NULL);
HRESULT hr = NULL;
hr=m_pBuilder->RenderStream(
&PIN_CATEGORY_PREVIEW, //&PIN_CATEGORY_CAPTURE, // Pin category
&MEDIATYPE_Video, // Media type
m_pVideoCap, // Capture filter
NULL, //m_pVidCompress, // Compression filter (optional)
NULL //m_pVideoRender // Multiplexer or renderer filter
);
if(hr == VFW_S_NOPREVIEWPIN)
{
// preview was faked up for us using the (only) capture pin
//gcap.fPreviewFaked = TRUE;
}
else if(hr != S_OK)
{
ErrMsg(TEXT("该视频卡不能进行视频浏览,请检查!"));
}
/*
hr = m_pGrapher->QueryInterface(IID_IVideoWindow, (void **)&m_pVidWin);
RECT rc;
m_pVidWin->put_Owner((OAHWND)AfxGetMainWnd()->m_hWnd); // We own the window now
m_pVidWin->put_WindowStyle(WS_CHILD); // you are now a child
// give the preview window all our space but where the status bar is
GetClientRect(AfxGetMainWnd()->m_hWnd, &rc);
m_pVidWin->SetWindowPosition(0, 0, rc.right, rc.bottom); // be this big
m_pVidWin->put_Visible(OATRUE);
*/
//hr=m_pBuilder->RenderStream(
// &PIN_CATEGORY_CAPTURE, // Pin category
// &MEDIATYPE_Video, // Media type
// m_pVideoCap, // Capture filter
// NULL,//m_pVidCompress, // Compression filter (optional)
// m_pVideoRender // Multiplexer or renderer filter
// );
return hr;
}
HRESULT CVideoSource::Stop()
{
// TODO: Add your implementation code here
HRESULT hr = NULL;
//REFERENCE_TIME t=0x7FFFFFFFFFFFFFFF;
//HRESULT hr=m_pBuilder->ControlStream(
// &PIN_CATEGORY_CAPTURE,//const GUID *pCategory,
// NULL,//const GUID *pType,
// NULL,//IBaseFilter *pFilter,
// &t,//REFERENCE_TIME *pstart,
// NULL,//REFERENCE_TIME *pstop,
// 0,//WORD wStartCookie,
// 0//WORD wStopCookie
// );
//// return hr;
IMediaControl *pMediaControl;
// HRESULT hr=m_pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
hr=m_pGrapher->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
if(hr==S_OK){
pMediaControl->Stop();
pMediaControl->Release();
}
return hr;
}
HRESULT CVideoSource::Play()
{
// TODO: Add your implementation code here
//REFERENCE_TIME t=0x7FFFFFFFFFFFFFFF;
//m_pBuilder->ControlStream(
// &PIN_CATEGORY_CAPTURE,//const GUID *pCategory,
// NULL,//const GUID *pType,
// NULL,//IBaseFilter *pFilter,
// NULL,//REFERENCE_TIME *pstart,
// &t,//REFERENCE_TIME *pstop,
// 0,//WORD wStartCookie,
// 0//WORD wStopCookie
// );
IMediaControl *pMediaControl;
HRESULT hr=m_pGrapher->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
if(hr==S_OK){
pMediaControl->Run();
pMediaControl->Release();
}
return hr;
}