hd

Record.cpp 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "StdAfx.h"
  2. #include "Record.h"
  3. #include "Config.h"
  4. #include "CtiCore.h"
  5. #include "LogicLine.h"
  6. SINGLETON_IMPLEMENT(CRecord)
  7. CRecord::CRecord(void)
  8. {
  9. // 获取录音参数信息
  10. CConfig& Config = CConfig::GetInstance();
  11. m_RecordType = Config.recordType();
  12. m_RecordFormat = Config.recordFormat();
  13. m_FilePath = Config.recFilePath();
  14. }
  15. CRecord::~CRecord(void)
  16. {
  17. }
  18. /*****************************************************************
  19. **【函数名称】 __creatFileName
  20. **【函数功能】 创建录音文件路径以及录音文件名
  21. **【参数】 pLine; 待录音线路
  22. FileName: 输出参数,生成的录音文件名
  23. **【返回值】
  24. ****************************************************************/
  25. void CRecord::__creatFileName( CLogicLine* pLine, CString& FileName )
  26. {
  27. CTime TimeNow = CTime::GetCurrentTime();
  28. CString DateMark = TimeNow.Format(_T("%Y%m%d")); // 日期标识
  29. CString TimeMark = TimeNow.Format(_T("%H%M%S")); // 时间标识
  30. CString strRecForm = _T("mp3");
  31. switch (m_RecordFormat)
  32. {
  33. case RECORD_FORMAT_MP3:
  34. strRecForm = _T("mp3");
  35. break;
  36. case RECORD_FORMAT_WAV:
  37. strRecForm = _T("wav");
  38. break;
  39. default:
  40. strRecForm = _T("mp3");
  41. break;
  42. }
  43. FileName.Format(_T("%s\\%s\\%d\\%d_%d_%s.%s"), m_FilePath, DateMark, pLine->lineId(),
  44. pLine->callId(), pLine->lineId(), TimeMark, strRecForm);
  45. }
  46. /*****************************************************************
  47. **【函数名称】 StartRecord
  48. **【函数功能】 开始录音
  49. **【参数】
  50. **【返回值】 录音是否成功
  51. ****************************************************************/
  52. bool CRecord::record( CLogicLine* pLine, CString& RecFile )
  53. {
  54. //if(m_RecordType != RECORD_TYPE_TRUNK && m_RecordType != RECORD_TYPE_EXTEN)
  55. //{
  56. // ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("{Record}: 启动录音时检测出录音类型配置错误, 类型=%d"), m_RecordType);
  57. // return false;
  58. //}
  59. if(pLine == NULL) return false;
  60. if(m_RecordType == RECORD_TYPE_TRUNK && pLine->type() == DEV_RES_TYPE_EXT) return false;
  61. if(m_RecordType == RECORD_TYPE_EXTEN && pLine->type() != DEV_RES_TYPE_EXT) return false;
  62. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Record}: RecordLine = %d,RecordType=%d,pLineType=%d"), pLine->lineId(), m_RecordType, pLine->type());
  63. if(pLine->recordFile() != "") return false;
  64. // 获取录音文件名
  65. __creatFileName(pLine, RecFile);
  66. // 发送录音命令
  67. LineOpParam LineOpInfo;
  68. memset(&LineOpInfo,0,sizeof(LineOpInfo));
  69. LineOpInfo.nParam1 = LINE_RECORD_START; // 开始录音
  70. lstrcpy((LPSTR)LineOpInfo.szParam3, RecFile);
  71. CCtiCore::GetInstance().getDevLink().exec(-1, LINE_OP_RECORD, pLine->lineId(), &LineOpInfo);
  72. // 显示日志
  73. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Record}: 开始录音, RecordLine = %d, RecordFile = %s"), pLine->lineId(), RecFile);
  74. return true;
  75. }