|
|
@@ -1,1624 +0,0 @@
|
|
|
-#include "stdafx.h"
|
|
|
-#include "mod_CameraConfigManage.h"
|
|
|
-#include "Event.h"
|
|
|
-#include "rec_common.h"
|
|
|
-#include "SpComm.hpp"
|
|
|
-#include "CommEntityUtil.hpp"
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
-#include <tchar.h>
|
|
|
-#include "SetupApi.h"
|
|
|
-#pragma comment(lib, "SetupAPI.lib")
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
-#include <algorithm>
|
|
|
-
|
|
|
-#include "ScannerSet_client_g.h"
|
|
|
-#include "ScannerSet_def_g.h"
|
|
|
-
|
|
|
-#include "fileutil.h"
|
|
|
-#include "iniutil.h"
|
|
|
-
|
|
|
-using namespace ScannerSet;
|
|
|
-
|
|
|
-using namespace CameraConfigManage;
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
-using namespace LibVideoEcho;
|
|
|
-
|
|
|
-static BOOL IsWow64()
|
|
|
-{
|
|
|
- BOOL bIsWow64 = FALSE;
|
|
|
-
|
|
|
- //IsWow64Process is not available on all supported versions of Windows.
|
|
|
- //Use GetModuleHandle to get a handle to the DLL that contains the function
|
|
|
- //and GetProcAddress to get a pointer to the function if available.
|
|
|
-
|
|
|
- typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
|
|
|
-
|
|
|
- LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
|
|
|
- GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
|
|
|
-
|
|
|
- if (NULL != fnIsWow64Process) {
|
|
|
- if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) {
|
|
|
- //handle error
|
|
|
- }
|
|
|
- }
|
|
|
- return bIsWow64;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static GUID* StrToGUID(const WCHAR* guid_string)
|
|
|
-{
|
|
|
- char buffer[64];
|
|
|
- GUID* guid = (GUID*)buffer;
|
|
|
- WCHAR upperGuid[40 + 1] = { 0 };
|
|
|
- for (int i = 0; i < 40 + 1; i++) {
|
|
|
- upperGuid[i] = guid_string[i];
|
|
|
- if (upperGuid[i] >= L'a' && upperGuid[i] <= L'z') {
|
|
|
- upperGuid[i] += L'A' - L'a';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- swscanf_s(upperGuid, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
|
|
- &guid->Data1,
|
|
|
- &guid->Data2,
|
|
|
- &guid->Data3,
|
|
|
- &guid->Data4[0],
|
|
|
- &guid->Data4[1],
|
|
|
- &guid->Data4[2],
|
|
|
- &guid->Data4[3],
|
|
|
- &guid->Data4[4],
|
|
|
- &guid->Data4[5],
|
|
|
- &guid->Data4[6],
|
|
|
- &guid->Data4[7]);
|
|
|
-
|
|
|
- return guid;
|
|
|
-}
|
|
|
-
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::OnPreStart(
|
|
|
- CAutoArray<CSimpleStringA> strArgs,
|
|
|
- CSmartPointer<ITransactionContext> pTransactionContext )
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- ErrorCodeEnum Error;
|
|
|
-
|
|
|
- m_eDeviceType = eStand2sType;
|
|
|
- g_eDeviceType = eStand2sType;
|
|
|
-
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
- CSystemStaticInfo stStaticinfo;
|
|
|
- spFunction->GetSystemStaticInfo(stStaticinfo);
|
|
|
- SP::Module::Comm::Site site = SP::Module::Comm::Str2Site(stStaticinfo.strSite);
|
|
|
- SP::Module::Comm::What type = SP::Module::Comm::Str2Type(stStaticinfo.strSite);
|
|
|
-
|
|
|
-
|
|
|
- if (type == SP::Module::Comm::RVC_PAD)
|
|
|
- {
|
|
|
- if (site == SP::Module::Comm::CMB_FLB)
|
|
|
- {
|
|
|
- LOG_TRACE("the type is mobile pad");
|
|
|
- m_eDeviceType = eMobilePadType;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LOG_TRACE("the type is pad");
|
|
|
- m_eDeviceType = ePadtype;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (type == SP::Module::Comm::RVC_Desk2S)
|
|
|
- {
|
|
|
- LOG_TRACE("the type is Desk2S");
|
|
|
- m_eDeviceType = eDesk2SType;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- LOG_TRACE("the type is standard");
|
|
|
- m_eDeviceType = eStand2sType;
|
|
|
- }
|
|
|
- g_eDeviceType = m_eDeviceType;
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- memset(&m_conf, 0, sizeof(capture_config_t));
|
|
|
- Error = (ErrorCodeEnum)capture_lib_init();
|
|
|
-
|
|
|
- if (Error == Error_Succeed) {
|
|
|
- LoadConfig(&m_conf);
|
|
|
- } else {
|
|
|
- LOG_TRACE("capture_lib_init failed!");
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- m_arrListener.Init(2);
|
|
|
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event,
|
|
|
- Severity_None, Error_IgnoreAll, EVENT_USB_CAMER_INPUT, NULL, false);
|
|
|
- GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event,
|
|
|
- Severity_None, Error_IgnoreAll, EVENT_USB_CAMER_OUTPUT, 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_nActiveCamera = CAMERA_TYPE_OPT;
|
|
|
- }
|
|
|
- else if (strValue[0] == 'O')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ENV;
|
|
|
- }
|
|
|
- else if(strValue[0] == 'B') ///////显示贴图
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
- }
|
|
|
- else if (strValue[0] == 'N')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ENV;
|
|
|
- }
|
|
|
-
|
|
|
- m_camerasConfig.strEnvCamera = "$";
|
|
|
- m_camerasConfig.envCamera.strFriendlyName = "$";
|
|
|
- m_camerasConfig.envCamera.strDevPath = "$";
|
|
|
- m_camerasConfig.envCamera.strMd5Val = "$";
|
|
|
- m_camerasConfig.strOptCamera = "$";
|
|
|
- m_camerasConfig.optCamera.strFriendlyName = "$";
|
|
|
- m_camerasConfig.optCamera.strDevPath = "$";
|
|
|
- m_camerasConfig.optCamera.strMd5Val = "$";
|
|
|
- m_camerasConfig.strEwsCamera = "$";
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName = "$";
|
|
|
- m_camerasConfig.ewsCamera.strDevPath = "$";
|
|
|
- m_camerasConfig.ewsCamera.strMd5Val = "$";
|
|
|
-
|
|
|
- LoadConfig(&m_originConfig);
|
|
|
- m_camerasConfig.strEnvCamera = m_originConfig.strEnvCamera;
|
|
|
- m_camerasConfig.strOptCamera = m_originConfig.strOptCamera;
|
|
|
- m_camerasConfig.strEwsCamera = m_originConfig.strEwsCamera;
|
|
|
-
|
|
|
- SyncVideoConfig();
|
|
|
-
|
|
|
- pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::OnStarted()
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- if (0 == mlibAudioMgr->audio_mgr_initialize()) {
|
|
|
- Dbg("Audio Manager Initialize success!");
|
|
|
- } else {
|
|
|
- Dbg("Audio Manager Initialize failed!");
|
|
|
- }
|
|
|
- RefreshCameras();
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::OnPreClose(
|
|
|
- EntityCloseCauseEnum eCloseCause,
|
|
|
- CSmartPointer<ITransactionContext> pTransactionContext )
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
-
|
|
|
- for (int i = 0; i < m_arrListener.GetCount(); ++i)
|
|
|
- {
|
|
|
- spFunction->UnsubscribeLog(m_arrListener[i]);
|
|
|
- }
|
|
|
-
|
|
|
- spFunction->UnregistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA);
|
|
|
- spFunction->UnregistSysVarEvent(SYSVAR_CAMERASTATE);
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::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_nActiveCamera = CAMERA_TYPE_OPT;
|
|
|
- }
|
|
|
- else if (pszValue[0] == 'O')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ENV;
|
|
|
- }
|
|
|
- else if(pszValue[0] == 'B') ///////显示贴图
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
- }
|
|
|
- else if (pszValue[0] == 'N')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_AUTO;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
|
|
|
- {
|
|
|
- if (m_iCameraState == 'N')
|
|
|
- {
|
|
|
- if (pszValue[0] == 'E')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_ENV;
|
|
|
- }
|
|
|
- else if (pszValue[0] == 'O')
|
|
|
- {
|
|
|
- m_nActiveCamera = CAMERA_TYPE_OPT;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::OnLog(
|
|
|
- const CAutoArray<CUUID> &SubIDs,
|
|
|
- const CUUID nLogID,
|
|
|
- const LogTypeEnum eLogType,
|
|
|
- const SeverityLevelEnum eLevel,
|
|
|
- const DWORD dwSysError,
|
|
|
- const DWORD dwUserCode,
|
|
|
- const DWORD dwEntityInstanceID,
|
|
|
- const WORD wEntityDevelID,
|
|
|
- const CAutoArray<DWORD> &Param,
|
|
|
- const char *pszEntityName,
|
|
|
- const char *pszModuleName,
|
|
|
- const char *pszMessage, const linkContext& pLinkInfo)
|
|
|
-{
|
|
|
- LOG_TRACE("user_code = %08x", dwUserCode);
|
|
|
- if (dwUserCode == EVENT_USB_CAMER_INPUT)
|
|
|
- {
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- ::Sleep(2000);
|
|
|
- camera_names_t usbCam;
|
|
|
- int id = capture_get_video_device_id(pszMessage, usbCam);
|
|
|
- if (id != -1) {
|
|
|
- Dbg("[dbg] %s inserted!", usbCam.strFriendlyName.GetData());
|
|
|
- CameraInserted evt;
|
|
|
- evt.CameraName = CSimpleStringA::Format("%s;%s",
|
|
|
- usbCam.strFriendlyName.GetData(), usbCam.strMd5Val.GetData());
|
|
|
- SpSendBroadcast(GetFunction(), SP_MSG_OF(CameraInserted),
|
|
|
- SP_MSG_SIG_OF(CameraInserted), evt);
|
|
|
- Dbg("[dbg] CameraInserted broadcast sent!");
|
|
|
- m_cameras.push_back(usbCam);
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- }
|
|
|
- else if (dwUserCode == EVENT_USB_CAMER_OUTPUT)
|
|
|
- {
|
|
|
- //::Sleep(1000);
|
|
|
- std::vector<camera_names_t> cams;
|
|
|
- GetAvailableCameras(cams);
|
|
|
- auto i = m_cameras.begin();
|
|
|
- for (; i != m_cameras.end(); ++i) {
|
|
|
- auto it = std::find_if(cams.begin(), cams.end(), [i](camera_names_t &c)
|
|
|
- {
|
|
|
- return i->strFriendlyName == c.strFriendlyName &&
|
|
|
- i->strDevPath == c.strDevPath &&
|
|
|
- i->strMd5Val == c.strMd5Val;
|
|
|
- });
|
|
|
- if (it == cams.end())
|
|
|
- break;
|
|
|
- }
|
|
|
- if (i != m_cameras.end()) {
|
|
|
- Dbg("[dbg] %s removed!", i->strFriendlyName.GetData());
|
|
|
- CameraRemoved evt;
|
|
|
- evt.CameraName = CSimpleStringA::Format("%s;%s",
|
|
|
- i->strFriendlyName.GetData(),i->strMd5Val.GetData());
|
|
|
- SpSendBroadcast(GetFunction(), SP_MSG_OF(CameraRemoved),
|
|
|
- SP_MSG_SIG_OF(CameraRemoved), evt);
|
|
|
- Dbg("[dbg] CameraRemoved broadcast sent!");
|
|
|
- m_cameras.erase(i);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::OnTimeout( DWORD dwTimerID )
|
|
|
-{
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::Debug( const char *fmt, ... )
|
|
|
-{
|
|
|
- va_list arg;
|
|
|
- va_start(arg, fmt);
|
|
|
- vDbg(fmt, arg);
|
|
|
- va_end(arg);
|
|
|
-}
|
|
|
-
|
|
|
-int CCameraConfigManageEntity::GetActiveCamera()
|
|
|
-{
|
|
|
- return m_nActiveCamera;
|
|
|
-}
|
|
|
-
|
|
|
-HINSTANCE CCameraConfigManageEntity::GetEntityHinstance()
|
|
|
-{
|
|
|
- return ModuleBase::GetModuleBase()->GetInstance();
|
|
|
-}
|
|
|
-
|
|
|
-ErrorCodeEnum CCameraConfigManageEntity::GetHSPCameras(
|
|
|
- CAutoArray<CSimpleStringA> &HSPCameras )
|
|
|
-{
|
|
|
- auto rc = Error_Succeed;
|
|
|
-
|
|
|
- auto pScannerSetClient = new ScannerService_ClientBase(this);
|
|
|
-
|
|
|
- if (pScannerSetClient->Connect() != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("连接ScannerSet实体失败");
|
|
|
- pScannerSetClient->SafeDelete();
|
|
|
- pScannerSetClient = NULL;
|
|
|
- rc = Error_DevConnFailed;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ScannerService_GetOnlineCameras_Req req = {};
|
|
|
-
|
|
|
- ScannerService_GetOnlineCameras_Ans ans = {};
|
|
|
-
|
|
|
- rc = (*pScannerSetClient)(EntityResource::getLink().upgradeLink())->GetOnlineCameras(req, ans, 10000);
|
|
|
- if (rc != Error_Succeed)
|
|
|
- {
|
|
|
- Dbg("ScannerSet 调用 GetOnlineCameras 失败: 0x%x", rc);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("ScannerSet invokes GetOnlineCameras suc.");
|
|
|
- Dbg("Count: %d", ans.devCount);
|
|
|
- if (ans.devCount > 0) {
|
|
|
- for (int i = 0; i < ans.devFriendlyNames.GetCount(); ++i) {
|
|
|
- Dbg("[%d]%s(%d)", i, (LPCTSTR)ans.devFriendlyNames[i],
|
|
|
- ans.devType[i]);
|
|
|
- CapTypeEnum devType = (CapTypeEnum)ans.devType[i];
|
|
|
- if (devType == CAMTYPE_HSPS)
|
|
|
- {
|
|
|
- HSPCameras.Append(ans.devFriendlyNames, i, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- pScannerSetClient->GetFunction()->CloseSession();
|
|
|
- pScannerSetClient = NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return rc;
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::GetAvailableCameras(std::vector<camera_names_t> &cams)
|
|
|
-{
|
|
|
- CAutoArray<CSimpleStringA> hspCams;
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- auto rc = GetHSPCameras(hspCams);
|
|
|
- Dbg("[GetHSPCameras]: (0x%x,%d)", rc, hspCams.GetCount());
|
|
|
- capture_enum_cameras(cams, hspCams);
|
|
|
-#else
|
|
|
- capture_enum_cameras(hspCams);
|
|
|
- for (int i = 0; i < hspCams.GetCount();++i) {
|
|
|
- camera_names_t t;
|
|
|
- t.strDevPath = t.strFriendlyName = hspCams[i];
|
|
|
- t.strMd5Val = "";
|
|
|
- Dbg("%d: %s", i, t.strDevPath.GetData());
|
|
|
- cams.push_back(t);
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-ErrorCodeEnum CCameraConfigManageEntity::LoadConfig( capture_config_t *conf )
|
|
|
-{
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
- CSmartPointer<IConfigInfo> spConfig;
|
|
|
- SpIniMappingTable table;
|
|
|
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spConfig);
|
|
|
- if (Error == Error_Succeed)
|
|
|
- {
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- table.AddEntryString("Audio", "handfree_in_dev", conf->strAudioIn, "$");
|
|
|
- table.AddEntryString("Video", "EnvCamera", conf->strVideo, "$");
|
|
|
- table.AddEntryInt("Video", "EnvRotate", conf->video_rotate, 0);
|
|
|
-#else
|
|
|
- table.AddEntryString("Audio", "handfree_in_dev", conf->strAudioIn, "$");
|
|
|
- table.AddEntryString("Video", "EnvCamera", conf->strVideoEnv, "$");
|
|
|
- table.AddEntryInt("Video", "EnvRotate", conf->video_env_rotate, 0);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- table.Load(spConfig);
|
|
|
- }
|
|
|
-
|
|
|
- return Error_Succeed;
|
|
|
-}
|
|
|
-
|
|
|
-ErrorCodeEnum CCameraConfigManageEntity::LoadConfig( VideoConfig *conf )
|
|
|
-{
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
- CSmartPointer<IConfigInfo> spConfig;
|
|
|
- SpIniMappingTable table;
|
|
|
- ErrorCodeEnum Error = spFunction->OpenConfig(Config_Root, spConfig);
|
|
|
- if (Error == Error_Succeed)
|
|
|
- {
|
|
|
- table.AddEntryString("Video", "EnvCamera", conf->strEnvCamera, "$");
|
|
|
- table.AddEntryString("Video", "OptCamera", conf->strOptCamera, "$");
|
|
|
- table.AddEntryString("Video", "EwsCamera", conf->strEwsCamera, "$");
|
|
|
- table.Load(spConfig);
|
|
|
- }
|
|
|
-
|
|
|
- return Error_Succeed;
|
|
|
-}
|
|
|
-
|
|
|
-ErrorCodeEnum CCameraConfigManageEntity::HandleEditConfigReq(
|
|
|
- const CAutoArray<CEditConfigReq> &reqs )
|
|
|
-{
|
|
|
- Dbg("entity edit config");
|
|
|
-
|
|
|
- auto pFunc = this->GetFunction();
|
|
|
-
|
|
|
- for (int i = 0; i < reqs.GetCount(); ++i)
|
|
|
- {
|
|
|
- auto req = reqs[i];
|
|
|
- //if (!stricmp(req.Value, "$"))
|
|
|
- //{
|
|
|
- // continue;
|
|
|
- //}
|
|
|
-
|
|
|
- CSimpleStringA strEntityName = req.EntityName;
|
|
|
- CSimpleStringA strCfgPath;
|
|
|
-
|
|
|
- if (stricmp(strEntityName, "Silverlight") == 0 || stricmp(strEntityName, "DualActive") == 0 ||
|
|
|
- stricmp(strEntityName, "SpHost") == 0 || stricmp(strEntityName, "SysInit") == 0 ||
|
|
|
- stricmp(strEntityName, "SpBase") == 0 || stricmp(strEntityName, "guardian") == 0)
|
|
|
- {
|
|
|
- Dbg("entity \"%s\" has no config", strEntityName);
|
|
|
- return Error_NotExist;
|
|
|
- }
|
|
|
-
|
|
|
- if (stricmp(strEntityName, "Root") == 0)
|
|
|
- {
|
|
|
- auto rc = pFunc->GetPath("HardwareCfg", strCfgPath);
|
|
|
- assert(rc == Error_Succeed);
|
|
|
- strCfgPath += SPLIT_SLASH_STR;
|
|
|
- strCfgPath += "root.ini";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- auto rc = pFunc->GetPath("Cfg", strCfgPath);
|
|
|
- assert(rc == Error_Succeed);
|
|
|
-
|
|
|
- strCfgPath += CSimpleStringA::Format(SPLIT_SLASH_STR "%s.ini", (const char*)strEntityName);
|
|
|
- }
|
|
|
-
|
|
|
- char cEditType = req.EditType;
|
|
|
- Dbg("edit config: entity = %s, type = %c, section = %s, key = %s, value = %s",
|
|
|
- (const char*)strEntityName, cEditType, req.Section, req.Key, req.Value);
|
|
|
-
|
|
|
- if (cEditType == 'A' || cEditType == 'U')
|
|
|
- {
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- WritePrivateProfileStringA(req.Section, req.Key, req.Value, strCfgPath);
|
|
|
-#else
|
|
|
- inifile_write_str(strCfgPath, req.Section, req.Key, req.Value);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- }
|
|
|
- else if (cEditType == 'D')
|
|
|
- {
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- WritePrivateProfileStringA(req.Section, req.Key, NULL, strCfgPath);
|
|
|
-#else
|
|
|
- inifile_write_str(strCfgPath, req.Section, req.Key, NULL);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return Error_Succeed;
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::SetCameraName( CSimpleStringA camName )
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- m_conf.strVideo = camName;
|
|
|
-#else
|
|
|
- m_conf.strVideoEnv = camName;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-CSimpleStringA CCameraConfigManageEntity::GetCameraName()
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- return m_conf.strVideo;
|
|
|
-#else
|
|
|
- return m_conf.strVideoEnv;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-BOOL CCameraConfigManageEntity::IsCameraStart()
|
|
|
-{
|
|
|
- return m_bStartCamera;
|
|
|
-}
|
|
|
-
|
|
|
-ErrorCodeEnum CCameraConfigManageEntity::StartCamera()
|
|
|
-{
|
|
|
- if (m_capture == NULL)
|
|
|
- {
|
|
|
- ErrorCodeEnum Error = Error_Succeed;
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- m_conf.ref_capture_count = &m_lCaptureCount;
|
|
|
-#else
|
|
|
- m_conf.ref_env_capture_count = &m_lCaptureCount;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- Error = (ErrorCodeEnum)capture_create(&m_conf, &m_capture);
|
|
|
- if (Error == Error_Succeed)
|
|
|
- {
|
|
|
- Error = capture_start(m_capture);
|
|
|
- Dbg("Error code=0x%x",Error);
|
|
|
- if (Error != Error_Succeed)
|
|
|
- {
|
|
|
- m_bStartCamera = FALSE;
|
|
|
- if (Error == Error_EnvCamera)
|
|
|
- {
|
|
|
- capture_destroy(m_capture);
|
|
|
- m_capture = NULL;
|
|
|
- return Error;
|
|
|
- }
|
|
|
- else // Error_AudioIN
|
|
|
- {
|
|
|
- return Error;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bStartCamera = TRUE;
|
|
|
- return Error_Succeed;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bStartCamera = FALSE;
|
|
|
- Dbg("create capture failed! %d", Error);
|
|
|
- m_capture = NULL;
|
|
|
- return Error_Unexpect;
|
|
|
- }
|
|
|
-
|
|
|
- return Error;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("m_capture == NULL");
|
|
|
- return Error_Unexpect;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::StopCamera()
|
|
|
-{
|
|
|
- if ((ePadtype==m_eDeviceType||eDesk2SType==m_eDeviceType)&&m_bStartCamera)
|
|
|
- {
|
|
|
- Dbg("stop camera");
|
|
|
- if (m_capture)
|
|
|
- {
|
|
|
- capture_stop(m_capture);
|
|
|
- capture_destroy(m_capture);
|
|
|
- m_capture = NULL;
|
|
|
- }
|
|
|
- m_bStartCamera = FALSE;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
-void CCameraConfigManageEntity::StartEchoVideo(int x, int y, int w, int h)
|
|
|
-{
|
|
|
- if (!m_bEchoVideo) {
|
|
|
- videoplay_session_conf_t video_conf;
|
|
|
- memset(&video_conf, 0, sizeof(video_conf));
|
|
|
- video_conf.local_video_view_x = x;
|
|
|
- video_conf.local_video_view_y = y;
|
|
|
- video_conf.local_video_view_cx = w;
|
|
|
- video_conf.local_video_view_cy = h;
|
|
|
- video_conf.pHostApi = this;
|
|
|
- strcpy(video_conf.local_video_preview_queue0, REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE);
|
|
|
- int rc = Local_videoplay_session_create(&video_conf, &m_pSession);
|
|
|
- if (rc != 0) {
|
|
|
- Dbg("create videoplay session failed! rc = %d", rc);
|
|
|
- } else {
|
|
|
- rc = Local_videoplay_session_start(m_pSession);
|
|
|
- if (rc != 0) {
|
|
|
- Dbg("start videoplay session failed! rc = %d", rc);
|
|
|
- Local_videoplay_session_destroy(m_pSession);
|
|
|
- m_pSession = NULL;
|
|
|
- } else {
|
|
|
- m_bEchoVideo = TRUE;
|
|
|
- Dbg("start videoplay session succed! rc = %d", rc);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::StopEchoVideo()
|
|
|
-{
|
|
|
- if (m_bEchoVideo && m_pSession) {
|
|
|
- m_bEchoVideo = FALSE;
|
|
|
- Local_videoplay_session_stop(m_pSession);
|
|
|
- Local_videoplay_session_destroy(m_pSession);
|
|
|
- m_pSession = NULL;
|
|
|
- Dbg("videoplay session stopped!");
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
-bool CCameraConfigManageEntity::ConvertEwsCameraName(
|
|
|
- CSimpleStringA& strRetrievedName,
|
|
|
- const CSimpleStringA& strDirectShowName )
|
|
|
-{
|
|
|
- bool bRet = false;
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- if (strDirectShowName.GetLength() <= 1) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- CSimpleStringA md5str = strDirectShowName;
|
|
|
- int pos = md5str.IndexOf(";");
|
|
|
- if (pos < 0 || pos + 1 >= md5str.GetLength()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- md5str = md5str.SubString(pos + 1, md5str.GetLength() - pos - 1);
|
|
|
-
|
|
|
- BOOL bFound = FALSE;
|
|
|
- CSimpleStringA strDevPath;
|
|
|
- for (int i = 0; i < m_cameras.size(); ++i) {
|
|
|
- if (m_cameras[i].strMd5Val == md5str) {
|
|
|
- strDevPath = m_cameras[i].strDevPath;
|
|
|
- bFound = TRUE;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!bFound) {
|
|
|
- Dbg("md5str %s does not be found!", md5str.GetData());
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- GUID deviceGuid[2] = {
|
|
|
- *StrToGUID(L"{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}"), // Image
|
|
|
- *StrToGUID(L"{CA3E7AB9-B4C3-4AE6-8251-579EF933890F}") // Camera
|
|
|
- };
|
|
|
-
|
|
|
- Dbg("Current EwsCamera: %s", strDevPath.GetData());
|
|
|
-
|
|
|
- for (int i = 0; i < 2; ++i) {
|
|
|
- Dbg("Enumerate %s devices", (0 == i ? "Image" : "Camera"));
|
|
|
- HDEVINFO hDev = SetupDiGetClassDevs(&deviceGuid[i], NULL, NULL, DIGCF_PRESENT);
|
|
|
- if (INVALID_HANDLE_VALUE == hDev) {
|
|
|
- return bRet;
|
|
|
- }
|
|
|
- SP_CLASSIMAGELIST_DATA _spImageData = { 0 };
|
|
|
- _spImageData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);
|
|
|
- SetupDiGetClassImageList(&_spImageData);
|
|
|
-
|
|
|
- SP_DEVINFO_DATA DevInfo;
|
|
|
- ZeroMemory(&DevInfo, sizeof(SP_DEVINFO_DATA));
|
|
|
- DevInfo.cbSize = sizeof(SP_DEVINFO_DATA);
|
|
|
- //if (IsWow64())
|
|
|
- // DevInfo.cbSize = 32;
|
|
|
- //else
|
|
|
- // DevInfo.cbSize = 28;
|
|
|
- DWORD DeviceIndex = 0;
|
|
|
- while (SetupDiEnumDeviceInfo(hDev, DeviceIndex, &DevInfo)) {
|
|
|
- int wImageIdx = 0;
|
|
|
- if (SetupDiGetClassImageIndex(&_spImageData, &DevInfo.ClassGuid, &wImageIdx)) {
|
|
|
- char szName[MAX_PATH] = { 0 };
|
|
|
- //获取设备实例路径
|
|
|
- if (SetupDiGetDeviceInstanceId(hDev, &DevInfo, szName, MAX_PATH - 1, NULL)) {
|
|
|
- Dbg("InstanceId: %s", szName);
|
|
|
- if (strstr(strDevPath.GetData(), szName)) {
|
|
|
- strRetrievedName = szName;
|
|
|
- bRet = strRetrievedName.GetLength() > 0;
|
|
|
- return bRet;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (SetupDiGetDeviceRegistryProperty(
|
|
|
- hDev, &DevInfo, SPDRP_DEVICEDESC, NULL, (PBYTE)szName, MAX_PATH - 1, 0)) {
|
|
|
- Dbg("RegistryProperty: %s", szName);
|
|
|
- if (strstr(strDevPath.GetData(), szName)) {
|
|
|
- strRetrievedName = szName;
|
|
|
- bRet = strRetrievedName.GetLength() > 0;
|
|
|
- return bRet;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- DeviceIndex++;
|
|
|
- }
|
|
|
- SetupDiDestroyClassImageList(&_spImageData);
|
|
|
-
|
|
|
- if (hDev) {
|
|
|
- SetupDiDestroyDeviceInfoList(hDev);
|
|
|
- }
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
- return bRet;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-bool getConfigCameraFriendlyName(const CSimpleStringA& strDirectShowName, CSimpleStringA &friendlyName){
|
|
|
- CSimpleStringA tmp = strDirectShowName;
|
|
|
- int pos = tmp.IndexOf(";");
|
|
|
- if (pos < 0 || pos+1 >= tmp.GetLength()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- friendlyName = tmp.SubString(0, pos);
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-bool getConfigCameraMd5Str(const CSimpleStringA& strDirectShowName, CSimpleStringA &md5str){
|
|
|
- CSimpleStringA tmp = strDirectShowName;
|
|
|
- int pos = tmp.IndexOf(";");
|
|
|
- if (pos < 0 || pos+1 >= tmp.GetLength()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- md5str = tmp.SubString(pos+1, tmp.GetLength()-pos-1);
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-bool CheckConfigCameraCanOpen(const CSimpleStringA strCam) {
|
|
|
-
|
|
|
- camera_names_t cameraDetail;
|
|
|
- //check Ews device
|
|
|
- if (strCam.GetLength() > 1)
|
|
|
- { // is not "$"
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- const int camera_id = capture_get_video_device_id((LPCTSTR)strCam, cameraDetail);
|
|
|
-#else
|
|
|
- const int camera_id = capture_get_video_device_id((LPCTSTR)strCam);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- if (camera_id == -1)
|
|
|
- {
|
|
|
- Dbg("find strCam:%s(-1)", (LPCTSTR)strCam);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //摄像头未配置,此时也认为摄像头OK
|
|
|
- }
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-//保证strEnvCamera与envCamera一致,都有配置信息
|
|
|
-void CCameraConfigManageEntity::SyncVideoConfig()
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- if ((m_camerasConfig.strEnvCamera.GetLength() > 1) && (m_camerasConfig.envCamera.strFriendlyName.GetLength() <= 1)) {
|
|
|
- if (capture_get_video_device_id(m_camerasConfig.strEnvCamera, m_camerasConfig.envCamera) < 0) {
|
|
|
- getConfigCameraFriendlyName(m_camerasConfig.strEnvCamera, m_camerasConfig.envCamera.strFriendlyName);
|
|
|
- getConfigCameraMd5Str(m_camerasConfig.strEnvCamera, m_camerasConfig.envCamera.strMd5Val);
|
|
|
- }
|
|
|
- Dbg("SyncVideoConfig, envCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.envCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- }
|
|
|
-
|
|
|
- if ((m_camerasConfig.strOptCamera.GetLength() > 1) && (m_camerasConfig.optCamera.strFriendlyName.GetLength() <= 1)) {
|
|
|
- if (capture_get_video_device_id(m_camerasConfig.strOptCamera, m_camerasConfig.optCamera) < 0) {
|
|
|
- getConfigCameraFriendlyName(m_camerasConfig.strOptCamera, m_camerasConfig.optCamera.strFriendlyName);
|
|
|
- getConfigCameraMd5Str(m_camerasConfig.strOptCamera, m_camerasConfig.optCamera.strMd5Val);
|
|
|
- }
|
|
|
- Dbg("SyncVideoConfig, optCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.optCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strDevPath, (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- }
|
|
|
-
|
|
|
- if ((m_camerasConfig.strEwsCamera.GetLength() > 1) && (m_camerasConfig.ewsCamera.strFriendlyName.GetLength() <= 1)) {
|
|
|
- capture_get_video_device_id(m_camerasConfig.strEwsCamera, m_camerasConfig.ewsCamera);
|
|
|
- Dbg("SyncVideoConfig, ewsCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.ewsCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::RefreshCameras(){
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- m_cameras.clear();
|
|
|
- CAutoArray<CSimpleStringA> hspCams;
|
|
|
- auto rc = GetHSPCameras(hspCams);
|
|
|
- Dbg("[GetHSPCameras]: (0x%x,%d)", rc, hspCams.GetCount());
|
|
|
- capture_enum_cameras(m_cameras, hspCams);
|
|
|
- for (int i = 0; i < m_cameras.size(); ++i) {
|
|
|
- Dbg("m_cameras[%d]:%s", i, m_cameras[i].strFriendlyName.GetData());
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-//打开前检查配置摄像头配置名是否正确,不正确尝试自纠正(插拔摄像头会导致其名字变更,需要我们打开前纠正其名字)
|
|
|
-//注意配置的摄像头名由摄像头名+摄像头路径MD5两部分组成
|
|
|
-bool CCameraConfigManageEntity::AutoCorrectCameraConfig(VideoConfig *config) {
|
|
|
- int errorCameraCnt = 0;
|
|
|
- bool convertResult = true;
|
|
|
- bool envCanOpen = true;
|
|
|
- bool optCanOpen = true;
|
|
|
- bool ewsCanOpen = true;
|
|
|
-
|
|
|
- envCanOpen = CheckConfigCameraCanOpen(m_camerasConfig.strEnvCamera);
|
|
|
- if (!envCanOpen) {
|
|
|
- errorCameraCnt++;
|
|
|
- }
|
|
|
- optCanOpen = CheckConfigCameraCanOpen(m_camerasConfig.strOptCamera);
|
|
|
- if (!optCanOpen) {
|
|
|
- errorCameraCnt++;
|
|
|
- }
|
|
|
- ewsCanOpen = CheckConfigCameraCanOpen(m_camerasConfig.strEwsCamera);
|
|
|
- if (!ewsCanOpen) {
|
|
|
- errorCameraCnt++;
|
|
|
- }
|
|
|
- Dbg("AutoCorrectCameraConfig, before update check result envCanOpen:%d, optCanOpen:%d, ewsCanOpen:%d", envCanOpen, optCanOpen, ewsCanOpen);
|
|
|
- Dbg("AutoCorrectCameraConfig, before update originConfig Env:%s, Opt:%s, Ews:%s",
|
|
|
- (LPCSTR)m_originConfig.strEnvCamera, (LPCSTR)m_originConfig.strOptCamera, (LPCSTR)m_originConfig.strEwsCamera);
|
|
|
- Dbg("AutoCorrectCameraConfig, before update config Env:%s, Opt:%s, Ews:%s",
|
|
|
- (LPCSTR)m_camerasConfig.strEnvCamera, (LPCSTR)m_camerasConfig.strOptCamera, (LPCSTR)m_camerasConfig.strEwsCamera);
|
|
|
-
|
|
|
- SyncVideoConfig();
|
|
|
-
|
|
|
- if (errorCameraCnt > 0) {
|
|
|
- bool envCanCorrect = true;
|
|
|
- bool optCanCorrect = true;
|
|
|
- bool ewsCanCorrect = true;
|
|
|
- bool envCorrected = false;
|
|
|
- bool optCorrected = false;
|
|
|
- bool ewsCorrected = false;
|
|
|
- CAutoArray<CSimpleStringA> hspCams;
|
|
|
- CSimpleStringA old_ews_str = m_camerasConfig.strEwsCamera;
|
|
|
- camera_names_t old_ews;
|
|
|
- old_ews.strFriendlyName = m_camerasConfig.ewsCamera.strFriendlyName;
|
|
|
- old_ews.strMd5Val = m_camerasConfig.ewsCamera.strMd5Val;
|
|
|
- old_ews.strDevPath = m_camerasConfig.ewsCamera.strDevPath;
|
|
|
- GetHSPCameras(hspCams);
|
|
|
-
|
|
|
- //1.首先采用找到与配置中Friendly摄像头名相同的唯一设备来纠正
|
|
|
- if (!envCanOpen) {
|
|
|
- envCanOpen = AutoCorrectCameraByOnlyFriendlyName(m_camerasConfig.envCamera,
|
|
|
- optCanOpen, ewsCanOpen, m_camerasConfig.optCamera, m_camerasConfig.ewsCamera, hspCams);
|
|
|
- if (envCanOpen) {
|
|
|
- envCorrected = true;
|
|
|
- errorCameraCnt--;
|
|
|
- m_camerasConfig.strEnvCamera = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.envCamera.strFriendlyName.GetData(), m_camerasConfig.envCamera.strMd5Val.GetData());
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName success, envCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.envCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- }else{
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName, strEnvCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!optCanOpen) {
|
|
|
- optCanOpen = AutoCorrectCameraByOnlyFriendlyName(m_camerasConfig.optCamera,
|
|
|
- envCanOpen, ewsCanOpen, m_camerasConfig.envCamera, m_camerasConfig.ewsCamera, hspCams);
|
|
|
- if (optCanOpen) {
|
|
|
- optCorrected = true;
|
|
|
- errorCameraCnt--;
|
|
|
- m_camerasConfig.strOptCamera = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.optCamera.strFriendlyName.GetData(), m_camerasConfig.optCamera.strMd5Val.GetData());
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName success, optCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.optCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strDevPath, (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- }else{
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName, strOptCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!ewsCanOpen) {
|
|
|
- ewsCanOpen = AutoCorrectCameraByOnlyFriendlyName(m_camerasConfig.ewsCamera,
|
|
|
- envCanOpen, optCanOpen, m_camerasConfig.envCamera, m_camerasConfig.optCamera, hspCams);
|
|
|
- if (ewsCanOpen) {
|
|
|
- CSimpleStringA tmp = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName.GetData(), m_camerasConfig.ewsCamera.strMd5Val.GetData());
|
|
|
- RefreshCameras();//m_cameras maybe don't refresh
|
|
|
- convertResult = ConvertEwsCameraName(m_camerasConfig.strEwsCamera, tmp);
|
|
|
- //防止strEwsCamera与ewsCamera.strFriendlyName、ewsCamera.strMd5Val值不一致,回退
|
|
|
- if (!convertResult){
|
|
|
- m_camerasConfig.strEwsCamera = old_ews_str;
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName = old_ews.strFriendlyName;
|
|
|
- m_camerasConfig.ewsCamera.strMd5Val = old_ews.strMd5Val;
|
|
|
- m_camerasConfig.ewsCamera.strDevPath = old_ews.strDevPath;
|
|
|
- ewsCanOpen = false;
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName, ConvertEwsCameraName failed, return Ews:%s",
|
|
|
- (LPCSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }else{
|
|
|
- errorCameraCnt--;
|
|
|
- ewsCorrected = true;
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName success, ewsCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.ewsCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
- }else {
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyFriendlyName, strEwsCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //2.采用排除法纠正(排除法用于只有唯一一个摄像头配置失败的场景,需要前面纠正后再来排除)
|
|
|
- if (errorCameraCnt == 1) {
|
|
|
- if (!envCanOpen) {
|
|
|
- envCanOpen = AutoCorrectCameraByOnlyOne(m_camerasConfig.envCamera,
|
|
|
- m_camerasConfig.optCamera, m_camerasConfig.ewsCamera, hspCams);
|
|
|
- if (envCanOpen) {
|
|
|
- envCorrected = true;
|
|
|
- errorCameraCnt--;
|
|
|
- m_camerasConfig.strEnvCamera = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.envCamera.strFriendlyName.GetData(), m_camerasConfig.envCamera.strMd5Val.GetData());
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne success, envCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.envCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.envCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- } else {
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne, strEnvCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (!optCanOpen) {
|
|
|
- optCanOpen = AutoCorrectCameraByOnlyOne(m_camerasConfig.optCamera,
|
|
|
- m_camerasConfig.envCamera, m_camerasConfig.ewsCamera, hspCams);
|
|
|
- if (optCanOpen) {
|
|
|
- optCorrected = true;
|
|
|
- errorCameraCnt--;
|
|
|
- m_camerasConfig.strOptCamera = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.optCamera.strFriendlyName.GetData(), m_camerasConfig.optCamera.strMd5Val.GetData());
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne success, optCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.optCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.optCamera.strDevPath, (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- } else {
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne, strOptCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (!ewsCanOpen) {
|
|
|
- ewsCanOpen = AutoCorrectCameraByOnlyOne(m_camerasConfig.ewsCamera,
|
|
|
- m_camerasConfig.envCamera, m_camerasConfig.optCamera, hspCams);
|
|
|
- if(ewsCanOpen){
|
|
|
- CSimpleStringA tmp = CSimpleStringA::Format("%s;%s",
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName.GetData(), m_camerasConfig.ewsCamera.strMd5Val.GetData());
|
|
|
- RefreshCameras();//m_cameras maybe don't refresh
|
|
|
- convertResult = ConvertEwsCameraName(m_camerasConfig.strEwsCamera, tmp);
|
|
|
- //防止strEwsCamera与ewsCamera.strFriendlyName、ewsCamera.strMd5Val值不一致,回退
|
|
|
- if (!convertResult){
|
|
|
- m_camerasConfig.strEwsCamera = old_ews_str;
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName = old_ews.strFriendlyName;
|
|
|
- m_camerasConfig.ewsCamera.strMd5Val = old_ews.strMd5Val;
|
|
|
- m_camerasConfig.ewsCamera.strDevPath = old_ews.strDevPath;
|
|
|
- ewsCanOpen = false;
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne, ConvertEwsCameraName failed, return Ews:%s",
|
|
|
- (LPCSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }else{
|
|
|
- errorCameraCnt--;
|
|
|
- ewsCorrected = true;
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne success, ewsCamera:FriendlyName:%s Md5Val:%s DevPath:%s Name:%s",
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strFriendlyName, (LPCTSTR)m_camerasConfig.ewsCamera.strMd5Val,
|
|
|
- (LPCTSTR)m_camerasConfig.ewsCamera.strDevPath, (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
- } else {
|
|
|
- Dbg("AutoCorrectCameraConfig ByOnlyOne, strEwsCamera:%s failed!",
|
|
|
- (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //注意:strEwsCamera记录的广角设备路径ID无法唯一标识设备(),导致出现纠正后strEwsCamera与env/opt设备路径ID一致而无法打开的情况
|
|
|
- //而strDevPath能唯一标识设备
|
|
|
- //这里对此种场景做特殊处理,对于纠正后广角与env/opt设备路径ID一致的回退不纠正
|
|
|
- if (ewsCorrected){
|
|
|
- CSimpleStringA tmpEnv = "$";
|
|
|
- CSimpleStringA tmpOpt = "$";
|
|
|
- ConvertEwsCameraName(tmpEnv, m_camerasConfig.strEnvCamera);
|
|
|
- ConvertEwsCameraName(tmpOpt, m_camerasConfig.strOptCamera);
|
|
|
- if((strcmp((LPCTSTR)m_camerasConfig.strEwsCamera, (LPCTSTR)tmpEnv) == 0) ||
|
|
|
- (strcmp((LPCTSTR)m_camerasConfig.strEwsCamera, (LPCTSTR)tmpOpt) == 0)){
|
|
|
- m_camerasConfig.strEwsCamera = old_ews_str;
|
|
|
- m_camerasConfig.ewsCamera.strFriendlyName = old_ews.strFriendlyName;
|
|
|
- m_camerasConfig.ewsCamera.strMd5Val = old_ews.strMd5Val;
|
|
|
- m_camerasConfig.ewsCamera.strDevPath = old_ews.strDevPath;
|
|
|
- ewsCanOpen = false;
|
|
|
- ewsCorrected = false;
|
|
|
- Dbg("AutoCorrectCameraConfig, Corrected Ews Same With Env or Opt, return Ews:%s",
|
|
|
- (LPCSTR)m_camerasConfig.strEwsCamera);
|
|
|
- }
|
|
|
- }
|
|
|
- Dbg("AutoCorrectCameraConfig, after update config Env:%s, Opt:%s, Ews:%s",
|
|
|
- (LPCSTR)m_camerasConfig.strEnvCamera, (LPCSTR)m_camerasConfig.strOptCamera, (LPCSTR)m_camerasConfig.strEwsCamera);
|
|
|
-
|
|
|
- //update to root.ini
|
|
|
- if (envCorrected || optCorrected || ewsCorrected){
|
|
|
- CAutoArray<CEditConfigReq> reqs(3);
|
|
|
- for (int i = 0; i < 3; ++i) {
|
|
|
- reqs[i].EditType = 'U';
|
|
|
- strcpy(reqs[i].EntityName, "Root");
|
|
|
- strcpy(reqs[i].Section, "Video");
|
|
|
- }
|
|
|
- if (m_camerasConfig.strEnvCamera.GetLength() <= 1) {
|
|
|
- m_camerasConfig.strEnvCamera = "$";
|
|
|
- }
|
|
|
- if (m_camerasConfig.strOptCamera.GetLength() <= 1) {
|
|
|
- m_camerasConfig.strOptCamera = "$";
|
|
|
- }
|
|
|
- if (m_camerasConfig.strEwsCamera.GetLength() <= 1) {
|
|
|
- m_camerasConfig.strEwsCamera = "$";
|
|
|
- }
|
|
|
- strcpy(reqs[0].Key, "EnvCamera");
|
|
|
- strcpy(reqs[0].Value, (LPCTSTR)m_camerasConfig.strEnvCamera);
|
|
|
- strcpy(reqs[1].Key, "OptCamera");
|
|
|
- strcpy(reqs[1].Value, (LPCTSTR)m_camerasConfig.strOptCamera);
|
|
|
- strcpy(reqs[2].Key, "EwsCamera");
|
|
|
- strcpy(reqs[2].Value, (LPCTSTR)m_camerasConfig.strEwsCamera);
|
|
|
- HandleEditConfigReq(reqs);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- config->strEnvCamera = m_camerasConfig.strEnvCamera;
|
|
|
- config->strOptCamera = m_camerasConfig.strOptCamera;
|
|
|
- config->strEwsCamera = m_camerasConfig.strEwsCamera;
|
|
|
- return errorCameraCnt == 0;
|
|
|
-}
|
|
|
-
|
|
|
-//尝试自纠正一个摄像头配置名,采用配置名中设备名(FriendlyName)纠正
|
|
|
-bool CCameraConfigManageEntity::AutoCorrectCameraByOnlyFriendlyName(camera_names_t &correct_camera,
|
|
|
- bool camera1_can_open, bool camera2_can_open,
|
|
|
- const camera_names_t &exclude_camera1, const camera_names_t &exclude_camera2,
|
|
|
- const CAutoArray<CSimpleStringA> &hspCams) {
|
|
|
-
|
|
|
- bool result = false;
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- do {
|
|
|
- camera_names_t tmp;
|
|
|
- CAutoArray<CSimpleStringA> excludeCams;
|
|
|
- //opt
|
|
|
- if (strcmp((LPCTSTR)correct_camera.strFriendlyName, (LPCTSTR)exclude_camera1.strFriendlyName) == 0) {
|
|
|
- if (!camera1_can_open) {
|
|
|
- //两设备同名都无法打开,无法矫正
|
|
|
- Dbg("AutoCorrectCameraByOnlyFriendlyName, strFriendlyName:%s can't correct for exclude_camera1 sameName",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName);
|
|
|
- break;
|
|
|
- } else {
|
|
|
- //去掉同名能正确打开设备
|
|
|
- excludeCams.Append(&exclude_camera1.strMd5Val, 0, 1);
|
|
|
- Dbg("AutoCorrectCameraByOnlyFriendlyName, correctCameraFriendlyName:%s add exclude camera1:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)exclude_camera1.strFriendlyName);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //两设备不同名,可以矫正
|
|
|
- }
|
|
|
- //ews
|
|
|
- if (strcmp((LPCTSTR)correct_camera.strFriendlyName, (LPCTSTR)exclude_camera2.strFriendlyName) == 0) {
|
|
|
- if (!camera2_can_open) {
|
|
|
- //两设备同名都无法打开,无法矫正
|
|
|
- Dbg("AutoCorrectCameraByOnlyFriendlyName, strFriendlyName:%s can't correct for exclude_camera2 sameName",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName);
|
|
|
- break;
|
|
|
- } else {
|
|
|
- excludeCams.Append(&exclude_camera2.strMd5Val, 0, 1);
|
|
|
- Dbg("AutoCorrectCameraByOnlyFriendlyName, correctCameraFriendlyName:%s add exclude camera2:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)exclude_camera2.strFriendlyName);
|
|
|
- }
|
|
|
- } else {
|
|
|
- //env与ews不同名,可以矫正
|
|
|
- }
|
|
|
- //矫正env
|
|
|
- result = capture_get_only_video_device_by_friendlyname(correct_camera.strFriendlyName,
|
|
|
- excludeCams, hspCams, tmp);
|
|
|
- if (result) {
|
|
|
- correct_camera.strFriendlyName = tmp.strFriendlyName;
|
|
|
- correct_camera.strDevPath = tmp.strDevPath;
|
|
|
- correct_camera.strMd5Val = tmp.strMd5Val;
|
|
|
- Dbg("AutoCorrectCameraByOnlyFriendlyName, find correct_camera strFriendlyName:%s strDevPath:%s strMd5Val:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)correct_camera.strDevPath, (LPCSTR)correct_camera.strMd5Val);
|
|
|
- }
|
|
|
-
|
|
|
- } while (0);
|
|
|
-
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-//尝试自纠正一个摄像头配置名,采用唯一性纠正
|
|
|
-bool CCameraConfigManageEntity::AutoCorrectCameraByOnlyOne(camera_names_t &correct_camera,
|
|
|
- const camera_names_t &exclude_camera1, const camera_names_t &exclude_camera2,
|
|
|
- const CAutoArray<CSimpleStringA> &hspCams) {
|
|
|
- bool result = false;
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- camera_names_t tmp;
|
|
|
- CAutoArray<CSimpleStringA> excludeCams;
|
|
|
- //opt
|
|
|
- excludeCams.Append(&exclude_camera1.strMd5Val, 0, 1);
|
|
|
- //ews
|
|
|
- excludeCams.Append(&exclude_camera2.strMd5Val, 0, 1);
|
|
|
- Dbg("AutoCorrectCameraByOnlyOne, correctCameraFriendlyName:%s exclude camera1:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)exclude_camera1.strFriendlyName);
|
|
|
- Dbg("AutoCorrectCameraByOnlyOne, correctCameraFriendlyName:%s exclude camera2:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)exclude_camera2.strFriendlyName);
|
|
|
-
|
|
|
- //矫正env
|
|
|
- result = capture_get_only_video_device(excludeCams, hspCams, tmp);
|
|
|
- if (result) {
|
|
|
- correct_camera.strFriendlyName = tmp.strFriendlyName;
|
|
|
- correct_camera.strDevPath = tmp.strDevPath;
|
|
|
- correct_camera.strMd5Val = tmp.strMd5Val;
|
|
|
- Dbg("AutoCorrectCameraByOnlyOne, find correct_camera strFriendlyName:%s strDevPath:%s strMd5Val:%s",
|
|
|
- (LPCSTR)correct_camera.strFriendlyName, (LPCSTR)correct_camera.strDevPath, (LPCSTR)correct_camera.strMd5Val);
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::GetMediaAvailableList(
|
|
|
- SpReqAnsContext<CameraConfigManageService_GetMediaAvailableList_Req,
|
|
|
- CameraConfigManageService_GetMediaAvailableList_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- int count = 0;
|
|
|
- const int maxCnt = 15;
|
|
|
-
|
|
|
- CAutoArray<CSimpleStringA> cameras;
|
|
|
- int icountmic(0);
|
|
|
- int icountspeaker(0);
|
|
|
-
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 1)) {
|
|
|
- capture_enum_cameras(cameras);
|
|
|
- count += cameras.GetCount();
|
|
|
- }
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 2)) {
|
|
|
- icountmic = mlibAudioMgr->audio_get_device_count(true);
|
|
|
- Dbg("audio input device(%d)", icountmic);
|
|
|
- count += icountmic;
|
|
|
- }
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 4)) {
|
|
|
- icountspeaker = mlibAudioMgr->audio_get_device_count(false);
|
|
|
- Dbg("audio output device(%d)", icountspeaker);
|
|
|
- count += icountspeaker;
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.AvailableList.Init(count);
|
|
|
- ctx->Ans.ListItemType.Init(count);
|
|
|
- ctx->Ans.ListItemStatus.Init(count);
|
|
|
- int curCnt(0);
|
|
|
-
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 1)) {
|
|
|
- for (int i = 0; i < cameras.GetCount(); ++i) {
|
|
|
- ctx->Ans.AvailableList[curCnt] = cameras[i];
|
|
|
- ctx->Ans.ListItemType[curCnt] = 1;
|
|
|
- ctx->Ans.ListItemStatus[curCnt] = 0;
|
|
|
- Dbg("%d: %s", i, ctx->Ans.AvailableList[curCnt].GetData());
|
|
|
- curCnt++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 2)) {
|
|
|
- for (int i=0; i < icountmic; i++) {
|
|
|
- char strname[MAX_PATH] = { 0 };
|
|
|
- mlibAudioMgr->audio_get_device_name(strname, MAX_PATH, true, i);
|
|
|
- ctx->Ans.AvailableList[curCnt] = strname;
|
|
|
- ctx->Ans.ListItemType[curCnt] = 2;
|
|
|
- ctx->Ans.ListItemStatus[curCnt] = 0;
|
|
|
- Dbg("%d: %s", i, ctx->Ans.AvailableList[curCnt].GetData());
|
|
|
- curCnt++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (ctx->Req.type == 0 || (ctx->Req.type & 4)) {
|
|
|
- for (int i = 0; i < icountspeaker; i++) {
|
|
|
- char strname[MAX_PATH] = { 0 };
|
|
|
- mlibAudioMgr->audio_get_device_name(strname, MAX_PATH, false, i);
|
|
|
- ctx->Ans.AvailableList[curCnt] = strname;
|
|
|
- ctx->Ans.ListItemType[curCnt] = 4;
|
|
|
- ctx->Ans.ListItemStatus[curCnt] = 0;
|
|
|
- Dbg("%d: %s", i, ctx->Ans.AvailableList[curCnt].GetData());
|
|
|
- curCnt++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.result = curCnt;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::SetMediaDevice(SpReqAnsContext<CameraConfigManageService_SetMediaDevice_Req, CameraConfigManageService_SetMediaDevice_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- ctx->Answer(Error_NotImpl);
|
|
|
-}
|
|
|
-
|
|
|
-void CCameraConfigManageEntity::TestAvailableMedieDev(SpReqAnsContext<CameraConfigManageService_TestAvailableMedieDev_Req, CameraConfigManageService_TestAvailableMedieDev_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- ctx->Answer(Error_NotImpl);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_BeginCameraConfigManage(
|
|
|
- SpOnewayCallContext<CameraConfigManageService_BeginCameraConfigManage_Info>::Pointer ctx )
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- m_pEntity->StopEchoVideo();
|
|
|
- m_pEntity->StopCamera();
|
|
|
- LogEvent(Severity_Middle, LOG_EVT_BEGIN_CAMERA_CONFIG, NULL);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_EndCameraConfigManage(
|
|
|
- SpOnewayCallContext<CameraConfigManageService_EndCameraConfigManage_Info>::Pointer ctx )
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- m_pEntity->StopEchoVideo();
|
|
|
- m_pEntity->StopCamera();
|
|
|
- LogEvent(Severity_Middle, LOG_EVT_END_CAMERA_CONFIG, NULL);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_GetCameraList(
|
|
|
- SpReqAnsContext<CameraConfigManageService_GetCameraList_Req,
|
|
|
- CameraConfigManageService_GetCameraList_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
- std::vector<camera_names_t> cams;
|
|
|
- m_pEntity->GetAvailableCameras(cams);
|
|
|
-
|
|
|
- if (!cams.empty()) {
|
|
|
- int nCount = cams.size();
|
|
|
- ctx->Ans.AvailableList.Init(nCount);
|
|
|
- for (int i = 0; i < nCount; ++i) {
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- ctx->Ans.AvailableList[i] = CSimpleStringA::Format("%s;%s",
|
|
|
- cams[i].strFriendlyName.GetData(), cams[i].strMd5Val.GetData());
|
|
|
-#else
|
|
|
- ctx->Ans.AvailableList[i] = cams[i].strDevPath;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- VideoConfig m_videoConfig;
|
|
|
- m_pEntity->LoadConfig(&m_videoConfig);
|
|
|
-
|
|
|
- bool bNull = m_videoConfig.strEnvCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.EnvCamera = bNull?"$":m_videoConfig.strEnvCamera;
|
|
|
-
|
|
|
- bNull = m_videoConfig.strOptCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.OptCamera = bNull?"$":m_videoConfig.strOptCamera;
|
|
|
-
|
|
|
- bNull = m_videoConfig.strEwsCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.EwsCamera = bNull?"$":m_videoConfig.strEwsCamera;
|
|
|
-
|
|
|
- if (eDesk2SType == m_pEntity->GetDeviceType()){
|
|
|
- if ('$' == ctx->Ans.EwsCamera[0]){
|
|
|
- ctx->Ans.EwsCamera = ctx->Ans.EnvCamera;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (ctx->Ans.EwsCamera != CSimpleStringA("$")) {
|
|
|
- BOOL bFound = FALSE;
|
|
|
- for (int i = 0; i < cams.size(); ++i) {
|
|
|
- if (strstr(cams[i].strDevPath.GetData(),m_videoConfig.strEwsCamera.GetData())) {
|
|
|
- bFound = TRUE;
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- ctx->Ans.EwsCamera = CSimpleStringA::Format("%s;%s",
|
|
|
- cams[i].strFriendlyName.GetData(), cams[i].strMd5Val.GetData());
|
|
|
-#else
|
|
|
- ctx->Ans.EwsCamera = cams[i].strDevPath;
|
|
|
-#endif //RVC_OS_WIN
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!bFound) {
|
|
|
- Dbg("[dbg] failed to find ewscam");
|
|
|
- }
|
|
|
- else {
|
|
|
- Dbg("[dbg] ewscamera:%s-->%s",m_videoConfig.strEwsCamera.GetData(),ctx->Ans.EwsCamera.GetData());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_EchoSomeCamera(
|
|
|
- SpReqAnsContext<CameraConfigManageService_EchoSomeCamera_Req,
|
|
|
- CameraConfigManageService_EchoSomeCamera_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- if (ctx->Req.CameraName.GetLength() <= 1 ||
|
|
|
- ctx->Req.WndParams.GetLength() <= 1) {
|
|
|
- ctx->Ans.Error_Code = 0x21D81001;
|
|
|
- ctx->Ans.Error_Msg = "params cannot be omitted";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const char* wndParams = (LPCTSTR)(ctx->Req.WndParams);
|
|
|
- Dbg("start to echo video, get pos = %s", wndParams);
|
|
|
- int xPos, yPos, width, height;
|
|
|
- int nsuc = sscanf(wndParams, "%d@%d@%d@%d", &xPos, &yPos, &width, &height);
|
|
|
- if (nsuc != 4) {
|
|
|
- ctx->Ans.Error_Code = 0x21D81002;
|
|
|
- ctx->Ans.Error_Msg = "WndParams is illegal";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Dbg("x=%d,y=%d,width=%d,height=%d", xPos, yPos, width, height);
|
|
|
- int ScreenWidth = GetSystemMetrics(SM_CXSCREEN); //主屏幕宽度
|
|
|
- int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); //主屏幕高度
|
|
|
-
|
|
|
- DeviceTypeEnum devType = m_pEntity->GetDeviceType();
|
|
|
- if (eDesk2SType == devType) // 低柜双屏在客户经理屏操作
|
|
|
- {
|
|
|
- if (xPos < 0 || yPos < 0 || width<0 || height < 0 ||
|
|
|
- xPos + width>2 * ScreenWidth || yPos + height>ScreenHeight) //
|
|
|
- {
|
|
|
- // 弹出模态窗口提示回显参数不正确
|
|
|
- ctx->Ans.Error_Code = 0x21D81003;
|
|
|
- ctx->Ans.Error_Msg = "WndParams is illegal";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- MessageBoxA(NULL, (LPCSTR)("窗口参数不正确,无法进行视频回显!"), NULL, MB_SYSTEMMODAL);
|
|
|
- return;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (xPos < 0 || yPos < 0 || width<0 || height<0 ||
|
|
|
- xPos + width>ScreenWidth || yPos + height>ScreenHeight) //
|
|
|
- {
|
|
|
- // 弹出模态窗口提示回显参数不正确
|
|
|
- ctx->Ans.Error_Code = 0x21D81003;
|
|
|
- ctx->Ans.Error_Msg = "WndParams is illegal";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- MessageBoxA(NULL, (LPCSTR)("窗口参数不正确,无法进行视频回显!"), NULL, MB_SYSTEMMODAL);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- CSimpleStringA currentCamName = m_pEntity->GetCameraName();
|
|
|
- if (currentCamName != ctx->Req.CameraName) {
|
|
|
- // 停止回显
|
|
|
- m_pEntity->StopEchoVideo();
|
|
|
- // 停止摄像头
|
|
|
- m_pEntity->StopCamera();
|
|
|
- // 摄像头赋值
|
|
|
- m_pEntity->SetCameraName(ctx->Req.CameraName);
|
|
|
- }
|
|
|
-
|
|
|
- Dbg("ctx->Req.CameraName:%s", ctx->Req.CameraName.GetData());
|
|
|
-
|
|
|
- if (!m_pEntity->IsCameraStart()) {
|
|
|
- // 启动摄像头
|
|
|
- ErrorCodeEnum error = m_pEntity->StartCamera();
|
|
|
- if (error != Error_Succeed) {
|
|
|
- ctx->Ans.Error_Code = 0x21D81004;
|
|
|
- ctx->Ans.Error_Msg = "failed to start camera";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 开始回显画面
|
|
|
- m_pEntity->StartEchoVideo(xPos, yPos, width, height);
|
|
|
-
|
|
|
- ctx->Ans.Error_Code = 0;
|
|
|
- ctx->Ans.Error_Msg = "";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-#else
|
|
|
- ctx->Answer(Error_NotImpl);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_SaveCameraConfig(
|
|
|
- SpReqAnsContext<CameraConfigManageService_SaveCameraConfig_Req,
|
|
|
- CameraConfigManageService_SaveCameraConfig_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
-
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- camera_names_t camera;
|
|
|
-
|
|
|
- if (ctx->Req.EnvCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.EnvCamera.GetData(), camera) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82001;
|
|
|
- ctx->Ans.Error_Msg = "EnvCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ctx->Req.OptCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.OptCamera.GetData(), camera) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82002;
|
|
|
- ctx->Ans.Error_Msg = "OptCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ctx->Req.EwsCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.EwsCamera.GetData(), camera) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82003;
|
|
|
- ctx->Ans.Error_Msg = "EwsCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-#else
|
|
|
- if (ctx->Req.EnvCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.EnvCamera.GetData()) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82001;
|
|
|
- ctx->Ans.Error_Msg = "EnvCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ctx->Req.OptCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.OptCamera.GetData()) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82002;
|
|
|
- ctx->Ans.Error_Msg = "OptCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (ctx->Req.EwsCamera.GetLength() > 1 &&
|
|
|
- capture_get_video_device_id(ctx->Req.EwsCamera.GetData()) < 0) {
|
|
|
- ctx->Ans.Error_Code = 0x21D82003;
|
|
|
- ctx->Ans.Error_Msg = "EwsCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-
|
|
|
- CAutoArray<CEditConfigReq> reqs(3);
|
|
|
-
|
|
|
- for (int i = 0; i < 3; ++i) {
|
|
|
- reqs[i].EditType = 'U';
|
|
|
- strcpy(reqs[i].EntityName,"Root");
|
|
|
- strcpy(reqs[i].Section,"Video");
|
|
|
- }
|
|
|
-
|
|
|
- if (ctx->Req.EnvCamera.GetLength() <= 1) {
|
|
|
- ctx->Req.EnvCamera = "$";
|
|
|
- }
|
|
|
- if (ctx->Req.OptCamera.GetLength() <= 1) {
|
|
|
- ctx->Req.OptCamera = "$";
|
|
|
- }
|
|
|
- if (ctx->Req.EwsCamera.GetLength() <= 1) {
|
|
|
- ctx->Req.EwsCamera = "$";
|
|
|
- }
|
|
|
-
|
|
|
- strcpy(reqs[0].Key,"EnvCamera");
|
|
|
- strcpy(reqs[0].Value,(LPCTSTR)ctx->Req.EnvCamera);
|
|
|
-
|
|
|
- strcpy(reqs[1].Key,"OptCamera");
|
|
|
- strcpy(reqs[1].Value,(LPCTSTR)ctx->Req.OptCamera);
|
|
|
-
|
|
|
- strcpy(reqs[2].Key,"EwsCamera");
|
|
|
- if (ctx->Req.EwsCamera.GetLength() > 1)
|
|
|
- {
|
|
|
- if (ctx->Req.EwsCamera != ctx->Req.EnvCamera)
|
|
|
- {
|
|
|
- CSimpleStringA ewsCamName;
|
|
|
- bool bRet = m_pEntity->ConvertEwsCameraName(ewsCamName,ctx->Req.EwsCamera);
|
|
|
- Dbg("%s to ConvertEwsCameraName", (bRet ? "succeeded" : "failed"));
|
|
|
- if (!bRet)
|
|
|
- {
|
|
|
- ctx->Ans.Error_Code = 0x21D82003;
|
|
|
- ctx->Ans.Error_Msg = "EwsCamera does not exist";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
- strcpy(reqs[2].Value, ewsCamName.GetData());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dbg("env camera is eqeul to ews camera, set ews camera to empty");
|
|
|
- strcpy(reqs[2].Value, "$");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- strcpy(reqs[2].Value, ctx->Req.EwsCamera.GetData());
|
|
|
- }
|
|
|
-
|
|
|
- m_pEntity->HandleEditConfigReq(reqs);
|
|
|
-
|
|
|
- ctx->Ans.Error_Code = 0;
|
|
|
- ctx->Ans.Error_Msg = "";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_StopEchoSomeCamera(
|
|
|
- SpReqAnsContext<CameraConfigManageService_StopEchoSomeCamera_Req,
|
|
|
- CameraConfigManageService_StopEchoSomeCamera_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
- CSimpleStringA currentCamName = m_pEntity->GetCameraName();
|
|
|
- if (currentCamName != ctx->Req.CameraName) {
|
|
|
- ctx->Ans.Error_Code = 0x21D83001;
|
|
|
- ctx->Ans.Error_Msg = "input camera name is incorrect";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- m_pEntity->StopEchoVideo();
|
|
|
- m_pEntity->StopCamera();
|
|
|
-
|
|
|
- ctx->Ans.Error_Code = 0;
|
|
|
- ctx->Ans.Error_Msg = "";
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-#else
|
|
|
- ctx->Answer(Error_NotSupport);
|
|
|
-#endif //RVC_OS_WIN
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_QueryCallState(
|
|
|
- SpReqAnsContext<CameraConfigManageService_QueryCallState_Req,
|
|
|
- CameraConfigManageService_QueryCallState_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
- CSimpleStringA strValue;
|
|
|
- ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("CallState", strValue);
|
|
|
- Dbg("QueryCallState: %s", strValue.GetData());
|
|
|
- if (Error != Error_Succeed)
|
|
|
- {
|
|
|
- strValue = "";
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.CallState = strValue;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_QueryUIState(
|
|
|
- SpReqAnsContext<CameraConfigManageService_QueryUIState_Req,
|
|
|
- CameraConfigManageService_QueryUIState_Ans>::Pointer ctx )
|
|
|
-{
|
|
|
- CSimpleStringA strValue;
|
|
|
- ErrorCodeEnum Error = m_pEntity->GetFunction()->GetSysVar("UIState", strValue);
|
|
|
- Dbg("QueryUIState: %s", strValue.GetData());
|
|
|
- if (Error != Error_Succeed)
|
|
|
- {
|
|
|
- strValue = "";
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.UIState = strValue;
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_AutoCorrectCameraConfig(
|
|
|
- SpReqAnsContext<CameraConfigManageService_AutoCorrectCameraConfig_Req,
|
|
|
- CameraConfigManageService_AutoCorrectCameraConfig_Ans>::Pointer ctx) {
|
|
|
-
|
|
|
- VideoConfig m_videoConfig;
|
|
|
- m_pEntity->AutoCorrectCameraConfig(&m_videoConfig);
|
|
|
-
|
|
|
- bool bNull = m_videoConfig.strEnvCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.EnvCamera = bNull ? "$" : m_videoConfig.strEnvCamera;
|
|
|
-
|
|
|
- bNull = m_videoConfig.strOptCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.OptCamera = bNull ? "$" : m_videoConfig.strOptCamera;
|
|
|
-
|
|
|
- bNull = m_videoConfig.strEwsCamera.IsNullOrEmpty();
|
|
|
- ctx->Ans.EwsCamera = bNull ? "$" : m_videoConfig.strEwsCamera;
|
|
|
-
|
|
|
- ctx->Answer(Error_Succeed);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_GetMediaAvailableList(SpReqAnsContext<CameraConfigManageService_GetMediaAvailableList_Req, CameraConfigManageService_GetMediaAvailableList_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- m_pEntity->GetMediaAvailableList(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_SetMediaDevice(SpReqAnsContext<CameraConfigManageService_SetMediaDevice_Req, CameraConfigManageService_SetMediaDevice_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- m_pEntity->SetMediaDevice(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-void CameraConfigManageServiceSession::Handle_TestAvailableMedieDev(SpReqAnsContext<CameraConfigManageService_TestAvailableMedieDev_Req, CameraConfigManageService_TestAvailableMedieDev_Ans>::Pointer ctx)
|
|
|
-{
|
|
|
- LOG_FUNCTION();
|
|
|
- m_pEntity->TestAvailableMedieDev(ctx);
|
|
|
-}
|
|
|
-
|
|
|
-SP_BEGIN_ENTITY_MAP()
|
|
|
-SP_ENTITY(CCameraConfigManageEntity)
|
|
|
-SP_END_ENTITY_MAP()
|
|
|
-
|