|
|
@@ -1886,7 +1886,9 @@ namespace MediaController {
|
|
|
int icamnum = 0;
|
|
|
CSimpleStringA strCamInfoJson("");
|
|
|
CSimpleStringA strCamListInfoJson("");
|
|
|
- Json::Value rootReq;
|
|
|
+ cJSON* array = cJSON_CreateArray();
|
|
|
+ cJSON* root = cJSON_CreateObject();
|
|
|
+
|
|
|
#ifdef RVC_OS_WIN
|
|
|
HRESULT hr = CoInitialize(NULL);
|
|
|
int rc;
|
|
|
@@ -1935,12 +1937,12 @@ namespace MediaController {
|
|
|
WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
|
|
|
videocap_get_device_instanceid(i, tmp2, ARRAYSIZE(tmp2));
|
|
|
WideCharToMultiByte(CP_ACP, 0, tmp2, -1, t2, sizeof(t2), 0, NULL);
|
|
|
-
|
|
|
- Json::Value item;
|
|
|
- item["DevicePath"] = t1;
|
|
|
- item["DeviceInstanceId"] = t2;
|
|
|
- item["FriendlyName"] = t;
|
|
|
- rootReq["CameraDevInfo"].append(item);
|
|
|
+
|
|
|
+ cJSON* pobject = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(pobject, "DevicePath", cJSON_CreateString(t1));
|
|
|
+ cJSON_AddItemToObject(pobject, "DeviceInstanceId", cJSON_CreateString(t2));
|
|
|
+ cJSON_AddItemToObject(pobject, "FriendlyName", cJSON_CreateString(t));
|
|
|
+ cJSON_AddItemToArray(array, pobject);
|
|
|
|
|
|
{
|
|
|
unsigned char x[MD5_DIGESTSIZE] = {0};
|
|
|
@@ -1952,6 +1954,7 @@ namespace MediaController {
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s;%s", i, t, t1);
|
|
|
strCamInfoJson += CSimpleStringA::Format("\"%d\":\"%s;%s\",", i, t, t1);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
{
|
|
|
@@ -1989,11 +1992,11 @@ namespace MediaController {
|
|
|
rvc_camera_info_t pcamerainfo;
|
|
|
memset(&pcamerainfo, 0, sizeof(rvc_camera_info_t));
|
|
|
if (0 == rvc_videocap_get_camera_infos(i, &pcamerainfo)) {
|
|
|
- Json::Value item;
|
|
|
- item["driver"] = pcamerainfo.strdriver;
|
|
|
- item["card"] = pcamerainfo.strcard;
|
|
|
- item["bus_info"] = pcamerainfo.strbus_info;
|
|
|
- rootReq["CameraDevInfo"].append(item);
|
|
|
+ cJSON* pobject = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(pobject, "driver", cJSON_CreateString(pcamerainfo.strdriver));
|
|
|
+ cJSON_AddItemToObject(pobject, "card", cJSON_CreateString(pcamerainfo.strcard));
|
|
|
+ cJSON_AddItemToObject(pobject, "bus_info", cJSON_CreateString(pcamerainfo.strbus_info));
|
|
|
+ cJSON_AddItemToArray(array, pobject);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2002,18 +2005,24 @@ namespace MediaController {
|
|
|
|
|
|
if (icamnum > 0) {
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMERA_COUNT, CSimpleStringA::Format("camera number is %d.", icamnum).GetData());
|
|
|
-
|
|
|
if (strCamInfoJson.GetLength() > 0) {
|
|
|
strCamInfoJson[strCamInfoJson.GetLength() - 1] = '\0';
|
|
|
}
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, CSimpleStringA::Format("[{%s}]", strCamInfoJson.GetData()).GetData());
|
|
|
+
|
|
|
+ cJSON_AddItemToObject(root, "CameraDevInfo", array);
|
|
|
+ char* pjsonstr = cJSON_Print(root);
|
|
|
+ strCamListInfoJson = pjsonstr;
|
|
|
+ cJSON_free(pjsonstr);
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode("QLR0402208V1").setAPI("RvcMedia_GetCameraDevInfo")(CSimpleStringA::Format("%s", strCamListInfoJson.GetData()).GetData());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cJSON_Delete(array);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402208V1").setResultCode("RTA280A")("获取摄像头列表失败,找不到摄像头");
|
|
|
}
|
|
|
|
|
|
*ivideonum = icamnum;
|
|
|
-
|
|
|
- Json::StyledWriter sw;
|
|
|
- strCamListInfoJson = sw.write(rootReq).c_str();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode("QLR0402208V1").setAPI("RvcMedia_GetCameraDevInfo")(CSimpleStringA::Format("%s", strCamListInfoJson.GetData()).GetData());
|
|
|
+ cJSON_Delete(root);
|
|
|
|
|
|
return Error_Succeed;
|
|
|
}
|