|
|
|
@ -1,236 +1,236 @@ |
|
|
|
#include "basicCamera.h"
|
|
|
|
|
|
|
|
// Constructor implementation
|
|
|
|
basicCamera::basicCamera(config_setting_t *Settings) : basicObject(), basicPosition(), basicEventHandler() { |
|
|
|
m_eCaps = (objectCaps)(OC_EVENT_HANDLER); |
|
|
|
m_pSettings = Settings; |
|
|
|
m_iStatus = PS_BORN; |
|
|
|
m_sCameraInfo.m_pName = NULL; |
|
|
|
m_sCameraInfo.m_pSourcePath = NULL; |
|
|
|
m_sCameraInfo.m_bAutoExposure = false; |
|
|
|
m_sCameraInfo.m_bAutoFocus = false; |
|
|
|
m_sCameraInfo.m_bAutoIris = false; |
|
|
|
m_sCameraInfo.m_bAutoWB = false; |
|
|
|
m_sCameraInfo.m_bDigitalZoom = false; |
|
|
|
m_sCameraInfo.m_bExpoEna = false; |
|
|
|
m_sCameraInfo.m_bFocusEna = false; |
|
|
|
m_sCameraInfo.m_bIrisEna = false; |
|
|
|
m_sCameraInfo.m_bMirrored = false; |
|
|
|
m_sCameraInfo.m_bOpticEna = false; |
|
|
|
m_sCameraInfo.m_bOpticZoom = false; |
|
|
|
m_sCameraInfo.m_bShuterEna = false; |
|
|
|
m_sCameraInfo.m_bUpsideDown = false; |
|
|
|
m_sCameraInfo.m_bWBEna = false; |
|
|
|
m_sCameraInfo.m_bWDR = false; |
|
|
|
m_sCameraInfo.m_bWDREna = false; |
|
|
|
m_sCameraInfo.m_bZoomEna = false; |
|
|
|
m_sCameraInfo.m_bZoomSpeedDynamic = false; |
|
|
|
m_sCameraInfo.m_fDigitalZoomMax = -1.f; |
|
|
|
m_sCameraInfo.m_fFLCurrent = -1.f; |
|
|
|
m_sCameraInfo.m_fFLMax = -1.f; |
|
|
|
m_sCameraInfo.m_fFLMin = -1.f; |
|
|
|
m_sCameraInfo.m_fFOV = -1.f; |
|
|
|
m_sCameraInfo.m_fManualExposure = -1.f; |
|
|
|
m_sCameraInfo.m_fManualFocus = -1.f; |
|
|
|
m_sCameraInfo.m_fManualIris = -1.f; |
|
|
|
m_sCameraInfo.m_fManualShutter = -1.f; |
|
|
|
m_sCameraInfo.m_fSensorSize = ( 1.f / 2.8f ) * .0254f; // in meters
|
|
|
|
m_sCameraInfo.m_fZoomSpeedMax = -1.f; |
|
|
|
m_sCameraInfo.m_fZoomSpeedMin = -1.f; |
|
|
|
m_sCameraInfo.m_iHeight = -1; |
|
|
|
m_sCameraInfo.m_iWidth = -1; |
|
|
|
m_sCameraInfo.m_bScaledOutput = false; |
|
|
|
m_sCameraInfo.m_iOutputWidth = -1; |
|
|
|
m_sCameraInfo.m_iOutputHeight = -1; |
|
|
|
m_sCameraInfo.m_iSourcePort = -1; |
|
|
|
m_sCameraInfo.m_iSourceType = -1; |
|
|
|
m_sCameraInfo.m_iCameraType = -1; |
|
|
|
m_sCameraInfo.m_iZoomMax = -1; |
|
|
|
m_sCameraInfo.m_iZoomMin = -1; |
|
|
|
m_sCameraInfo.m_fMaxRange = -1; |
|
|
|
m_pVideoSource = NULL; |
|
|
|
m_pVideoNode = new videoNode(m_pSettings); |
|
|
|
}; |
|
|
|
|
|
|
|
// Destructor implementation
|
|
|
|
basicCamera::~basicCamera(){ |
|
|
|
m_vOSD.clear(); |
|
|
|
updateSettings(); |
|
|
|
if (m_pVideoNode != NULL){ |
|
|
|
m_pVideoNode->setStatus(TH_EXIT); |
|
|
|
delete(m_pVideoNode); |
|
|
|
}; |
|
|
|
if (m_sCameraInfo.m_pName != NULL)free(m_sCameraInfo.m_pName); |
|
|
|
if (m_sCameraInfo.m_pSourcePath != NULL)free(m_sCameraInfo.m_pSourcePath); |
|
|
|
}; |
|
|
|
|
|
|
|
bool basicCamera::create(void){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
if (m_pSettings == NULL) return false; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_TYPE); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iCameraType = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_TYPE); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iSourceType = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_WIDTH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iWidth = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_HEIGHT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iHeight = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PORT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iSourcePort = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_NAME); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
if (m_sCameraInfo.m_pName == NULL) m_sCameraInfo.m_pName = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pName, "%s", config_setting_get_string(pSetting)); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PATH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
if (m_sCameraInfo.m_pSourcePath == NULL) m_sCameraInfo.m_pSourcePath = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pSourcePath, "%s", config_setting_get_string(pSetting)); |
|
|
|
/*Location*/ |
|
|
|
float tLat, tLon, tAlt, tRoll, tPitch, tYaw; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tLat = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tLon = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tAlt = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tRoll = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tPitch = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tYaw = config_setting_get_float(pSetting); |
|
|
|
setPositionDeg(tLat, tLon, tAlt, tPitch, tRoll, tYaw); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool basicCamera::create(mediaSourceInfo *SI){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
|
|
|
|
if (m_pSettings == NULL) return false; |
|
|
|
if (SI == NULL) return false; |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_TYPE); |
|
|
|
m_sCameraInfo.m_iCameraType = SI->type; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_TYPE, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iCameraType); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_TYPE); |
|
|
|
m_sCameraInfo.m_iSourceType = SI->subtype; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_TYPE, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iSourceType); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_WIDTH); |
|
|
|
if (SI->frameIsWide){ |
|
|
|
m_sCameraInfo.m_iWidth = g_aFrameWidthStandard_16_9[SI->sizeId]; |
|
|
|
} else { |
|
|
|
m_sCameraInfo.m_iWidth = g_aFrameWidthStandard_4_3[SI->sizeId]; |
|
|
|
}; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_IMAGE_WIDTH, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iWidth); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_HEIGHT); |
|
|
|
if (SI->frameIsWide){ |
|
|
|
m_sCameraInfo.m_iHeight = g_aFrameHeightStandard_16_9[SI->sizeId]; |
|
|
|
} else { |
|
|
|
m_sCameraInfo.m_iHeight = g_aFrameHeightStandard_4_3[SI->sizeId]; |
|
|
|
}; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_IMAGE_HEIGHT, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iWidth); |
|
|
|
|
|
|
|
/*Location*/ |
|
|
|
float tLat, tLon, tAlt, tRoll, tPitch, tYaw; |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT); |
|
|
|
tLat = systemAnchor::getInstance()->getLat(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tLat ); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON); |
|
|
|
tLon = systemAnchor::getInstance()->getLon(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tLon); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT); |
|
|
|
tAlt = systemAnchor::getInstance()->getAlt(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tAlt); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH); |
|
|
|
tPitch = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tPitch); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL); |
|
|
|
tRoll = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tRoll); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW); |
|
|
|
tYaw = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tYaw); |
|
|
|
|
|
|
|
setPositionDeg(tLat, tLon, tAlt, tPitch, tRoll, tYaw); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PORT); |
|
|
|
m_sCameraInfo.m_iSourcePort = SI->capturePin; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_PORT, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iSourcePort); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_NAME); |
|
|
|
if (m_sCameraInfo.m_pName == NULL) m_sCameraInfo.m_pName = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pName, "%s", SI->deviceName); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_NAME, CONFIG_TYPE_STRING); |
|
|
|
}; |
|
|
|
config_setting_set_string(pSetting, m_sCameraInfo.m_pName); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PATH); |
|
|
|
if (m_sCameraInfo.m_pSourcePath == NULL) m_sCameraInfo.m_pSourcePath = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pSourcePath, "%s", SI->devicePath); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_PATH, CONFIG_TYPE_STRING); |
|
|
|
}; |
|
|
|
config_setting_set_string(pSetting, m_sCameraInfo.m_pSourcePath); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
void basicCamera::updateSettings(void){ |
|
|
|
if(!m_pSettings) return; |
|
|
|
#include "basicCamera.h"
|
|
|
|
|
|
|
|
// Constructor implementation
|
|
|
|
basicCamera::basicCamera(config_setting_t *Settings) : basicObject(), basicPosition(), basicEventHandler() { |
|
|
|
m_eCaps = (objectCaps)(OC_EVENT_HANDLER); |
|
|
|
m_pSettings = Settings; |
|
|
|
m_iStatus = PS_BORN; |
|
|
|
m_sCameraInfo.m_pName = NULL; |
|
|
|
m_sCameraInfo.m_pSourcePath = NULL; |
|
|
|
m_sCameraInfo.m_bAutoExposure = false; |
|
|
|
m_sCameraInfo.m_bAutoFocus = false; |
|
|
|
m_sCameraInfo.m_bAutoIris = false; |
|
|
|
m_sCameraInfo.m_bAutoWB = false; |
|
|
|
m_sCameraInfo.m_bDigitalZoom = false; |
|
|
|
m_sCameraInfo.m_bExpoEna = false; |
|
|
|
m_sCameraInfo.m_bFocusEna = false; |
|
|
|
m_sCameraInfo.m_bIrisEna = false; |
|
|
|
m_sCameraInfo.m_bMirrored = false; |
|
|
|
m_sCameraInfo.m_bOpticEna = false; |
|
|
|
m_sCameraInfo.m_bOpticZoom = false; |
|
|
|
m_sCameraInfo.m_bShuterEna = false; |
|
|
|
m_sCameraInfo.m_bUpsideDown = false; |
|
|
|
m_sCameraInfo.m_bWBEna = false; |
|
|
|
m_sCameraInfo.m_bWDR = false; |
|
|
|
m_sCameraInfo.m_bWDREna = false; |
|
|
|
m_sCameraInfo.m_bZoomEna = false; |
|
|
|
m_sCameraInfo.m_bZoomSpeedDynamic = false; |
|
|
|
m_sCameraInfo.m_fDigitalZoomMax = -1.f; |
|
|
|
m_sCameraInfo.m_fFLCurrent = -1.f; |
|
|
|
m_sCameraInfo.m_fFLMax = -1.f; |
|
|
|
m_sCameraInfo.m_fFLMin = -1.f; |
|
|
|
m_sCameraInfo.m_fFOV = -1.f; |
|
|
|
m_sCameraInfo.m_fManualExposure = -1.f; |
|
|
|
m_sCameraInfo.m_fManualFocus = -1.f; |
|
|
|
m_sCameraInfo.m_fManualIris = -1.f; |
|
|
|
m_sCameraInfo.m_fManualShutter = -1.f; |
|
|
|
m_sCameraInfo.m_fSensorSize = ( 1.f / 2.8f ) * .0254f; // in meters
|
|
|
|
m_sCameraInfo.m_fZoomSpeedMax = -1.f; |
|
|
|
m_sCameraInfo.m_fZoomSpeedMin = -1.f; |
|
|
|
m_sCameraInfo.m_iHeight = -1; |
|
|
|
m_sCameraInfo.m_iWidth = -1; |
|
|
|
m_sCameraInfo.m_bScaledOutput = false; |
|
|
|
m_sCameraInfo.m_iOutputWidth = -1; |
|
|
|
m_sCameraInfo.m_iOutputHeight = -1; |
|
|
|
m_sCameraInfo.m_iSourcePort = -1; |
|
|
|
m_sCameraInfo.m_iSourceType = -1; |
|
|
|
m_sCameraInfo.m_iCameraType = -1; |
|
|
|
m_sCameraInfo.m_iZoomMax = -1; |
|
|
|
m_sCameraInfo.m_iZoomMin = -1; |
|
|
|
m_sCameraInfo.m_fMaxRange = -1; |
|
|
|
m_pVideoSource = NULL; |
|
|
|
m_pVideoNode = new videoNode(m_pSettings); |
|
|
|
}; |
|
|
|
|
|
|
|
// Destructor implementation
|
|
|
|
basicCamera::~basicCamera(){ |
|
|
|
m_vOSD.clear(); |
|
|
|
updateSettings(); |
|
|
|
if (m_pVideoNode != NULL){ |
|
|
|
m_pVideoNode->setStatus(TH_EXIT); |
|
|
|
delete(m_pVideoNode); |
|
|
|
}; |
|
|
|
if (m_sCameraInfo.m_pName != NULL)free(m_sCameraInfo.m_pName); |
|
|
|
if (m_sCameraInfo.m_pSourcePath != NULL)free(m_sCameraInfo.m_pSourcePath); |
|
|
|
}; |
|
|
|
|
|
|
|
bool basicCamera::create(void){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
if (m_pSettings == NULL) return false; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_TYPE); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iCameraType = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_TYPE); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iSourceType = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_WIDTH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iWidth = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_HEIGHT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iHeight = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PORT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
m_sCameraInfo.m_iSourcePort = config_setting_get_int(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_NAME); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
if (m_sCameraInfo.m_pName == NULL) m_sCameraInfo.m_pName = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pName, "%s", config_setting_get_string(pSetting)); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PATH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
if (m_sCameraInfo.m_pSourcePath == NULL) m_sCameraInfo.m_pSourcePath = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pSourcePath, "%s", config_setting_get_string(pSetting)); |
|
|
|
/*Location*/ |
|
|
|
float tLat, tLon, tAlt, tRoll, tPitch, tYaw; |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tLat = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tLon = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tAlt = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tRoll = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tPitch = config_setting_get_float(pSetting); |
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW); |
|
|
|
if (pSetting == NULL) return false; |
|
|
|
tYaw = config_setting_get_float(pSetting); |
|
|
|
setPositionDeg(tLat, tLon, tAlt, tPitch, tRoll, tYaw); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool basicCamera::create(mediaSourceInfo *SI){ |
|
|
|
config_setting_t *pSetting; |
|
|
|
|
|
|
|
if (m_pSettings == NULL) return false; |
|
|
|
if (SI == NULL) return false; |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_TYPE); |
|
|
|
m_sCameraInfo.m_iCameraType = SI->type; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_TYPE, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iCameraType); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_TYPE); |
|
|
|
m_sCameraInfo.m_iSourceType = SI->subtype; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_TYPE, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iSourceType); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_WIDTH); |
|
|
|
if (SI->frameIsWide){ |
|
|
|
m_sCameraInfo.m_iWidth = g_aFrameWidthStandard_16_9[SI->sizeId]; |
|
|
|
} else { |
|
|
|
m_sCameraInfo.m_iWidth = g_aFrameWidthStandard_4_3[SI->sizeId]; |
|
|
|
}; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_IMAGE_WIDTH, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iWidth); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_IMAGE_HEIGHT); |
|
|
|
if (SI->frameIsWide){ |
|
|
|
m_sCameraInfo.m_iHeight = g_aFrameHeightStandard_16_9[SI->sizeId]; |
|
|
|
} else { |
|
|
|
m_sCameraInfo.m_iHeight = g_aFrameHeightStandard_4_3[SI->sizeId]; |
|
|
|
}; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_IMAGE_HEIGHT, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iWidth); |
|
|
|
|
|
|
|
/*Location*/ |
|
|
|
float tLat, tLon, tAlt, tRoll, tPitch, tYaw; |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT); |
|
|
|
tLat = systemAnchor::getInstance()->getLat(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tLat ); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON); |
|
|
|
tLon = systemAnchor::getInstance()->getLon(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tLon); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT); |
|
|
|
tAlt = systemAnchor::getInstance()->getAlt(); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tAlt); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_PITCH); |
|
|
|
tPitch = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_PITCH, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tPitch); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ROLL); |
|
|
|
tRoll = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_ROLL, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tRoll); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_YAW); |
|
|
|
tYaw = 0.f; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, TAG_POSITION_YAW, CONFIG_TYPE_FLOAT); |
|
|
|
}; |
|
|
|
config_setting_set_float(pSetting, tYaw); |
|
|
|
|
|
|
|
setPositionDeg(tLat, tLon, tAlt, tPitch, tRoll, tYaw); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PORT); |
|
|
|
m_sCameraInfo.m_iSourcePort = SI->capturePin; |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_PORT, CONFIG_TYPE_INT); |
|
|
|
}; |
|
|
|
config_setting_set_int(pSetting, m_sCameraInfo.m_iSourcePort); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_CAMERA_NAME); |
|
|
|
if (m_sCameraInfo.m_pName == NULL) m_sCameraInfo.m_pName = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pName, "%s", SI->deviceName); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_CAMERA_NAME, CONFIG_TYPE_STRING); |
|
|
|
}; |
|
|
|
config_setting_set_string(pSetting, m_sCameraInfo.m_pName); |
|
|
|
|
|
|
|
pSetting = config_setting_get_member(m_pSettings, BCI_TAG_SOURCE_PATH); |
|
|
|
if (m_sCameraInfo.m_pSourcePath == NULL) m_sCameraInfo.m_pSourcePath = (CSTR)malloc(255); |
|
|
|
sprintf(m_sCameraInfo.m_pSourcePath, "%s", SI->devicePath); |
|
|
|
if (pSetting == NULL){ |
|
|
|
pSetting = config_setting_add(m_pSettings, BCI_TAG_SOURCE_PATH, CONFIG_TYPE_STRING); |
|
|
|
}; |
|
|
|
config_setting_set_string(pSetting, m_sCameraInfo.m_pSourcePath); |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
return create(); |
|
|
|
}; |
|
|
|
|
|
|
|
void basicCamera::updateSettings(void){ |
|
|
|
if(!m_pSettings) return; |
|
|
|
config_setting_t *pSetting; |
|
|
|
int tInt; |
|
|
|
double tFloat; |
|
|
|
@ -332,44 +332,44 @@ void basicCamera::updateSettings(void){ |
|
|
|
basicSettingsProvider::getInstance()->compromise(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (basicSettingsProvider::getInstance()->isCompromised()) basicSettingsProvider::getInstance()->validate(); |
|
|
|
}; |
|
|
|
|
|
|
|
void basicCamera::dispatchEvent( basicEvent *Evt ){ |
|
|
|
if( Evt->m_eClass == EVT_CLASS_SENSOR ) { |
|
|
|
switch (Evt->m_eType){ |
|
|
|
case EVT_TARGET: |
|
|
|
case EVT_TARGET_WHITE: |
|
|
|
case EVT_TARGET_BLACK: |
|
|
|
case EVT_ALARM: |
|
|
|
CLIENT_EVENT *tData; |
|
|
|
tData = ( CLIENT_EVENT *) Evt->m_pEvtData; |
|
|
|
// Basic Camera Reaction - Start Record
|
|
|
|
|
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
} else |
|
|
|
if (Evt->m_eClass == EVT_CLASS_IMAGE){ |
|
|
|
switch (Evt->m_eType){ |
|
|
|
case EVT_COMMAND: |
|
|
|
basicCameraCommand *pData; |
|
|
|
pData = (basicCameraCommand *)Evt->m_pEvtData; |
|
|
|
// Basic Camera Commands
|
|
|
|
switch( pData->m_cCode ){ |
|
|
|
case CMD_CAMERA_START_RECORD: |
|
|
|
m_pVideoNode->startRecord(); |
|
|
|
break; |
|
|
|
case CMD_CAMERA_STOP_RECORD: |
|
|
|
m_pVideoNode->stopRecord(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
if (basicSettingsProvider::getInstance()->isCompromised()) basicSettingsProvider::getInstance()->validate(); |
|
|
|
}; |
|
|
|
|
|
|
|
void basicCamera::dispatchEvent( basicEvent *Evt ){ |
|
|
|
if( Evt->m_eClass == EVT_CLASS_SENSOR ) { |
|
|
|
switch (Evt->m_eType){ |
|
|
|
case EVT_TARGET: |
|
|
|
case EVT_TARGET_WHITE: |
|
|
|
case EVT_TARGET_BLACK: |
|
|
|
case EVT_ALARM: |
|
|
|
CLIENT_EVENT *tData; |
|
|
|
tData = ( CLIENT_EVENT *) Evt->m_pEvtData; |
|
|
|
// Basic Camera Reaction - Start Record
|
|
|
|
|
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
} else |
|
|
|
if (Evt->m_eClass == EVT_CLASS_IMAGE){ |
|
|
|
switch (Evt->m_eType){ |
|
|
|
case EVT_COMMAND: |
|
|
|
basicCameraCommand *pData; |
|
|
|
pData = (basicCameraCommand *)Evt->m_pEvtData; |
|
|
|
// Basic Camera Commands
|
|
|
|
switch( pData->m_cCode ){ |
|
|
|
case CMD_CAMERA_START_RECORD: |
|
|
|
m_pVideoNode->startRecord(); |
|
|
|
break; |
|
|
|
case CMD_CAMERA_STOP_RECORD: |
|
|
|
m_pVideoNode->stopRecord(); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |