⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recorddlg.cpp

📁 三汇CTI示例程序源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
						else
							strTrkstat = "Code-control";
					}
					break;
			}
			m_ChList.GetItemText(nIndex, 2, szOldStat, 10);
			if(strTrkstat != szOldStat)
			{
				m_ChList.SetItemText(nIndex, 2, strTrkstat.GetBuffer(30));
			}

			if(ChState[i].ConState == DTMF_CTRL)
			{
				m_ChList.GetItemText(nIndex, 3, szOldStat, 10);
				if(strcmp(szOldStat, "*") != 0) 
				{
					m_ChList.SetItemText(nIndex, 3, "*");
				}
			}
			else
				m_ChList.SetItemText(nIndex, 3, "");
			
			sprintf(szNewStat, "%s", ChState[i].szDTMF);			
			m_ChList.GetItemText(nIndex, 4, szOldStat, 99);
			if(strcmp(szNewStat, szOldStat) != 0) 
			{
				m_ChList.SetItemText(nIndex, 4, szNewStat);
			}
			
			m_ChList.SetItemText(nIndex, 5, ChState[i].szCallerId);  

			nIndex++;
		}
	}
}


LRESULT CRecordDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class

	int		nEventCode; //event ID
	int		nCh;		//channel ID
	int		nNewState;  //new state
	CString str;		//recording file 
	char	temp[1];	//latest DTMF character 
	WORD	wDtmf;

    //adoopt windows message mechanism
	//windows message code:event code + 0x7000(WM_USER)
	if((message > WM_USER) && (ChState[wParam].WorkState != -1))  
	{		
		nEventCode = message - WM_USER;	
		switch(nEventCode)
		{
		case E_SYS_BargeIn:   //BargeIn event is detected 
			{
				nCh = wParam; //wParam: number of channel output the event 
				if(ChState[nCh].bIgnoreLineVoltage)	//ignore voltage-detecting
				{
					if(ChState[nCh].WorkState == TRK_IDLE)
					{					
						if((ChState[nCh].ConState == VOICE_CTRL) && (lParam == 1))
						{						
							//recording file name + channel Id 
							str.Format("Test%d.wav", nCh);
							char *pRecFileName =(char *)(LPCTSTR)(str);
							if(SsmRecToFile(nCh, pRecFileName, -1, 0L, -1, -1, 0) == -1)  //start recording
							{
								WriteLog("failed to call function SsmRecToFile()");
							}
							ChState[nCh].WorkState =TRK_RECORD;						
						}					
					}
				}
				else
				{
					if(ChState[nCh].WorkState == TRK_PICKUP)
					{					
						if((ChState[nCh].ConState == VOICE_CTRL) && (lParam == 1))
						{						
							//recording file name + channel Id 
							str.Format("Test%d.wav", nCh);
							char *pRecFileName =(char *)(LPCTSTR)(str);
							if(SsmRecToFile(nCh, pRecFileName, -1, 0L, -1, -1, 0) == -1)  //start recording
							{
								WriteLog("failed to call function SsmRecToFile()");
							}
							ChState[nCh].WorkState =TRK_RECORD;						
						}					
					}
				}
			}
			break;

		case E_SYS_NoSound:
			{
				nCh = wParam; //wParam: number of channel output the event 
				if(ChState[nCh].bIgnoreLineVoltage)
				{
					if(ChState[nCh].WorkState == TRK_RECORD)
					{					
						if(ChState[nCh].ConState == VOICE_CTRL)
						{						
							if(SsmStopRecToFile(nCh) == -1)  //stop recording
							{
								WriteLog("failed to call function SsmStopRecToFile()");
							}
							ChState[nCh].WorkState =TRK_IDLE;						
						}					
					}
				}
			}
			break;

		case E_CHG_ChState:  //channel state change event
			{   				
				nCh = wParam; //wParam: number of channel output the event 
				nNewState = (int)(lParam & 0xFFFF); //lParam:DWORD(HWORD wOldState---old state,LWORD wNewState---new state)

				if(nNewState == S_CALL_STANDBY)
				{
					ChState[nCh].szDTMF[0]  = 0;	//clear DTMF buffer
					ChState[nCh].nIndex		= 0;
					ChState[nCh].WorkState  = TRK_IDLE;
					ChState[nCh].szCallerId[0] = 0;
					if(SsmStopRecToFile(nCh) == -1)  //stop recording
					{
						WriteLog("failed to call function SsmStopRecToFile()");
					}
					if(SsmClearRxDtmfBuf(nCh) == -1)  //clear dtmf receive buffer
					{
						WriteLog("failed to call function SsmClearRxDtmfBuf()");
					}
					
				}
				else if(nNewState == S_CALL_PICKUPED)
				{
					ChState[nCh].WorkState = TRK_PICKUP;

					//receive CallerId
					if(SsmGetCallerId(nCh, ChState[nCh].szCallerId) == -1)
					{
						WriteLog("failed to call function SsmGetCallerId()");
					}
				}
				else if(nNewState == S_CALL_OFFLINE)
				{
					if(SsmStopRecToFile(nCh) == -1)  //stop recording
					{
						WriteLog("failed to call function SsmStopRecToFile()");
					}
					ChState[nCh].WorkState = TRK_OUTLINE;
					if(SsmClearRxDtmfBuf(nCh) == -1)  //cleare DTMF receive buffer
					{
						WriteLog("failed to call function SsmClearRxDtmfBuf()");
					}
					ChState[nCh].szDTMF[0]  = 0;	//clear DTMF buffer
					ChState[nCh].nIndex		= 0;
				}

				switch(ChState[nCh].WorkState)
				{
		/*		case TRK_IDLE:
					{
						if(nNewState == S_CALL_RINGING)
						{
							ChState[nCh].WorkState = TRK_RINGING;
						}
						//receive CallerId
						if(SsmGetCallerId(nCh, ChState[nCh].szCallerId) == -1)
						{
							WriteLog("failed to call function SsmGetCallerId()");
						}
					}
					break;
		*/		case TRK_PICKUP:
					{
						if(ChState[nCh].ConState == VOLTAGE_CTRL)
						{																				
							if(nNewState == S_CALL_PICKUPED)
							{	//recording file name + channel Id
								str.Format("Test%d.wav", nCh);
								char *pRecFileName = (char *)(LPCTSTR)(str);
								if(SsmRecToFile(nCh, pRecFileName, -1, 0L, -1, -1, 0) == -1)  //start recording
								{
									WriteLog("failed to call function SsmRecToFile()");
								}
								ChState[nCh].WorkState = TRK_RECORD;								
							}
						}																																																								
					}
					break;
				case TRK_OUTLINE:
					{
						nCh = wParam;  //number of channel output the event
						if(nNewState == S_CALL_STANDBY)
						{
							ChState[nCh].WorkState  = TRK_IDLE;
						}
					}
					break;
				default:
					break;
				} //end of workstate				
			}																		
			break;
			
		case E_CHG_RcvDTMF:  //DTMF receive event
			{				
				nCh		= wParam;	//number of channel output the event 
				wDtmf	= (WORD)(lParam & 0xFFFF);	//DWORD(HWORD wDtmfLen:length of DTMFs received,LWORD wNewChar--new DTMF character received)
				*temp	= (char)wDtmf;	
				//store DTMF received into buffer 
				ChState[nCh].szDTMF[ChState[nCh].nIndex++] = *temp;
				if(ChState[nCh].nIndex >= 99)
				{
					ChState[nCh].nIndex = 0;
				}
				ChState[nCh].szDTMF[ChState[nCh].nIndex] = 0;

				if(ChState[nCh].WorkState == TRK_PICKUP)
				{
					if(ChState[nCh].ConState == DTMF_CTRL)
					{   
						if((*temp) == '*')
						{	//recording file name + channel Id
							str.Format("Test%d.wav", nCh);
							char *pRecFileName =(char *)(LPCTSTR)(str);
							if(SsmRecToFile(nCh, pRecFileName, -1, 0L, -1, -1, 0) == -1) //start recording
							{
								WriteLog("failed to call function SsmRecToFile()");
							}
							ChState[nCh].WorkState = TRK_RECORD;
						}
					}
				}
				else if(ChState[nCh].WorkState == TRK_RECORD)
				{
					if(ChState[nCh].ConState == DTMF_CTRL)
					{	
						if((*temp) == '*')
						{
							if(SsmStopRecToFile(nCh) == -1)  //stop recording
							{
								WriteLog("failed to call function SsmStopRecToFile()");
							}
							ChState[nCh].WorkState  = TRK_PICKUP;
						}
					}
				}
			}
			break;	
        
		case E_PROC_RecordEnd:	//recording end event
			{
				nCh = wParam;   //number of channel output the event 
				if(ChState[nCh].WorkState == TRK_RECORD)
				{
					ChState[nCh].WorkState = TRK_PICKUP;					
				}
			}
			break;

		case E_CHG_RingCount:
			nCh = wParam;
			if((ChState[nCh].WorkState == TRK_IDLE ) && (lParam == 2))
			{
				ChState[nCh].WorkState = TRK_RINGING;
				//receive CallerId
				if(SsmGetCallerId(nCh, ChState[nCh].szCallerId) == -1)
				{
					WriteLog("failed to call function SsmGetCallerId()");
				}
			}
			break;

		default:
			{
				return CDialog::WindowProc(message, wParam, lParam);
			}
			break;
		}//end of nEventCode

		UpdateChList();		//update list

	}//end of message
	
	return CDialog::WindowProc(message, wParam, lParam);
}


