Browse Source

Z991239-1528 #comment other: 优化linux下摄像头信息获取库(从videoframework解耦出)

陈礼鹏80274480 4 years ago
parent
commit
db7e95de3b

+ 1 - 1
Other/libmediadeviceinfo/CMakeLists.txt

@@ -4,7 +4,7 @@ set(MODULE_PREFIX "MEDIADEVICEINFO_FUNC")
 if(RVC_DEBUG_MODE)
     set(TOOLKIT_LIB libtoolkitd)
 else()
-    set(TOOLKIT libtoolkit)
+    set(TOOLKIT_LIB libtoolkit)
 endif(RVC_DEBUG_MODE)
 
 set(${MODULE_PREFIX}_SRCS

+ 6 - 6
Other/libmediadeviceinfo/imediadeviceinfo.h

@@ -17,7 +17,7 @@
 /**
  * get video camera devices count, return device count numbers
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_count();
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_device_count();
 
 /**
  * get video camera name, buf length should not be larger than 255,
@@ -25,29 +25,29 @@ extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_count();
  * if buf == null, len is ignored, return value is the required buffer size
  * else return value is copy to buf, including null-terminated char
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_name(int device_id, char* buf, int len);
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_device_name(int device_id, char* buf, int len);
 
 /**
  * get video device path string, buf length should not be larger than 255,
  * return -1 on error, if buf == null, len is ignored, return value is the required buffer size
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_path(int device_id, char* buf, int len);
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_device_path(int device_id, char* buf, int len);
 
 /**
  * get video camera name and path, buf length should not be larger than 255,
  * return -1 if error
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_info(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen);
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_device_info(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen);
 
 
 /**
  * get video camera recognise name, buf length should not be larger than 255,
  * return -1 if error
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_device_fullpathname(int device_id, char* fullnamebuf, int fulllen);
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_device_fullpathname(int device_id, char* fullnamebuf, int fulllen);
 
 /**
  * get video device id
  * return -1 if error
  */
-extern "C" LIBMEDIADEVICEINFO_API int videocap_get_video_device_id(const char* dev_name);
+extern "C" LIBMEDIADEVICEINFO_API int rvc_videocap_get_video_device_id(const char* dev_name);

+ 12 - 11
Other/libmediadeviceinfo/libvideodeviceinfo.cpp

@@ -19,7 +19,7 @@
 
 
 
-int videocap_get_device_count()
+int  rvc_videocap_get_device_count()
 {
 	int icount = 0;
 	int fd = -1;
@@ -79,7 +79,7 @@ int videocap_get_device_count()
 }
 
 
-int videocap_get_device_name(int device_id, char* buf, int len)
+int  rvc_videocap_get_device_name(int device_id, char* buf, int len)
 {
 	int iret = -1;
 
@@ -133,13 +133,13 @@ int videocap_get_device_name(int device_id, char* buf, int len)
 }
 
 
-int videocap_get_device_path(int device_id, char* buf, int len)
+int  rvc_videocap_get_device_path(int device_id, char* buf, int len)
 {
 	return 0;
 }
 
 
-int videocap_get_device_info(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen)
+int  rvc_videocap_get_device_info(int device_id, char* namebuf, int namelen, char* pathbuf, int pathlen)
 {
 	int iret = -1;
 
@@ -213,7 +213,7 @@ static int bin2str(unsigned char* x, int xlen, char* str, int str_size)
 }
 
 
-int videocap_get_device_fullpathname(int device_id, char* fullnamebuf, int fulllen)
+int  rvc_videocap_get_device_fullpathname(int device_id, char* fullnamebuf, int fulllen)
 {
 	int iret = -1;
 
@@ -280,19 +280,20 @@ int videocap_get_device_fullpathname(int device_id, char* fullnamebuf, int fulll
 	return iret;
 }
 
-int videocap_get_video_device_id(const char* dev_name)
+int  rvc_videocap_get_video_device_id(const char* dev_name)
 {
 	int iret = -1;
-	if (NULL == dev_name)
-	{
+	if (NULL == dev_name){
 		return iret;
 	}
 
-	int n = videocap_get_device_count();
+	int n = rvc_videocap_get_device_count();
+	printf("device count is %d.\n", n);
 	for (int i = 0; i < 2*n; ++i) {
 		char strfullname[2*MAX_PATH] = { 0 };
-		if (0 == videocap_get_device_fullpathname(i, strfullname, 2 * MAX_PATH))
-		{
+		if (0 == rvc_videocap_get_device_fullpathname(i, strfullname, 2 * MAX_PATH)){
+			printf("camera name is: %s\n", strfullname);
+			printf("   dev name is: %s\n", dev_name);
 			if (0 == strcasecmp(strfullname, dev_name))
 			{
 				iret = i;