123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770 |
- #include "stdafx.h"
- #include "mod_SalesRecorder.h"
- #include "Event.h"
- #include "rvc_media_common.h"
- #include "fileutil.h"
- #include "array.h"
- #include <memutil.h>
- #include <algorithm>
- #include "y2k_time.h"
- #ifdef RVC_OS_WIN
- #include <Windows.h>
- #else
- #include <dirent.h>
- #include <sys/ioctl.h>
- #include <sys/stat.h>
- #include <sys/fcntl.h>
- #endif
- #include "mod_customeraware/Event.h"
- #include "mod_facetracking/sysvar.h"
- #include "mod_mediacontroller/Event.h"
- #include "mod_interactivecontrol/Event.h"
- #include <assert.h>
- #include "EventCode.h"
- #include <string.h>
- #include "filecryption.h"
- #ifndef RVC_MIN_FILESIZE
- #define RVC_MIN_FILESIZE 10240
- #endif
- #ifndef MAX_LOG_LEN
- #define MAX_LOG_LEN 512
- #endif
- #define MAX_DISK_PERCENT 95 // 磁盘最大占用百分比
- static const char* record_failed_case_table[] = {
- "[RTA3L01] 启动录像失败,初始化失败",
- "[RTA3L02] 启动录像失败,字体为空,添加水印失败",
- "[RTA3L03] 开始录像失败,请稍后(约30秒)再试",
- "[RTA3L04] 录像失败,摄像头故障,获取不到视频,请联系厂商进行维修",
- "[RTA3L05] 录像失败,获取不到远端音频,请检查风险提示音是否正常播放且音量大小是否正常",
- "[RTA3L06] 录像失败,麦克风故障,获取不到本地音频,请联系厂商进行维修",
- "[RTA3L07] 录像失败,系统不支持当前音频采样率",
- "[RTA3L08] 录像失败,音频流写入失败,请稍后(约30秒)再试",
- "[RTA3L09] 录像失败,获取不到远端视频,请稍后(约30秒)再试"
- };
- static BOOL CheckDiskStatus(const char *szRoot, int nPercent, int *pFreeRatio)
- {
- //todo 调用resourcewatcher
- return TRUE;
- }
- static int hch2int(char hch)
- {
- if (hch >= '0' && hch <= '9')
- return hch-'0';
- else if (hch >= 'a' && hch <= 'f')
- return hch-'a'+10;
- else if (hch >= 'A' && hch <= 'F')
- return hch-'A'+10;
- return 0;
- }
- static long hexstr2int(const char *str, int len)
- {
- long result = 0;
- if (str && len <= strlen(str)) {
- for (int i = 0; i < len; ++i) {
- result += (hch2int(str[i]) << ((len-i-1) << 2));
- }
- }
- return result;
- }
- static CSimpleStringA VideoSerialID2TimeString(const char *videoserialid)
- {
- DWORD nTimeTicks = hexstr2int(videoserialid,8);
- return ((CSmallDateTime)nTimeTicks).ToTimeString();
- }
- static void CStringSplit(char* str, char** result, const char* del)
- {
- char* pdata = NULL;
- char* p = NULL;
- //TODO: CrossPlaform [Gifur@2025730]
- #ifdef RVC_OS_WIN
- p = strtok_s(str, del, &pdata);
- #else
- p = strtok_r(str, del, &pdata);
- #endif // RVC_OS_WIN
- while (p != NULL) {
- *result++ = p;
- #ifdef RVC_OS_WIN
- p = strtok_s(NULL, del, &pdata);
- #else
- p = strtok_r(NULL, del, &pdata);
- #endif
- }
- }
- static bool rvcMoveFile(const char* strSrcFile, const char* strDstFile)
- {
- bool bRet = false;
- if (NULL == strSrcFile || NULL == strDstFile) {
- return bRet;
- }
- //TODO: CrossPlaform [Gifur@2025730]
- #ifdef RVC_OS_WIN
- bRet = MoveFile(strSrcFile, strDstFile);
- #else
- if (0 == rename(strSrcFile, strDstFile)) {
- bRet = true;
- }
- #endif // RVC_OS_WIN
- return bRet;
- }
- //TODO: CrossPlaform [Gifur@2025728]
- static bool RvcDeleteFile(const char* strSrcFile)
- {
- bool bRet = false;
- if (NULL == strSrcFile) {
- return bRet;
- }
- #ifdef RVC_OS_WIN
- bRet = DeleteFile(strSrcFile);
- #else
- if (0 == remove(strSrcFile)) {
- bRet = true;
- }
- #endif // RVC_OS_WIN
- return bRet;
- }
- #ifdef RVC_OS_WIN
- // 寻找某目录下与通配符匹配的文件
- static bool FindMatchedFile(const char* pstrFindPath, const char* pstrFindFileName, uint32_t & uCountFile)
- {
- char sPath[MAX_PATH] = {0};
- char sFormatFileName[MAX_PATH + 2] = "*";
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
- bool fFinished = false;
- strcpy(sFormatFileName, pstrFindPath);
- if (pstrFindPath[strlen(pstrFindPath) - 1] != SPLIT_SLASH)
- {
- strcat(sFormatFileName, SPLIT_SLASH_STR);
- strcat(sFormatFileName, "*");
- }
- else
- {
- strcat(sFormatFileName, "*");
- }
- strcat(sFormatFileName, pstrFindFileName);
- strcat(sFormatFileName, "*");
- hFind = FindFirstFile(sFormatFileName, &FindFileData);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- return false;
- }
- else
- {
- while (!fFinished)
- {
- strcpy(sPath, pstrFindPath);
- if (sPath[strlen(sPath) - 1] != SPLIT_SLASH)
- {
- strcat(sPath, SPLIT_SLASH_STR);
- }
- strcat(sPath, FindFileData.cFileName);
- if (!(FILE_ATTRIBUTE_DIRECTORY & FindFileData.dwFileAttributes))
- {
- ++uCountFile;
- }
- if (!FindNextFile(hFind, &FindFileData))
- {
- if (GetLastError() == ERROR_NO_MORE_FILES)
- {
- fFinished = true;
- }
- else
- {
- break;
- }
- }
- }
- FindClose(hFind);
- }
- return true;
- }
- #else
- static bool FindMatchedFile(const char* sFindPath, const char* sFindFileName, uint32_t& uCountFile)
- {
- bool bRet = false;
- DIR* pDir = NULL;
- struct dirent* pFile = NULL;
- CSimpleStringA tmpFindFileName = sFindFileName;
- pDir = opendir(sFindPath);
- if (pDir == NULL) {
- return bRet;
- }
- //linux不支持*查找,去掉后缀
- char strsuffix[MAX_PATH] = { 0 };
- snprintf(strsuffix, MAX_PATH, "*.%s", RECORD_MP4_SUFFIX);
- if (tmpFindFileName.IsEndWith(strsuffix)) {
- tmpFindFileName = tmpFindFileName.SubString(0, tmpFindFileName.GetLength() - 5);
- }
- while ((pFile = readdir(pDir)) != NULL) {
- if (pFile->d_type & DT_DIR) {
- continue;
- }
- else {
- if (0 == _strnicmp(pFile->d_name, tmpFindFileName.GetData(), tmpFindFileName.GetLength())) {
- ++uCountFile;
- bRet = true;
- }
- }
- }
- closedir(pDir);
- return bRet;
- }
- #endif
- static CSimpleStringA DecryptString(const char* lpszEncrpyted)
- {
- if (NULL == lpszEncrpyted) {
- return CSimpleStringA("");
- }
- int iEncrypt = 0;
- int len = strlen(lpszEncrpyted);
- CSimpleStringA csPlainTxt('\0', (len) / 2 + 1);
- int iCh = 0;
- for (int i = 0; i < len; i += 2) {
- sscanf(lpszEncrpyted + i, "%02X", &iCh);
- csPlainTxt[i / 2] = (char)(((char)iCh) ^ (128 | (iEncrypt++ & 127)));
- }
- return CSimpleStringA((LPCTSTR)csPlainTxt);
- }
- //TODO: CrossPlaform [Gifur@2025730]
- static unsigned long GetFileSize(const char* pfilename)
- {
- #ifdef RVC_OS_WIN
- unsigned long usize = 0;
- if (NULL == pfilename) {
- return usize;
- }
- FILE* pFile = fopen(pfilename, "rb");
- if (pFile) {
- fseek(pFile, 0, SEEK_END);
- usize = ftell(pFile);
- fclose(pFile);
- }
- return usize;
- #else
- struct stat statbuf;
- if (0 == stat(pfilename, &statbuf)) {
- return statbuf.st_size;
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("errno info is %s.", strerror(errno));
- return 0;
- }
- #endif
- }
- static void rvcDbg(filecrypt_loglevel elevel, const char* fmt, ...)
- {
- va_list arg;
- va_start(arg, fmt);
- int n = vsnprintf(NULL, 0, fmt, arg);
- if (n >= MAX_LOG_LEN) {
- char* buf = (char*)malloc((size_t)(n + 1));
- vsnprintf(buf, n + 1, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", buf);
- free(buf);
- }
- else {
- char strlog[MAX_LOG_LEN] = { 0 };
- vsnprintf(strlog, MAX_LOG_LEN, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", strlog);
- }
- va_end(arg);
- }
- void SalesRecordServiceSession::Handle_GetOFLVideoRecords( SpReqAnsContext<SalesRecorderSerVice_GetOFLVideoRecords_Req, SalesRecorderSerVice_GetOFLVideoRecords_Ans>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_CheckVideoDiskStatus( SpReqAnsContext<SalesRecorderSerVice_CheckVideoDiskStatus_Req, SalesRecorderSerVice_CheckVideoDiskStatus_Ans>::Pointer ctx )
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- int nFreeRatio = 0;
- int bSufficient = CheckDiskStatus(ctx->Req.DriveLetter.GetData(), m_pEntity->GetMaxDiskPercent(), &nFreeRatio);
- ctx->Ans.IsSufficient = bSufficient;
- ctx->Ans.FreeRatio = nFreeRatio;
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_PlayVideo(SpReqAnsContext<SalesRecorderSerVice_PlayVideo_Req, SalesRecorderSerVice_PlayVideo_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_SaveVideo(SpReqAnsContext<SalesRecorderSerVice_SaveVideo_Req, SalesRecorderSerVice_SaveVideo_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ErrorCodeEnum ErrorCode = m_pEntity->HandleSaveVideo();
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_StopRecord(SpReqAnsContext<SalesRecorderSerVice_StopRecord_Req, SalesRecorderSerVice_StopRecord_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ErrorCodeEnum ErrorCode = m_pEntity->HandleStopRecord(CSimpleStringW2A(ctx->Req.VideoName).GetData());
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_SetAudioTransFlag(SpReqAnsContext<SalesRecorderSerVice_SetAudioTransFlag_Req, SalesRecorderSerVice_SetAudioTransFlag_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_StopShowVideo(SpReqAnsContext<SalesRecorderSerVice_StopShowVideo_Req, SalesRecorderSerVice_StopShowVideo_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_PlaySalesRecord(SpReqAnsContext<SalesRecorderSerVice_PlaySalesRecord_Req, SalesRecorderSerVice_PlaySalesRecord_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_StartRemoteRecord(SpReqAnsContext<SalesRecorderSerVice_StartRemoteRecord_Req, SalesRecorderSerVice_StartRemoteRecord_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ErrorCodeEnum ErrorCode = m_pEntity->HandleStartRecord(ctx->Req.VideoName.GetData(), true);
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_DeleteVideo(SpReqAnsContext<SalesRecorderSerVice_DeleteVideo_Req, SalesRecorderSerVice_DeleteVideo_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ErrorCodeEnum ErrorCode = m_pEntity->HandleDeleteVideo();
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_AppendWatermark(SpReqAnsContext<SalesRecorderSerVice_AppendWatermark_Req, SalesRecorderSerVice_AppendWatermark_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- #ifdef RVC_OS_WIN
- ErrorCodeEnum ErrorCode = m_pEntity->HandleVideoAppendWatermark(CSimpleStringW2A(ctx->Req.VideoName).GetData(), CSimpleStringW2A(ctx->Req.Watermark).GetData());
- #else
- ErrorCodeEnum ErrorCode = m_pEntity->HandleVideoAppendWatermark(CSimpleStringW2A(ctx->Req.VideoName).GetData(), ctx->Req.Watermark.GetData());
- #endif
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_SetRecordCamera(SpReqAnsContext<SalesRecorderSerVice_SetRecordCamera_Req, SalesRecorderSerVice_SetRecordCamera_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- ErrorCodeEnum ErrorCode = m_pEntity->SetRecordCamera(ctx->Req.iCamera);
- ctx->Answer(ErrorCode);
- }
- CServerSessionBase * CSalesRecorderEntity::OnNewSession( const char* pszRemoteEntityName, const char * pszClass )
- {
- return new SalesRecordServiceSession(this);
- }
- void CSalesRecorderEntity::OnPreStart( CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext )
- {
- ErrorCodeEnum Error = __OnStart(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- }
- ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
- {
- //MessageBoxA(0,0,0,0);
- m_eDeviceType = eStand2sType;
- m_bNeedRestart = false;
- #ifdef RVC_OS_WIN
- m_xIdlePre = m_xKernelPre = m_xUserPre = 0;
- if (SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set Process(%d) RealTime Priority Success.", GetCurrentProcessId());
- }
- #endif // RVC_OS_WIN
- m_eDeviceType = RvcGetDeviceType();
- if (preOperationError != Error_Succeed) {
- return preOperationError;
- }
- ErrorCodeEnum Error = Error_Succeed;
- m_iActiveCamera = CAMERA_TYPE_ENV;
- m_iCameraState = 'N';
- m_iRecordCamera = CAMERA_TYPE_ENV;
-
- int i = 0;
- m_arrListener.Init(4);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_RETURNMENU, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_High, Error_IgnoreAll, LOG_EVT_SALESRECORD_ENTITY_EXCEPTION, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_SALESRECORD_SECTION_FINISHED, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_SALESRECORD_WHOLE_FINISHED, NULL, false);
- GetFunction()->RegistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA,this);
- GetFunction()->RegistSysVarEvent(SYSVAR_CAMERASTATE,this);
- CSimpleStringA strValue;
- GetFunction()->GetSysVar(SYSVAR_CAMERASTATE, strValue);
- m_iCameraState = strValue[0];
- if (strValue[0] == 'E'){
- m_iActiveCamera = CAMERA_TYPE_OPT;
- }
- else{
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- Error = GetFunction()->GetPath("Temp", m_TempDir);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get global record temp path failed!");
- }
- if (m_TempDir.GetLength() > 0 && m_TempDir[m_TempDir.GetLength()-1] != SPLIT_SLASH) {
- m_TempDir += SPLIT_SLASH_STR;
- }
- Error = GetFunction()->GetPath("UploadVideo", m_RecordSaveDir);
- if (Error != Error_Succeed) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get global record save path failed!");
- }
- if (m_RecordSaveDir.GetLength() > 0 && m_RecordSaveDir[m_RecordSaveDir.GetLength()-1] != SPLIT_SLASH) {
- m_RecordSaveDir += SPLIT_SLASH_STR;
- }
- return Error;
- }
- void CSalesRecorderEntity::OnStarted()
- {
- m_eAudioOutQuality = eUltraHD;
- m_bIsAudioNsOn = false;
- m_iAudioNsPolicy = 2;
- m_iAudioChannels = 1;
- m_bWholeSection = false;
- m_bEncFlag = true;
- m_iRemoteRecordType = 0;
- GetEntityConfig();
- #ifndef RVC_OS_WIN
- InitSalesRecorder();
- #endif
- LogEvent(Severity_Middle, LOG_EVT_MOD_SALESRECORDER_STARTED_SUCCESS, "sales recorder entity started successfully.");
- }
- void CSalesRecorderEntity::OnPreClose( EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext )
- {
- ErrorCodeEnum Error = __OnClose(Error_Succeed);
- pTransactionContext->SendAnswer(Error);
- }
- ErrorCodeEnum CSalesRecorderEntity::__OnClose( ErrorCodeEnum preOperationError )
- {
- if (preOperationError != Error_Succeed) {
- return preOperationError;
- }
-
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- for (int i = 0; i < m_arrListener.GetCount(); ++i) {
- spFunction->UnsubscribeLog(m_arrListener[i]);
- }
- GetFunction()->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
- GetFunction()->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
- StopRecord();
- #ifndef RVC_OS_WIN
- ReleaseSalesRecorder();
- #endif
- return Error_Succeed;
- }
- void CSalesRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- if (Test_ShakeHand == eTestType)
- {
- if (m_bNeedRestart){
- pTransactionContext->SendAnswer(Error_Unexpect);
- }
- else{
- pTransactionContext->SendAnswer(Error_Succeed);
- }
- }
- }
- void CSalesRecorderEntity::Debug(record_loglevel elevel, const char* fmt, ...)
- {
- va_list arg;
- va_start(arg, fmt);
- int n = vsnprintf(NULL, 0, fmt, arg);
- if (n >= MAX_PATH) {
- char* buf = (char*)malloc((size_t)(n + 1));
- vsnprintf(buf, n + 1, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", buf);
- free(buf);
- }
- else {
- char strlog[MAX_PATH] = { 0 };
- vsnprintf(strlog, MAX_PATH, fmt, arg);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", strlog);
- }
- va_end(arg);
- }
- void CSalesRecorderEntity::vDebug(record_loglevel elevel, const char* str, va_list list)
- {
- int n = vsnprintf(NULL, 0, str, list);
- if (n >= MAX_PATH) {
- char* buf = (char*)malloc((size_t)(n + 1));
- vsnprintf(buf, n + 1, str, list);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", buf);
- free(buf);
- }
- else {
- char strlog[MAX_PATH] = { 0 };
- vsnprintf(strlog, MAX_PATH, str, list);
- DbgWithLink((LOG_LEVEL_E)elevel, LOG_TYPE_SYSTEM)("%s", strlog);
- }
- }
- int CSalesRecorderEntity::GetRecordCamera()
- {
- int iRecordCamera = m_iRecordCamera;
- if (1 != m_iRemoteRecordType) {
- iRecordCamera = m_iActiveCamera;
- }
- else {
- if (0 == iRecordCamera) {
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SALESRECORD_USE_ENVCAMERA, "remote video record use env camera.");
- }
- else {
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SALESRECORD_USE_OPTCAMERA, "remote video record use opt camera.");
- }
- }
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote record camera is %d.", iRecordCamera);
-
- return iRecordCamera;
- }
- int CSalesRecorderEntity::GetCameraState()
- {
- return m_iCameraState;
- }
- void CSalesRecorderEntity::OnRecordFailed(eRvcRecordFailedCase eCase, const char* pszMessage, bool bRecordDevFault)
- {
- #ifdef RVC_OS_WIN
- double fCpuUsage = GetSystemCpuUsage();
- if (fCpuUsage > 50.0){
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_UI_RECORDFAILED_FOR_HIGHCPU, "more than 50 percent.");
- }
- #endif
- if (eCase < eDefault && eCase >= 0){
- LogEvent(Severity_Middle, LOG_EVT_UI_RECORDFAILED, record_failed_case_table[eCase]);
- }
- #ifdef RVC_OS_WIN
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_FAILED, CSimpleStringA::Format("{%s} current memory usage is %d, and cpu usage is %f.", pszMessage ? pszMessage : " ", GetSystemMemoryUsage(), fCpuUsage).GetData());
- #else
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_FAILED, CSimpleStringA::Format("%s", pszMessage ? pszMessage : " ").GetData());
- #endif
- if (eBeginFailed == eCase) {
- m_bNeedRestart = true;
- RealSelfCheck();
- }
- }
- void CSalesRecorderEntity::OnRecordEntityExcption()
- {
- LogEvent(Severity_High,LOG_EVT_SALESRECORD_ENTITY_EXCEPTION,"现场销售双录出现异常,请稍候重录,系统正在恢复中,预计60秒!");
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_SALESRECORD_ENTITY_EXCEPTION, "sales record entity exception!");
- }
- void CSalesRecorderEntity::OnRecordFinished()
- {
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FINISHED, "现场销售双录已完成.");
- }
- void CSalesRecorderEntity::OnASectionFinished(const char* pszMessage, int iSerialNum, bool bfinished)
- {
- if (false == bfinished) {
- LogEvent(Severity_Middle, LOG_EVT_SALESRECORD_SECTION_FINISHED, pszMessage);
- }
- else {
- LogEvent(Severity_Middle, LOG_EVT_SALESRECORD_WHOLE_FINISHED, pszMessage);
- if (m_bEncFlag) {
- HandleEncryptVideoRecord(pszMessage);
- }
- }
- }
- void CSalesRecorderEntity::OnTimeout(DWORD dwTimerID)
- {
- }
- void CSalesRecorderEntity::OnSysVarEvent( const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName )
- {
- if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 0)
- {
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnSysVarEvent Key = %s, Value = %s.", pszKey, pszValue);
- m_iCameraState = pszValue[0];
- if (pszValue[0] == 'E')
- {
- m_iActiveCamera = CAMERA_TYPE_OPT;
- }
- else
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- }
- else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
- {
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnSysVarEvent Key = %s, Value = %s.", pszKey, pszValue);
- if (m_iCameraState == 'N')
- {
- if (pszValue[0] == 'E')
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if (pszValue[0] == 'O')
- {
- m_iActiveCamera = CAMERA_TYPE_OPT;
- }
- }
- }
- }
- void CSalesRecorderEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel, const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext &pLinkInfo)
- {
- // 响应客户经理销售录像相关的事件
- switch (dwUserCode)
- {
- case LOG_EVT_UI_RETURNMENU:
- HandleReturnMenu();
- break;
- case LOG_EVT_SALESRECORD_ENTITY_EXCEPTION:
- HandleSalesRecordEntityException(pszMessage);
- break;
- case LOG_EVT_SALESRECORD_SECTION_FINISHED:
- {
- if (m_bEncFlag) {
- HandleEncryptVideoRecord(pszMessage);
- }
- }
- break;
- case LOG_EVT_SALESRECORD_WHOLE_FINISHED:
- {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("recv LOG_EVT_SALESRECORD_WHOLE_FINISHED EVENT.");
- }
- break;
- default:
- break;
- }
- }
- bool CSalesRecorderEntity::GetStandardQualityOnSiteSalesRecorder()
- {
- bool bRet = false;
- m_pRecorder = new Clibvideorecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,
- REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
-
- return bRet;
- }
- bool CSalesRecorderEntity::GetHighQualityOnSiteSalesRecorder()
- {
- bool bRet = false;
- m_pRecorder = new Clibvideorecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,
- REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- return bRet;
- }
- void CSalesRecorderEntity::StartOnSiteSalesRecord(const int fps, const char* videofilename, int videoquality, SubtitleParam* subtitleParam, bool bWholeSection, bool bSessionManage, eRvcRecordType eRecordType)
- {
- #ifdef RVC_OS_WIN
- bool bRet = false;
- bRet = GetStandardQualityOnSiteSalesRecorder();
- if (false == bRet){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get onsite sales recorder failed.");
- return;
- }
- #endif
- Rvc_RecordAudioParam_t tAudioParams;
- tAudioParams.eRecordType = eRecordType;
- tAudioParams.eOutPutType = m_eAudioOutQuality;
- tAudioParams.bIsNsOn = m_bIsAudioNsOn;
- tAudioParams.iNsPolicy = m_iAudioNsPolicy;
- tAudioParams.iAudioChannels = m_iAudioChannels;
- tAudioParams.bMuteAudioMode = false;
- if (eStand2Agent == eRecordType) {
- tAudioParams.eOutPutType = eLowDefinition;
- tAudioParams.bIsNsOn = false;
- }
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("init lib video record success! and record type is %s and output audio quality is %s, audio noise suppression flag is %s. noise suppression policy is %d.", record_type_table[eRecordType], audio_quality_type_table[m_eAudioOutQuality], tAudioParams.bIsNsOn ? "true" : "false", tAudioParams.iNsPolicy);
- if (m_pRecorder->StartVideoRecord(fps, videoquality, eMP4, &tAudioParams, subtitleParam, bWholeSection, false, m_TempDir.GetData(),
- m_TempDir.GetLength(), videofilename, strlen(videofilename)))
- {
- m_bStarted = true;
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Start VideoRecord failed!");
- }
- }
- void CSalesRecorderEntity::StartRecord(const char * pszVideoName, int videoquality, SubtitleParam *subtitleParam /* = NULL */, bool bWholeSection /* = false */, bool bSessionManage /* = false */, eRvcRecordType eRecordType /* = eSingleSide */)
- {
- StartOnSiteSalesRecord(10, pszVideoName, videoquality, subtitleParam, bWholeSection, bSessionManage, eRecordType);
- }
- ErrorCodeEnum CSalesRecorderEntity::StopRecord()
- {
- ErrorCodeEnum eCode = Error_Succeed;
- if (m_bStarted) {
- m_pRecorder->StopVideoRecord();
- #ifdef RVC_OS_WIN
- delete m_pRecorder;
- m_pRecorder = NULL;
- #endif
- m_bStarted = false;
- }
- else{
- eCode = Error_InvalidState;
- }
- return eCode;
- }
- void CSalesRecorderEntity::DeleteAllVideo( const char * pszVideoName)
- {
- if(!m_bStarted)
- {
- CSimpleStringA strPath;
- ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
- if (Error == Error_Succeed) {
- if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
- strPath += SPLIT_SLASH_STR;
- }
- uint32_t uVideoCount = 0;
- CSimpleStringA strFindFileName = CSimpleStringA::Format("S_%s*.%s", pszVideoName, RECORD_MP4_SUFFIX);
- bool bRet = FindMatchedFile(strPath.GetData(), strFindFileName.GetData(), uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("succeed to get sales record count while delete video!");
- CSimpleStringA fileName("");
- bool bDeleteSucc = true;
- for(int i = 0; i != uVideoCount; ++i)
- {
- fileName = CSimpleStringA::Format("%s%s_%d.%s", strPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
- bRet = RvcDeleteFile(fileName.GetData());
- if(!bRet) {
- bDeleteSucc = false;
- #ifdef RVC_OS_WIN
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Error Code %lu while delete %s.", GetLastError(), fileName.GetData());
- #else
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s(%d) while delete %s.", strerror(errno), errno, fileName.GetData());
- #endif // RVC_OS_WIN
-
- }
- }
- if (!bDeleteSucc) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("failed to delete sales video!");
- }
- }
- }
- }
- }
- ErrorCodeEnum CSalesRecorderEntity::DeleteVideo( const char *videofilename)
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- if(!m_bStarted)
- {
- CSimpleStringA strPath;
- ErrorCodeEnum Error = GetFunction()->GetPath("Temp", strPath);
- if (Error == Error_Succeed) {
- if (strPath.GetLength() > 0 && strPath[strPath.GetLength()-1] != SPLIT_SLASH) {
- strPath += SPLIT_SLASH_STR;
- }
- CSimpleStringA strFindFileName = CSimpleStringA::Format("%s*.%s", videofilename, RECORD_MP4_SUFFIX);
- uint32_t uVideoCount = 0;
- bool bRet = FindMatchedFile(strPath.GetData(), strFindFileName.GetData(), uVideoCount);
- if(bRet)
- {
- CSimpleStringA fileName;
- bool bDeleteSucc = true;
- for(int i = 0; i != uVideoCount; ++i)
- {
- fileName = CSimpleStringA::Format("%s%s_%d.%s", strPath.GetData(), videofilename, i, RECORD_MP4_SUFFIX);
- bRet = RvcDeleteFile(fileName.GetData());
- if(!bRet) {
- bDeleteSucc = false;
- //TODO: CrossPlaform [Gifur@2025730]
- #ifdef RVC_OS_WIN
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Error Code %lu while delete %s ", GetLastError(), fileName.GetData());
- #else
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s(%d) while delete %s ", strerror(errno), errno, fileName.GetData());
- #endif
- }
- }
- if (!bDeleteSucc) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("delete videos failed!");
- }
- }
- else
- {
- ErrorCode = Error_NotExist;
- }
- }
- }
- else {
- ErrorCode = Error_NotImpl;
- }
- return ErrorCode;
- }
- /*
- SaveVideo包含两步,找到录像和移动录像
- Error_Succeed 提交上传成功
- Error_NotExist not exist
- Error_NotImpl 方法执行失败
- */
- ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- if (NULL == videofilename || 0 == strlen(videofilename)) {
- return Error_Param;
- }
- if(!m_bStarted)
- {
- CSimpleStringA sourPath;
- ErrorCodeEnum Error = GetFunction()->GetPath("Temp", sourPath);
- if(Error == Error_Succeed)
- {
- if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != SPLIT_SLASH) {
- sourPath += SPLIT_SLASH_STR;
- }
- uint32_t uVideoCount = 0;
- CSimpleStringA strFindFileName = CSimpleStringA::Format("S_%s*.%s", videofilename, RECORD_MP4_SUFFIX);
- bool bRet = FindMatchedFile(sourPath.GetData(), strFindFileName.GetData(), uVideoCount);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("FindMatchedFile count is %d.", uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("strFindFileName is %s.", strFindFileName.GetData());
- CSimpleStringA destPath;
- Error = GetFunction()->GetPath("UploadVideo", destPath);
- if(Error == Error_Succeed)
- {
- if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
- destPath += SPLIT_SLASH_STR;
- }
- CSimpleStringA sourFileName(""), destFileName("");
- bool bMoveSucc = false;
- for(int i = 0; i != uVideoCount; ++i)
- {
- sourFileName = CSimpleStringA::Format("%s%s_%d.%s", sourPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
- destFileName = CSimpleStringA::Format("%s%s_%d.%s", destPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
- unsigned long ufilesize = GetFileSize(sourFileName.GetData());
- char strhash[MAX_PATH] = { 0 };
- get_file_sm3digest(strhash, MAX_PATH, sourFileName.GetData());
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FILEINFO, CSimpleStringA::Format("%s file size is %u byte,sm3 digest is %s.", sourFileName.GetData(), ufilesize, strhash).GetData());
- bRet = rvcMoveFile(sourFileName.GetData(), destFileName.GetData());
- if (!bRet) {
- ErrorCode = Error_NotImpl;
- #ifdef RVC_OS_WIN
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, CSimpleStringA::Format("Error Code %lu while move %s.", GetLastError(), sourFileName.GetData()).GetData());
- if (183 == GetLastError()) {
- ErrorCode = Error_InvalidState;
- }
- #else
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, CSimpleStringA::Format("%s(%d) while move %s.", strerror(errno), errno, sourFileName.GetData()).GetData());
- #endif // RVC_OS_WIN
- }
- else {
- bMoveSucc = true;
- CSimpleStringA strVideoName = CSimpleStringA::Format("%s_%d.%s", strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
- }
- if (RVC_MIN_FILESIZE > ufilesize){
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_INVALID_FILE, CSimpleStringA::Format("%s file size is %u.", sourFileName.GetData(), ufilesize).GetData());
- ErrorCode = Error_Failed;
- }
- }
- if (bMoveSucc) {
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_SAVED_SUCCESS, CSimpleStringA::Format("succeed to save sales video, move it from %s to %s.", sourFileName.GetData(), destFileName.GetData()).GetData());
- }
- }
- }
- else{
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, "sales videos not exist or have been deleted");
- ErrorCode = Error_NotExist;
- }
- }
- }
- else{
- ErrorCode = Error_InvalidState;
- }
- return ErrorCode;
- }
- CSimpleStringA CSalesRecorderEntity::GetTerminalStage()
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue = "";
- Func->GetSysVar("TerminalStage", strValue);
- return strValue;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleStartRecord(const char *pszMessage, const bool bRemoteRecord)
- {
- ErrorCodeEnum Error = Error_Succeed;
- eRvcRecordType eRecordType = eSingleSide;
- if (NULL == pszMessage){
- return Error_Param;
- }
- size_t ulen = strlen(pszMessage);
- char *tmp = new char[ulen+1];
- memset(tmp, 0, ulen + 1);
- memcpy(tmp, pszMessage, ulen);
- char* result[16] = { 0 };
- #ifdef RVC_OS_WIN
- auto arr1 = CSimpleStringA2W(tmp).Split('@');
- auto arr2 = CAutoArray<CSimpleStringA>(arr1.GetCount());
- for (int i = 0; i < arr1.GetCount(); ++i){
- arr2[i] = CSimpleStringW2A(arr1[i]);
- result[i] = const_cast<char*>(arr2[i].GetData());
- }
- _snprintf(m_SalesVideoName, MAX_PATH, "%s", result[4]); //录像名:录像类型标志_录像流水号(如S_C13213EF)
- #else
- CStringSplit(tmp, result, "@");
- memset(m_SalesVideoName, 0, MAX_PATH);
- if (result[4]) {
- snprintf(m_SalesVideoName, MAX_PATH, "%s", result[4]); //录像名:录像类型标志_录像流水号(如S_C13213EF)
- }
- #endif
- int iPostionArr[4][2] = { 0 };
- for (int i = 0; i < 4; i++){
- sscanf(result[i], "%d|%d", &iPostionArr[i][0], &iPostionArr[i][1]);
- }
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("local video frame size is (%d,%d).", iPostionArr[2][0], iPostionArr[3][0]);
- if (iPostionArr[2][0] >= iPostionArr[3][0]) {
- m_iRecordCamera = CAMERA_TYPE_ENV;
- }
- else {
- m_iRecordCamera = CAMERA_TYPE_OPT;
- }
- RecordSubTitle subTitle;
- memset(&subTitle, 0, sizeof(RecordSubTitle));
- if (result[5]) {
- CSimpleStringA strCardNo = DecryptString(result[5]);
- if (sizeof(subTitle.CustCardNo) > strCardNo.GetLength()) {
- _snprintf(subTitle.CustCardNo, sizeof(subTitle.CustCardNo), "%s", strCardNo.GetData());
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Invalid CustCardNo.");
- }
- }
- char* pStr = result[6];
- if (pStr) {
- CSimpleStringW szCustName = CSimpleStringA2W(pStr);
- if (szCustName.GetLength() <= 4) {
- strcpy(subTitle.CustName, pStr);
- }
- else {
- CSimpleStringW aa = szCustName.SubString(0, 4);
- _snprintf(subTitle.CustName, 32, "%s...", CSimpleStringW2A(aa).GetData());
- }
- }
- pStr = result[7];
- if (pStr) {
- int nProductCodeLen = strlen(pStr);
- if (nProductCodeLen <= 10) {
- strcpy(subTitle.ProductCode, pStr);
- }
- else {
- char aa[5] = { 0 }, bb[5] = { 0 };
- strncpy(aa, pStr, 4);
- strncpy(bb, pStr + nProductCodeLen - 4, 4);
- _snprintf(subTitle.ProductCode, 32, "%s...%s", aa, bb);
- }
- }
- pStr = result[8];
- if (pStr) {
- CSimpleStringW szProductName = CSimpleStringA2W(pStr);
- if (szProductName.GetLength() <= 5) {
- strcpy(subTitle.ProductName, pStr);
- }
- else {
- CSimpleStringW aa = szProductName.SubString(0, 3);
- CSimpleStringW bb = szProductName.SubString(szProductName.GetLength() - 2, 2);
- _snprintf(subTitle.ProductName, 128, "%s...%s", CSimpleStringW2A(aa).GetData(), CSimpleStringW2A(bb).GetData());
- }
- }
- if (result[9]) {
- strcpy(subTitle.SapID, result[9]);
- }
- else {
- subTitle.SapID[0] = '\0';
- }
- if (result[10]) {
- pStr = result[10];
- CSimpleStringW szCustManagerName = CSimpleStringA2W(pStr);
- if (szCustManagerName.GetLength() <= 4) {
- strcpy(subTitle.CustManagerName, result[10]);
- }
- else {
- CSimpleStringW aa = szCustManagerName.SubString(0,4);
- _snprintf(subTitle.CustManagerName, 32,"%s...",CSimpleStringW2A(aa).GetData());
- }
- } else {
- subTitle.CustManagerName[0] = '\0';
- }
- delete[] tmp;
- tmp = NULL;
- SubtitleParam subtitleParam;
- memset(&subtitleParam, 0, sizeof(SubtitleParam));
- subtitleParam.bSubtitle = true;
- subtitleParam.bSubtitleSection = true;
- subtitleParam.topSubtitleData[0] = '\0';
- #ifdef RVC_OS_WIN
- if (strlen(subTitle.SapID)>0&&strlen(subTitle.CustManagerName)>0){
- _snprintf(subtitleParam.bottomSubtitleData1, MAX_PATH, "%s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode);
- _snprintf(subtitleParam.bottomSubtitleData2, MAX_PATH, "%s %s %s", subTitle.ProductName, subTitle.SapID, subTitle.CustManagerName);
- }
- else{
- _snprintf(subtitleParam.bottomSubtitleData1, MAX_PATH, "%s %s", subTitle.CustCardNo, subTitle.CustName);
- _snprintf(subtitleParam.bottomSubtitleData2, MAX_PATH, "%s %s", subTitle.ProductCode, subTitle.ProductName);
- }
- #else
- if (strlen(subTitle.SapID)>0&&strlen(subTitle.CustManagerName)>0){
- swprintf(subtitleParam.bottomSubtitleData1, MAX_PATH, L"%s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode);
- swprintf(subtitleParam.bottomSubtitleData2, MAX_PATH, L"%s %s %s", subTitle.ProductName, subTitle.SapID, subTitle.CustManagerName);
- }
- else{
- swprintf(subtitleParam.bottomSubtitleData1, MAX_PATH, L"%s %s", subTitle.CustCardNo, subTitle.CustName);
- swprintf(subtitleParam.bottomSubtitleData2, MAX_PATH, L"%s %s", subTitle.ProductCode, subTitle.ProductName);
- }
- #endif
- if (bRemoteRecord){
- if (eStand2sType == m_eDeviceType || eStand1SPlusType == m_eDeviceType) { //如果是大机
- eRecordType = eStand2Agent; //可视柜台大机的双向录像
- }
- }
- StartRecord(m_SalesVideoName, 90, &subtitleParam, m_bWholeSection, false, eRecordType);
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_START_REMOTERECORD, CSimpleStringA::Format("start remote record %s.", m_SalesVideoName).GetData());
- return Error;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleStopRecord(const char *pszMessage)
- {
- ErrorCodeEnum ErrorCode = StopRecord();
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleSaveVideo()
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- // 将视频从tmp移动到uploadvideo
- ErrorCode = SaveVideo(m_SalesVideoName+2);
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleDeleteVideo()
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- // 删除tmp中的视频
- ErrorCode = DeleteVideo(m_SalesVideoName);
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- return ErrorCode;
- }
- void CSalesRecorderEntity::HandleReturnMenu()
- {
- CSimpleStringA strValue;
- GetFunction()->GetSysVar("DesktopType", strValue);
- if (strValue != CSimpleStringA("U"))
- {
- if (m_bStarted) // 如果正在进行客户经理录像
- {
- // 停止录像
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop record and return menu!");
- StopRecord();
- }
- // 删除tmp中的视频
- if (strlen(m_SalesVideoName) > 0)
- {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("delete sales record!");
- DeleteAllVideo(m_SalesVideoName+2);
- }
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- }
- }
- #ifdef RVC_OS_WIN
- ErrorCodeEnum CSalesRecorderEntity::HandleVideoAppendWatermark(const char* pszVideoName, const char* pszWaterMark)
- {
- ErrorCodeEnum Error = Error_Failed;
- if (NULL == pszWaterMark) {
- return Error_Param;
- }
- if (m_bStarted && (NULL != m_pRecorder)) {
- if (m_pRecorder->SetRightVideoWaterMark(pszWaterMark)) {
- Error = Error_Succeed;
- }
- }
- return Error;
- }
- #else
- ErrorCodeEnum CSalesRecorderEntity::HandleVideoAppendWatermark(const char* pszVideoName, const wchar_t* pszWaterMark)
- {
- ErrorCodeEnum Error = Error_Failed;
- if (NULL == pszWaterMark){
- return Error_Param;
- }
- if (m_bStarted && (NULL != m_pRecorder)){
- if (m_pRecorder->SetRightVideoWaterMark(pszWaterMark)) {
- Error = Error_Succeed;
- }
- }
- return Error;
- }
- #endif
- ErrorCodeEnum CSalesRecorderEntity::HandleSalesRecordEntityException(const char* pszMessage)
- {
- // 通知到业务中台
- SalesRecordException evt;
- evt.failedmsg = CSimpleStringA2W(pszMessage==NULL?"现场销售双录过程出现异常!":pszMessage);
- SpSendBroadcast(GetFunction(), SP_MSG_OF(SalesRecordException), SP_MSG_SIG_OF(SalesRecordException), evt);
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] SalesRecord entity exception broadcast sent!");
- //停止录像
- StopRecord();
- m_bNeedRestart = true;
- //重启实体
- RealSelfCheck();
- return Error_Succeed;
- }
- #ifdef RVC_OS_LINUX
- bool CSalesRecorderEntity::InitSalesRecorder()
- {
- bool bRet = false;
- bRet = GetStandardQualityOnSiteSalesRecorder();
-
- return bRet;
- }
- bool CSalesRecorderEntity::ReleaseSalesRecorder()
- {
- if (m_pRecorder) {
- delete m_pRecorder;
- m_pRecorder = NULL;
- }
- return true;
- }
- #endif
- ErrorCodeEnum CSalesRecorderEntity::RealSelfCheck()
- {
- ErrorCodeEnum Error = Error_Succeed;
- HealthManagerService_ClientBase* pHMClient = new HealthManagerService_ClientBase(this);
- Error = pHMClient->Connect();
- if (Error != Error_Succeed){
- pHMClient->SafeDelete();
- pHMClient = NULL;
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("pHMClient connect fail!");
- }
- if (pHMClient)
- {
- HealthManagerService_RealCheck_Req req;
- req.name = GetEntityName();
- HealthManagerService_RealCheck_Ans ans;
- DWORD Timeout = 500;
- Error = pHMClient->RealCheck(req,ans,Timeout);
- if (Error!=Error_Succeed){
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("RealSelfcheck fail!");
- }
- }
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_ENTITY_RESTART, "sales record entity self restart.");
- return Error;
- }
- #ifdef RVC_OS_WIN
- bool IsMatchedVideo(WIN32_FIND_DATA fileData)
- {
- bool bRet = false;
-
- if ('S' == fileData.cFileName[0] || 'W' == fileData.cFileName[0]){
- SYSTEMTIME sysTime;
- FileTimeToSystemTime(&fileData.ftCreationTime, &sysTime);
- //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("File %s create data info is %d %d %d.", fileData.cFileName, sysTime.wYear, sysTime.wMonth, sysTime.wDay);
- if ((2020 == sysTime.wYear) && (sysTime.wMonth == 1)){
- if (sysTime.wDay >= 3 && sysTime.wDay <= 10){
- bRet = true;
- }
- }
- }
-
- return bRet;
- }
- void CSalesRecorderEntity::UploadTempPathVideos()
- {
- CSimpleStringA sourPath;
- CSimpleStringA destPath;
- ErrorCodeEnum Error = GetFunction()->GetPath("Temp", sourPath);
- Error = GetFunction()->GetPath("UploadVideo", destPath);
-
- if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength()-1] != SPLIT_SLASH) {
- sourPath += SPLIT_SLASH_STR;
- }
- if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
- destPath += SPLIT_SLASH_STR;
- }
- if(Error == Error_Succeed)
- {
- char srcFilePath[MAX_PATH]={0};
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
- BOOL fFinished = FALSE;
- sprintf_s(srcFilePath, MAX_PATH, "%s*.%s", sourPath, RECORD_MP4_SUFFIX);
- hFind = FindFirstFile(srcFilePath, &FindFileData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- while (!fFinished)
- {
- if (FILE_ATTRIBUTE_DIRECTORY & FindFileData.dwFileAttributes)
- {
- continue;
- }
- if (IsMatchedVideo(FindFileData)){
- CSimpleStringA sourFileName = CSimpleStringA::Format("%s%s", (LPCSTR)sourPath, FindFileData.cFileName);
- CSimpleStringA destFileName = CSimpleStringA::Format("%sBAK_%s", (LPCSTR)destPath, FindFileData.cFileName);
- if(!MoveFile((LPCSTR)sourFileName, (LPCSTR)destFileName)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
- }
- }
- else{
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("File (%s) is not matched.", FindFileData.cFileName);
- }
- if (!FindNextFile(hFind, &FindFileData))
- {
- if (GetLastError() == ERROR_NO_MORE_FILES)
- {
- fFinished = TRUE;
- }
- else
- {
- break;
- }
- }
- }
- FindClose(hFind);
- }
- }
- }
- int CSalesRecorderEntity::GetSystemMemoryUsage()
- {
- // Use to convert bytes to KB
- #define DIV 1024
- MEMORYSTATUSEX statex;
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx (&statex);
- return statex.dwMemoryLoad;
- }
- double CSalesRecorderEntity::GetSystemCpuUsage()
- {
- double ratio = 0;
- #define _WIN32_WINNT 0x0601
- FILETIME idleTime,kernelTime,userTime;
- BOOL ret = GetSystemTimes(&idleTime,&kernelTime,&userTime);
- if (ret == 0)
- {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetSystemCPUStatus.GetSystemTimes failed(%d).",GetLastError());
- return 80.0;
- }
- __int64 xIdle,xKernel,xUser;
- xIdle = idleTime.dwHighDateTime;
- xIdle <<= 32;
- xIdle |= idleTime.dwLowDateTime;
- xKernel = kernelTime.dwHighDateTime;
- xKernel <<= 32;
- xKernel |= kernelTime.dwLowDateTime;
- xUser = userTime.dwHighDateTime;
- xUser <<= 32;
- xUser |= userTime.dwLowDateTime;
- if (m_xIdlePre != 0)
- {
- __int64 xI,xK,xU;
- xI = xIdle - m_xIdlePre;
- xK = xKernel - m_xKernelPre;
- xU = xUser - m_xUserPre;
-
- if ((xK +xU) != 0)
- ratio = (xK - xI + xU) * 100 / (xK + xU);
- }
- m_xIdlePre = xIdle;
- m_xKernelPre = xKernel;
- m_xUserPre = xUser;
- return ratio;
- }
- #else
- /*
- **time_t转SYSTEMTIME
- */
- SYSTEMTIME Time_tToSystemTime(time_t t)
- {
- tm temptm = *localtime(&t);
- SYSTEMTIME st = { 1900 + temptm.tm_year,
- 1 + temptm.tm_mon,
- temptm.tm_wday,
- temptm.tm_mday,
- temptm.tm_hour,
- temptm.tm_min,
- temptm.tm_sec,
- 0 };
- return st;
- }
- bool IsMatchedVideo(LPCTSTR path, struct dirent* file)
- {
- bool bRet = false;
- if ((file->d_reclen > 0) && ('S' == file->d_name[0] || 'W' == file->d_name[0])){
- struct stat fileInfo;
- char ttp[256];
- bzero(ttp, sizeof(ttp));
- strcat(ttp, path);
- if (strcmp(ttp, "/") != 0)strcat(ttp, "/");//如果是根目录不需要加
- strcat(ttp, file->d_name);
- if (stat(ttp, &fileInfo) == 0) {
- SYSTEMTIME sysTime;
- sysTime = Time_tToSystemTime(fileInfo.st_mtime);
- if ((2020 == sysTime.wYear) && (sysTime.wMonth == 1)) {
- if (sysTime.wDay >= 3 && sysTime.wDay <= 10) {
- bRet = true;
- }
- }
- }
- }
- return bRet;
- }
- void CSalesRecorderEntity::UploadTempPathVideos() {
- CSimpleStringA sourPath;
- CSimpleStringA destPath;
- ErrorCodeEnum Error = GetFunction()->GetPath("Temp", sourPath);
- Error = GetFunction()->GetPath("UploadVideo", destPath);
- if (sourPath.GetLength() > 0 && sourPath[sourPath.GetLength() - 1] != SPLIT_SLASH) {
- sourPath += SPLIT_SLASH_STR;
- }
- if (destPath.GetLength() > 0 && destPath[destPath.GetLength() - 1] != SPLIT_SLASH) {
- destPath += SPLIT_SLASH_STR;
- }
- if (Error == Error_Succeed)
- {
- char srcFilePath[MAX_PATH] = { 0 };
- DIR* pDir = NULL;
- struct dirent* pFile = NULL;
- snprintf(srcFilePath, MAX_PATH, "%s*.%s", sourPath, RECORD_MP4_SUFFIX);
- pDir = opendir(sourPath);
- if (pDir == NULL) return ;
- while ((pFile = readdir(pDir)) != NULL) {
- if (pFile->d_type & DT_DIR) {
- continue;
- }
- else {
- if (IsMatchedVideo((LPCSTR)sourPath, pFile)) {
- CSimpleStringA sourFileName = CSimpleStringA::Format("%s%s", (LPCSTR)sourPath, pFile->d_name);
- CSimpleStringA destFileName = CSimpleStringA::Format("%sBAK_%s", (LPCSTR)destPath, pFile->d_name);
- if (rename(sourFileName.GetData(), destFileName.GetData())) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Error Code %lu while move %s.", errno, sourFileName.GetData());
- }
- }
- else {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("File (%s) is not matched.", pFile->d_name);
- }
- }
- }
- closedir(pDir);
- }
- }
- #endif
- ErrorCodeEnum CSalesRecorderEntity::SetRecordAudioQuality(int iAudioQuality)
- {
- ErrorCodeEnum eRet = Error_Succeed;
- switch (iAudioQuality)
- {
- case 1:
- m_eAudioOutQuality = eLowDefinition;
- break;
- case 2:
- m_eAudioOutQuality = eStandardDefinition;
- break;
- case 3:
- m_eAudioOutQuality = eHighDefinition;
- break;
- case 4:
- m_eAudioOutQuality = eUltraHD;
- break;
- default:
- m_eAudioOutQuality = eUltraHD;
- break;
- }
- return eRet;
- }
- ErrorCodeEnum CSalesRecorderEntity::SetRecordAudioNsPolicy(int iNsPolicy)
- {
- ErrorCodeEnum eRet = Error_Succeed;
- if (1 == iNsPolicy || 3 == iNsPolicy){
- m_iAudioNsPolicy = iNsPolicy;
- }
- else{
- m_iAudioNsPolicy = 2;
- }
- return eRet;
- }
- ErrorCodeEnum CSalesRecorderEntity::SetRecordAudioChannles(int iAudioChannles)
- {
- ErrorCodeEnum eRet = Error_Succeed;
- m_iAudioChannels = 2;
- return eRet;
- }
- DeviceTypeEnum CSalesRecorderEntity::RvcGetDeviceType()
- {
- DeviceTypeEnum eType = eStand2sType;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSystemStaticInfo stStaticinfo;
- spFunction->GetSystemStaticInfo(stStaticinfo);
- m_terminalNo = stStaticinfo.strTerminalID;
- if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
- eType = eStand1SPlusType;
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
- eType = eCardStore;
- }
- else {
- eType = eStand2sType;
- }
- if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("device type is %s.", Device_Type_Table[eType]);
- }
- return eType;
- }
- int CSalesRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
- {
- int iRet = -1;
- if (NULL == videofilename) {
- return iRet;
- }
- if (!ExistsFile(videofilename)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("File %s is not exist.", videofilename);
- return iRet;
- }
- filecryption_callback_t cb = { 0 };
- cb.dbg = &rvcDbg;
- char strOutFile[MAX_PATH] = { 0 };
- int iresult = encryption_file(strOutFile, MAX_PATH, videofilename, &cb, eVerB);
- if (0 != iresult) {
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_ENCRYPT_FAILED, CSimpleStringA::Format("encryption file %s failed, delete out temp file %s!", videofilename, strOutFile).GetData());
- if (ExistsFile(strOutFile)) {
- if (!RvcDeleteFile(strOutFile)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
- }
- }
- return iRet;
- }
- bool bRet = RvcDeleteFile(videofilename);
- if (!bRet) {
- //TODO: CrossPlaform [Gifur@2025730]
- #ifdef RVC_OS_WIN
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_DELETE_FAILED, CSimpleStringA::Format("Error Code %lu while delete %s, delete out temp file[%s]!", GetLastError(), videofilename, strOutFile).GetData());
- #else
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_DELETE_FAILED, CSimpleStringA::Format("%s(%d) while delete %s, delete out temp file[%s]!", strerror(errno), errno, videofilename, strOutFile).GetData());
- #endif // RVC_OS_WIN
- if (!RvcDeleteFile(strOutFile)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
- }
- return iRet;
- }
- else {
- if (rvcMoveFile(strOutFile, videofilename)) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("rename %s to %s success!", strOutFile, videofilename);
- iRet = 0;
- }
- else {
- //TODO: CrossPlaform [Gifur@2025730]
- #ifdef RVC_OS_WIN
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
- #else
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_RENAME_FAILED, CSimpleStringA::Format("%s(%d) while rename %s.", strerror(errno), errno, strOutFile).GetData());
- #endif // RVC_OS_WIN
- }
- }
- #if 0
- char strdecFile[MAX_PATH] = { 0 };
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin decrypt file %s.", videofilename);
- iresult = decryption_file(strdecFile, MAX_PATH, videofilename, &cb, eVerB);
- if (0 == iresult) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("decrypt file %s -> %s success!", videofilename, strdecFile);
- }
- else {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("decrypt file %s -> %s failed!", videofilename, strdecFile);
- }
- #endif
- return iRet;
- }
- ErrorCodeEnum CSalesRecorderEntity::SetRecordCamera(int iCamera)
- {
- ErrorCodeEnum Error = Error_Succeed;
- if (CAMERA_TYPE_OPT == iCamera) {
- m_iRecordCamera = CAMERA_TYPE_OPT;
- }
- else {
- m_iRecordCamera = CAMERA_TYPE_ENV;
- }
- return Error;
- }
- int CSalesRecorderEntity::GetMaxDiskPercent()
- {
- return m_max_disk_percent;
- }
- ErrorCodeEnum CSalesRecorderEntity::GetEntityConfig()
- {
- ErrorCodeEnum Error = Error_Succeed;
- int iAudioQuality = 3;
- int iAudioNsPolicy = 2;
- int iIsAudioNsOn = 0;
- int iAudioChannels = 1;
- int iTimeOut = RVC_HTTPTIMEOUT;
- CSimpleStringA strHttpServerAddr("");
- int iPostOn = 0;
- m_max_disk_percent = MAX_DISK_PERCENT;
- int iStopEncflag = 0;
- int iRemoteRecordType = 0;
- CSmartPointer<IConfigInfo> spConfig;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- if (spFunction->OpenConfig(Config_CenterSetting, spConfig) == Error_Succeed) {
- spConfig->ReadConfigValueInt("SalesRecorder", "AudioNsPolicy", iAudioNsPolicy);
- spConfig->ReadConfigValueInt("SalesRecorder", "IsAudioNsOn", iIsAudioNsOn);
- spConfig->ReadConfigValueInt("SalesRecorder", "AudioQuality", iAudioQuality);
- spConfig->ReadConfigValueInt("SalesRecorder", "AudioChannels", iAudioChannels);
- spConfig->ReadConfigValueInt("SalesRecorder", "stopencflag", iStopEncflag);
- spConfig->ReadConfigValueInt("InteractiveControl", "RemoteRecordType", iRemoteRecordType);
- }
- SetRecordAudioQuality(iAudioQuality);
- SetRecordAudioNsPolicy(iAudioNsPolicy);
- SetRecordAudioChannles(iAudioChannels);
- if (0 != iIsAudioNsOn) {
- m_bIsAudioNsOn = true;
- }
- if (1 == iStopEncflag) {
- m_bEncFlag = false;
- }
- if (1 == iRemoteRecordType) {
- m_iRemoteRecordType = 1;
- }
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_bEncFlag is %s, m_iRemoteRecordType is %d.", m_bEncFlag ? "true" : "false", m_iRemoteRecordType);
- return Error;
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CSalesRecorderEntity)
- SP_END_ENTITY_MAP()
|