void CRecordDlg::OnRADIOConState()	//voice-control mode
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	int     nCurLine;
	char	sz[10];

	memset(sz, 0, sizeof(char)*10);
    m_CurLine.GetLBText(m_CurLine.GetCurSel(), sz);
	nCurLine = atoi(sz);
	ChState[nCurLine].ConState = VOICE_CTRL;
	UpdateChList();	
}


void CRecordDlg::OnRADIOConState1()  //voltage-control mode
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	int nCurLine;
    char	sz[10];

	memset(sz, 0, sizeof(char)*10);
    m_CurLine.GetLBText(m_CurLine.GetCurSel(), sz);
	nCurLine = atoi(sz);
	ChState[nCurLine].ConState = VOLTAGE_CTRL;
	UpdateChList();	
}


void CRecordDlg::OnRADIOConState2()  //code-control mode
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	int nCurLine;
    char	sz[10];

	memset(sz, 0, sizeof(char)*10);
    m_CurLine.GetLBText(m_CurLine.GetCurSel(), sz);
	nCurLine = atoi(sz);
	ChState[nCurLine].ConState = DTMF_CTRL;
	UpdateChList();	
}


void CRecordDlg::OnButtonPlay()		//play file
{
	// TODO: Add your control notification handler code here
	CPlayFile dlg;
	dlg.DoModal();	
}


