#include "StdAfx.h" #include "Record.h" #include "Config.h" #include "CtiCore.h" #include "LogicLine.h" SINGLETON_IMPLEMENT(CRecord) CRecord::CRecord(void) { // 获取录音参数信息 CConfig& Config = CConfig::GetInstance(); m_RecordType = Config.recordType(); m_RecordFormat = Config.recordFormat(); m_FilePath = Config.recFilePath(); } CRecord::~CRecord(void) { } /***************************************************************** **【函数名称】 __creatFileName **【函数功能】 创建录音文件路径以及录音文件名 **【参数】 pLine; 待录音线路 FileName: 输出参数,生成的录音文件名 **【返回值】 ****************************************************************/ void CRecord::__creatFileName( CLogicLine* pLine, CString& FileName ) { CTime TimeNow = CTime::GetCurrentTime(); CString DateMark = TimeNow.Format(_T("%Y%m%d")); // 日期标识 CString TimeMark = TimeNow.Format(_T("%H%M%S")); // 时间标识 CString strRecForm = _T("mp3"); switch (m_RecordFormat) { case RECORD_FORMAT_MP3: strRecForm = _T("mp3"); break; case RECORD_FORMAT_WAV: strRecForm = _T("wav"); break; default: strRecForm = _T("mp3"); break; } FileName.Format(_T("%s\\%s\\%d\\%d_%d_%s.%s"), m_FilePath, DateMark, pLine->lineId(), pLine->callId(), pLine->lineId(), TimeMark, strRecForm); } /***************************************************************** **【函数名称】 StartRecord **【函数功能】 开始录音 **【参数】 **【返回值】 录音是否成功 ****************************************************************/ bool CRecord::record( CLogicLine* pLine, CString& RecFile ) { //if(m_RecordType != RECORD_TYPE_TRUNK && m_RecordType != RECORD_TYPE_EXTEN) //{ // ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("{Record}: 启动录音时检测出录音类型配置错误, 类型=%d"), m_RecordType); // return false; //} if(pLine == NULL) return false; if(m_RecordType == RECORD_TYPE_TRUNK && pLine->type() == DEV_RES_TYPE_EXT) return false; if(m_RecordType == RECORD_TYPE_EXTEN && pLine->type() != DEV_RES_TYPE_EXT) return false; ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Record}: RecordLine = %d,RecordType=%d,pLineType=%d"), pLine->lineId(), m_RecordType, pLine->type()); if(pLine->recordFile() != "") return false; // 获取录音文件名 __creatFileName(pLine, RecFile); // 发送录音命令 LineOpParam LineOpInfo; memset(&LineOpInfo,0,sizeof(LineOpInfo)); LineOpInfo.nParam1 = LINE_RECORD_START; // 开始录音 lstrcpy((LPSTR)LineOpInfo.szParam3, RecFile); CCtiCore::GetInstance().getDevLink().exec(-1, LINE_OP_RECORD, pLine->lineId(), &LineOpInfo); // 显示日志 ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Record}: 开始录音, RecordLine = %d, RecordFile = %s"), pLine->lineId(), RecFile); return true; }