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

📄 recdemo.cpp

📁 三汇CTI示例程序源码
💻 CPP
字号:
// RecDemo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "../../../../api/vc6.0/inc/Shpa3api.h"

enum{
	CHKRECORD_APPLICATION_END = 1,		//应用程序中止 
	CHKRECORD_DTMF_END = 2,				//DTMF中止 
	CHKRECORD_REMOTEHANGUP_END = 3,		//远端挂机中止 
	CHECKRECORD_TIMEUP_END = 4,			//录音到达用户指定长度 
	CHECKRECORD_FILE_PAUSED = 5,		//文件录音被暂停 
	CHECKRECORD_FILE_WRITE_ERROR = 6	//文件录音文件句柄写错误中止 
};

int i=0;
char	szErrMsg[300];
EVENT_SET_INFO EventSet;
#define E_PROC_RecordEnd  0x0013
#define E_PROC_RecordFile 0x0014  
//define the function pointer
typedef int (WINAPI *pFun)(WORD,int,DWORD,DWORD);		

//file record
void RecordFile(int Ch, char* FileName)		
{
	int nResult = SsmRecToFile(Ch,FileName,-1,0L,-1,10,0);
	if(nResult == -1)
	{
		printf("\nerr ch=%d path = %s",Ch,FileName);
		SsmGetLastErrMsg(szErrMsg);
		printf(szErrMsg);
	}
}

// pause file record
void PauseRec(int Ch)				
{
	int nResult = SsmPauseRecToFile(Ch);
	if(nResult == -1)
	{
		SsmGetLastErrMsg(szErrMsg);
		printf(szErrMsg);
	}
}
//restart record after pausing record
void RestartRec(int Ch)				
{
	int nResult = SsmRestartRecToFile(Ch);
	if(nResult == -1)
	{
		SsmGetLastErrMsg(szErrMsg);
		printf(szErrMsg);
	}
}

//stop record
void StopRecordFile(int Ch)		
{
	int nResult = SsmStopRecToFile(Ch);
	if(nResult == -1)
	{
		SsmGetLastErrMsg(szErrMsg);
		printf(szErrMsg);
	}
}
//callback function
int WINAPI CallBackFun(WORD wEvent, int nReference, DWORD dwParam, DWORD dwUser)
{
	switch(wEvent&0xffff)
	{
	case E_PROC_RecordEnd:
		switch(dwParam)
		{
		case CHKRECORD_APPLICATION_END:	
			printf("\n stop the recording and application \n");
			break;
		case CHECKRECORD_TIMEUP_END:	
			printf("\n the record is finish because the length recorded is same with the user define\n");
			break;
		case CHECKRECORD_FILE_PAUSED:	
			printf("\nthe record is paused\n");
			break;
		case CHECKRECORD_FILE_WRITE_ERROR:	
			printf("\nthe record is stop because failing to write file\n");
			break;
		default:
			break;
		}
		break;
	case E_PROC_RecordFile:
		if(i%7 == 0)		//print the time of recording every seven second
			printf("\nchannel %d record time is %dms	",nReference,dwParam);
		i++;
		break;
	default:
		break;
	}
	return 0;
}


int main(int argc, char* argv[])
{
	char* pcCh;
	int nCh = -1;
	char* pcFilePath;
	char szCommline[80];
	char* pcComm;
	int nIsSsmStartCtiOK;
	bool bIsInitError;
	//initiate board 
	nIsSsmStartCtiOK = SsmStartCti("ShConfig.ini", "ShIndex.ini");
	if(nIsSsmStartCtiOK != 0)
	{
		bIsInitError = true;
		SsmGetLastErrMsg(szErrMsg);
		printf(szErrMsg);
		bIsInitError = false;
		return 0;
	}
	if(SsmGetMaxUsableBoard() != SsmGetMaxCfgBoard())
	{
		bIsInitError = true;
		SsmGetLastErrMsg(szErrMsg);
		printf("\nWARNNING: sum of boards=%d, sum of success to initiate boards=%d!\n ErrMsg=\"%s\"",
					SsmGetMaxCfgBoard(),
					SsmGetMaxUsableBoard(),
					szErrMsg);
		bIsInitError = false;
		return 0;
	}
	//set the callback mode 
	pFun EventCallBackProc = CallBackFun;
	EventSet.dwWorkMode = EVENT_CALLBACK;	
	EventSet.lpHandlerParam = EventCallBackProc;
	SsmSetEvent(-1, -1, 1, &EventSet);

	printf("\nplease input command and channel id ");
	printf("\nexample:		");
	printf("\n	rec nCh filename	to start recording");
	printf("\n	pause nCh		to pause recording");
	printf("\n	restart nCh		to restart recording");
	printf("\n	stop nCh		to stop recording");
	printf("\n	quit			to quit the app");
	printf("\n		notice: the format is command+space+nch+space+filename");

	for(;;)
	{
		printf("\n*CLI>");
		gets(szCommline);
		if(*szCommline == 0)
		{
			printf("\nplease input correct command");
			continue;
		}
			
		pcComm = strtok(szCommline, " ");
		if(!stricmp(pcComm,"rec"))
		{
			pcCh = strtok(NULL, " ");
			if(pcCh == NULL)
			{
				printf("\nplease input correct command");
				continue;
			}
			nCh = atoi(pcCh);
			pcFilePath = strtok(NULL, " ");
			if(pcFilePath == NULL)
			{
				printf("\nplease input correct command");
				continue;
			}
			RecordFile(nCh,pcFilePath);
		}
		else if(!stricmp(pcComm, "pause"))
		{
			pcCh = strtok(NULL, " ");
			if(pcCh == NULL)
			{
				printf("\nplease input correct command");
				continue;
			}
				
			nCh = atoi(pcCh);
			PauseRec(nCh);
		}
		else if(!stricmp(pcComm, "restart"))
		{
			pcCh = strtok(NULL, " ");
			if(pcCh == NULL)
			{
				printf("\nplease input correct command");
				continue;
			}
			nCh = atoi(pcCh);
			RestartRec(nCh);
		}
		else if(!stricmp(pcComm, "stop"))
		{
			pcCh = strtok(NULL, " ");
			if(pcCh == NULL)
			{
				printf("\nplease input correct command");
				continue;
			}
			nCh = atoi(pcCh);
			StopRecordFile(nCh);
		}
		else if(!stricmp(pcComm, "quit"))
		{
			break;
		}
	}
	SsmCloseCti();	
	return 0;
}





⌨️ 快捷键说明

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