void CRecordDlg::OnSelchangeCOMBOCurLine() 
{
	// TODO: Add your control notification handler code here
	int nCurLine;
	char sz[100];
	m_CurLine.GetLBText(m_CurLine.GetCurSel(), sz);
    nCurLine = atoi(sz);
	switch(ChState[nCurLine].ConState)
	{
	case VOICE_CTRL:		m_Constate = 0;		break;
	case VOLTAGE_CTRL:		m_Constate = 1;		break;
    case DTMF_CTRL:			m_Constate = 2;		break;
	}
	UpdateData(FALSE);	
}


void CRecordDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
	SsmCloseCti();		//close ShCti driver
}


void CRecordDlg::OnButtonListen()	//set listening
{
	// TODO: Add your control notification handler code here
	CListenDlg dlg;
	dlg.DoModal();	
}


void CRecordDlg::OnButtoSetagc()	//set AGC
{
	// TODO: Add your control notification handler code here
	CSetRecAGC dlg;
	dlg.DoModal();	
}


void CRecordDlg::InitLab()
{	
	if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
	{
		//Chinese
		strLab[0].Format("录音控制方式");
		strLab[1].Format("通道");
		strLab[2].Format("声控");
		strLab[3].Format("压控");
		strLab[4].Format("码控");
		strLab[5].Format("其他功能");
		strLab[6].Format("设置监听");
		strLab[7].Format("播放文件");
		strLab[8].Format("设置AGC");
		strLab[9].Format("退出");		
	}
	else
	{	//English
		strLab[0].Format("Recording Mode");	
		strLab[1].Format("Channel Id");
		strLab[2].Format("Voice-control");
		strLab[3].Format("Voltage-control");
		strLab[4].Format("Code-control");
		strLab[5].Format("OtherFunction");
		strLab[6].Format("SetListen");
		strLab[7].Format("PlayFile");
		strLab[8].Format("SetAGC");
		strLab[9].Format("Exit");
	}
	SetWinTextLab(this, IDC_STATIC_RecControl,	strLab[0]);
	SetWinTextLab(this, IDC_STATIC_Ch,			strLab[1]);
	SetWinTextLab(this, IDC_RADIO_ConState,		strLab[2]);
	SetWinTextLab(this, IDC_RADIO_ConState1,	strLab[3]);
	SetWinTextLab(this, IDC_RADIO_ConState2,	strLab[4]);
	SetWinTextLab(this, IDC_STATIC_OTHERS,		strLab[5]);
	SetWinTextLab(this, IDC_BUTTON_LISTEN,		strLab[6]);
	SetWinTextLab(this, IDC_BUTTON_PLAY,		strLab[7]);
	SetWinTextLab(this, IDC_BUTTO_SETAGC,		strLab[8]);
	SetWinTextLab(this, IDCANCEL,				strLab[9]);	
}


BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	InitLabAbout();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CAboutDlg::InitLabAbout()
{
	CString strLabAbout[10];
	if(g_dwLanguageConversion == g_dwCHINESE_SIMPLIFIED)
	{	
		//Chinese
		strLabAbout[0].Format("Record 1.0 版");
		strLabAbout[1].Format("版权所有 (C) 2006");
		strLabAbout[2].Format("确定");
	}
	else
	{
		//English
		strLabAbout[0].Format("V1.0");
		strLabAbout[1].Format("Copyright (c) 2006 All right reserved");
		strLabAbout[2].Format("OK");
	}
	SetWinTextLab(this, IDC_STATIC_EDITION ,	strLabAbout[0]);
	SetWinTextLab(this, IDC_STATIC_COPYRIGHT,	strLabAbout[1]);
	SetWinTextLab(this, IDOK,					strLabAbout[2]);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -