|
|
@@ -1929,8 +1929,10 @@ namespace MediaController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- int capture_lib_init()
|
|
|
+ int capture_lib_init(int *ivideonum)
|
|
|
{
|
|
|
+ int icamnum = 0;
|
|
|
+ CSimpleStringA strCamInfoJson("");
|
|
|
#ifdef RVC_OS_WIN
|
|
|
HRESULT hr = CoInitialize(NULL);
|
|
|
int rc;
|
|
|
@@ -1965,10 +1967,8 @@ namespace MediaController {
|
|
|
}
|
|
|
|
|
|
{
|
|
|
- int i, n;
|
|
|
- n = videocap_get_device_count();
|
|
|
- CSimpleStringA strJson;
|
|
|
- for (i = 0; i < n; ++i) {
|
|
|
+ icamnum = videocap_get_device_count();
|
|
|
+ for (int i = 0; i < icamnum; ++i) {
|
|
|
WCHAR tmp[256] = {0};
|
|
|
char t[256] = {0};
|
|
|
WCHAR tmp1[256] ={0};
|
|
|
@@ -1985,19 +1985,7 @@ namespace MediaController {
|
|
|
Bin2Str(x, sizeof(x), t1, sizeof(t1));
|
|
|
}
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s;%s", i, t, t1);
|
|
|
- strJson += CSimpleStringA::Format("\"%d\":\"%s;%s\",", i, t, t1);
|
|
|
- }
|
|
|
-
|
|
|
- if (n > 0){
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMERA_COUNT, CSimpleStringA::Format("camera number is %d.", n).GetData());
|
|
|
-
|
|
|
- if (strJson.GetLength() > 0){
|
|
|
- strJson[strJson.GetLength( )-1] = '\0';
|
|
|
- }
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, CSimpleStringA::Format("[{%s}]", strJson.GetData()).GetData());
|
|
|
- }
|
|
|
- else{
|
|
|
- LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_MEDIACONTROLLER_NOCAMERA, "can not find camera.");
|
|
|
+ strCamInfoJson += CSimpleStringA::Format("\"%d\":\"%s;%s\",", i, t, t1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2022,27 +2010,33 @@ namespace MediaController {
|
|
|
#else
|
|
|
{
|
|
|
int inumber = 0;
|
|
|
- CSimpleStringA strJson("");
|
|
|
- int icount = rvc_videocap_get_device_count();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("camera count is %d.", icount);
|
|
|
- for (int i = 0; i < 64 && inumber < icount; ++i) {
|
|
|
+ icamnum = rvc_videocap_get_device_count();
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("camera count is %d.", icamnum);
|
|
|
+ for (int i = 0; i < 64 && inumber < icamnum; ++i) {
|
|
|
char strcamera[2 * MAX_PATH] = { 0 };
|
|
|
char strpath[MAX_PATH] = { 0 };
|
|
|
|
|
|
if (0 == rvc_videocap_get_device_fullpathname(i, strcamera, 2 * MAX_PATH)){
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s", inumber, strcamera);
|
|
|
- strJson += CSimpleStringA::Format("\"%d\":\"%s\",", inumber, strcamera);
|
|
|
+ strCamInfoJson += CSimpleStringA::Format("\"%d\":\"%s\",", inumber, strcamera);
|
|
|
inumber++;
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (strJson.GetLength() > 0) {
|
|
|
- strJson[strJson.GetLength() - 1] = '\0';
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+ 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}]", strJson.GetData()).GetData());
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, CSimpleStringA::Format("[{%s}]", strCamInfoJson.GetData()).GetData());
|
|
|
}
|
|
|
|
|
|
-#endif // RVC_OS_WIN
|
|
|
+ *ivideonum = icamnum;
|
|
|
+
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
|