| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726 |
- #include "stdafx.h"
- #include "mod_SalesRecorder.h"
- #include "rvcmediacommon/rvc_media_common.h"
- #include "fileutil.h"
- #include "array.h"
- #include <memutil.h>
- #include <algorithm>
- #ifdef RVC_OS_WIN
- #include <Windows.h>
- #endif
- #include "mod_customeraware/Event.h"
- #include "mod_facetracking/sysvar.h"
- #include <assert.h>
- #include "EventCode.h"
- #include "offline_video_record_t.h"
- #include <winpr/file.h>
- #include <winpr/ini.h>
- #include <winpr/string.h>
- #include <winpr/thread.h>
- #include <winpr/timezone.h>
- #include "mod_MobileDial/MobileDial_client_g.h"
- #include "mod_MobileDial/MobileDial_def_g.h"
- #include "mod_interactivecontrol/InteractiveControl_client_g.h"
- #include "mod_interactivecontrol/InteractiveControl_def_g.h"
- #define LOG_EVT_UI_RECORDFAILED 0x31500001 //双录失败
- #define LOG_EVT_SALESRECORD_ENTITY_EXCEPTION 0x31500002 //销售双录实体异常
- #define LOG_EVT_SALESRECORD_FINISHED 0x31500003 //销售双录结束
- #define LOG_EVT_AUDIOSTREAM_TRANSMISSION_FAILED 0x31600001 //音频流传输失败
- #ifndef EWS_CAMERA_FLAG
- #define EWS_CAMERA_FLAG "ews|"
- #endif
- #ifndef EWS_CAMERA_FLAG_LEN
- #define EWS_CAMERA_FLAG_LEN 4
- #endif
- #define SYSVAR_CALLTYPE "CallType"
- #define CALLTYPE_NORMAL 'N' // 呼叫类型,普通模式
- #define CALLTYPE_MOBILE 'M' // 呼叫类型,手机模式
- #define TIMERID_UPOFLRECORD 1 // 离线双录提交计时器ID add by ly 2018/02/13
- #define TIMERID_DISKCHK 2 // 离线磁盘检查计时器ID add by ly 2018/02/24
- #define UPLOAD_CYCLE 300000 // 离线双录提交定时间隔 add by ly 2018/02/13
- #define DISKCHK_CYCLE 60000 // 离线磁盘检查计时间隔 add by ly 2018/02/24
- #define MAX_DISK_PERCENT 95 // 磁盘最大占用百分比 add by ly 2018/02/24
- static ErrorCodeEnum ParseIPAddress(const char *str, CSimpleStringA &ip, int &port)
- {
- ErrorCodeEnum Error = Error_Unexpect;
- if (str) {
- char tmp1[32] = {};
- char tmp2[16] = {};
- sscanf(str, "%s %s", tmp1, tmp2);
- if (tmp1[0] != 0 && tmp2[0] != 0)
- {
- ip = tmp1;
- port = atoi(tmp2);
- Error = Error_Succeed;
- }
- else
- return Error;
- }
- return Error;
- }
- static BOOL CheckDiskStatus(const char *szRoot, int nPercent, int *pFreeRatio)
- {
- #ifdef RVC_OS_WIN
- _ULARGE_INTEGER lpFreeBytesAvailableToCaller = {}, lpTotalNumberOfBytes = {}, lpTotalNumberOfFreeBytes = {};
- BOOL ret = GetDiskFreeSpaceEx(szRoot, &lpFreeBytesAvailableToCaller, &lpTotalNumberOfBytes, &lpTotalNumberOfFreeBytes);
- if (ret == 0)
- {
- Dbg("CheckDiskStatus.GetDiskFreeSpaceEx failed(%d).",GetLastError());
- return FALSE;
- }
- DWORD dwTotal = lpTotalNumberOfBytes.QuadPart/1048576;
- DWORD dwTotalFree = lpTotalNumberOfFreeBytes.QuadPart/1048576;
- int ratio = dwTotalFree*100/dwTotal;
- *pFreeRatio = ratio;
- Dbg("free disk %d MB, %d percent free.\n", dwTotalFree, ratio);
- //if (ratio < (100-MAX_DISK_PERCENT))
- if (ratio < (100-nPercent))
- {
- return FALSE;
- }
- return TRUE;
- #else
- //todo 调用resourcewatcher
- return TRUE;
- #endif
- }
- 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();
- }
- // 按分隔符分隔字符串 add by ly
- static void CStringSplit(char *str, char **result, const char *del)
- {
- char *p = strtok(str, del);
- while(p != NULL)
- {
- *result++ = p;
- p = strtok(NULL, del);
- }
- }
- #ifdef RVC_OS_WIN
- // 寻找某目录下与通配符匹配的文件
- static BOOL FindMatchedFile(LPCSTR sFindPath, LPCSTR sFindFileName, ULONGLONG& uCountFile)
- {
- char sPath[MAX_PATH];
- ZeroMemory(sPath, MAX_PATH);
- char sFormatFileName[MAX_PATH + 2] = "*";
- WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
- BOOL fFinished = FALSE;
- strcpy(sFormatFileName, sFindPath);
- if (sFindPath[strlen(sFindPath) - 1] != SPLIT_SLASH)
- {
- strcat(sFormatFileName, SPLIT_SLASH_STR);
- strcat(sFormatFileName, "*");
- }
- else
- {
- strcat(sFormatFileName, "*");
- }
- strcat(sFormatFileName, sFindFileName);
- strcat(sFormatFileName, "*");
- hFind = FindFirstFile(sFormatFileName, &FindFileData);
- if (hFind == INVALID_HANDLE_VALUE)
- {
- return FALSE;
- }
- else
- {
- while (!fFinished)
- {
- strcpy(sPath, sFindPath);
- 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(LPCSTR sFindPath, LPCSTR sFindFileName, ULONGLONG& uCountFile)
- {
- DIR* pDir = NULL;
- struct dirent* pFile = NULL;
- CSimpleStringA tmpFindFileName = sFindFileName;
- pDir = opendir(sFindPath);
- if (pDir == NULL) return FALSE;
- //linux不支持*查找,去掉后缀
- if (tmpFindFileName.IsEndWith("*.wmv")) {
- tmpFindFileName = tmpFindFileName.SubString(0, tmpFindFileName.GetLength() - 5);
- }
- while ((pFile = readdir(pDir)) != NULL) {
- if (pFile->d_type & DT_DIR) {
- //m_pHostApi->Debug("FindMatchedFile DIR name: %s.", pFile->d_name);
- if (strcmp(pFile->d_name, ".") == 0
- || strcmp(pFile->d_name, "..") == 0) continue;
- char Path[256];
- int len = strlen(sFindPath);
- strncpy(Path, sFindPath, len + 1);
- if (sFindPath[len - 1] != '/') strncat(Path, "/", 2);
- strncat(Path, pFile->d_name, strlen(pFile->d_name) + 1);
- //m_pHostApi->Debug("FindMatchedFile Path: %s.", Path);
- FindMatchedFile(Path, (LPCTSTR)tmpFindFileName, uCountFile);
- }
- else {
- //m_pHostApi->Debug("FindMatchedFile FILE name: %s.", pFile->d_name);
- if (strstr(pFile->d_name, (LPCTSTR)tmpFindFileName) != NULL) {
- ++uCountFile;
- }
- }
- }
- closedir(pDir);
- return TRUE;
- }
- #endif
- static bool OFLCmp(const OFLVideoRecord &a, const OFLVideoRecord &b)
- {
- return strcmp(a.VideoSerialID,b.VideoSerialID)>0;
- }
- CSimpleStringA DecryptString(LPCTSTR lpszEncrpyted)
- {
- 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);
- }
- void SalesRecordServiceSession::Handle_GetOFLVideoRecords( SpReqAnsContext<SalesRecorderSerVice_GetOFLVideoRecords_Req, SalesRecorderSerVice_GetOFLVideoRecords_Ans>::Pointer ctx )
- {
- CSimpleStringA Name = CSimpleStringW2A(ctx->Req.Name);
- CSimpleStringA CardNo = CSimpleStringW2A(ctx->Req.CardNo);
- CSimpleStringA BeginTime = CSimpleStringW2A(ctx->Req.BeginTime);
- CSimpleStringA EndTime = CSimpleStringW2A(ctx->Req.EndTime);
- /*Dbg("Handle_GetOFLVideoRecords:Name=%s,CardNo=%s,BeginTime=%s,EndTime=%s",(LPCTSTR)Name,(LPCTSTR)CardNo,(LPCTSTR)BeginTime,(LPCTSTR)EndTime);*/
- Dbg("Handle_GetOFLVideoRecords:BeginTime=%s,EndTime=%s",(LPCTSTR)BeginTime,(LPCTSTR)EndTime);
- ctx->Ans.VideoRecords = m_pEntity->GetOFLVideoRecords(Name, CardNo, BeginTime, EndTime);
- ctx->Answer(Error_Succeed);
- }
- void SalesRecordServiceSession::Handle_CheckVideoDiskStatus( SpReqAnsContext<SalesRecorderSerVice_CheckVideoDiskStatus_Req, SalesRecorderSerVice_CheckVideoDiskStatus_Ans>::Pointer ctx )
- {
- int nFreeRatio = 0;
- int bSufficient = CheckDiskStatus((LPCTSTR)ctx->Req.DriveLetter,m_pEntity->m_max_disk_percent,&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)
- {
- Dbg("PlayVideo name is %s.", (LPCTSTR)CSimpleStringW2A(ctx->Req.VideoName));
- ErrorCodeEnum ErrorCode = m_pEntity->HandleDisplayVideo();
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_SaveVideo(SpReqAnsContext<SalesRecorderSerVice_SaveVideo_Req, SalesRecorderSerVice_SaveVideo_Ans>::Pointer ctx)
- {
- Dbg("Save Video name is %s.", (LPCTSTR)CSimpleStringW2A(ctx->Req.VideoName));
- ErrorCodeEnum ErrorCode = m_pEntity->HandleSaveVideo();
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_StopRecord(SpReqAnsContext<SalesRecorderSerVice_StopRecord_Req, SalesRecorderSerVice_StopRecord_Ans>::Pointer ctx)
- {
- ErrorCodeEnum ErrorCode = m_pEntity->HandleStopRecord((LPCTSTR)CSimpleStringW2A(ctx->Req.VideoName));
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_SetAudioTransFlag(SpReqAnsContext<SalesRecorderSerVice_SetAudioTransFlag_Req, SalesRecorderSerVice_SetAudioTransFlag_Ans>::Pointer ctx)
- {
- Dbg("Audio transmission flag is %s.", ctx->Req.TransFlag ? "true" : "false");
- ErrorCodeEnum ErrorCode = m_pEntity->HandleSetAudioTransmissionFlag(ctx->Req.TransFlag);
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_StopShowVideo(SpReqAnsContext<SalesRecorderSerVice_StopShowVideo_Req, SalesRecorderSerVice_StopShowVideo_Ans>::Pointer ctx)
- {
- Dbg("Stop Show Video name is %s.", (LPCTSTR)CSimpleStringW2A(ctx->Req.VideoName));
- ErrorCodeEnum ErrorCode = m_pEntity->HandleStopShowVideo();
- ctx->Answer(ErrorCode);
- }
- void SalesRecordServiceSession::Handle_PlaySalesRecord(SpReqAnsContext<SalesRecorderSerVice_PlaySalesRecord_Req, SalesRecorderSerVice_PlaySalesRecord_Ans>::Pointer ctx)
- {
- Dbg("Stop Show Video name is %s.", (LPCTSTR)CSimpleStringW2A(ctx->Req.VideoName));
- ErrorCodeEnum ErrorCode = m_pEntity->HandlePlaySalesRecordVideo(ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight);
- ctx->Answer(ErrorCode);
- }
- CServerSessionBase * CSalesRecorderEntity::OnNewSession( const char* pszRemoteEntityName, const char * pszClass )
- {
- LOG_FUNCTION();
- LOG_TRACE("%s connected class = %s!", pszRemoteEntityName, 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 )
- {
- LOG_FUNCTION();
- //MessageBoxA(0,0,0,0);
- m_eDeviceType = eStand2sType;
- m_nSysCallType = 0;
- //is Pad Version
- m_bNeedRestart = false;
- m_eAudioOutQuality = eUltraHD;
- m_bIsAudioNsOn = false;
- m_iAudioNsPolicy = 2;
- m_bIsAudioTransOn = false;
- m_xIdlePre = m_xKernelPre = m_xUserPre = 0;
- #ifdef RVC_OS_WIN
- if (SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)){
- Dbg("Set Process(%d) RealTime Priority Success.",GetCurrentProcessId());
- }
- #endif
- m_eDeviceType = RvcGetDeviceType();
- int iAudioQuality = 3;
- int iAudioNsPolicy = 2;
- int iIsAudioNsOn = 0;
- m_max_disk_percent = MAX_DISK_PERCENT; // add by ly 2018/02/24
- CSmartPointer<IConfigInfo> spConfig;
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- if (spFunction->OpenConfig(Config_CenterSetting, spConfig) == Error_Succeed)
- {
- spConfig->ReadConfigValueInt("SalesRecorder","MaxDiskPercent",m_max_disk_percent);
- spConfig->ReadConfigValueInt("SalesRecorder","AudioSampleRate",m_audio_samplerate);
- spConfig->ReadConfigValueInt("SalesRecorder","AudioBitRate",m_audio_out_bitrate);
- spConfig->ReadConfigValueInt("SalesRecorder","WholeSection",m_bWholeSection);
- spConfig->ReadConfigValueInt("SalesRecorder","ApplyHighQuality",m_bApplyHighQuality);
- spConfig->ReadConfigValueInt("SalesRecorder","AudioNsPolicy",iAudioNsPolicy);
- spConfig->ReadConfigValueInt("SalesRecorder","IsAudioNsOn",iIsAudioNsOn);
- spConfig->ReadConfigValueInt("SalesRecorder","AudioQuality",iAudioQuality);
- }
- if (m_max_disk_percent <= 0 || m_max_disk_percent >= 100)
- {
- m_max_disk_percent = MAX_DISK_PERCENT;
- }
- SetRecordAudioQuality(iAudioQuality);
- SetRecordAudioNsPolicy(iAudioNsPolicy);
- if (0 != iIsAudioNsOn){
- m_bIsAudioNsOn = true;
- }
- //if (m_audio_samplerate != 8 && m_audio_samplerate != 16)
- //{
- // m_audio_samplerate = 8;
- //}
- //if (m_audio_samplerate == 8)
- //{
- // if (m_audio_out_bitrate < 8)
- // {
- // m_audio_out_bitrate = 8;
- // }
- // if (m_audio_out_bitrate > 128)
- // {
- // m_audio_out_bitrate = 128;
- // }
- //}
- //else
- //{
- // if (m_audio_out_bitrate < 8)
- // {
- // m_audio_out_bitrate = 8;
- // }
- // if (m_audio_out_bitrate > 256)
- // {
- // m_audio_out_bitrate = 256;
- // }
- //}
-
- if (m_bWholeSection != 0 && m_bWholeSection != 1)
- {
- m_bWholeSection = FALSE;
- }
- if (m_bApplyHighQuality != 0 && m_bApplyHighQuality != 1)
- {
- m_bApplyHighQuality = FALSE;
- }
- Dbg("[dbg] m_bApplyHighQuality:%d",m_bApplyHighQuality);
- m_bEwsRecord = FALSE;
- if (preOperationError != Error_Succeed)
- return preOperationError;
- ErrorCodeEnum Error = Error_Succeed;
- m_iActiveCamera = CAMERA_TYPE_ENV;
- m_iCameraState = 'N';
-
- int i = 0;
- if (ePadtype == m_eDeviceType||eMobilePadType == m_eDeviceType||eDesk2SType == m_eDeviceType||eDesk1SType == m_eDeviceType||eDesk2SIntegratedType == m_eDeviceType)
- {
- // add by ly(edit by ly 2018/03/12)
- #ifdef RVC_OS_WIN
- m_pPlayer = new Clibwmpplayer(this);
- #else
- m_pPlayer = new Clibmediaplayer(this);
- #endif // RVC_OS_WIN
- m_arrListener.Init(9);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTRECORD, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTAFTERPREVIEWRECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STOPRECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_SHOWVIDEO, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_SAVEVIDEO, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_DELETEVIDEO, NULL, false);
- 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_None, Error_IgnoreAll, EVENT_UKEY_PULLOUT, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_VIDEOAPPENDWATERMARK, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD, 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_High, Error_IgnoreAll, LOG_EVT_AUDIOSTREAM_TRANSMISSION_FAILED, NULL, false);
- }
- else
- {
- // add by ly @2018/01/10
- #ifdef RVC_OS_WIN
- m_pPlayer = new Clibwmpplayer(this);
- #else
- m_pPlayer = new Clibmediaplayer(this);
- #endif // RVC_OS_WIN
- m_arrListener.Init(8);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTRECORD, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTAFTERPREVIEWRECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STOPRECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_SHOWVIDEO, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_SAVEVIDEO, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_DELETEVIDEO, NULL, false);
- 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_None, Error_IgnoreAll, LOG_EVT_UI_VIDEOAPPENDWATERMARK, NULL, false);
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STARTREMOTERECORD, NULL, false);
- //GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_UI_STOPREMOTERECORD, 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_High, Error_IgnoreAll, LOG_EVT_AUDIOSTREAM_TRANSMISSION_FAILED, 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 if (strValue[0] == 'O')
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if(strValue[0] == 'B') ///////显示贴图
- {
- m_iActiveCamera = CAMERA_TYPE_ERROR;
- }
- else if (strValue[0] == 'N')
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- GetFunction()->RegistSysVarEvent(SYSVAR_CALLTYPE, this);
- GetFunction()->GetSysVar(SYSVAR_CALLTYPE, strValue);
- if (strValue[0] == CALLTYPE_NORMAL)
- {
- m_nSysCallType = 0;
- }
- else if (strValue[0] == CALLTYPE_MOBILE)
- {
- m_nSysCallType = 1;
- }
- else
- {
- assert(0);
- }
- Error = GetFunction()->RegistSysVarEvent("SessionID", this);
- if (Error != Error_Succeed)
- {
- LOG_TRACE("register sysvar %s failed!", "SessionID");
- }
- // add by ly 2018/02/13
- Error = GetFunction()->GetPath("Temp", m_TempDir);
- if (Error != Error_Succeed) {
- LOG_TRACE("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) {
- LOG_TRACE("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()
- {
- GetFunction()->SetTimer(TIMERID_UPOFLRECORD,this,UPLOAD_CYCLE);
- GetFunction()->SetTimer(TIMERID_DISKCHK,this,DISKCHK_CYCLE);
- }
- void CSalesRecorderEntity::OnPreClose( EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext )
- {
- ErrorCodeEnum Error = __OnClose(Error_Succeed);
- GetFunction()->KillTimer(TIMERID_UPOFLRECORD);
- GetFunction()->KillTimer(TIMERID_DISKCHK);
- pTransactionContext->SendAnswer(Error);
- }
- ErrorCodeEnum CSalesRecorderEntity::__OnClose( ErrorCodeEnum preOperationError )
- {
- LOG_FUNCTION();
- if (preOperationError != Error_Succeed)
- return preOperationError;
- // edit by ly @2018/01/10
- delete m_pPlayer; m_pPlayer = NULL;
- 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();
- return Error_Succeed;
- }
- void CSalesRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
- {
- if (Test_ShakeHand == eTestType)
- {
- if (m_bNeedRestart){
- Dbg("[OnSelfTest] entity need restart now.");
- pTransactionContext->SendAnswer(Error_Unexpect);
- }
- else{
- pTransactionContext->SendAnswer(Error_Succeed);
- }
- }
- }
- int CSalesRecorderEntity::GetActiveCamera()
- {
- //Debug("get camera = %d",nActiveCamera);
- return m_iActiveCamera;
- }
- void CSalesRecorderEntity::OnRecordFailed( bool bRecordDevFault )
- {
- Dbg("OnSalesRecordFailed!");
- if (!bRecordDevFault)
- {
- LogEvent(Severity_Middle,LOG_EVT_UI_RECORDFAILED,"0");
- }
- else
- {
- LogEvent(Severity_Middle,LOG_EVT_UI_RECORDFAILED,"1");
- }
- Dbg("Current memory usage is %d.", GetSystemMemoryUsage());
- Dbg("Current CPU usage is %f", GetSystemCpuUsage());
- }
- void CSalesRecorderEntity::OnRecordEntityExcption()
- {
- Dbg("现场销售双录出现异常,请稍候重录,系统正在恢复中,预计60秒!");
- LogEvent(Severity_High,LOG_EVT_SALESRECORD_ENTITY_EXCEPTION,"现场销售双录出现异常,请稍候重录,系统正在恢复中,预计60秒!");
- }
- void CSalesRecorderEntity::OnRecordFinished()
- {
- Dbg("现场销售录像已完成");
- LogEvent(Severity_High, LOG_EVT_SALESRECORD_FINISHED, "现场销售双录已完成.");
- }
- void CSalesRecorderEntity::Debug(const char* fmt, ...)
- {
- va_list arg;
- va_start(arg, fmt);
- vDbg(fmt, arg);
- va_end(arg);
- }
- #ifdef RVC_OS_WIN
- void CSalesRecorderEntity::WmpDebug( const char *fmt, ... )
- {
- va_list arg;
- va_start(arg, fmt);
- vDbg(fmt, arg);
- va_end(arg);
- }
- #else
- void CSalesRecorderEntity::Debug(media_loglevel log_level, const char* fmt, ...)
- {
- if (log_level >= MEDIA_LOG_ERROR) {
- va_list arg;
- va_start(arg, fmt);
- vDbg(fmt, arg);
- va_end(arg);
- }
- }
- #endif // RVC_OS_WIN
- // 定时任务:扫描是否有待提交的离线双录记录 add by ly @2018/02/08
- void CSalesRecorderEntity::OnTimeout( DWORD dwTimerID )
- {
- if (dwTimerID == TIMERID_UPOFLRECORD)
- {
- Dbg("On upload timer!");
- if (CheckNetState() == Error_Succeed) {
- UploadOFLVideoRecordTask *task = new UploadOFLVideoRecordTask(this);
- GetFunction()->PostThreadPoolTask(task);
- }
- }
- if (dwTimerID == TIMERID_DISKCHK)
- {
- if (strstr(m_SalesVideoName, "OFL")) {
- Dbg("On DISKCHK timer!");
- int nFreeRatio = 0;
- #ifdef RVC_OS_WIN
- m_last_disk_overtop = !CheckDiskStatus("C:\\",m_max_disk_percent,&nFreeRatio);
- #else
- m_last_disk_overtop = !CheckDiskStatus("/home/", m_max_disk_percent, &nFreeRatio);
- #endif
- if (m_last_disk_overtop) {
- CSimpleStringA msg = CSimpleStringA::Format("磁盘所剩空间不足%d%%,已停止离线双录!",100-m_max_disk_percent);
- Dbg((LPCTSTR)msg);
- StopRecord();
- // notify user desktop
- #ifdef RVC_OS_WIN
- MessageBoxA(NULL,(LPCSTR)msg,NULL,MB_SYSTEMMODAL);
- #endif//RVC_OS_WIN
- }
- }
- }
- }
- void CSalesRecorderEntity::OnSysVarEvent( const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName )
- {
- if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 0)
- {
- Dbg("camera state from : %c to %c", pszOldValue[0], pszValue[0]);
- m_iCameraState = pszValue[0];
- if (pszValue[0] == 'E')
- {
- m_iActiveCamera = CAMERA_TYPE_OPT;
- }
- else if (pszValue[0] == 'O')
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if(pszValue[0] == 'B') ///////显示贴图
- {
- m_iActiveCamera = CAMERA_TYPE_ERROR;
- }
- else if (pszValue[0] == 'N')
- {
- m_iActiveCamera = CAMERA_TYPE_AUTO;
- }
- }
- else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
- {
- if (m_iCameraState == 'N')
- {
- if (pszValue[0] == 'E')
- {
- m_iActiveCamera = CAMERA_TYPE_ENV;
- }
- else if (pszValue[0] == 'O')
- {
- m_iActiveCamera = CAMERA_TYPE_OPT;
- }
- }
- }
- else if (_stricmp(pszKey, SYSVAR_CALLTYPE) == 0)
- {
- Dbg("sys calltype from: %c to %c", pszOldValue[0], pszValue[0]);
- if(pszValue[0] == CALLTYPE_NORMAL)
- {
- m_nSysCallType = 0;
- }
- else if(pszValue[0] == CALLTYPE_MOBILE)
- {
- m_nSysCallType = 1;
- }
- else
- {
- m_nSysCallType = -1;
- }
- }
- }
- 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 )
- {
- // 响应客户经理销售录像相关的事件
- switch (dwUserCode)
- {
- case LOG_EVT_UI_STARTRECORD:
- case LOG_EVT_UI_STARTAFTERPREVIEWRECORD:
- Dbg("start record, pszMessage = %s.",pszMessage);
- HandleStartRecord(pszMessage, false);
- break;
- case LOG_EVT_UI_STARTREMOTERECORD:
- Dbg("start remote record, pszMessage = %s.",pszMessage);
- HandleStartRecord(pszMessage, true);
- break;
- case LOG_EVT_UI_STOPREMOTERECORD:
- Dbg("stop remote record, pszMessage = %s.",pszMessage);
- StopRecord();
- break;
- case LOG_EVT_UI_STOPRECORD:
- Dbg("stop record, pszMessage = %s.",pszMessage);
- HandleStopRecord(pszMessage);
- break;
- case LOG_EVT_UI_SHOWVIDEO:
- Dbg("show video record, pszMessage = %s.",pszMessage);
- HandleDisplayVideo();
- break;
- case LOG_EVT_UI_SAVEVIDEO:
- Dbg("save record!");
- HandleSaveVideo();
- break;
- case LOG_EVT_UI_DELETEVIDEO:
- Dbg("delete record!");
- HandleDeleteVideo();
- break;
- case LOG_EVT_UI_RETURNMENU:
- HandleReturnMenu();
- break;
- case EVENT_UKEY_PULLOUT:
- Dbg("ukey pull out!");
- HandleUkeyPullout();
- break;
- case LOG_EVT_UI_VIDEOAPPENDWATERMARK:
- Dbg("handle video append water mark param is %s.", pszMessage);
- HandleVideoAppendWatermark(pszMessage);
- break;
- case LOG_EVT_SALESRECORD_ENTITY_EXCEPTION:
- Dbg("handle sales record entity exception, and message is %s.", pszMessage);
- HandleSalesRecordEntityException(pszMessage);
- break;
- case LOG_EVT_AUDIOSTREAM_TRANSMISSION_FAILED:
- Dbg("handle audio stream transmission failed.");
- HandleStopAudioStreamEnTransQueue();
- break;
- default:
- break;
- }
- }
- // we use root.ini Video section config to decide camera count
- ErrorCodeEnum CSalesRecorderEntity::DecideCameraCount( int &nCount )
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spConfig);
- if (Error == Error_Succeed) {
- CSimpleStringA strVideoEnv;
- CSimpleStringA strVideoOpt;
- SpIniMappingTable table;
- nCount = 0;
- table.AddEntryString("Video", "EnvCamera", strVideoEnv, "$");
- table.AddEntryString("Video", "OptCamera", strVideoOpt, "$");
- Error = table.Load(spConfig);
- if (Error == Error_Succeed) {
- if (strVideoEnv.GetLength() > 1)
- nCount++;
- if (strVideoOpt.GetLength() > 1)
- nCount++;
- }
- }
- return Error;
- }
- void CSalesRecorderEntity::StartPhone2PadRecord(const int fps, const char* wmvfilename, int videoquality, int audioOutBitRate, SubtitleParam* subtitleParam, BOOL bWholeSection, BOOL bSessionManage, eRvcRecordType eRecordType)
- {
- BOOL bRet = FALSE;
- // edit by ly@2019/03/01
- if ((ePadtype == m_eDeviceType) || (eMobilePadType == m_eDeviceType) || (eDesk1SType == m_eDeviceType) || (eDesk2SIntegratedType == m_eDeviceType))
- {
- //在线双录,录像统一使用前置摄像头, pad 版增加远端视频队列
- Dbg("m_pRecorder local video is REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE.");
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- else if (eDesk2SType == m_eDeviceType)
- {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_SALES_EWS_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- else
- {
- // == 2
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- Rvc_RecordAudioParam_t tAudioParams;
- tAudioParams.eRecordType = ePhone2Pad;
- tAudioParams.eOutPutType = m_eAudioOutQuality;
- tAudioParams.bIsNsOn = m_bIsAudioNsOn;
- tAudioParams.iNsPolicy = m_iAudioNsPolicy;
- tAudioParams.iAudioOutBitRate = 8;
- tAudioParams.bIsTransOn = m_bIsAudioTransOn;
- if (m_pRecorder->StartWmvRecord(fps, videoquality, &tAudioParams, subtitleParam, bWholeSection, FALSE, (LPCSTR)m_TempDir,
- m_TempDir.GetLength(), wmvfilename, strlen(wmvfilename)))
- {
- m_bStarted = TRUE;
- }
- }
- BOOL CSalesRecorderEntity::GetStandardQualityOnSiteSalesRecorder(const eRvcRecordType eRecordType)
- {
- BOOL bRet = FALSE;
- if ((ePadtype == m_eDeviceType) || (eMobilePadType == m_eDeviceType) || eDesk2SType == m_eDeviceType)
- {
- if (!m_bEwsRecord){
- if (ePad2Agent != eRecordType) {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- else{
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- }
- else{
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_SALES_EWS_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- }
- else if(eDesk1SType == m_eDeviceType || eDesk2SIntegratedType == m_eDeviceType)
- {
- if (ePad2Agent != eRecordType) {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- else {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- }
- else
- {
- if (eStand2Agent != eRecordType){
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- else{
- m_pRecorder = new Clibwmvrecord(&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(const eRvcRecordType eRecordType)
- {
- BOOL bRet = FALSE;
- if (ePadtype == m_eDeviceType || eMobilePadType == m_eDeviceType || eDesk2SType == m_eDeviceType)
- {
- if (!m_bEwsRecord)
- {
- if (ePad2Agent == eRecordType) {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- else {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- }
- else{
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_EWS_SHM_SNAPSHOT_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- }
- else if (eDesk1SType == m_eDeviceType || eDesk2SIntegratedType == m_eDeviceType)
- {
- if (ePad2Agent == eRecordType) {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE, REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE, REC_COMMON_REMOTEAUDIO_SHM_QUEUE);
- }
- else {
- m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SALESOL_SHM_QUEUE, REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,
- NULL, REC_COMMON_AUDIO_SALES_SHM_QUEUE);
- }
- }
- else
- {
- if (eStand2Agent != eRecordType){
- m_pRecorder = new Clibwmvrecord(&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);
- }
- else{
- m_pRecorder = new Clibwmvrecord(&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* wmvfilename, int videoquality, int audioOutBitRate, SubtitleParam* subtitleParam, BOOL bWholeSection, BOOL bSessionManage, eRvcRecordType eRecordType)
- {
- BOOL bRet = FALSE;
- if (m_bApplyHighQuality)
- {
- bRet = GetHighQualityOnSiteSalesRecorder(eRecordType);
- }
- else
- {
- bRet = GetStandardQualityOnSiteSalesRecorder(eRecordType);
- }
- if (FALSE == bRet){
- Dbg("get onsite sales recorder failed.");
- return;
- }
- Rvc_RecordAudioParam_t tAudioParams;
- tAudioParams.eRecordType = eRecordType;
- tAudioParams.eOutPutType = m_eAudioOutQuality;
- tAudioParams.bIsNsOn = m_bIsAudioNsOn;
- tAudioParams.iNsPolicy = m_iAudioNsPolicy;
- tAudioParams.iAudioOutBitRate = audioOutBitRate;
- tAudioParams.bIsTransOn = m_bIsAudioTransOn;
- if (eStand2Agent == eRecordType || ePad2Agent == eRecordType) {
- tAudioParams.eOutPutType = eLowDefinition;
- tAudioParams.bIsNsOn = false;
- }
- Dbg("init lib wmv 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->StartWmvRecord(fps, videoquality, &tAudioParams, subtitleParam, bWholeSection, FALSE, (LPCSTR)m_TempDir,
- m_TempDir.GetLength(), wmvfilename, strlen(wmvfilename)))
- {
- m_bStarted = TRUE;
- }
- else {
- Dbg("Start WmvRecord failed!");
- }
- }
- void CSalesRecorderEntity::StartRecord(const char *wmvfilename, int videoquality, int audioOutBitRate, SubtitleParam *subtitleParam /* = NULL */, BOOL bWholeSection /* = FALSE */, BOOL bSessionManage /* = FALSE */, eRvcRecordType eRecordType /* = eSingleSide */)
- {
- Dbg("wmvfilename = %s", wmvfilename);
- //Dbg("strPath = %s", (LPCSTR)m_TempDir);
- int fps = 5;
- //是否需要录制双向视频和音频
- if(m_nSysCallType == 1)
- {
- StartPhone2PadRecord(fps, wmvfilename, videoquality, audioOutBitRate, subtitleParam, bWholeSection, bSessionManage, eRecordType);
- }
- // 现场销售录音录像
- else
- {
- StartOnSiteSalesRecord(fps, wmvfilename, videoquality, audioOutBitRate, subtitleParam, bWholeSection, bSessionManage, eRecordType);
- }
- }
- ErrorCodeEnum CSalesRecorderEntity::StopRecord()
- {
- ErrorCodeEnum eCode = Error_Succeed;
- if (m_bStarted)
- {
- m_pRecorder->StopWmvRecord();
- delete m_pRecorder;
- m_pRecorder = NULL;
- m_bStarted = FALSE;
- }
- else{
- eCode = Error_InvalidState;
- }
- return eCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::ShowVideo( const char *wmvfilename )
- {
- 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*.wmv", wmvfilename);
- ULONGLONG uVideoCount = 0;
- BOOL bRet = FindMatchedFile((LPCSTR)strPath, (LPCTSTR)strFindFileName, uVideoCount);
- Dbg("bRet = %d while find %s", bRet, wmvfilename);
- if(bRet){
- Dbg("succeed to get record count while play video!");
- Dbg("m_pPlayer = %p while play!", m_pPlayer);
- m_pPlayer->PlayVideo((LPCSTR)strPath, wmvfilename, uVideoCount);
- Dbg("succeed to play video!");
- }
- else{
- ErrorCode = Error_NotExist;
- Dbg("play video failed for %s no exist!", wmvfilename);
- }
- }
- }
- else{
- ErrorCode = Error_NotImpl;
- }
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::PlaySalesRecordVideo( const char *wmvfilename, int iWndX, int iWndY, int iWndWidth, int iWndHeight)
- {
- 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*.wmv", wmvfilename);
- ULONGLONG uVideoCount = 0;
- BOOL bRet = FindMatchedFile((LPCSTR)strPath, (LPCTSTR)strFindFileName, uVideoCount);
- Dbg("bRet = %d while find %s", bRet, wmvfilename);
- if(bRet){
- Dbg("succeed to get record count while play sales record video!");
- Dbg("m_pPlayer = %p while play!", m_pPlayer);
- m_pPlayer->PlaySalesRecordVideo(iWndX, iWndY, iWndWidth, iWndHeight,(LPCSTR)strPath, wmvfilename, uVideoCount);
- Dbg("succeed to play sales record video!");
- }
- else{
- ErrorCode = Error_NotExist;
- Dbg("play play sales record video failed for %s no exist!", wmvfilename);
- }
- }
- }
- else{
- ErrorCode = Error_NotImpl;
- }
- return ErrorCode;
- }
- void CSalesRecorderEntity::DeleteAllVideo( const char *wmvfilename )
- {
- 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;
- }
- ULONGLONG uVideoCount = 0;
- // 删除客户经理录像 edit by ly 2018/03/05
- CSimpleStringA strFindFileName = CSimpleStringA::Format("S_%s*.wmv", wmvfilename);
- if (strstr(m_SalesVideoName, "OFL")) {
- strFindFileName = CSimpleStringA::Format("OFL_%s*.wmv", wmvfilename);
- }
- BOOL bRet = FindMatchedFile((LPCSTR)strPath, (LPCSTR)strFindFileName, uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- Dbg("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.wmv", (LPCSTR)strPath, (LPCSTR)strFindFileName, i);
- bRet = DeleteFile((LPCSTR)fileName);
- if(!bRet) {
- bDeleteSucc = FALSE;
- Dbg("Error Code %lu while delete %s ", GetLastError(), (LPCSTR)fileName);
- }
- }
- if (bDeleteSucc) {
- Dbg("succeed to delete sales video!");
- }
- }
- else
- {
- Dbg("sales videos not exist or have been deleted!");
- }
- // 删除见证录像
- uVideoCount = 0;
- strFindFileName = CSimpleStringA::Format("W_%s*.wmv", wmvfilename);
- bRet = FindMatchedFile((LPCSTR)strPath, (LPCSTR)strFindFileName, uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- Dbg("succeed to get witness record count while delete video!");
- CSimpleStringA fileName;
- BOOL bDeleteSucc = TRUE;
- Dbg("uVideoCount=%d", uVideoCount);
- for(int i = 0; i != uVideoCount; ++i)
- {
- fileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)strPath, (LPCSTR)strFindFileName, i);
- bRet = DeleteFile((LPCSTR)fileName);
- if(!bRet) {
- bDeleteSucc = FALSE;
- Dbg("Error Code %lu while delete %s ", GetLastError(), (LPCSTR)fileName);
- }
- }
- if (bDeleteSucc) {
- Dbg("succeed to delete witness video!");
- }
- }
- else
- {
- Dbg("witness videos not exist or have been deleted!");
- }
- }
- }
- }
- void CSalesRecorderEntity::DeleteVideo( const char *wmvfilename )
- {
- 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*.wmv", wmvfilename);
- ULONGLONG uVideoCount = 0;
- BOOL bRet = FindMatchedFile((LPCSTR)strPath, (LPCTSTR)strFindFileName, uVideoCount);
- if(bRet)
- {
- Dbg("succeed to get record count while delete video!");
- CSimpleStringA fileName;
- BOOL bDeleteSucc = TRUE;
- for(int i = 0; i != uVideoCount; ++i)
- {
- fileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)strPath, wmvfilename, i);
- bRet = DeleteFile((LPCSTR)fileName);
- if(!bRet) {
- bDeleteSucc = FALSE;
- Dbg("Error Code %lu while delete %s ", GetLastError(), (LPCSTR)fileName);
- }
- }
- if (bDeleteSucc) {
- Dbg("succeed to delete videos!");
- }
- }
- else
- {
- Dbg("[DeleteVideo] videos not exist or have been deleted!");
- }
- }
- }
- }
- /*
- SaveVideo包含两步,找到录像和移动录像
- Error_Succeed 提交上传成功
- Error_NotExist not exist
- Error_NotImpl 方法执行失败
- */
- ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char *wmvfilename )
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- 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;
- }
- ULONGLONG uVideoCount = 0;
- // 移动销售录像 edit by ly 2018/03/05
- CSimpleStringA strFindFileName = CSimpleStringA::Format("S_%s*.wmv", wmvfilename);
- if (strstr(m_SalesVideoName, "OFL")) {
- strFindFileName = CSimpleStringA::Format("OFL_%s*.wmv", wmvfilename);
- }
- BOOL bRet = FindMatchedFile((LPCSTR)sourPath, (LPCSTR)strFindFileName, uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- Dbg("succeed to get sales record count while save video!");
- 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 = TRUE;
- Dbg("strFindFileName=%s", (LPCSTR)strFindFileName);
- for(int i = 0; i != uVideoCount; ++i)
- {
- sourFileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)sourPath, (LPCSTR)strFindFileName, i);
- destFileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)destPath, (LPCSTR)strFindFileName, i);
- bRet = MoveFile((LPCSTR)sourFileName, (LPCSTR)destFileName);
- if(!bRet) {
- bMoveSucc = FALSE;
- Dbg("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
- ErrorCode = Error_NotImpl;
- }
- }
- if (bMoveSucc) {
- Dbg("succeed to save sales video!");
- }
- }
- }
- else
- {
- Dbg("sales videos not exist or have been deleted!");
- ErrorCode = Error_NotExist;
- }
- // 移动见证录像
- uVideoCount = 0;
- strFindFileName = CSimpleStringA::Format("W_%s*.wmv", wmvfilename);
- bRet = FindMatchedFile((LPCSTR)sourPath, (LPCSTR)strFindFileName, uVideoCount);
- if(bRet)
- {
- strFindFileName = strFindFileName.SubString(0,strFindFileName.GetLength()-5);
- Dbg("succeed to get witness record count while save video!");
- 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 = TRUE;
- Dbg("uVideoCount=%d", uVideoCount);
- for(int i = 0; i != uVideoCount; ++i)
- {
- sourFileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)sourPath, (LPCSTR)strFindFileName, i);
- destFileName = CSimpleStringA::Format("%s%s_%d.wmv", (LPCSTR)destPath, (LPCSTR)strFindFileName, i);
- bRet = MoveFile((LPCSTR)sourFileName, (LPCSTR)destFileName);
- if(!bRet) {
- bMoveSucc = FALSE;
- Dbg("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
- }
- }
- if (bMoveSucc) {
- Dbg("succeed to save witness video!");
- ErrorCode = Error_Succeed;
- }
- }
- }
- else
- {
- Dbg("witness videos not exist or have been deleted!");
- }
- }
- }
- else{
- ErrorCode = Error_NotImpl;
- }
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::CheckNetState()
- {
- auto rc = Error_Succeed;
- auto pMobileDialClient = new MobileDial::MobileDialService_ClientBase(this);
- if(pMobileDialClient->Connect() != Error_Succeed)
- {
- pMobileDialClient->SafeDelete();
- pMobileDialClient = NULL;
- rc = Error_DevConnFailed;
- }
- else
- {
- Dbg("MobileDialClient connected success!");
- MobileDial::MobileDialService_Query_Req req;
- MobileDial::MobileDialService_Query_Ans ans;
- rc = pMobileDialClient->Query(req, ans, 5000);
- if(rc != Error_Succeed)
- {
- Dbg("Query Network status failed return 0x%08x", rc);
- }
- else
- {
- //网络已断开
- if(ans.netstatus == 0)
- {
- Dbg("Disconnected: %s", (LPCTSTR)ans.reserved3);
- CSimpleStringA csRet = ans.reserved3;
- CAutoArray<CSimpleStringA> splitStrings = csRet.Split('#');
- if(splitStrings.GetCount() >= 2)
- {
- Dbg("%s %s", (LPCTSTR)splitStrings[0], (LPCTSTR)splitStrings[1]);
- }
- rc = Error_NetBroken;
- }
- //网络已连接,返回信号值
- else
- {
- Dbg("Connected and signal %d", ans.netstatus);
- }
- }
- pMobileDialClient->GetFunction()->CloseSession();
- pMobileDialClient = NULL;
- }
- return rc;
- }
- CSimpleStringA CSalesRecorderEntity::GetTerminalStage()
- {
- CSmartPointer<IEntityFunction> Func = GetFunction();
- CSimpleStringA strValue = "";
- Func->GetSysVar("TerminalStage", strValue);
- Dbg("TerminalStage:%s", (LPCTSTR)strValue);
- return strValue;
- }
- ErrorCodeEnum CSalesRecorderEntity::LoadServerConfig()
- {
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_CenterSetting, spConfig);
- if (Error == Error_Succeed) {
- CSimpleStringA str;
- Error = spConfig->ReadConfigValue("SalesRecorder", "Server", str);
- if (Error == Error_Succeed)
- {
- Error = ParseIPAddress(str, m_server1, m_server1_port);
- }
- if (Error == Error_Succeed)
- {
- ErrorCodeEnum ErrorCode;
- ErrorCode = spConfig->ReadConfigValue("SalesRecorder", "Server_Backup", str);
- if (ErrorCode == Error_Succeed)
- {
- ErrorCode = ParseIPAddress(str, m_server2, m_server2_port);
- }
- if (ErrorCode != Error_Succeed)
- {
- m_server2 = NULL;
- m_server2_port = 0;
- }
- }
- }
- return Error;
- }
- bool CSalesRecorderEntity::SecureClientConnect()
- {
- if (m_pConnection!=NULL && m_pConnection->IsConnectionOK())
- {
- return true;
- }
- SecureClientRelease();
- m_pConnection = new CUploadOFLRecordConnection(this);
- return m_pConnection->ConnectFromCentralSetting();
- }
- void CSalesRecorderEntity::SecureClientRelease()
- {
- if (m_pConnection != NULL)
- {
- if (m_pConnection->IsConnectionOK())
- {
- m_pConnection->Close();
- }
- m_pConnection->DecRefCount();
- m_pConnection = NULL;
- }
- }
- void CSalesRecorderEntity::OnEndUploadRecord( const char *videoserialid, int result )
- {
- Dbg("%s upload result: %d", videoserialid, result);
- if (0 == result)
- {
- Dbg("succeed to save video record: OFL_%s", videoserialid);
- CSimpleStringA cfn = CSimpleStringA::Format("%sOFL_%s.txt", (LPCTSTR)m_TempDir, videoserialid);
- DeleteFile(cfn);
- }
- }
- // 请求InteractiveControl结束录像 add by ly 2018/03/12
- ErrorCodeEnum CSalesRecorderEntity::StopRecordVideo()
- {
- auto rc = Error_Succeed;
- auto pUIClient = new InteractiveControl::UIService_ClientBase(this);
- if(pUIClient->Connect() != Error_Succeed)
- {
- pUIClient->SafeDelete();
- pUIClient = NULL;
- rc = Error_DevConnFailed;
- }
- else
- {
- Dbg("UIClient connected success!");
- InteractiveControl::UIService_StopRecordVideo_Req req;
- InteractiveControl::UIService_StopRecordVideo_Ans ans;
- rc = pUIClient->StopRecordVideo(req, ans, 5000);
- if(rc != Error_Succeed)
- {
- Dbg("Stop record video failed return 0x%08x", rc);
- }
- pUIClient->GetFunction()->CloseSession();
- pUIClient = NULL;
- }
- return rc;
- }
- BOOL CSalesRecorderEntity::OFLRecordInit( char *pszVideoParam[] )
- {
- if (pszVideoParam == NULL) {
- return FALSE;
- }
- CSimpleStringA fn = CSimpleStringA::Format("%s%s.txt",
- (LPCTSTR)m_TempDir,pszVideoParam[4]);
- HANDLE hFile = CreateFile((LPCTSTR)fn,GENERIC_WRITE,FILE_SHARE_READ,
- NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
- if (hFile != INVALID_HANDLE_VALUE) {
- CloseHandle(hFile);
- hFile = NULL;
- WritePrivateProfileString("VideoRecord","CardNo",pszVideoParam[5],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","Name",pszVideoParam[6],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","ProductCode",pszVideoParam[7],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","ProductName",pszVideoParam[8],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","ManagerSAP",pszVideoParam[9],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","ManagerName",pszVideoParam[10],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","ProductType",pszVideoParam[11],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","BusinessType",pszVideoParam[12],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","CompanyCode",pszVideoParam[13],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","WitnessSAP",pszVideoParam[14],(LPCTSTR)fn);
- WritePrivateProfileString("VideoRecord","WitnessName",pszVideoParam[15],(LPCTSTR)fn);
- return TRUE;
- }
- else {
- Dbg("error to create file %s(error code:%d)!",(LPCTSTR)fn,GetLastError());
- return FALSE;
- }
- }
- void CSalesRecorderEntity::SaveOFLRecordDuration( int nDuration )
- {
- CSimpleStringA cfn = CSimpleStringA::Format("%s%s.txt",
- (LPCTSTR)m_TempDir,m_SalesVideoName);
- char strtmp[20] = {0};
- sprintf_s(strtmp, 20, "%d", nDuration);
- WritePrivateProfileString("VideoRecord","Duration",strtmp,(LPCTSTR)cfn);
- }
- void CSalesRecorderEntity::UploadOFLVideoRecord( const char *videorecordname )
- {
- if (videorecordname == NULL)
- {
- if (SecureClientConnect())
- {
- auto arr = fileutil_get_sub_files((LPCTSTR)m_TempDir);
- if (arr != NULL)
- {
- char szTmp[128];
- std::vector<offline_video_record_t *> videorecordlist;
- for (int i = 0; i < arr->nelts; ++i)
- {
- char *pszFile = ARRAY_IDX(arr, i, char*);
- if (strstr(pszFile,".txt") && strstr(pszFile,"OFL")
- && (!strlen(m_SalesVideoName) || !strstr(pszFile,m_SalesVideoName)))
- {
- if (videorecordlist.size() >= MAX_LISTSIZE)
- {
- break;
- }
- offline_video_record_t* r = ZALLOC_T(offline_video_record_t);
- r->TerminalNo = _strdup((LPCTSTR)m_terminalNo);
- CSimpleStringA filename = pszFile;
- int pos = filename.IndexOf("OFL");
- filename = filename.SubString(pos, filename.GetLength() - pos);
- sscanf((LPCTSTR)filename, "OFL_%[^.].txt", szTmp);
- r->VideoSerialID = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "CardNo", "", szTmp, 128, pszFile);
- r->CardNo = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "Name", "", szTmp, 128, pszFile);
- r->Name = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductCode", "", szTmp, 128, pszFile);
- r->ProductCode = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductName", "", szTmp, 128, pszFile);
- r->ProductName = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerSAP", "", szTmp, 128, pszFile);
- r->ManagerSAP = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerName", "", szTmp, 128, pszFile);
- r->ManagerName = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductType", "", szTmp, 128, pszFile);
- r->ProductType = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "BusinessType", "", szTmp, 128, pszFile);
- r->BusinessType = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "CompanyCode", "", szTmp, 128, pszFile);
- r->CompanyCode = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessSAP", "", szTmp, 128, pszFile);
- r->WitnessSAP = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessName", "", szTmp, 128, pszFile);
- r->WitnessName = _strdup(szTmp);
- r->Duration = GetPrivateProfileInt("VideoRecord", "Duration", 0, pszFile);
- videorecordlist.push_back(r);
- }
- else if (strstr(pszFile,".wmv") && strstr(pszFile,"OFL")
- && (!strlen(m_SalesVideoName) || !strstr(pszFile,m_SalesVideoName)))
- {
- CSimpleStringA strWmvFile = pszFile;
- int pos = strWmvFile.IndexOf("OFL");
- strWmvFile = strWmvFile.SubString(pos, strWmvFile.GetLength() - pos);
- CSimpleStringA srcfn = CSimpleStringA::Format("%s%s",
- (LPCTSTR)m_TempDir,(LPCTSTR)strWmvFile);
- CSimpleStringA dstfn = CSimpleStringA::Format("%s%s",
- (LPCTSTR)m_RecordSaveDir,(LPCTSTR)strWmvFile);
- BOOL bRet = MoveFile((LPCSTR)srcfn, (LPCSTR)dstfn);
- if(!bRet) {
- Dbg("Error Code %lu while move %s ", GetLastError(), (LPCSTR)srcfn);
- }
- }
- }
- Dbg("%d records added to upload list.", videorecordlist.size());
- toolkit_array_free2(arr);
- if (m_pConnection != NULL && m_pConnection->IsConnectionOK())
- {
- if (videorecordlist.size() > 0)
- {
- m_pConnection->SendOFLVideoRecords(videorecordlist);
- }
- }
- for (std::vector<offline_video_record_t *>::size_type i = 0; i < videorecordlist.size(); ++i)
- {
- offline_video_record_destroy(videorecordlist[i]);
- }
- }
- }
- }
- else
- {
- if (SecureClientConnect())
- {
- if (m_pConnection != NULL && m_pConnection->IsConnectionOK())
- {
- char szTmp[128];
- offline_video_record_t* r = ZALLOC_T(offline_video_record_t);
- r->TerminalNo = _strdup((LPCTSTR)m_terminalNo);
- CSimpleStringA filename = videorecordname;
- int pos = filename.IndexOf("OFL");
- filename = filename.SubString(pos, filename.GetLength() - pos);
- sscanf((LPCTSTR)filename, "OFL_%[^.].txt", szTmp);
- r->VideoSerialID = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "CardNo", "", szTmp, 128, videorecordname);
- r->CardNo = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "Name", "", szTmp, 128, videorecordname);
- r->Name = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductCode", "", szTmp, 128, videorecordname);
- r->ProductCode = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductName", "", szTmp, 128, videorecordname);
- r->ProductName = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerSAP", "", szTmp, 128, videorecordname);
- r->ManagerSAP = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerName", "", szTmp, 128, videorecordname);
- r->ManagerName = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "ProductType", "", szTmp, 128, videorecordname);
- r->ProductType = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "BusinessType", "", szTmp, 128, videorecordname);
- r->BusinessType = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "CompanyCode", "", szTmp, 128, videorecordname);
- r->CompanyCode = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessSAP", "", szTmp, 128, videorecordname);
- r->WitnessSAP = _strdup(szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessName", "", szTmp, 128, videorecordname);
- r->WitnessName = _strdup(szTmp);
- r->Duration = GetPrivateProfileInt("VideoRecord", "Duration", 0, videorecordname);
- m_pConnection->SendOFLVideoRecord(r);
- offline_video_record_destroy(r);
- }
- }
- }
- }
- CSimpleStringW CSalesRecorderEntity::GetOFLVideoRecords( CSimpleStringA Name, CSimpleStringA CardNo, CSimpleStringA BeginTime, CSimpleStringA EndTime )
- {
- CSimpleStringA result("");
- std::vector<OFLVideoRecord> videorecordlist;
- auto arr = fileutil_get_sub_files((LPCTSTR)m_TempDir);
- if (arr != NULL)
- {
- char szTmp[128];
- for (int i = 0; i < arr->nelts; ++i)
- {
- char *pszFile = ARRAY_IDX(arr, i, char*);
- if (strstr(pszFile,".txt") && strstr(pszFile,"OFL")
- && (!strlen(m_SalesVideoName) || !strstr(pszFile,m_SalesVideoName)))
- {
- OFLVideoRecord r;
- ZeroMemory(&r,sizeof(OFLVideoRecord));
- CSimpleStringA filename = pszFile;
- int pos = filename.IndexOf("OFL");
- filename = filename.SubString(pos, filename.GetLength() - pos);
- sscanf((LPCTSTR)filename, "OFL_%[^.].txt", szTmp);
- strcpy(r.VideoSerialID,szTmp);
- GetPrivateProfileString("VideoRecord", "CardNo", "", szTmp, 128, pszFile);
- strcpy(r.CardNo,szTmp);
- GetPrivateProfileString("VideoRecord", "Name", "", szTmp, 128, pszFile);
- strcpy(r.Name,szTmp);
- GetPrivateProfileString("VideoRecord", "ProductCode", "", szTmp, 128, pszFile);
- strcpy(r.ProductCode,szTmp);
- GetPrivateProfileString("VideoRecord", "ProductName", "", szTmp, 128, pszFile);
- strcpy(r.ProductName,szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerSAP", "", szTmp, 128, pszFile);
- strcpy(r.ManagerSAP,szTmp);
- GetPrivateProfileString("VideoRecord", "ManagerName", "", szTmp, 128, pszFile);
- strcpy(r.ManagerName,szTmp);
- GetPrivateProfileString("VideoRecord", "ProductType", "", szTmp, 128, pszFile);
- strcpy(r.ProductType,szTmp);
- GetPrivateProfileString("VideoRecord", "BusinessType", "", szTmp, 128, pszFile);
- strcpy(r.BusinessType,szTmp);
- GetPrivateProfileString("VideoRecord", "CompanyCode", "", szTmp, 128, pszFile);
- strcpy(r.CompanyCode,szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessSAP", "", szTmp, 128, pszFile);
- strcpy(r.WitnessSAP,szTmp);
- GetPrivateProfileString("VideoRecord", "WitnessName", "", szTmp, 128, pszFile);
- strcpy(r.WitnessName,szTmp);
- r.Duration = GetPrivateProfileInt("VideoRecord", "Duration", 0, pszFile);
- CSimpleStringA _BeginTime = VideoSerialID2TimeString(r.VideoSerialID);
- strcpy(r.BeginTime,(LPCTSTR)_BeginTime);
- if (Name.GetLength() > 0 && strcmp(r.Name,(LPCTSTR)Name))
- {
- continue;
- }
- if (CardNo.GetLength() > 0 && strcmp(r.CardNo,(LPCTSTR)CardNo))
- {
- continue;
- }
- if (BeginTime.GetLength() > 0 && BeginTime.Compare(_BeginTime) > 0)
- {
- continue;
- }
- if (EndTime.GetLength() > 0 && EndTime.Compare(_BeginTime) < 0)
- {
- continue;
- }
- videorecordlist.push_back(r);
- }
- }
- Dbg("%d offline video records added to list.", videorecordlist.size());
- toolkit_array_free2(arr);
- }
- sort(videorecordlist.begin(),videorecordlist.end(),OFLCmp); // 按日期倒序排列
- for (std::vector<OFLVideoRecord>::size_type i = 0; i < videorecordlist.size(); ++i)
- {
- OFLVideoRecord &item = videorecordlist[i];
- CSimpleStringA r = CSimpleStringA::Format("VideoSerialID=%s;BeginTime=%s;CardNo=%s;Name=%s;ProductCode=%s;ProductName=%s;ManagerSAP=%s;ManagerName=%s;ProductType=%s;BusinessType=%s;CompanyCode=%s;WitnessSAP=%s;WitnessName=%s",
- item.VideoSerialID,item.BeginTime,item.CardNo,item.Name, item.ProductCode,item.ProductName,item.ManagerSAP,item.ManagerName,item.ProductType,item.BusinessType,item.CompanyCode,item.WitnessSAP,item.WitnessName);
- result += r;
- if (i != videorecordlist.size()-1)
- {
- result += "|";
- }
- }
- return CSimpleStringA2W(result);
- }
- void CSalesRecorderEntity::HandleStartRecord(const char *pszMessage, const bool bRemoteRecord)
- {
- eRvcRecordType eRecordType = eSingleSide;
- if (NULL == pszMessage){
- return;
- }
- size_t ulen = strlen(pszMessage);
- char *tmp = new char[ulen+1];
- m_bEwsRecord = FALSE;
-
- if ((false == bRemoteRecord) && (ulen >= EWS_CAMERA_FLAG_LEN) && (0 == strnicmp(pszMessage,EWS_CAMERA_FLAG,EWS_CAMERA_FLAG_LEN)))
- {
- m_bEwsRecord = TRUE;
- //strncpy_s(tmp, ulen+1, pszMessage+EWS_CAMERA_FLAG_LEN, ulen-EWS_CAMERA_FLAG_LEN);
- strncpy(tmp, pszMessage + EWS_CAMERA_FLAG_LEN, ulen - EWS_CAMERA_FLAG_LEN);
- }
- else{
- //strncpy_s(tmp, ulen+1, pszMessage, ulen);
- strncpy(tmp, pszMessage, ulen);
- }
-
- char *result[16] = {0};
- //CStringSplit(tmp, result, "@");
- // 解决中文stringsplit偶现乱码的问题 edit by ly@2018/07/04
- 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<LPSTR>(arr2[i].GetData());
- }
- sprintf(m_SalesVideoName, "%s", result[4]);//录像名:录像类型标志_录像流水号(如S_C13213EF)
- RecordSubTitle subTitle;
- ZeroMemory(&subTitle,sizeof(RecordSubTitle));
- CSimpleStringA strCardNo = DecryptString(result[5]);
- if (sizeof(subTitle.CustCardNo) > strCardNo.GetLength()) {
- strcpy_s(subTitle.CustCardNo, 24, strCardNo.GetData());
- }
- else {
- Dbg("Invalid CustCardNo.");
- }
- char *pStr = result[6]; // edit by ly 2018/03/21
- CSimpleStringW szCustName = CSimpleStringA2W(pStr);
- if (szCustName.GetLength() <= 4) {
- strcpy(subTitle.CustName, pStr);
- }
- else {
- CSimpleStringW aa = szCustName.SubString(0,4);
- sprintf(subTitle.CustName,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- }
-
- // 解决产品代码、产品名称过长,画面上显示不下的问题 add by ly at 20160603(edit by ly 2018/03/21)
- // 朝朝赢和招财赢支持双向录像
- pStr = result[7];
- int nProductCodeLen = strlen(pStr);
- Dbg("ProductCode = %s, and nProductCodeLen = %d.", pStr, nProductCodeLen);
- 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);
- sprintf(subTitle.ProductCode,"%s...%s",aa,bb);
- }
- Dbg("subTitle.ProductCode=%s",subTitle.ProductCode);
- pStr = result[8];
- 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);
- sprintf(subTitle.ProductName,"%s...%s",(LPCTSTR)CSimpleStringW2A(aa),(LPCTSTR)CSimpleStringW2A(bb));
- }
- Dbg("subTitle.ProductName=%s",subTitle.ProductName);
- // edit by ly @2018/03/21
- 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);
- sprintf(subTitle.CustManagerName,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- }
- } else {
- subTitle.CustManagerName[0] = '\0';
- }
- Dbg("subTitle.CustManagerName=%s",subTitle.CustManagerName);
- // 如果是离线双录,则保存业务要素到外存 add by ly 2018/03/08
- if (strstr(m_SalesVideoName, "OFL")) {
- strcpy(subTitle.Reserved1, result[14]); // 保存见证人员sap
- pStr = result[15];
- CSimpleStringW szWitnessName = CSimpleStringA2W(pStr);
- if (szWitnessName.GetLength() <= 4) {
- strcpy(subTitle.Reserved2, result[15]); // 保存见证人员姓名
- }
- else {
- CSimpleStringW aa = szWitnessName.SubString(0,4);
- sprintf(subTitle.Reserved2,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- }
- Dbg("subTitle.WitnessName=%s",subTitle.Reserved2);
- Dbg("[OFLRecordInit]:%d", OFLRecordInit(result));
- }
- delete[] tmp;
- tmp = NULL;
- SubtitleParam subtitleParam;
- ZeroMemory(&subtitleParam,sizeof(SubtitleParam));
- subtitleParam.bSubtitle = TRUE;
- subtitleParam.bSubtitleSection = TRUE;
- subtitleParam.topSubtitleData[0] = '\0';
- if (strlen(subTitle.SapID)>0&&strlen(subTitle.CustManagerName)>0) // 有无客户经理的双录字幕 edit by ly @2018/01/10
- {
- sprintf(subtitleParam.bottomSubtitleData1, "%s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode);
- sprintf(subtitleParam.bottomSubtitleData2, "%s %s %s", subTitle.ProductName, subTitle.SapID, subTitle.CustManagerName);
- if (strstr(m_SalesVideoName,"OFL") && stricmp(subTitle.Reserved1,"X") && stricmp(subTitle.Reserved2,"X"))
- {
- sprintf(subtitleParam.bottomSubtitleData1, "%s %s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode, subTitle.ProductName);
- sprintf(subtitleParam.bottomSubtitleData2, "%s %s %s %s", subTitle.SapID, subTitle.CustManagerName, subTitle.Reserved1, subTitle.Reserved2);
- }
- }
- else
- {
- sprintf(subtitleParam.bottomSubtitleData1, "%s %s", subTitle.CustCardNo, subTitle.CustName);
- sprintf(subtitleParam.bottomSubtitleData2, "%s %s", subTitle.ProductCode, subTitle.ProductName);
- }
- int i_audio_out_bitrate = m_audio_out_bitrate;
- if (bRemoteRecord)
- {
- if (m_eDeviceType == eStand2sType) { //如果是大机
- eRecordType = eStand2Agent; //可视柜台大机的双向录像
- }
- else{
- eRecordType = ePad2Agent; //可视柜台pad的双向录像
- }
- if(256 == m_audio_out_bitrate){
- i_audio_out_bitrate = 128;
- Dbg("change remote record audio out bitrate to %d.", i_audio_out_bitrate);
- }
- }
- StartRecord(m_SalesVideoName, 90, i_audio_out_bitrate, &subtitleParam, m_bWholeSection, FALSE, eRecordType);
- }
- //void CSalesRecorderEntity::HandleStartRecord(const char *pszMessage)
- //{
- // int nRecordBothSideType = 0;
- // /*Dbg("pszMessage = %s", pszMessage);*/
- // char *tmp = new char[strlen(pszMessage)+1];
- // m_bEwsRecord = FALSE;
- // if (strlen(pszMessage)>=4&&!strnicmp(pszMessage,"ews|",4))
- // {
- // m_bEwsRecord = TRUE;
- // }
- //
- // if (!m_bEwsRecord)
- // {
- // strcpy(tmp, pszMessage);
- // }
- // else
- // {
- // strcpy(tmp, pszMessage+4);
- // }
- //
- // char *result[16] = {0};
- // //CStringSplit(tmp, result, "@");
- // // 解决中文stringsplit偶现乱码的问题 edit by ly@2018/07/04
- // 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<LPSTR>(arr2[i].GetData());
- // }
- //
- // sprintf(m_SalesVideoName, "%s", result[4]);//录像名:录像类型标志_录像流水号(如S_C13213EF)
- // RecordSubTitle subTitle;
- // ZeroMemory(&subTitle,sizeof(RecordSubTitle));
- // strcpy(subTitle.CustCardNo, result[5]);
- //
- // char *pStr = result[6]; // edit by ly 2018/03/21
- // CSimpleStringW szCustName = CSimpleStringA2W(pStr);
- // if (szCustName.GetLength() <= 4) {
- // strcpy(subTitle.CustName, pStr);
- // }
- // else {
- // CSimpleStringW aa = szCustName.SubString(0,4);
- // sprintf(subTitle.CustName,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- // }
- // /*Dbg("lytest subTitle.CustName=%s",subTitle.CustName);*/
- //
- // // 解决产品代码、产品名称过长,画面上显示不下的问题 add by ly at 20160603(edit by ly 2018/03/21)
- // // 朝朝赢和招财赢支持双向录像
- // pStr = result[7];
- // int nProductCodeLen = strlen(pStr);
- // Dbg("ProductCode = %s, and nProductCodeLen = %d.", pStr, nProductCodeLen);
- // if (0 == memcmp(pStr, "000607", nProductCodeLen) || 0 == memcmp(pStr, "ZCY", nProductCodeLen))
- // {
- // if (m_eDeviceType == eStand2sType) //如果是大机
- // {
- // nRecordBothSideType = 3; //可视柜台大机的双向录像
- // }
- // else
- // {
- // nRecordBothSideType = 2; //可视柜台pad的双向录像
- // }
- // Dbg("nRecordBothSideType =%d", nRecordBothSideType);
- // }
- // 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);
- // sprintf(subTitle.ProductCode,"%s...%s",aa,bb);
- // }
- // Dbg("lytest subTitle.ProductCode=%s",subTitle.ProductCode);
- //
- // pStr = result[8];
- // 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);
- // sprintf(subTitle.ProductName,"%s...%s",(LPCTSTR)CSimpleStringW2A(aa),(LPCTSTR)CSimpleStringW2A(bb));
- // }
- // Dbg("lytest subTitle.ProductName=%s",subTitle.ProductName);
- //
- // // edit by ly @2018/03/21
- // 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);
- // sprintf(subTitle.CustManagerName,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- // }
- // } else {
- // subTitle.CustManagerName[0] = '\0';
- // }
- // Dbg("lytest subTitle.CustManagerName=%s",subTitle.CustManagerName);
- //
- // // 如果是离线双录,则保存业务要素到外存 add by ly 2018/03/08
- // if (strstr(m_SalesVideoName, "OFL")) {
- // strcpy(subTitle.Reserved1, result[14]); // 保存见证人员sap
- //
- // pStr = result[15];
- // CSimpleStringW szWitnessName = CSimpleStringA2W(pStr);
- // if (szWitnessName.GetLength() <= 4) {
- // strcpy(subTitle.Reserved2, result[15]); // 保存见证人员姓名
- // }
- // else {
- // CSimpleStringW aa = szWitnessName.SubString(0,4);
- // sprintf(subTitle.Reserved2,"%s...",(LPCTSTR)CSimpleStringW2A(aa));
- // }
- // Dbg("lytest subTitle.WitnessName=%s",subTitle.Reserved2);
- //
- // Dbg("[OFLRecordInit]:%d", OFLRecordInit(result));
- // }
- //
- // delete[] tmp;
- // tmp = NULL;
- //
- // SubtitleParam subtitleParam;
- // ZeroMemory(&subtitleParam,sizeof(SubtitleParam));
- // subtitleParam.bSubtitle = TRUE;
- // subtitleParam.bSubtitleSection = TRUE;
- // subtitleParam.topSubtitleData[0] = '\0';
- // if (strlen(subTitle.SapID)>0&&strlen(subTitle.CustManagerName)>0) // 有无客户经理的双录字幕 edit by ly @2018/01/10
- // {
- // sprintf(subtitleParam.bottomSubtitleData1, "%s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode);
- // sprintf(subtitleParam.bottomSubtitleData2, "%s %s %s", subTitle.ProductName, subTitle.SapID, subTitle.CustManagerName);
- // if (strstr(m_SalesVideoName,"OFL") && stricmp(subTitle.Reserved1,"X") && stricmp(subTitle.Reserved2,"X"))
- // {
- // sprintf(subtitleParam.bottomSubtitleData1, "%s %s %s %s", subTitle.CustCardNo, subTitle.CustName, subTitle.ProductCode, subTitle.ProductName);
- // sprintf(subtitleParam.bottomSubtitleData2, "%s %s %s %s", subTitle.SapID, subTitle.CustManagerName, subTitle.Reserved1, subTitle.Reserved2);
- // }
- // }
- // else
- // {
- // sprintf(subtitleParam.bottomSubtitleData1, "%s %s", subTitle.CustCardNo, subTitle.CustName);
- // sprintf(subtitleParam.bottomSubtitleData2, "%s %s", subTitle.ProductCode, subTitle.ProductName);
- // }
- //
- // // edit by ly@20180725
- // LOG_TRACE("nRecordBothSideType = %d.", nRecordBothSideType);
- // StartRecord(m_SalesVideoName, 90, m_audio_out_bitrate, &subtitleParam, m_bWholeSection, FALSE, nRecordBothSideType);
- //}
- ErrorCodeEnum CSalesRecorderEntity::HandleStopRecord(const char *pszMessage)
- {
- ErrorCodeEnum ErrorCode = StopRecord();
- // 保存录像时长(秒) add by ly 2018/02/13
- if (strstr(m_SalesVideoName, "OFL")&&pszMessage&&strlen(pszMessage)>0) {
- SaveOFLRecordDuration(atoi(pszMessage));
- }
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleSetAudioTransmissionFlag(bool bFlag)
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- m_bIsAudioTransOn = bFlag;
- Dbg("Set Audio Transmission Flag to %s.", m_bIsAudioTransOn ? "true" : "false");
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleStopAudioStreamEnTransQueue()
- {
- ErrorCodeEnum eCode = Error_Succeed;
- if (m_bIsAudioTransOn)
- {
- m_pRecorder->StopAudioEnTransQueue();
- m_bIsAudioTransOn = false;
- }
- else {
- eCode = Error_NotImpl;
- }
- return eCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleDisplayVideo()
- {
- // 视频播放 libwmpplayer
- m_bIsShowVideo = TRUE;
- Dbg("play record file name is %s!", m_SalesVideoName);
- ErrorCodeEnum ErrorCode = ShowVideo(m_SalesVideoName);
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandlePlaySalesRecordVideo(int iWndX, int iWndY, int iWndWidth, int iWndHeight)
- {
- // 视频播放 libwmpplayer
- m_bIsShowVideo = TRUE;
- Dbg("play sales record video file name is %s!", m_SalesVideoName);
- ErrorCodeEnum ErrorCode = PlaySalesRecordVideo(m_SalesVideoName, iWndX, iWndY, iWndWidth, iWndHeight);
- Dbg("play sales record video return code is 0x%08x.", ErrorCode);
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleStopShowVideo()
- {
- // 视频播放 libwmpplayer
- Dbg("stop show video record file name is %s!", m_SalesVideoName);
- ErrorCodeEnum ErrorCode = Error_Succeed;
- if(m_bIsShowVideo)
- {
- Dbg("m_pPlayer = %p while play!", m_pPlayer);
- m_pPlayer->Close();
- m_bIsShowVideo = FALSE;
- Dbg("succeed to stop show video!");
- }
- else{
- ErrorCode = Error_NotImpl;
- }
- return ErrorCode;
- }
- ErrorCodeEnum CSalesRecorderEntity::HandleSaveVideo()
- {
- ErrorCodeEnum ErrorCode = Error_Succeed;
- // 将视频从tmp移动到uploadvideo
- if (!strstr(m_SalesVideoName, "OFL")) // edit by ly 20180228
- {
- ErrorCode = SaveVideo(m_SalesVideoName+2);
- }
- else
- {
- ErrorCode = SaveVideo(m_SalesVideoName+4);
- }
- // 尝试提交离线双录记录 add by ly 2018/02/13
- if (strstr(m_SalesVideoName, "OFL") && CheckNetState() == Error_Succeed) {
- CSimpleStringA cfn = CSimpleStringA::Format("%s%s.txt",(LPCTSTR)m_TempDir,m_SalesVideoName);
- UploadOFLVideoRecord((LPCTSTR)cfn);
- }
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- return ErrorCode;
- }
- void CSalesRecorderEntity::HandleDeleteVideo()
- {
- if (strstr(m_SalesVideoName, "OFL")) {
- // 删除录像记录临时文件
- CSimpleStringA cfn = CSimpleStringA::Format("%s%s.txt", (LPCTSTR)m_TempDir, m_SalesVideoName);
- DeleteFile(cfn);
- }
- // 删除tmp中的视频
- DeleteVideo(m_SalesVideoName); // edit by ly 20151119
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- }
- void CSalesRecorderEntity::HandleReturnMenu()
- {
- CSimpleStringA strValue;
- GetFunction()->GetSysVar("DesktopType", strValue);
- if (strValue != CSimpleStringA("U"))
- {
- if (m_bStarted) // 如果正在进行客户经理录像
- {
- // 停止录像
- Dbg("stop record and return menu!");
- StopRecord();
- }
- else if (m_bIsShowVideo) // 如果正在播放客户经理录像
- {
- Dbg("auto close play and return menu!");
- m_pPlayer->Close();
- m_bIsShowVideo = FALSE;
- }
- // 删除tmp中的视频
- if (strlen(m_SalesVideoName) > 0)
- {
- Dbg("delete sales record!");
- DeleteAllVideo(m_SalesVideoName+2); // edit by ly 20160713
- }
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- }
- }
- void CSalesRecorderEntity::HandleUkeyPullout()
- {
- if (m_SalesVideoName && strstr(m_SalesVideoName, "OFL"))
- {
- if (m_bStarted) // 如果正在进行客户经理录像
- {
- // 停止录像
- Dbg("stop record and return menu!");
- StopRecord();
- }
- else if (m_bIsShowVideo) // 如果正在播放客户经理录像
- {
- Dbg("auto close play and return menu!");
- m_pPlayer->Close();
- m_bIsShowVideo = FALSE;
- }
- // 删除录像记录临时文件
- CSimpleStringA cfn = CSimpleStringA::Format("%s%s.txt", (LPCTSTR)m_TempDir, m_SalesVideoName);
- DeleteFile(cfn);
- // 删除tmp中的视频
- if (strlen(m_SalesVideoName) > 0)
- {
- Dbg("delete sales record!");
- DeleteAllVideo(m_SalesVideoName+4);
- }
- ZeroMemory(m_SalesVideoName,sizeof(m_SalesVideoName));
- StopRecordVideo();
- }
- }
- void CSalesRecorderEntity::HandleVideoAppendWatermark(const char* pszMessage)
- {
- if (NULL == pszMessage){
- return;
- }
- char *result[10] = {0};
- auto arr1 = CSimpleStringA2W(pszMessage).Split('|');
- auto arr2 = CAutoArray<CSimpleStringA>(arr1.GetCount());
- int icount = sizeof(result)/sizeof(char*);
- for (int i = 0; i < arr1.GetCount() && i < sizeof(result)/sizeof(char*); i++)
- {
- arr2[i] = CSimpleStringW2A(arr1[i]);
- result[i] = const_cast<LPSTR>(arr2[i].GetData());
- }
- Dbg("m_SalesVideoName = %s, strVideoName = %s, strWaterMark = %s.",m_SalesVideoName, result[0], result[1]);
- if (m_bStarted && (NULL != m_pRecorder))
- {
- m_pRecorder->SetRightVideoWaterMark(result[1]);
- }
- }
- 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);
- Dbg("[dbg] SalesRecord entity exception broadcast sent!");
- //停止录像
- StopRecord();
- m_bNeedRestart = true;
- //重启实体
- RealSelfCheck();
- return Error_Succeed;
- }
- ErrorCodeEnum CSalesRecorderEntity::RealSelfCheck()
- {
- ErrorCodeEnum Error = Error_Succeed;
- SelfChekerClient* pSelfcheckClient = new SelfChekerClient(this);
- Error = pSelfcheckClient->Connect();
- if (Error != Error_Succeed)
- {
- pSelfcheckClient->SafeDelete();
- pSelfcheckClient = NULL;
- Dbg("SelfcheckClient connect fail!");
- }
- else
- {
- Dbg("SelfcheckClient connect success!");
- }
- if (pSelfcheckClient)
- {
- SelfChecker::SelfCheckerService_RealCheck_Req req;
- req.name = GetEntityName();
- SelfChecker::SelfCheckerService_RealCheck_Ans ans;
- DWORD Timeout = 500;
- Error = pSelfcheckClient->RealCheck(req,ans,Timeout);
- if (Error!=Error_Succeed)
- {
- Dbg("RealSelfcheck fail!");
- }
- else
- {
- Dbg("RealSelfcheck success!");
- }
- pSelfcheckClient->GetFunction()->CloseSession();
- }
- 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);
- Dbg("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*.wmv", sourPath);
- 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)) {
- Dbg("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
- }else{
- Dbg("Move File %s success.", (LPCSTR)sourFileName);
- }
- }
- else{
- Dbg("File (%s) is not matched.", FindFileData.cFileName);
- }
- if (!FindNextFile(hFind, &FindFileData))
- {
- if (GetLastError() == ERROR_NO_MORE_FILES)
- {
- fFinished = TRUE;
- }
- else
- {
- break;
- }
- }
- }
- FindClose(hFind);
- }
- }
- }
- #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);
- Dbg("File %s create data info is %d %d %d.", file->d_name, 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 };
- DIR* pDir = NULL;
- struct dirent* pFile = NULL;
- sprintf_s(srcFilePath, MAX_PATH, "%s*.wmv", sourPath);
- pDir = opendir(sourPath);
- if (pDir == NULL) return ;
- while ((pFile = readdir(pDir)) != NULL) {
- if (pFile->d_type & DT_DIR) {
- //m_pHostApi->Debug("MoveTempPathVideos DIR name: %s.", pFile->d_name);
- continue;
- }
- else {
- //m_pHostApi->Debug("MoveTempPathVideos FILE name: %s.", pFile->d_name);
- 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 (!MoveFile((LPCSTR)sourFileName, (LPCSTR)destFileName)) {
- Dbg("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
- }
- else {
- Dbg("Move File %s success.", (LPCSTR)sourFileName);
- }
- }
- else {
- Dbg("File (%s) is not matched.", pFile->d_name);
- }
- }
- }
- closedir(pDir);
- }
- }
- #endif
- int CSalesRecorderEntity::GetSystemMemoryUsage()
- {
- #ifdef RVC_OS_WIN
- // Use to convert bytes to KB
- #define DIV 1024
- MEMORYSTATUSEX statex;
- statex.dwLength = sizeof (statex);
- GlobalMemoryStatusEx (&statex);
- return statex.dwMemoryLoad;
- #else
- //todo 从resourcewatcher获取
- return 0;
- #endif
- }
- double CSalesRecorderEntity::GetSystemCpuUsage()
- {
- #ifdef RVC_OS_WIN
- double ratio = 0;
- #define _WIN32_WINNT 0x0601
- FILETIME idleTime,kernelTime,userTime;
- BOOL ret = GetSystemTimes(&idleTime,&kernelTime,&userTime);
- if (ret == 0)
- {
- Dbg("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
- //todo 从resourcewatcher获取
- return 0;
- #endif
- }
- ErrorCodeEnum CSalesRecorderEntity::SetRecordAudioQuality(int iAudioQuality)
- {
- ErrorCodeEnum eRet = Error_Succeed;
- Dbg("iAudioQuality == %d.", iAudioQuality);
- 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;
- Dbg("iNsPolicy == %d.", iNsPolicy);
- if (1 == iNsPolicy || 3 == iNsPolicy){
- m_iAudioNsPolicy = iNsPolicy;
- }
- else{
- m_iAudioNsPolicy = 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.PAD") == 0) {
- if (stricmp(stStaticinfo.strSite, "CMB.FLB") == 0) {
- eType = eMobilePadType;
- }
- else {
- eType = ePadtype;
- }
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk2S") == 0) {
- eType = eDesk2SType;
- WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
- WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
- Dbg("MachineVersion is %d.%d", nMajor, nMinor);
- if (2 == nMajor) {
- eType = eDesk2SIntegratedType;
- }
- }
- else if (stricmp(stStaticinfo.strMachineType, "RPM.Stand1S") == 0) {
- eType = eRpm1sType;
- }
- else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk1S") == 0) {
- eType = eDesk1SType;
- }
- else {
- eType = eStand2sType;
- }
- if (eType >= 0 && eType < sizeof(Device_Type_Table) / sizeof(char*)) {
- LOG_TRACE("device type is %s.", Device_Type_Table[eType]);
- }
- return eType;
- }
- SelfChekerClient::SelfChekerClient( CSalesRecorderEntity *pEntity ) : SelfChecker::SelfCheckerService_ClientBase(pEntity)
- {
- }
- void UploadOFLVideoRecordTask::Process()
- {
- return m_pEntity->UploadOFLVideoRecord(NULL);
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CSalesRecorderEntity)
- SP_END_ENTITY_MAP()
|