📄 mmsserverdlg.cpp
字号:
CString str_path;
GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
str_path.ReleaseBuffer();
int index = str_path.ReverseFind('\\');
str_path= str_path.Left(index+1);
ConfigFile myfile((str_path+"CaptureServer.cfg").GetBuffer(MAX_PATH));
string spIP=myfile.Value("CaptureServer","spAddress");
string MMSAdress=myfile.Value("CaptureServer","MMSAddress");
////////Get The Data And Add it in ListControl
string strChannel;
strChannel.append(dlg.m_strChannel);
string Address = (string )dlg.m_strAddr;
string MMS ;
string Name;
int iCount = m_lstMMS.GetItemCount();
for(m_Item = 0 ; m_Item < iCount ; m_Item ++)
{
Name= string (m_lstMMS.GetItemText(m_Item,0));
MMS= string(m_lstMMS.GetItemText(m_Item,1));
if (Address == MMS && strChannel == Name)
{
MessageBox ("MMS地址和Channel Name与列表中其他条目有重复,请重新输入.");
return ;
}
else if(m_Item==iCount-1)
{
break;
}
else
continue ;
}
m_lstMMS.AddItem(dlg.m_strChannel,
dlg.m_strAddr,
"0.00",
"0",
"Stopped",
spIP.data(),
"0");
}
}
void CMMSServerDlg::OnBtnPlay()
{
int cout = m_lstMMS.GetItemCount();
for( int listitem = 0 ; listitem < cout ; listitem++)
{
CString temp = m_lstMMS.GetItemText(listitem,4);
if (m_lstMMS.GetItemText(listitem,4) == "Initializing")
return;
}
UINT i, uSelectedCount = m_lstMMS.GetSelectedCount();
int nItem = -1;
// Update all of the selected items.
if (uSelectedCount > 0)
{
for (i=0; i < uSelectedCount; i++)
{
nItem = m_lstMMS.GetNextItem(nItem, LVNI_SELECTED);
if(nItem == -1)
break;
//Set User Interface
m_lstMMS.SetItemText(nItem,4,"Initializing");
//Get from List
string channel = string (m_lstMMS.GetItemText(nItem,0));
string address = string (m_lstMMS.GetItemText(nItem,1));
string spIP = string (m_lstMMS.GetItemText(nItem,5));
//Get App Path
CString str_path;
GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
str_path.ReleaseBuffer();
int nPos;
nPos= str_path.ReverseFind('\\');
str_path= str_path=str_path.Left(nPos+1);
//write to CaptureServer.cfg
FILE *pfile = fopen(str_path+"CaptureServer.cfg","w");
fprintf(pfile,"%s\n","[CaptureServer]");
fprintf(pfile,"%s%s\n","channelName=",channel.data());
fprintf(pfile,"%s\n","userID=10040");
fprintf(pfile,"%s\n","password=ccc602a8ef81836cdd332ce0d31ef268");
fprintf(pfile,"%s%s\n","spAddress=",spIP.data());
fprintf(pfile,"%s\n","ReconnectTime=60");
fprintf(pfile,"%s%s\n","MMSAddress=",address.data());
fclose(pfile);
// add new mms to mmspool
string strChannelName;
strChannelName.append(channel);
string strMMSAddress;
strMMSAddress.append(address);
if(!m_MMSPool.AddNewMMS(strChannelName ,strMMSAddress ))
{
AfxMessageBox("连接mms服务器失败!");
//Set User Interface
m_lstMMS.SetItemText(nItem,4,"Stopped");
return;
}
if(!m_MMSPool.RunMMS(strChannelName)) {
m_lstMMS.SetItemText(nItem,4,"Stopped");
MessageBox("RunMMS failed!");
return;
}
}
}
}
void CMMSServerDlg::OnBtnPause()
{
UINT i, uSelectedCount = m_lstMMS.GetSelectedCount();
int nItem = -1;
// Update all of the selected items.
if (uSelectedCount > 0)
{
for (i=0; i < uSelectedCount; i++)
{
nItem = m_lstMMS.GetNextItem(nItem, LVNI_SELECTED);
if(nItem == -1)
break;
CString strChannel = m_lstMMS.GetItemText(nItem, 0);
string str;
str.append(strChannel);
if(!m_MMSPool.PauseMMS(str))
return ;
}
}
}
void CMMSServerDlg::OnBtnStop()
{
UINT i, uSelectedCount = m_lstMMS.GetSelectedCount();
int nItem = -1;
// Update all of the selected items.
if (uSelectedCount > 0)
{
for (i=0; i < uSelectedCount; i++)
{
nItem = m_lstMMS.GetNextItem(nItem, LVNI_SELECTED);
if(nItem == -1)
break;
CString strChannel = m_lstMMS.GetItemText(nItem, 0);
string str;
str.append(strChannel);
m_MMSPool.StopMMS(str);
}
}
}
void CMMSServerDlg::OnTimer(UINT nIDEvent)
{
UINT uCount = m_lstMMS.GetItemCount();
for(UINT i = 0;i < uCount; i++)
{
CString strChannel = m_lstMMS.GetItemText(i, 0);
CString strAddress = m_lstMMS.GetItemText(i, 1);
string str;
str.append(strChannel);
MMSGRAPHINFO *pInfo = m_MMSPool.GetMMSGraphInfo(str);
if(pInfo == NULL)
continue;
CString strTime;
strTime.Format("%d", pInfo->llTimeEscaped);
CString strState;
if(pInfo->mmsState == INIT)
strState = CString("Initializing");
else if(pInfo->mmsState == RUNNING)
strState = CString("Running");
else if(pInfo->mmsState == PAUSED)
strState = CString("Paused");
else if(pInfo->mmsState == STOPPED)
strState = CString("Stopped");
else if(pInfo->mmsState == RECONNECTING)
strState = CString("Reconnecting");
CString strDataRate;
strDataRate.Format("%.2f", pInfo->fDataRate);
CString strTotalByte;
strTotalByte.Format("%I64d",pInfo->fTotalBytes);
// TRACE(strDataRate);
//CString DebugInfo;
//DebugInfo.Format(" %d,%s,%f\n",i,str.data(),pInfo->fDataRate);
// TRACE(DebugInfo);
m_lstMMS.SetItemText(i, 2, strDataRate);
m_lstMMS.SetItemText(i, 3, strTime);
m_lstMMS.SetItemText(i, 4, strState);
m_lstMMS.SetItemText(i, 6, strTotalByte);
}
CDialog::OnTimer(nIDEvent);
}
void CMMSServerDlg::OnBtnDeleteMms()
{
UINT i, uSelectedCount = m_lstMMS.GetSelectedCount();
int nItem = -1;
KillTimer(m_dwTimer);
// Update all of the selected items.
if (uSelectedCount > 0)
{
for (i=0; i < uSelectedCount; i++)
{
nItem = m_lstMMS.GetNextItem(nItem, LVNI_SELECTED);
if(nItem == -1)
return;
CString strChannel = m_lstMMS.GetItemText(nItem, 0);
string str;
str.append(strChannel);
m_MMSPool.RemoveMMS(str);
m_lstMMS.DeleteItem(nItem);
}
}
m_dwTimer = SetTimer(100, 1000, NULL);
}
void CMMSServerDlg::OnClickListMms(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code h
m_Index = m_lstMMS.GetSelectionMark();
name = m_lstMMS.GetItemText(m_Index,0);
mmsadress = m_lstMMS.GetItemText(m_Index,1);
superpeerIP = m_lstMMS.GetItemText(m_Index,5);
*pResult = 0;
}
void CMMSServerDlg::OnButtonEdit()
{
UINT i, uSelectedCount = m_lstMMS.GetSelectedCount();
int nItem = -1;
KillTimer(m_dwTimer);
// Update all of the selected items.
if (uSelectedCount > 0)
{
for (i=0; i < uSelectedCount; i++)
{
nItem = m_lstMMS.GetNextItem(nItem, LVNI_SELECTED);
if(nItem == -1)
break;
MMSINFO dlg;
dlg.m_ChannelName = m_lstMMS.GetItemText(nItem, 0);
dlg.m_MMSADDR = m_lstMMS.GetItemText(nItem, 1);
dlg.m_SPIP = m_lstMMS.GetItemText(nItem, 5);
if( dlg.DoModal())
{
m_lstMMS.SetItemText(m_Index,0,dlg.m_ChannelName);
m_lstMMS.SetItemText(m_Index,1,dlg.m_MMSADDR);
m_lstMMS.SetItemText(m_Index,5,dlg.m_SPIP);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -