int CRevPlayWnd::ReceiveData()
{//接收组播数据
CString msg;
int status;
DWORD cbRet;
DWORD dFlag;
int iLen;
SOCKADDR_IN stSrcAddr;
cbRet = 0;
iLen = sizeof (stSrcAddr);
dFlag = 0;
//接收组播数据,存放到缓冲区stWSABuf中
status = WSARecvFrom (MultiSock, /* socket */
&stWSABuf, /* input buffer structure */
1, /* buffer count */
&cbRet, /* number of bytes recv'd */
&dFlag, /* flags */
(struct sockaddr *)&stSrcAddr,/* source address */
&iLen, /* size of addr structure */
NULL, /* overlapped structure */
NULL); /* overlapped callback function */
if (status == SOCKET_ERROR)
{
//数据丢失,丢失的块数计数加1
m_LostBlock++;
msg.Format ("WSARecvFrom() failed, Err:%d", WSAGetLastError());
MessageBox (msg);
return -1;
}
return cbRet;
}
void CRevPlayWnd::OnSave()
{
// TODO: Add your command handler code here
m_Save=!m_Save;
DWORD dwFlags;
CString SaveFileName;
CString strSave;
TCHAR Driver;
CFileDialog dlg(TRUE,NULL,"temp.mpg",NULL,"mpeg文件(*.mpg)|*.mpg|AVI文件(*.avi)|*.avi");
dlg.m_ofn.lpstrTitle="保存到...";
if(dlg.DoModal()==IDOK)
{
SaveFileName=dlg.GetPathName();
Driver=SaveFileName.GetAt(0);
CWnd* pParent = GetOwner();
strSave.Format("保存到:%s",SaveFileName);
CMainFrame* pFrame=(CMainFrame*)pParent->GetOwner();
// pFrame->m_wndStatusBar.SetPaneText(1,strSave);
}
dwFlags = MMIO_CREATE | MMIO_WRITE;
hmmioSave = mmioOpen(SaveFileName.GetBuffer(_MAX_PATH), (LPMMIOINFO)NULL, dwFlags);
SaveFileName.ReleaseBuffer();
}