void CRevPlayWnd::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_POP_MENU);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
}
void CRevPlayWnd::OnStopReceive()
{
// TODO: Add your command handler code here
StopReceive();
m_Save=FALSE;
m_FirstRead=TRUE;
m_RenderOk=FALSE;
m_Stop=FALSE;
rIndex=0;
}
int CRevPlayWnd::InitGraph()
{//构建Filter Graph
HRESULT hr;
hr = S_OK;
//设置媒体类型,为MPEG1数据流
mt.majortype = MEDIATYPE_Stream;
mt.subtype = MEDIASUBTYPE_MPEG1System;
//创建Source Filter
m_pStream = new CMemStream(achInBuf, 0x80000000, INFINITE);
m_pStream->pWnd=this;
m_rdr = new CMemReader(m_pStream, &mt, &hr);
if(FAILED(hr) || m_rdr == NULL)
{
MessageBox("CMemReader Error");
return -1;
}
m_rdr -> AddRef();
//创建Filter Graph
CHECK_ERROR(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IFilterGraph, (void**)&m_pifg),"CoCreateInstance Error") ;
//将Source Filter加入到Filter Graph中
CHECK_ERROR(m_pifg -> AddFilter(m_rdr, NULL), "AddFilter Error");
//查询IGraphBuilder接口
CHECK_ERROR(m_pifg -> QueryInterface(IID_IGraphBuilder, (void **)&m_pigb),"QueryInterface(IGraphBuilder) Error");
m_pigb->AddRef ();
//查询IMediaControl接口
CHECK_ERROR(m_pigb -> QueryInterface(IID_IMediaControl, (void **)&m_pimc),"QueryInterface(IMediaControl) Error");
m_pimc->AddRef ();
//查询IVideoWindow接口
CHECK_ERROR(m_pigb -> QueryInterface(IID_IVideoWindow, (void **)&m_pivw),"QueryInterface(IVideoWindow) Error");
m_pivw->AddRef ();
//查询IMediaPosition接口
CHECK_ERROR(m_pigb -> QueryInterface(IID_IMediaPosition, (void **)&m_ppos),"QueryInterface(IMediaPosition) Error");
m_ppos->AddRef ();
return 0;
}