| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #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_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")); // 时间标识
- FileName.Format(_T("%s\\%s\\%d\\%d_%d_%s.wav"), m_FilePath, DateMark, pLine->lineId(),
- pLine->callId(), pLine->lineId(), TimeMark);
- }
- /*****************************************************************
- **【函数名称】 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;
- 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;
- }
|